From ef6d26d4fa9a2218186b7992ac08d2873973dd6b Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 4 Feb 2019 15:03:25 +0200 Subject: [PATCH] build(docs-infra): keep other dependencies pinned when installing local Angular packages (#28510) `ng-packages-installer` can be used to replace Angular packages with locally built ones (from `dist/packages-dist/`) along with their peer dependencies. Previously, in order to achieve this, `yarn install` was called with the `--no-lockfile` option, which resulted in installing the latest versions of all dependencies (including transitive ones) permitted by the corresponding version ranges in `package.json` files. As a result, newly released versions would be picked, resulting in unexpected, non-deterministic breakages in CI. This commit calls `yarn install` with the `--pure-lockfile` option instead. As a result, only the Angular packages (for which the locally built ones are used) and their peer dependencies are unpinned; the pinned versions from `yarn.lock` are used for all other (direct and transitive) dependencies. While this does not eliminate non-determinism across builds, it significantly reduces it. PR Close #28510 --- aio/tools/ng-packages-installer/index.js | 2 +- aio/tools/ng-packages-installer/index.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aio/tools/ng-packages-installer/index.js b/aio/tools/ng-packages-installer/index.js index 3dd30a516c..25b67ff9d3 100644 --- a/aio/tools/ng-packages-installer/index.js +++ b/aio/tools/ng-packages-installer/index.js @@ -107,7 +107,7 @@ class NgPackagesInstaller { try { this._log(`Writing temporary local ${PACKAGE_JSON} to ${pathToPackageConfig}`); fs.writeFileSync(pathToPackageConfig, localPackageConfigJson); - this._installDeps('--no-lockfile', '--check-files'); + this._installDeps('--pure-lockfile', '--check-files'); this._setLocalMarker(localPackageConfigJson); } finally { this._log(`Restoring original ${PACKAGE_JSON} to ${pathToPackageConfig}`); diff --git a/aio/tools/ng-packages-installer/index.spec.js b/aio/tools/ng-packages-installer/index.spec.js index b532a05e20..1a0bb8ad5d 100644 --- a/aio/tools/ng-packages-installer/index.spec.js +++ b/aio/tools/ng-packages-installer/index.spec.js @@ -145,7 +145,7 @@ describe('NgPackagesInstaller', () => { beforeEach(() => { log = []; fs.writeFileSync.and.callFake((filePath, contents) => filePath === packageJsonPath && log.push(`writeFile: ${contents}`)); - installer._installDeps.and.callFake(() => log.push('installDeps:')); + installer._installDeps.and.callFake((...args) => log.push(`installDeps: ${args.join(' ')}`)); installer._checkLocalMarker.and.returnValue(false); installer.installLocalDependencies(); }); @@ -198,7 +198,7 @@ describe('NgPackagesInstaller', () => { it('should overwrite package.json, then install deps, then restore original package.json', () => { expect(log).toEqual([ `writeFile: ${expectedModifiedPackageJson}`, - `installDeps:`, + `installDeps: --pure-lockfile --check-files`, `writeFile: ${dummyPackageJson}` ]); });