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
This commit is contained in:
George Kalpakas 2019-02-04 15:03:25 +02:00 committed by Misko Hevery
parent 08f55b35a5
commit 9ce0c23c77
2 changed files with 3 additions and 3 deletions

View File

@ -107,7 +107,7 @@ class NgPackagesInstaller {
try { try {
this._log(`Writing temporary local ${PACKAGE_JSON} to ${pathToPackageConfig}`); this._log(`Writing temporary local ${PACKAGE_JSON} to ${pathToPackageConfig}`);
fs.writeFileSync(pathToPackageConfig, localPackageConfigJson); fs.writeFileSync(pathToPackageConfig, localPackageConfigJson);
this._installDeps('--no-lockfile', '--check-files'); this._installDeps('--pure-lockfile', '--check-files');
this._setLocalMarker(localPackageConfigJson); this._setLocalMarker(localPackageConfigJson);
} finally { } finally {
this._log(`Restoring original ${PACKAGE_JSON} to ${pathToPackageConfig}`); this._log(`Restoring original ${PACKAGE_JSON} to ${pathToPackageConfig}`);

View File

@ -145,7 +145,7 @@ describe('NgPackagesInstaller', () => {
beforeEach(() => { beforeEach(() => {
log = []; log = [];
fs.writeFileSync.and.callFake((filePath, contents) => filePath === packageJsonPath && log.push(`writeFile: ${contents}`)); 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._checkLocalMarker.and.returnValue(false);
installer.installLocalDependencies(); installer.installLocalDependencies();
}); });
@ -198,7 +198,7 @@ describe('NgPackagesInstaller', () => {
it('should overwrite package.json, then install deps, then restore original package.json', () => { it('should overwrite package.json, then install deps, then restore original package.json', () => {
expect(log).toEqual([ expect(log).toEqual([
`writeFile: ${expectedModifiedPackageJson}`, `writeFile: ${expectedModifiedPackageJson}`,
`installDeps:`, `installDeps: --pure-lockfile --check-files`,
`writeFile: ${dummyPackageJson}` `writeFile: ${dummyPackageJson}`
]); ]);
}); });