mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* 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 { Rule } from '@angular-devkit/schematics';
|
|
import { addPackageJsonDependency, getPackageJsonDependency } from '../../utility/dependencies';
|
|
import { latestVersions } from '../../utility/latest-versions';
|
|
|
|
export function updateDependencies(): Rule {
|
|
return host => {
|
|
const dependenciesToUpdate: Record<string, string> = {
|
|
'@angular/pwa': latestVersions.AngularPWA,
|
|
'@angular-devkit/build-angular': latestVersions.DevkitBuildAngular,
|
|
'@angular-devkit/build-ng-packagr': latestVersions.DevkitBuildNgPackagr,
|
|
'@angular-devkit/build-webpack': latestVersions.DevkitBuildWebpack,
|
|
'zone.js': latestVersions.ZoneJs,
|
|
'ng-packagr': latestVersions.ngPackagr,
|
|
'web-animations-js': '^2.3.2',
|
|
'codelyzer': '^5.1.2',
|
|
};
|
|
|
|
for (const [name, version] of Object.entries(dependenciesToUpdate)) {
|
|
const current = getPackageJsonDependency(host, name);
|
|
if (!current || current.version === version) {
|
|
continue;
|
|
}
|
|
|
|
addPackageJsonDependency(host, {
|
|
type: current.type,
|
|
name,
|
|
version,
|
|
overwrite: true,
|
|
});
|
|
}
|
|
};
|
|
}
|