refactor(ngcc): expose a hash of the project configuration (#35931)

This will be used in the entry-point manifest since a change to
configuration might change the entry-points that are found.

PR Close #35931
This commit is contained in:
Pete Bacon Darwin
2020-03-10 10:49:16 +00:00
committed by Andrew Kushnir
parent 5af0e7523c
commit 74e47c503a
2 changed files with 61 additions and 0 deletions

View File

@ -5,6 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {createHash} from 'crypto';
import {satisfies} from 'semver';
import * as vm from 'vm';
import {AbsoluteFsPath, FileSystem, dirname, join, resolve} from '../../../src/ngtsc/file_system';
@ -159,10 +160,12 @@ export class NgccConfiguration {
private defaultConfig: NgccProjectConfig<VersionedPackageConfig[]>;
private projectConfig: NgccProjectConfig<VersionedPackageConfig[]>;
private cache = new Map<string, VersionedPackageConfig>();
readonly hash: string;
constructor(private fs: FileSystem, baseDir: AbsoluteFsPath) {
this.defaultConfig = this.processProjectConfig(baseDir, DEFAULT_NGCC_CONFIG);
this.projectConfig = this.processProjectConfig(baseDir, this.loadProjectConfig(baseDir));
this.hash = this.computeHash();
}
/**
@ -283,6 +286,10 @@ export class NgccConfiguration {
] :
[packagePathAndVersion, undefined];
}
private computeHash(): string {
return createHash('md5').update(JSON.stringify(this.projectConfig)).digest('hex');
}
}
function findSatisfactoryVersion(