Filipe Silva 3fc4c91fff feat(@schematics/angular): update @types/node for version 9
Angular will only support TS 3.6+ on version 9, and older versions of `@types/node` are incompatible with it and will cause all builds to fail.

Related to https://github.com/angular/angular/pull/33250
2019-10-21 09:37:29 -07:00

47 lines
1.4 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,
removePackageJsonDependency,
} from '../../utility/dependencies';
import { latestVersions } from '../../utility/latest-versions';
export function updateDependencies(): Rule {
return host => {
const dependenciesToUpdate: Record<string, string> = {
'@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',
'@types/node': '^12.11.1',
};
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,
});
}
// `@angular/pwa` package is only needed when running `ng-add`.
removePackageJsonDependency(host, '@angular/pwa');
};
}