Skip to content

Commit

Permalink
refactor(@schematics/angular): remove deprecated spec and `styleext…
Browse files Browse the repository at this point in the history
…` options

BREAKING CHANGE:

Deprecated `styleext` and `spec` options have been removed.  Use `style` and `skipTests` options instead.
  • Loading branch information
alan-agius4 authored and vikerman committed Oct 22, 2019
1 parent 613f7db commit e92c46a
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 118 deletions.
30 changes: 0 additions & 30 deletions packages/angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand All @@ -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.",
Expand All @@ -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.",
Expand Down
3 changes: 0 additions & 3 deletions packages/schematics/angular/class/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions packages/schematics/angular/class/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Class Schematic', () => {
const defaultOptions: ClassOptions = {
name: 'foo',
type: '',
spec: false,
skipTests: true,
project: 'bar',
};

Expand Down Expand Up @@ -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();
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/class/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
7 changes: 0 additions & 7 deletions packages/schematics/angular/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
29 changes: 0 additions & 29 deletions packages/schematics/angular/component/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
12 changes: 0 additions & 12 deletions packages/schematics/angular/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.",
Expand Down
3 changes: 0 additions & 3 deletions packages/schematics/angular/directive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/directive/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
3 changes: 0 additions & 3 deletions packages/schematics/angular/pipe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 0 additions & 1 deletion packages/schematics/angular/pipe/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('Pipe Schematic', () => {
);
const defaultOptions: PipeOptions = {
name: 'foo',
spec: true,
module: undefined,
export: false,
flat: true,
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/pipe/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
3 changes: 0 additions & 3 deletions packages/schematics/angular/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/service/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/commands/new/new-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down

0 comments on commit e92c46a

Please sign in to comment.