Skip to content

Commit 0ad61c7

Browse files
FrozenPandazvsavkin
authored andcommitted
feat(schematics): deprecate nx update
1 parent 72f546a commit 0ad61c7

File tree

6 files changed

+43
-79
lines changed

6 files changed

+43
-79
lines changed

e2e/schematics/command-line.test.ts

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -72,63 +72,14 @@ describe('Command line', () => {
7272
);
7373
});
7474

75-
// TODO reenable
76-
xit(
77-
'update should run migrations',
78-
() => {
79-
newProject();
80-
updateFile(
81-
'node_modules/@nrwl/schematics/migrations/20200101-test-migration.js',
82-
`
83-
exports.default = {
84-
description: 'Test migration',
85-
run: function() {
86-
console.log('Running test migration');
87-
}
88-
};
89-
`
90-
);
91-
const checkOut = runCommand('npm run update:check');
92-
expect(checkOut).toContain(
93-
'Run "npm run update" to run the following migrations'
94-
);
95-
expect(checkOut).toContain('20200101-test-migration');
96-
97-
const migrateOut = runCommand('npm run update');
98-
expect(migrateOut).toContain('Test migration');
99-
expect(migrateOut).toContain('Running test migration');
100-
expect(migrateOut).toContain(
101-
`The latestMigration property in .angular-cli.json has been set to "20200101-test-migration".`
102-
);
103-
104-
updateFile(
105-
'node_modules/@nrwl/schematics/migrations/20200102-test-migration.js',
106-
`
107-
exports.default = {
108-
description: 'Test migration2',
109-
run: function() {
110-
console.log('Running test migration');
111-
}
112-
};
113-
`
114-
);
115-
116-
const checkOut2 = runCommand('npm run update:check');
117-
expect(checkOut2).toContain(
118-
'Run "npm run update" to run the following migrations'
119-
);
120-
expect(checkOut2).toContain('20200102-test-migration');
121-
122-
const skipOut = runCommand('npm run update:skip');
123-
expect(skipOut).toContain(
124-
`The latestMigration property in .angular-cli.json has been set to "20200102-test-migration".`
125-
);
126-
127-
expect(runCommand('npm run update:check')).not.toContain('IMPORTANT');
128-
expect(runCommand('npm run update')).toContain('No migrations to run');
129-
},
130-
1000000
131-
);
75+
it('update should print deprecation information', () => {
76+
newProject();
77+
const update = runCommand('./node_modules/.bin/nx update');
78+
expect(update).toContain('Nx update is now deprecated.');
79+
expect(update).toContain(
80+
'Please use "ng update @nrwl/schematics" instead.'
81+
);
82+
});
13283

13384
it(
13485
'affected should print, build, and test affected apps',

e2e/schematics/ng-add.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ describe('Nrwl Convert to Nx Workspace', () => {
7979
format: './node_modules/.bin/nx format:write',
8080
'format:write': './node_modules/.bin/nx format:write',
8181
'format:check': './node_modules/.bin/nx format:check',
82-
update: './node_modules/.bin/nx update',
83-
'update:check': './node_modules/.bin/nx update:check',
84-
'update:skip': './node_modules/.bin/nx update:skip',
82+
update: 'ng update @nrwl/schematics',
83+
'update:check': 'ng update',
8584
'dep-graph': './node_modules/.bin/nx dep-graph',
8685
'workspace-schematic': './node_modules/.bin/nx workspace-schematic',
8786
help: './node_modules/.bin/nx help'

packages/schematics/migrations/update-6-1-0/update-6-1-0.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,30 @@ function displayInformation(host: Tree, context: SchematicContext) {
2020
`);
2121
}
2222

23+
const addImplicitDependencies = updateJsonInTree('nx.json', nxJson => {
24+
return {
25+
...nxJson,
26+
implicitDependencies: {
27+
'angular.json': '*',
28+
'package.json': '*',
29+
'tsconfig.json': '*',
30+
'tslint.json': '*',
31+
'nx.json': '*'
32+
}
33+
};
34+
});
35+
36+
const changeNpmRunUpdate = updateJsonInTree('package.json', packageJson => {
37+
packageJson.scripts.update = 'ng update @nrwl/schematics';
38+
packageJson.scripts['update:check'] = 'ng update';
39+
delete packageJson.scripts['update:skip'];
40+
return packageJson;
41+
});
42+
2343
export default function(): Rule {
2444
return chain([
2545
displayInformation,
26-
updateJsonInTree('nx.json', nxJson => {
27-
return {
28-
...nxJson,
29-
implicitDependencies: {
30-
'angular.json': '*',
31-
'package.json': '*',
32-
'tsconfig.json': '*',
33-
'tslint.json': '*',
34-
'nx.json': '*'
35-
}
36-
};
37-
})
46+
addImplicitDependencies,
47+
changeNpmRunUpdate
3848
]);
3949
}

packages/schematics/src/collection/ng-add/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ function updatePackageJson() {
6565
format: './node_modules/.bin/nx format:write',
6666
'format:write': './node_modules/.bin/nx format:write',
6767
'format:check': './node_modules/.bin/nx format:check',
68-
update: './node_modules/.bin/nx update',
69-
'update:check': './node_modules/.bin/nx update:check',
70-
'update:skip': './node_modules/.bin/nx update:skip',
68+
update: 'ng update @nrwl/schematics',
69+
'update:check': 'ng update',
7170
lint: './node_modules/.bin/nx lint && ng lint',
7271
'dep-graph': './node_modules/.bin/nx dep-graph',
7372
'workspace-schematic': './node_modules/.bin/nx workspace-schematic',

packages/schematics/src/collection/ng-new/files/__directory__/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
"format": "./node_modules/.bin/nx format:write",
1919
"format:write": "./node_modules/.bin/nx format:write",
2020
"format:check": "./node_modules/.bin/nx format:check",
21-
"update": "./node_modules/.bin/nx update",
22-
"update:check": "./node_modules/.bin/nx update:check",
23-
"update:skip": "./node_modules/.bin/nx update:skip",
21+
"update": "ng update @nrwl/schematics",
22+
"update:check": "ng update",
2423
"workspace-schematic": "./node_modules/.bin/nx workspace-schematic",
2524
"dep-graph": "./node_modules/.bin/nx dep-graph",
2625
"help": "./node_modules/.bin/nx help"

packages/schematics/src/command-line/update.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
33

4+
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
5+
46
import { updateJsonFile, readCliConfigFile } from '../utils/fileutils';
57

68
type Migration = { description: string; run(): void };
@@ -53,7 +55,11 @@ function calculateMigrationsToRun(
5355
latestMigration: string
5456
) {
5557
if (latestMigration === 'ANGULAR CLI 6') {
56-
return [];
58+
console.error(stripIndents`
59+
Nx update is now deprecated.
60+
Please use "ng update @nrwl/schematics" instead.
61+
`);
62+
process.exit(1);
5763
}
5864
const startingWith = latestMigration
5965
? migrations.findIndex(item => item.name === latestMigration) + 1

0 commit comments

Comments
 (0)