Skip to content

fix(@schematics/update): update fail when using yarn 2.0 protocols #19217

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

Merged
merged 1 commit into from
Oct 27, 2020
Merged
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
7 changes: 3 additions & 4 deletions packages/schematics/update/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,9 @@ export default function(options: UpdateSchema): Rule {
try {
return isPkgFromRegistry(name, specifier);
} catch {
// Abort on failure because package.json is malformed.
throw new SchematicsException(
`Failed to parse dependency "${name}" with specifier "${specifier}"`
+ ` from package.json. Is the specifier malformed?`);
logger.warn(`Package ${name} was not found on the registry. Skipping.`);

return false;
}
}));
const packages = _buildPackageList(options, npmDeps, logger);
Expand Down
18 changes: 18 additions & 0 deletions packages/schematics/update/update/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ describe('@schematics/update', () => {
).toPromise().then(done, done.fail);
}, 45000);

it('should not error with yarn 2.0 protocols', async () => {
const tree = new UnitTestTree(new HostTree(new virtualFs.test.TestHost({
'/package.json': `{
"name": "blah",
"dependencies": {
"src": "src@link:./src",
"@angular-devkit-tests/update-base": "1.0.0"
}
}`,
})));

const newTree = await schematicRunner.runSchematicAsync('update', {
packages: ['@angular-devkit-tests/update-base'],
}, tree).toPromise();
const { dependencies } = JSON.parse(newTree.readContent('/package.json'));
expect(dependencies['@angular-devkit-tests/update-base']).toBe('1.1.0');
});

it('updates Angular as compatible with Angular N-1', done => {
// Add the basic migration package.
const content = virtualFs.fileBufferToString(host.sync.read(normalize('/package.json')));
Expand Down