nx/packages/angular/src/migrations/update-16-7-0/update-angular-cli.ts

24 lines
603 B
TypeScript

import { formatFiles, Tree, updateJson } from '@nx/devkit';
export const angularCliVersion = '~16.2.0-rc.1';
export default async function (tree: Tree) {
let shouldFormat = false;
updateJson(tree, 'package.json', (json) => {
if (json.devDependencies?.['@angular/cli']) {
json.devDependencies['@angular/cli'] = angularCliVersion;
shouldFormat = true;
} else if (json.dependencies?.['@angular/cli']) {
json.dependencies['@angular/cli'] = angularCliVersion;
shouldFormat = true;
}
return json;
});
if (shouldFormat) {
await formatFiles(tree);
}
}