Skip to content

Commit 6b9942f

Browse files
committed
fix(core): decorate angular cli to error when ng update is used
1 parent ceac479 commit 6b9942f

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

packages/cli/lib/init-local.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function initLocal(workspace: Workspace) {
2727
if (runOpts === false || process.env.NX_SKIP_TASKS_RUNNER) {
2828
if (workspace.type === 'angular' && process.argv[2] === 'update') {
2929
console.log(
30-
`Nx provides a much improved version of "ng update". It runs same migrations, but allows you to:`
30+
`Nx provides a much improved version of "ng update". It runs the same migrations, but allows you to:`
3131
);
3232
console.log(`- rerun the same migration multiple times`);
3333
console.log(`- reorder migrations`);

packages/workspace/migrations.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
"version": "10.4.5",
140140
"description": "Update the 'update' npm script to invoke nx migrate",
141141
"factory": "./src/migrations/update-10-4-0/update-script-to-invoke-nx-migrate"
142+
},
143+
"update-decorate-angular-cli": {
144+
"version": "10.4.6",
145+
"description": "Update the decoration script when using Angular CLI",
146+
"factory": "./src/migrations/update-10-4-0/update-decorate-angular-cli"
142147
}
143148
},
144149
"packageJsonUpdates": {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { join as pathJoin } from 'path';
2+
import { readFileSync } from 'fs';
3+
import { Tree } from '@angular-devkit/schematics';
4+
5+
export default function update() {
6+
return (host: Tree) => {
7+
const decorateCli = readFileSync(
8+
pathJoin(
9+
__dirname as any,
10+
'..',
11+
'..',
12+
'schematics',
13+
'utils',
14+
'decorate-angular-cli.js__tmpl__'
15+
)
16+
).toString();
17+
if (host.exists('/decorate-angular-cli.js')) {
18+
host.overwrite('/decorate-angular-cli.js', decorateCli);
19+
}
20+
};
21+
}

packages/workspace/src/schematics/utils/decorate-angular-cli.js__tmpl__

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ if (!process.env['NX_CLI_SET']) {
5050
const { output } = require('@nrwl/workspace');
5151
output.warn({ title: 'The Angular CLI was invoked instead of the Nx CLI. Use "npx ng [command]" or "nx [command]" instead.' });
5252
}
53+
54+
if (process.argv[2] === 'update') {
55+
const { output } = require('@nrwl/workspace');
56+
output.error({
57+
title: '"ng update" is deprecated in favor of "nx migrate". Read more: https://nx.dev/latest/angular/workspace/update'
58+
});
59+
throw new Error();
60+
}
5361
${angularCLIInit}
5462
`);
5563
}

0 commit comments

Comments
 (0)