From e92c46a3cf01d44e9393b661a03a48e3775e821f Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 22 Oct 2019 18:57:55 +0200 Subject: [PATCH] refactor(@schematics/angular): remove deprecated `spec` and `styleext` options BREAKING CHANGE: Deprecated `styleext` and `spec` options have been removed. Use `style` and `skipTests` options instead. --- packages/angular/cli/lib/config/schema.json | 30 ------------------- packages/schematics/angular/class/index.ts | 3 -- .../schematics/angular/class/index_spec.ts | 4 +-- packages/schematics/angular/class/schema.json | 6 ---- .../schematics/angular/component/index.ts | 7 ----- .../angular/component/index_spec.ts | 29 ------------------ .../schematics/angular/component/schema.json | 12 -------- .../schematics/angular/directive/index.ts | 3 -- .../schematics/angular/directive/schema.json | 6 ---- packages/schematics/angular/pipe/index.ts | 3 -- .../schematics/angular/pipe/index_spec.ts | 1 - packages/schematics/angular/pipe/schema.json | 6 ---- packages/schematics/angular/service/index.ts | 3 -- .../schematics/angular/service/schema.json | 6 ---- .../e2e/tests/commands/new/new-style.ts | 2 +- 15 files changed, 3 insertions(+), 118 deletions(-) diff --git a/packages/angular/cli/lib/config/schema.json b/packages/angular/cli/lib/config/schema.json index 1fde7a4b6541..cdb0ff65b476 100644 --- a/packages/angular/cli/lib/config/schema.json +++ b/packages/angular/cli/lib/config/schema.json @@ -134,16 +134,6 @@ "description": "Flag to skip the module import.", "default": false }, - "spec": { - "type": "boolean", - "description": "Specifies if a spec file is generated.", - "default": true - }, - "styleext": { - "description": "The file extension to be used for style files.", - "type": "string", - "default": "css" - }, "style": { "description": "The file extension or preprocessor to use for style files.", "type": "string", @@ -199,11 +189,6 @@ "description": "Flag to skip the module import.", "default": false }, - "spec": { - "type": "boolean", - "description": "Specifies if a spec file is generated.", - "default": true - }, "skipTests": { "type": "boolean", "description": "When true, does not create test files.", @@ -251,11 +236,6 @@ "default": true, "description": "Flag to indicate if a directory is created." }, - "spec": { - "type": "boolean", - "description": "Specifies if a spec file is generated.", - "default": true - }, "skipTests": { "type": "boolean", "description": "When true, does not create test files.", @@ -271,11 +251,6 @@ "default": true, "description": "Flag to indicate if a directory is created." }, - "spec": { - "type": "boolean", - "description": "Specifies if a spec file is generated.", - "default": true - }, "skipTests": { "type": "boolean", "description": "When true, does not create test files.", @@ -302,11 +277,6 @@ "@schematics/angular:class": { "type": "object", "properties": { - "spec": { - "type": "boolean", - "description": "Specifies if a spec file is generated.", - "default": true - }, "skipTests": { "type": "boolean", "description": "When true, does not create test files.", diff --git a/packages/schematics/angular/class/index.ts b/packages/schematics/angular/class/index.ts index 46c1f4626bc7..d01184b655a8 100644 --- a/packages/schematics/angular/class/index.ts +++ b/packages/schematics/angular/class/index.ts @@ -35,9 +35,6 @@ export default function (options: ClassOptions): Rule { options.name = parsedPath.name; options.path = parsedPath.path; - // todo remove these when we remove the deprecations - options.skipTests = options.skipTests || !options.spec; - const templateSource = apply(url('./files'), [ options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(), applyTemplates({ diff --git a/packages/schematics/angular/class/index_spec.ts b/packages/schematics/angular/class/index_spec.ts index 5e198256e811..674d083d759d 100644 --- a/packages/schematics/angular/class/index_spec.ts +++ b/packages/schematics/angular/class/index_spec.ts @@ -19,7 +19,7 @@ describe('Class Schematic', () => { const defaultOptions: ClassOptions = { name: 'foo', type: '', - spec: false, + skipTests: true, project: 'bar', }; @@ -55,7 +55,7 @@ describe('Class Schematic', () => { it('should create the class and spec file', async () => { const options = { ...defaultOptions, - spec: true, + skipTests: false, }; const tree = await schematicRunner.runSchematicAsync('class', options, appTree) .toPromise(); diff --git a/packages/schematics/angular/class/schema.json b/packages/schematics/angular/class/schema.json index 285cfc55af14..7f432949bc73 100644 --- a/packages/schematics/angular/class/schema.json +++ b/packages/schematics/angular/class/schema.json @@ -27,12 +27,6 @@ "$source": "projectName" } }, - "spec": { - "type": "boolean", - "description": "When true (the default), generates a \"spec.ts\" test file for the new class.", - "default": true, - "x-deprecated": "Use \"skipTests\" instead." - }, "skipTests": { "type": "boolean", "description": "When true, does not create \"spec.ts\" test files for the new class.", diff --git a/packages/schematics/angular/component/index.ts b/packages/schematics/angular/component/index.ts index 84783fe31008..cdeeba206700 100644 --- a/packages/schematics/angular/component/index.ts +++ b/packages/schematics/angular/component/index.ts @@ -143,13 +143,6 @@ export default function (options: ComponentOptions): Rule { options.path = parsedPath.path; options.selector = options.selector || buildSelector(options, project && project.prefix || ''); - // todo remove these when we remove the deprecations - options.style = ( - options.style && options.style !== Style.Css - ? options.style : options.styleext as Style - ) || Style.Css; - options.skipTests = options.skipTests || !options.spec; - validateName(options.name); validateHtmlSelector(options.selector); diff --git a/packages/schematics/angular/component/index_spec.ts b/packages/schematics/angular/component/index_spec.ts index 3968de0b552f..696009a249f3 100644 --- a/packages/schematics/angular/component/index_spec.ts +++ b/packages/schematics/angular/component/index_spec.ts @@ -333,33 +333,4 @@ describe('Component Schematic', () => { .toPromise(); expect(appTree.files).toContain('/projects/bar/custom/app/foo/foo.component.ts'); }); - - // testing deprecating options don't cause conflicts - it('should respect the deprecated styleext (scss) option', async () => { - const options = { ...defaultOptions, style: undefined, styleext: 'scss' }; - const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise(); - const files = tree.files; - expect(files).toContain('/projects/bar/src/app/foo/foo.component.scss'); - }); - - it('should respect the deprecated styleext (css) option', async () => { - const options = { ...defaultOptions, style: undefined, styleext: 'css' }; - const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise(); - const files = tree.files; - expect(files).toContain('/projects/bar/src/app/foo/foo.component.css'); - }); - - it('should respect the deprecated spec option when false', async () => { - const options = { ...defaultOptions, skipTests: undefined, spec: false }; - const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise(); - const files = tree.files; - expect(files).not.toContain('/projects/bar/src/app/foo/foo.component.spec.ts'); - }); - - it('should respect the deprecated spec option when true', async () => { - const options = { ...defaultOptions, skipTests: false, spec: true }; - const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise(); - const files = tree.files; - expect(files).toContain('/projects/bar/src/app/foo/foo.component.spec.ts'); - }); }); diff --git a/packages/schematics/angular/component/schema.json b/packages/schematics/angular/component/schema.json index 2cbc2524a8f7..8172eaf9a305 100644 --- a/packages/schematics/angular/component/schema.json +++ b/packages/schematics/angular/component/schema.json @@ -69,12 +69,6 @@ } ] }, - "styleext": { - "description": "The file extension to use for style files.", - "type": "string", - "default": "css", - "x-deprecated": "Use \"style\" instead." - }, "style": { "description": "The file extension or preprocessor to use for style files.", "type": "string", @@ -93,12 +87,6 @@ "description": "Adds a developer-defined type to the filename, in the format \"name.type.ts\".", "default": "Component" }, - "spec": { - "type": "boolean", - "description": "When true (the default), generates a \"spec.ts\" test file for the new component.", - "default": true, - "x-deprecated": "Use \"skipTests\" instead." - }, "skipTests": { "type": "boolean", "description": "When true, does not create \"spec.ts\" test files for the new component.", diff --git a/packages/schematics/angular/directive/index.ts b/packages/schematics/angular/directive/index.ts index 28d89e5d00e1..056455fb6b3b 100644 --- a/packages/schematics/angular/directive/index.ts +++ b/packages/schematics/angular/directive/index.ts @@ -121,9 +121,6 @@ export default function (options: DirectiveOptions): Rule { validateHtmlSelector(options.selector); - // todo remove these when we remove the deprecations - options.skipTests = options.skipTests || !options.spec; - const templateSource = apply(url('./files'), [ options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(), applyTemplates({ diff --git a/packages/schematics/angular/directive/schema.json b/packages/schematics/angular/directive/schema.json index d2ea12577f69..41ec011e366f 100644 --- a/packages/schematics/angular/directive/schema.json +++ b/packages/schematics/angular/directive/schema.json @@ -41,12 +41,6 @@ } ] }, - "spec": { - "type": "boolean", - "description": "When true (the default), generates a \"spec.ts\" test file for the new directive.", - "default": true, - "x-deprecated": "Use \"skipTests\" instead." - }, "skipTests": { "type": "boolean", "description": "When true, does not create \"spec.ts\" test files for the new class.", diff --git a/packages/schematics/angular/pipe/index.ts b/packages/schematics/angular/pipe/index.ts index 54b09cb0a2dd..0e6345076490 100644 --- a/packages/schematics/angular/pipe/index.ts +++ b/packages/schematics/angular/pipe/index.ts @@ -96,9 +96,6 @@ export default function (options: PipeOptions): Rule { options.name = parsedPath.name; options.path = parsedPath.path; - // todo remove these when we remove the deprecations - options.skipTests = options.skipTests || !options.spec; - const templateSource = apply(url('./files'), [ options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(), applyTemplates({ diff --git a/packages/schematics/angular/pipe/index_spec.ts b/packages/schematics/angular/pipe/index_spec.ts index 84edd9f654e5..98772fe02470 100644 --- a/packages/schematics/angular/pipe/index_spec.ts +++ b/packages/schematics/angular/pipe/index_spec.ts @@ -19,7 +19,6 @@ describe('Pipe Schematic', () => { ); const defaultOptions: PipeOptions = { name: 'foo', - spec: true, module: undefined, export: false, flat: true, diff --git a/packages/schematics/angular/pipe/schema.json b/packages/schematics/angular/pipe/schema.json index 5f65fffff113..09788e639dcf 100644 --- a/packages/schematics/angular/pipe/schema.json +++ b/packages/schematics/angular/pipe/schema.json @@ -32,12 +32,6 @@ "default": true, "description": "When true (the default) creates files at the top level of the project." }, - "spec": { - "type": "boolean", - "default": true, - "description": "When true (the default), generates a \"spec.ts\" test file for the new pipe.", - "x-deprecated": "Use \"skipTests\" instead." - }, "skipTests": { "type": "boolean", "description": "When true, does not create \"spec.ts\" test files for the new pipe.", diff --git a/packages/schematics/angular/service/index.ts b/packages/schematics/angular/service/index.ts index 2e6681e03b58..c509f05c164f 100644 --- a/packages/schematics/angular/service/index.ts +++ b/packages/schematics/angular/service/index.ts @@ -33,9 +33,6 @@ export default function (options: ServiceOptions): Rule { options.name = parsedPath.name; options.path = parsedPath.path; - // todo remove these when we remove the deprecations - options.skipTests = options.skipTests || !options.spec; - const templateSource = apply(url('./files'), [ options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(), applyTemplates({ diff --git a/packages/schematics/angular/service/schema.json b/packages/schematics/angular/service/schema.json index e11a84e1b957..0c84ee245c10 100644 --- a/packages/schematics/angular/service/schema.json +++ b/packages/schematics/angular/service/schema.json @@ -32,12 +32,6 @@ "default": true, "description": "When true (the default), creates files at the top level of the project." }, - "spec": { - "type": "boolean", - "default": true, - "description": "When true (the default), generates a \"spec.ts\" test file for the new service.", - "x-deprecated": "Use \"skipTests\" instead." - }, "skipTests": { "type": "boolean", "description": "When true, does not create \"spec.ts\" test files for the new service.", diff --git a/tests/legacy-cli/e2e/tests/commands/new/new-style.ts b/tests/legacy-cli/e2e/tests/commands/new/new-style.ts index 62958ef392de..c0e2d9e2b894 100644 --- a/tests/legacy-cli/e2e/tests/commands/new/new-style.ts +++ b/tests/legacy-cli/e2e/tests/commands/new/new-style.ts @@ -5,7 +5,7 @@ import {expectFileToExist} from '../../../utils/fs'; export default function() { return Promise.resolve() - .then(() => ng('config', 'defaults.styleExt', 'scss', '--global')) + .then(() => ng('config', 'defaults.style', 'scss', '--global')) .then(() => createProject('style-project')) .then(() => expectFileToExist('src/app/app.component.scss'))