Skip to content

Commit 4b2fcfd

Browse files
crisbetoAndrewKushnir
authored andcommittedApr 29, 2019
fix: disable injectable-pipe migration (#30180)
Disables the injectable pipe migration until we can decide whether this is the right solution for Ivy. Rolling it out properly will involve a more detailed plan and more changes like updating the styleguide, scaffolding schematics etc. Context for the new `test-migrations.json`: since we use the `migrations.json` both for the real migrations and for tests, it doesn't allow us to disable a schematic, but continue running its tests. This change adds the test-specific file so that we can continue running the `injectable-pipe` tests, even though the schematic itself is disabled. PR Close #30180
1 parent b4d291a commit 4b2fcfd

9 files changed

+234
-220
lines changed
 

‎packages/core/schematics/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("//tools:defaults.bzl", "npm_package")
33
exports_files([
44
"tsconfig.json",
55
"migrations.json",
6+
"test-migrations.json",
67
])
78

89
npm_package(

‎packages/core/schematics/migrations.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
"version": "8-beta",
1515
"description": "Warns developers if values are assigned to template variables",
1616
"factory": "./migrations/template-var-assignment/index"
17-
},
18-
"migration-v8-injectable-pipe": {
19-
"version": "8-beta",
20-
"description": "Migrates all Pipe classes so that they have an Injectable annotation",
21-
"factory": "./migrations/injectable-pipe/index"
2217
}
2318
}
2419
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"schematics": {
3+
"migration-move-document": {
4+
"description": "Migrates DOCUMENT Injection token from platform-browser imports to common import",
5+
"factory": "./migrations/move-document/index"
6+
},
7+
"migration-static-queries": {
8+
"description": "Migrates ViewChild and ContentChild to explicit query timing",
9+
"factory": "./migrations/static-queries/index"
10+
},
11+
"migration-template-local-variables": {
12+
"description": "Warns developers if values are assigned to template variables",
13+
"factory": "./migrations/template-var-assignment/index"
14+
},
15+
"migration-injectable-pipe": {
16+
"description": "Migrates all Pipe classes so that they have an Injectable annotation",
17+
"factory": "./migrations/injectable-pipe/index"
18+
}
19+
}
20+
}

