fix(core): whitelist registries that support obtaining migration config via 'npm view' (#16423)
Co-authored-by: Craigory Coppola <craigorycoppola@gmail.com>
This commit is contained in:
parent
db6e14eca5
commit
a7c14fca1e
@ -13,6 +13,7 @@ import {
|
||||
satisfies,
|
||||
valid,
|
||||
} from 'semver';
|
||||
import { URL } from 'url';
|
||||
import { promisify } from 'util';
|
||||
import {
|
||||
MigrationsJson,
|
||||
@ -933,14 +934,33 @@ async function getPackageMigrationsConfigFromRegistry(
|
||||
const result = await packageRegistryView(
|
||||
packageName,
|
||||
packageVersion,
|
||||
'nx-migrations ng-update --json'
|
||||
'nx-migrations ng-update dist --json'
|
||||
);
|
||||
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return readNxMigrateConfig(JSON.parse(result));
|
||||
const json = JSON.parse(result);
|
||||
|
||||
if (!json['nx-migrations'] && !json['ng-update']) {
|
||||
const registry = new URL('dist' in json ? json.dist.tarball : json.tarball)
|
||||
.hostname;
|
||||
|
||||
// Registries other than npmjs and the local registry may not support full metadata via npm view
|
||||
// so throw error so that fetcher falls back to getting config via install
|
||||
if (
|
||||
!['registry.npmjs.org', 'localhost', 'artifactory'].some((v) =>
|
||||
registry.includes(v)
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
`Getting migration config from registry is not supported from ${registry}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return readNxMigrateConfig(json);
|
||||
}
|
||||
|
||||
async function downloadPackageMigrationsFromRegistry(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user