Skip to content

fix(@angular/cli): handles not found packages for ng-update #29358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/angular/cli/src/commands/update/schematic/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ describe('@schematics/update', () => {
);
}, 45000);

it('ignores dependencies hosted on alternative/private NPM registries', async () => {
let newTree = new UnitTestTree(
new HostTree(
new virtualFs.test.TestHost({
'/package.json': `{
"name": "blah",
"dependencies": {
"@fortawesome/pro-thin-svg-icons": "^6.6.0",
"@nostr/tools": "npm:@jsr/nostr__tools@^2.10.3"
}
}`,
'/.npmrc': `@jsr:registry=https://npm.jsr.io`,
}),
),
);

newTree = await schematicRunner.runSchematic('update', undefined, newTree);
const packageJson = JSON.parse(newTree.readContent('/package.json'));
expect(packageJson['dependencies']['@fortawesome/pro-thin-svg-icons']).toBe('^6.6.0');
expect(packageJson['dependencies']['@nostr/tools']).toBe('npm:@jsr/nostr__tools@^2.10.3');
}, 45000);

it('should not error with yarn 2.0 protocols', async () => {
let newTree = new UnitTestTree(
new HostTree(
Expand Down
20 changes: 13 additions & 7 deletions packages/angular/cli/src/utilities/package-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,20 @@ export async function getNpmPackageJson(
fullMetadata: true,
...npmrc,
...(registry ? { registry } : {}),
}).then((response) => {
// While pacote type declares that versions cannot be undefined this is not the case.
if (!response.versions) {
response.versions = {};
}
})
.then((response) => {
// While pacote type declares that versions cannot be undefined this is not the case.
if (!response.versions) {
response.versions = {};
}

return response;
});
return response;
})
.catch((err) => {
logger.warn(`Could not find ${packageName}`, { err });

return {} as Partial<NpmRepositoryPackageJson>;
});

npmPackageJsonCache.set(packageName, response);

Expand Down
Loading