‎packages/core/schematics/test/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ts_library(
55
testonly = True,
66
srcs = glob(["**/*.ts"]),
77
data = [
8-
"//packages/core/schematics:migrations.json",
8+
"//packages/core/schematics:test-migrations.json",
99
],
1010
deps = [
1111
"//packages/core/schematics/migrations/injectable-pipe",

‎packages/core/schematics/test/injectable_pipe_migration_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('injectable pipe migration', () => {
2020
let previousWorkingDir: string;
2121

2222
beforeEach(() => {
23-
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
23+
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
2424
host = new TempScopedNodeJsSyncHost();
2525
tree = new UnitTestTree(new HostTree(host));
2626

@@ -123,5 +123,5 @@ describe('injectable pipe migration', () => {
123123
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
124124
}
125125

126-
function runMigration() { runner.runSchematic('migration-v8-injectable-pipe', {}, tree); }
126+
function runMigration() { runner.runSchematic('migration-injectable-pipe', {}, tree); }
127127
});

‎packages/core/schematics/test/move_document_migration_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('move-document migration', () => {
2020
let previousWorkingDir: string;
2121

2222
beforeEach(() => {
23-
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
23+
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
2424
host = new TempScopedNodeJsSyncHost();
2525
tree = new UnitTestTree(new HostTree(host));
2626

@@ -151,5 +151,5 @@ describe('move-document migration', () => {
151151
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
152152
}
153153

154-
function runMigration() { runner.runSchematic('migration-v8-move-document', {}, tree); }
154+
function runMigration() { runner.runSchematic('migration-move-document', {}, tree); }
155155
});

‎packages/core/schematics/test/static_queries_migration_template_spec.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('static-queries migration with template strategy', () => {
2121
let warnOutput: string[];
2222

2323
beforeEach(() => {
24-
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
24+
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
2525
host = new TempScopedNodeJsSyncHost();
2626
tree = new UnitTestTree(new HostTree(host));
2727

@@ -97,15 +97,15 @@ describe('static-queries migration with template strategy', () => {
9797
}
9898

9999
async function runMigration() {
100-
await runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
100+
await runner.runSchematicAsync('migration-static-queries', {}, tree).toPromise();
101101
}
102102

103103
describe('ViewChild', () => {
104104

105105
it('should detect queries selecting elements through template reference', async() => {
106106
writeFile('/index.ts', `
107107
import {Component, NgModule, ViewChild} from '@angular/core';
108-
108+
109109
@Component({template: \`
110110
<ng-template>
111111
<button #myButton>My Button</button>
@@ -118,7 +118,7 @@ describe('static-queries migration with template strategy', () => {
118118
private @ViewChild('myButton') query: any;
119119
private @ViewChild('myStaticButton') query2: any;
120120
}
121-
121+
122122
@NgModule({declarations: [MyComp]})
123123
export class MyModule {}
124124
`);
@@ -134,7 +134,7 @@ describe('static-queries migration with template strategy', () => {
134134
it('should detect queries selecting ng-template as static', async() => {
135135
writeFile('/index.ts', `
136136
import {Component, NgModule, ViewChild} from '@angular/core';
137-
137+
138138
@Component({template: \`
139139
<ng-template #myTmpl>
140140
My template
@@ -143,7 +143,7 @@ describe('static-queries migration with template strategy', () => {
143143
export class MyComp {
144144
private @ViewChild('myTmpl') query: any;
145145
}
146-
146+
147147
@NgModule({declarations: [MyComp]})
148148
export class MyModule {}
149149
`);
@@ -157,29 +157,29 @@ describe('static-queries migration with template strategy', () => {
157157
it('should detect queries selecting component view providers through string token', async() => {
158158
writeFile('/index.ts', `
159159
import {Component, Directive, NgModule, ViewChild} from '@angular/core';
160-
160+
161161
@Directive({
162162
selector: '[myDirective]',
163163
providers: [
164164
{provide: 'my-token', useValue: 'test'}
165165
]
166166
})
167167
export class MyDirective {}
168-
168+
169169
@Directive({
170170
selector: '[myDirective2]',
171171
providers: [
172172
{provide: 'my-token-2', useValue: 'test'}
173173
]
174174
})
175175
export class MyDirective2 {}
176-
176+
177177
@Component({templateUrl: './my-tmpl.html'})
178178
export class MyComp {
179179
private @ViewChild('my-token') query: any;
180180
private @ViewChild('my-token-2') query2: any;
181181
}
182-
182+
183183
@NgModule({declarations: [MyComp, MyDirective, MyDirective2]})
184184
export class MyModule {}
185185
`);
@@ -202,28 +202,28 @@ describe('static-queries migration with template strategy', () => {
202202
it('should detect queries selecting component view providers using class token', async() => {
203203
writeFile('/index.ts', `
204204
import {Component, Directive, NgModule, ViewChild} from '@angular/core';
205-
205+
206206
export class MyService {}
207207
export class MyService2 {}
208-
208+
209209
@Directive({
210210
selector: '[myDirective]',
211211
providers: [MyService]
212212
})
213213
export class MyDirective {}
214-
214+
215215
@Directive({
216216
selector: '[myDirective2]',
217217
providers: [MyService2]
218218
})
219219
export class MyDirective2 {}
220-
220+
221221
@Component({templateUrl: './my-tmpl.html'})
222222
export class MyComp {
223223
private @ViewChild(MyService) query: any;
224224
private @ViewChild(MyService2) query2: any;
225225
}
226-
226+
227227
@NgModule({declarations: [MyComp, MyDirective, MyDirective2]})
228228
export class MyModule {}
229229
`);
@@ -247,7 +247,7 @@ describe('static-queries migration with template strategy', () => {
247247
writeFile('/index.ts', `
248248
import {Component, NgModule, ViewChild} from '@angular/core';
249249
import {HomeComponent, HomeComponent2} from './home-comp';
250-
250+
251251
@Component({
252252
template: \`
253253
<home-comp></home-comp>
@@ -260,20 +260,20 @@ describe('static-queries migration with template strategy', () => {
260260
private @ViewChild(HomeComponent) query: any;
261261
private @ViewChild(HomeComponent2) query2: any;
262262
}
263-
263+
264264
@NgModule({declarations: [MyComp, HomeComponent, HomeComponent2]})
265265
export class MyModule {}
266266
`);
267267

268268
writeFile(`/home-comp.ts`, `
269269
import {Component} from '@angular/core';
270-
270+
271271
@Component({
272272
selector: 'home-comp',
273273
template: '<span>Home</span>'
274274
})
275275
export class HomeComponent {}
276-
276+
277277
@Component({
278278
selector: 'home-comp2',
279279
template: '<span>Home 2</span>'
@@ -294,12 +294,12 @@ describe('static-queries migration with template strategy', () => {
294294
writeFile('/index.ts', `
295295
import {Component, NgModule, ViewChild} from '@angular/core';
296296
import {MyLibComponent} from 'my-lib';
297-
297+
298298
@Component({templateUrl: './my-tmpl.html'})
299299
export class MyComp {
300300
private @ViewChild(MyLibComponent) query: any;
301301
}
302-
302+
303303
@NgModule({declarations: [MyComp, MyLibComponent]})
304304
export class MyModule {}
305305
`);
@@ -319,12 +319,12 @@ describe('static-queries migration with template strategy', () => {
319319
writeFile('/index.ts', `
320320
import {Component, NgModule, ViewChild} from '@angular/core';
321321
import {MyLibComponent} from 'my-lib';
322-
322+
323323
@Component({templateUrl: './my-tmpl.html'})
324324
export class MyComp {
325325
private @ViewChild(MyLibComponent) query: any;
326326
}
327-
327+
328328
@NgModule({declarations: [MyComp, MyLibComponent]})
329329
export class MyModule {}
330330
`);
@@ -345,16 +345,16 @@ describe('static-queries migration with template strategy', () => {
345345
it('should detect queries within structural directive', async() => {
346346
writeFile('/index.ts', `
347347
import {Component, Directive, NgModule, ViewChild} from '@angular/core';
348-
348+
349349
@Directive({selector: '[ngIf]'})
350350
export class FakeNgIf {}
351-
351+
352352
@Component({templateUrl: 'my-tmpl.html'})
353353
export class MyComp {
354354
private @ViewChild('myRef') query: any;
355355
private @ViewChild('myRef2') query2: any;
356356
}
357-
357+
358358
@NgModule({declarations: [MyComp, FakeNgIf]})
359359
export class MyModule {}
360360
`);
@@ -375,14 +375,14 @@ describe('static-queries migration with template strategy', () => {
375375
it('should detect inherited queries', async() => {
376376
writeFile('/index.ts', `
377377
import {Component, NgModule, ViewChild} from '@angular/core';
378-
378+
379379
export class BaseClass {
380380
@ViewChild('myRef') query: any;
381381
}
382-
382+
383383
@Component({templateUrl: 'my-tmpl.html'})
384384
export class MyComp extends BaseClass {}
385-
385+
386386
@NgModule({declarations: [MyComp]})
387387
export class MyModule {}
388388
`);
@@ -400,7 +400,7 @@ describe('static-queries migration with template strategy', () => {
400400
it('should add a todo if a query is not declared in any component', async() => {
401401
writeFile('/index.ts', `
402402
import {Component, NgModule, ViewChild, SomeToken} from '@angular/core';
403-
403+
404404
export class NotAComponent {
405405
@ViewChild('myRef', {read: SomeToken}) query: any;
406406
}
@@ -420,17 +420,17 @@ describe('static-queries migration with template strategy', () => {
420420
it('should add a todo if a query is used multiple times with different timing', async() => {
421421
writeFile('/index.ts', `
422422
import {Component, NgModule, ViewChild} from '@angular/core';
423-
423+
424424
export class BaseClass {
425425
@ViewChild('myRef') query: any;
426426
}
427-
427+
428428
@Component({template: '<ng-template><p #myRef></p></ng-template>'})
429429
export class FirstComp extends BaseClass {}
430-
430+
431431
@Component({template: '<span #myRef></span>'})
432432
export class SecondComp extends BaseClass {}
433-
433+
434434
@NgModule({declarations: [FirstComp, SecondComp]})
435435
export class MyModule {}
436436
`);
@@ -448,12 +448,12 @@ describe('static-queries migration with template strategy', () => {
448448
it('should gracefully exit migration if queries could not be analyzed', async() => {
449449
writeFile('/index.ts', `
450450
import {Component, ViewChild} from '@angular/core';
451-
451+
452452
@Component({template: '<ng-template><p #myRef></p></ng-template>'})
453453
export class MyComp {
454454
@ViewChild('myRef') query: any;
455455
}
456-
456+
457457
// **NOTE**: Analysis will fail as there is no "NgModule" that declares the component.
458458
`);
459459

@@ -533,7 +533,7 @@ describe('static-queries migration with template strategy', () => {
533533
writeFile('/src/test.ts', `
534534
import {ViewChild} from '@angular/core';
535535
import {AppComponent} from './app.component';
536-
536+
537537
@Component({template: '<span #test>Test</span>'})
538538
class MyTestComponent {
539539
@ViewChild('test') query: any;
@@ -542,7 +542,7 @@ describe('static-queries migration with template strategy', () => {
542542

543543
writeFile('/src/app.component.ts', `
544544
import {Component, ViewChild} from '@angular/core';
545-
545+
546546
@Component({template: '<span #test></span>'})
547547
export class AppComponent {
548548
@ViewChild('test') query: any;
@@ -552,7 +552,7 @@ describe('static-queries migration with template strategy', () => {
552552
writeFile('/src/app.module.ts', `
553553
import {NgModule} from '@angular/core';
554554
import {AppComponent} from './app.component';
555-
555+
556556
@NgModule({declarations: [AppComponent]})
557557
export class MyModule {}
558558
`);

0 commit comments

Comments
 (0)