build(aio): support ignoring dist packages in "local" mode (#19511)
PR Close #19511
This commit is contained in:
parent
ab8ee4d0d9
commit
9ef8d8b85a
@ -37,6 +37,7 @@ class NgPackagesInstaller {
|
|||||||
constructor(projectDir, options = {}) {
|
constructor(projectDir, options = {}) {
|
||||||
this.debug = options.debug;
|
this.debug = options.debug;
|
||||||
this.force = options.force;
|
this.force = options.force;
|
||||||
|
this.ignorePackages = options.ignorePackages || [];
|
||||||
this.projectDir = path.resolve(projectDir);
|
this.projectDir = path.resolve(projectDir);
|
||||||
this.localMarkerPath = path.resolve(this.projectDir, LOCAL_MARKER_PATH);
|
this.localMarkerPath = path.resolve(this.projectDir, LOCAL_MARKER_PATH);
|
||||||
|
|
||||||
@ -145,9 +146,13 @@ class NgPackagesInstaller {
|
|||||||
.map(filePath => filePath.slice(ANGULAR_DIST_PACKAGES.length + 1))
|
.map(filePath => filePath.slice(ANGULAR_DIST_PACKAGES.length + 1))
|
||||||
.filter(filePath => PACKAGE_JSON_REGEX.test(filePath))
|
.filter(filePath => PACKAGE_JSON_REGEX.test(filePath))
|
||||||
.forEach(packagePath => {
|
.forEach(packagePath => {
|
||||||
const packageConfig = require(path.resolve(ANGULAR_DIST_PACKAGES, packagePath));
|
|
||||||
const packageName = `@angular/${packagePath.slice(0, -PACKAGE_JSON.length -1)}`;
|
const packageName = `@angular/${packagePath.slice(0, -PACKAGE_JSON.length -1)}`;
|
||||||
packageConfigs[packageName] = packageConfig;
|
if (this.ignorePackages.indexOf(packageName) === -1) {
|
||||||
|
const packageConfig = require(path.resolve(ANGULAR_DIST_PACKAGES, packagePath));
|
||||||
|
packageConfigs[packageName] = packageConfig;
|
||||||
|
} else {
|
||||||
|
this._log('Ignoring package', packageName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this._log('Found the following Angular distributables:', Object.keys(packageConfigs).map(key => `\n - ${key}`));
|
this._log('Found the following Angular distributables:', Object.keys(packageConfigs).map(key => `\n - ${key}`));
|
||||||
return packageConfigs;
|
return packageConfigs;
|
||||||
@ -216,8 +221,9 @@ function main() {
|
|||||||
|
|
||||||
.option('debug', { describe: 'Print additional debug information.', default: false })
|
.option('debug', { describe: 'Print additional debug information.', default: false })
|
||||||
.option('force', { describe: 'Force the command to execute even if not needed.', default: false })
|
.option('force', { describe: 'Force the command to execute even if not needed.', default: false })
|
||||||
|
.option('ignore-packages', { describe: 'List of Angular packages that should not be used in local mode.', default: [], array: true })
|
||||||
|
|
||||||
.command('overwrite <projectDir> [--force] [--debug]', 'Install dependencies from the locally built Angular distributables.', () => {}, argv => {
|
.command('overwrite <projectDir> [--force] [--debug] [--ignore-packages package1 package2]', 'Install dependencies from the locally built Angular distributables.', () => {}, argv => {
|
||||||
const installer = new NgPackagesInstaller(argv.projectDir, argv);
|
const installer = new NgPackagesInstaller(argv.projectDir, argv);
|
||||||
installer.installLocalDependencies();
|
installer.installLocalDependencies();
|
||||||
})
|
})
|
||||||
|
@ -162,6 +162,14 @@ describe('NgPackagesInstaller', () => {
|
|||||||
expect(ngPackages['@angular/upgrade']).toBeDefined();
|
expect(ngPackages['@angular/upgrade']).toBeDefined();
|
||||||
|
|
||||||
expect(ngPackages['@angular/upgrade/static']).not.toBeDefined();
|
expect(ngPackages['@angular/upgrade/static']).not.toBeDefined();
|
||||||
|
|
||||||
|
it('should not include packages that have been ignored', () => {
|
||||||
|
installer = new NgPackagesInstaller(rootDir, { ignorePackages: ['@angular/router'] });
|
||||||
|
const ngPackages = installer._getDistPackages();
|
||||||
|
|
||||||
|
expect(ngPackages['@angular/common']).toBeDefined();
|
||||||
|
expect(ngPackages['@angular/router']).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user