Skip to content

Commit 31ec09c

Browse files
alan-agius4clydin
authored andcommitted
refactor(@schematics/angular): remove migrations for unsupported versions
1 parent 0e7277c commit 31ec09c

23 files changed

+29
-2178
lines changed

packages/angular/cli/commands/update-impl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,13 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
611611
// Migrations for non LTS versions of Angular CLI are no longer included in @schematics/angular v12.
612612
const toBeInstalledMajorVersion = +manifest.version.split('.')[0];
613613
const currentMajorVersion = +node.package.version.split('.')[0];
614-
if (currentMajorVersion < 9 && toBeInstalledMajorVersion >= 12) {
614+
if (currentMajorVersion < 10 && toBeInstalledMajorVersion >= 12) {
615615
const updateVersions: Record<number, number> = {
616616
1: 6,
617617
6: 7,
618618
7: 8,
619619
8: 9,
620+
9: 10,
620621
};
621622

622623
const updateTo = updateVersions[currentMajorVersion];

packages/schematics/angular/migrations/migration-collection.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
{
22
"schematics": {
3-
"workspace-version-9": {
4-
"version": "9.0.0-beta.0",
5-
"factory": "./update-9",
6-
"description": "Angular Workspace migration. Update an Angular CLI workspace to version 9."
7-
},
83
"lazy-loading-syntax": {
94
"version": "9.0.0-next.6",
105
"factory": "./update-12/update-lazy-module-paths",
116
"description": "Lazy loading syntax migration. Update lazy loading syntax to use dynamic imports."
127
},
13-
"schematic-options-9": {
14-
"version": "9.0.2",
15-
"factory": "./update-9/schematic-options",
16-
"description": "Replace deprecated 'styleext' and 'spec' Angular schematic options."
17-
},
188
"tslint-version-6": {
199
"version": "10.0.0-beta.0",
2010
"factory": "./update-10/update-tslint",
@@ -32,7 +22,7 @@
3222
},
3323
"schematic-options-10": {
3424
"version": "10.0.0-beta.2",
35-
"factory": "./update-9/schematic-options",
25+
"factory": "./update-10/schematic-options",
3626
"description": "Replace deprecated and removed 'styleext' and 'spec' Angular schematic options with 'style' and 'skipTests', respectively."
3727
},
3828
"update-angular-config": {
@@ -107,7 +97,7 @@
10797
},
10898
"remove-deprecated-i18n-options": {
10999
"version": "12.0.0-next.7",
110-
"factory": "./update-9/update-i18n#updateI18nConfig",
100+
"factory": "./update-12/update-i18n",
111101
"description": "Remove deprecated ViewEngine-based i18n build and extract options. Options present in the configuration will be converted to use non-deprecated options."
112102
},
113103
"update-web-workers-webpack-5": {

packages/schematics/angular/migrations/update-9/schematic-options_spec.ts renamed to packages/schematics/angular/migrations/update-10/schematic-options_spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/te
1111

1212
const workspacePath = '/angular.json';
1313

14-
describe('Migration to version 9', () => {
14+
describe('Migration to version 10', () => {
1515
describe('Migrate workspace config', () => {
1616
const schematicRunner = new SchematicTestRunner(
1717
'migrations',
@@ -47,7 +47,7 @@ describe('Migration to version 9', () => {
4747
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
4848

4949
const tree2 = await schematicRunner
50-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
50+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
5151
.toPromise();
5252
const { schematics } = JSON.parse(tree2.readContent(workspacePath));
5353
expect(schematics['@schematics/angular:component'].styleext).toBeUndefined();
@@ -64,7 +64,7 @@ describe('Migration to version 9', () => {
6464
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
6565

6666
const tree2 = await schematicRunner
67-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
67+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
6868
.toPromise();
6969
const { schematics } = JSON.parse(tree2.readContent(workspacePath));
7070
expect(schematics['@schematics/some-other:component'].styleext).toBe('scss');
@@ -81,7 +81,7 @@ describe('Migration to version 9', () => {
8181
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
8282

8383
const tree2 = await schematicRunner
84-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
84+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
8585
.toPromise();
8686
const { schematics } = JSON.parse(tree2.readContent(workspacePath));
8787
expect(schematics['@schematics/angular:component'].spec).toBeUndefined();
@@ -98,7 +98,7 @@ describe('Migration to version 9', () => {
9898
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
9999

100100
const tree2 = await schematicRunner
101-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
101+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
102102
.toPromise();
103103
const { schematics } = JSON.parse(tree2.readContent(workspacePath));
104104
expect(schematics['@schematics/angular:component'].spec).toBeUndefined();
@@ -127,7 +127,7 @@ describe('Migration to version 9', () => {
127127
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
128128

129129
const tree2 = await schematicRunner
130-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
130+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
131131
.toPromise();
132132
const { schematics } = JSON.parse(tree2.readContent(workspacePath));
133133
for (const key of Object.keys(workspace.schematics)) {
@@ -147,7 +147,7 @@ describe('Migration to version 9', () => {
147147
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
148148

149149
const tree2 = await schematicRunner
150-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
150+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
151151
.toPromise();
152152
const { schematics } = JSON.parse(tree2.readContent(workspacePath));
153153
expect(schematics['@schematics/angular:component'].styleext).toBeUndefined();
@@ -167,7 +167,7 @@ describe('Migration to version 9', () => {
167167
tree.overwrite(workspacePath, JSON.stringify(workspace, undefined, 2));
168168

169169
const tree2 = await schematicRunner
170-
.runSchematicAsync('schematic-options-9', {}, tree.branch())
170+
.runSchematicAsync('schematic-options-10', {}, tree.branch())
171171
.toPromise();
172172
const {
173173
projects: {

packages/schematics/angular/migrations/update-9/update-i18n.ts renamed to packages/schematics/angular/migrations/update-12/update-i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { latestVersions } from '../../utility/latest-versions';
1818
import { allTargetOptions, allWorkspaceTargets, updateWorkspace } from '../../utility/workspace';
1919
import { Builders } from '../../utility/workspace-models';
2020

21-
export function updateI18nConfig(): Rule {
21+
export default function (): Rule {
2222
return (tree, { logger }) =>
2323
updateWorkspace((workspace) => {
2424
// Process extraction targets first since they use browser option values

packages/schematics/angular/migrations/update-9/update-i18n_spec.ts renamed to packages/schematics/angular/migrations/update-12/update-i18n_spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function updateWorkspaceTargets(tree: UnitTestTree, workspaceTargets: WorkspaceT
2424

2525
const workspacePath = '/angular.json';
2626

27-
describe('Migration to version 9', () => {
27+
describe('Migration to version 12', () => {
2828
describe('Migrate workspace config', () => {
2929
const schematicRunner = new SchematicTestRunner(
3030
'migrations',
@@ -72,7 +72,7 @@ describe('Migration to version 9', () => {
7272
updateWorkspaceTargets(tree, config);
7373

7474
const tree2 = await schematicRunner
75-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
75+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
7676
.toPromise();
7777
const { dependencies } = JSON.parse(tree2.readContent('/package.json'));
7878
expect(dependencies['@angular/localize']).toBe(latestVersions.Angular);
@@ -86,7 +86,7 @@ describe('Migration to version 9', () => {
8686
updateWorkspaceTargets(tree, config);
8787

8888
const tree2 = await schematicRunner
89-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
89+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
9090
.toPromise();
9191
config = getWorkspaceTargets(tree2).build;
9292
expect(config.options.localize).toEqual(['fr']);
@@ -101,7 +101,7 @@ describe('Migration to version 9', () => {
101101
updateWorkspaceTargets(tree, config);
102102

103103
const tree2 = await schematicRunner
104-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
104+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
105105
.toPromise();
106106
config = getWorkspaceTargets(tree2).build;
107107
expect(config.options.i18nFormat).toBeUndefined();
@@ -119,7 +119,7 @@ describe('Migration to version 9', () => {
119119
updateWorkspaceTargets(tree, config);
120120

121121
const tree2 = await schematicRunner
122-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
122+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
123123
.toPromise();
124124
config = getWorkspaceTargets(tree2).build;
125125
expect(config.configurations.fr.baseHref).toBeUndefined();
@@ -134,7 +134,7 @@ describe('Migration to version 9', () => {
134134
updateWorkspaceTargets(tree, config);
135135

136136
const tree2 = await schematicRunner
137-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
137+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
138138
.toPromise();
139139
config = getWorkspaceTargets(tree2).build;
140140
expect(config.configurations.fr.outputPath).toBe('dist');
@@ -149,7 +149,7 @@ describe('Migration to version 9', () => {
149149
updateWorkspaceTargets(tree, config);
150150

151151
const tree2 = await schematicRunner
152-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
152+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
153153
.toPromise();
154154
config = getWorkspaceTargets(tree2).build;
155155
expect(config.configurations.fr.outputPath).toBe('dist/abc');
@@ -170,7 +170,7 @@ describe('Migration to version 9', () => {
170170
updateWorkspaceTargets(tree, config);
171171

172172
const tree2 = await schematicRunner
173-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
173+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
174174
.toPromise();
175175
config = getWorkspaceTargets(tree2).build;
176176
expect(config.configurations.staging.baseHref).toBe('/de/');
@@ -183,7 +183,7 @@ describe('Migration to version 9', () => {
183183
updateWorkspaceTargets(tree, config);
184184

185185
const tree2 = await schematicRunner
186-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
186+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
187187
.toPromise();
188188
config = getWorkspaceTargets(tree2).build;
189189
expect(config.options.baseHref).toBe('/my-app/');
@@ -197,7 +197,7 @@ describe('Migration to version 9', () => {
197197
updateWorkspaceTargets(tree, config);
198198

199199
const tree2 = await schematicRunner
200-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
200+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
201201
.toPromise();
202202
config = getWorkspaceTargets(tree2)['extract-i18n'];
203203
expect(config.options.i18nFormat).toBeUndefined();
@@ -214,7 +214,7 @@ describe('Migration to version 9', () => {
214214
updateWorkspaceTargets(tree, config);
215215

216216
const tree2 = await schematicRunner
217-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
217+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
218218
.toPromise();
219219
const projectConfig = JSON.parse(tree2.readContent(workspacePath)).projects[
220220
'migration-test'
@@ -230,7 +230,7 @@ describe('Migration to version 9', () => {
230230
updateWorkspaceTargets(tree, config);
231231

232232
const tree2 = await schematicRunner
233-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
233+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
234234
.toPromise();
235235
const projectConfig = JSON.parse(tree2.readContent(workspacePath)).projects[
236236
'migration-test'
@@ -249,7 +249,7 @@ describe('Migration to version 9', () => {
249249
updateWorkspaceTargets(tree, config);
250250

251251
const tree2 = await schematicRunner
252-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
252+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
253253
.toPromise();
254254
const projectConfig = JSON.parse(tree2.readContent(workspacePath)).projects[
255255
'migration-test'
@@ -269,7 +269,7 @@ describe('Migration to version 9', () => {
269269
updateWorkspaceTargets(tree, config);
270270

271271
const tree2 = await schematicRunner
272-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
272+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
273273
.toPromise();
274274
const projectConfig = JSON.parse(tree2.readContent(workspacePath)).projects[
275275
'migration-test'
@@ -285,7 +285,7 @@ describe('Migration to version 9', () => {
285285
describe('when i18n builder options are not set', () => {
286286
it(`should not add 'localize' option`, async () => {
287287
const tree2 = await schematicRunner
288-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
288+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
289289
.toPromise();
290290
const config = getWorkspaceTargets(tree2).build;
291291
expect(config.options.localize).toBeUndefined();
@@ -294,7 +294,7 @@ describe('Migration to version 9', () => {
294294

295295
it('should not add i18n project config', async () => {
296296
const tree2 = await schematicRunner
297-
.runSchematicAsync('workspace-version-9', {}, tree.branch())
297+
.runSchematicAsync('remove-deprecated-i18n-options', {}, tree.branch())
298298
.toPromise();
299299
const projectConfig = JSON.parse(tree2.readContent(workspacePath)).projects[
300300
'migration-test'

packages/schematics/angular/migrations/update-9/add-tslib.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/schematics/angular/migrations/update-9/index.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)