From bf352efb2199ab0d3e3348943a61b450efbded5c Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 27 Oct 2020 17:21:53 +0100 Subject: [PATCH] fix(@schematics/update): update fail when using yarn 2.0 protocols Closes #19203 --- packages/schematics/update/update/index.ts | 7 +++---- .../schematics/update/update/index_spec.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/schematics/update/update/index.ts b/packages/schematics/update/update/index.ts index ccb115698603..908e6eb88e6f 100644 --- a/packages/schematics/update/update/index.ts +++ b/packages/schematics/update/update/index.ts @@ -865,10 +865,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); diff --git a/packages/schematics/update/update/index_spec.ts b/packages/schematics/update/update/index_spec.ts index dcbe57590025..e9d71e7cca49 100644 --- a/packages/schematics/update/update/index_spec.ts +++ b/packages/schematics/update/update/index_spec.ts @@ -173,6 +173,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')));