Append / to end of registries url

Avoids a bug in 2.10.4. Also, add some better handling for invalid
registries blocks.
This commit is contained in:
Andrew Eisenberg
2022-09-07 20:32:47 -07:00
parent 59744464eb
commit 6085805a3a
7 changed files with 119 additions and 30 deletions
+11 -1
View File
@@ -1900,9 +1900,19 @@ export async function downloadPacks(
function createRegistriesBlock(registries: RegistryConfigWithCredentials[]): {
registries: RegistryConfigNoCredentials[];
} {
if (
!Array.isArray(registries) ||
registries.some((r) => !r.url || !r.packages)
) {
throw new Error(
"Invalid 'registries' input. Must be an array of objects with 'url' and 'packages' properties."
);
}
// be sure to remove the `token` field from the registry before writing it to disk.
const safeRegistries = registries.map((registry) => ({
url: registry.url,
// ensure the url ends with a slash to avoid a bug in the CLI 2.10.4
url: !registry?.url.endsWith("/") ? `${registry.url}/` : registry.url,
packages: registry.packages,
}));
const qlconfig = {