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:
parent
08f55b35a5
commit
9ce0c23c77
|
@ -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}`);
|
||||
|
|
|
@ -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}`
|
||||
]);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue