From 3af99a7b4aed592fa2dbf2b73458d3a5e2ad68e1 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 27 Aug 2019 15:09:09 +0200 Subject: [PATCH] refactor(core): wire up missing-injectable migration for ng-update (#32349) Initially the `missing-injectable` migration was only being used in google3. Wiring the migration up in the CLI migrations was planned to be done in a follow-up. PR Close #32349 --- packages/core/schematics/BUILD.bazel | 1 + packages/core/schematics/migrations.json | 5 +++++ packages/core/schematics/test/BUILD.bazel | 1 - .../test/missing_injectable_migration_spec.ts | 4 ++-- packages/core/schematics/test/test-migrations.json | 10 ---------- 5 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 packages/core/schematics/test/test-migrations.json diff --git a/packages/core/schematics/BUILD.bazel b/packages/core/schematics/BUILD.bazel index 4c227c9316..23433e4a0d 100644 --- a/packages/core/schematics/BUILD.bazel +++ b/packages/core/schematics/BUILD.bazel @@ -10,6 +10,7 @@ npm_package( srcs = ["migrations.json"], visibility = ["//packages/core:__pkg__"], deps = [ + "//packages/core/schematics/migrations/missing-injectable", "//packages/core/schematics/migrations/move-document", "//packages/core/schematics/migrations/renderer-to-renderer2", "//packages/core/schematics/migrations/static-queries", diff --git a/packages/core/schematics/migrations.json b/packages/core/schematics/migrations.json index e4255c52f8..aac7cb8d82 100644 --- a/packages/core/schematics/migrations.json +++ b/packages/core/schematics/migrations.json @@ -20,6 +20,11 @@ "description": "Migrates usages of Renderer to Renderer2", "factory": "./migrations/renderer-to-renderer2/index" }, + "migration-v9-missing-injectable": { + "version": "9-beta", + "description": "Decorates all declared undecorated provider classes with @Injectable", + "factory": "./migrations/missing-injectable/index" + }, "migration-v9-undecorated-classes-with-di": { "version": "9-beta", "description": "Decorates undecorated base classes of directives/components that use dependency injection. Copies metadata from base classes to derived directives/components/pipes that are not decorated.", diff --git a/packages/core/schematics/test/BUILD.bazel b/packages/core/schematics/test/BUILD.bazel index d863cfd32c..f342e28309 100644 --- a/packages/core/schematics/test/BUILD.bazel +++ b/packages/core/schematics/test/BUILD.bazel @@ -5,7 +5,6 @@ ts_library( testonly = True, srcs = glob(["**/*.ts"]), data = [ - "test-migrations.json", "//packages/core/schematics:migrations.json", ], deps = [ diff --git a/packages/core/schematics/test/missing_injectable_migration_spec.ts b/packages/core/schematics/test/missing_injectable_migration_spec.ts index d74fb88ac3..5614e7581c 100644 --- a/packages/core/schematics/test/missing_injectable_migration_spec.ts +++ b/packages/core/schematics/test/missing_injectable_migration_spec.ts @@ -21,7 +21,7 @@ describe('Missing injectable migration', () => { let warnOutput: string[]; beforeEach(() => { - runner = new SchematicTestRunner('test', require.resolve('./test-migrations.json')); + runner = new SchematicTestRunner('test', require.resolve('../migrations.json')); host = new TempScopedNodeJsSyncHost(); tree = new UnitTestTree(new HostTree(host)); @@ -61,7 +61,7 @@ describe('Missing injectable migration', () => { } async function runMigration() { - await runner.runSchematicAsync('migration-missing-injectable', {}, tree).toPromise(); + await runner.runSchematicAsync('migration-v9-missing-injectable', {}, tree).toPromise(); } it('should migrate type provider in NgModule', async() => { diff --git a/packages/core/schematics/test/test-migrations.json b/packages/core/schematics/test/test-migrations.json deleted file mode 100644 index dca30a068c..0000000000 --- a/packages/core/schematics/test/test-migrations.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // Migrations which are not publicly enabled but still run as part of tests need to - // be part of a schematic collection in order to be able to run it. - "schematics": { - "migration-missing-injectable": { - "description": "Migrates all declared undecorated providers with the @Injectable decorator", - "factory": "../migrations/missing-injectable/index" - } - } -}