Skip to content

Commit

Permalink
feat(@schematics/angular): remove deprecated options
Browse files Browse the repository at this point in the history
With this change we removed several deprecated `@schematics/angular` deprecated options.

BREAKING CHANGE:

We removed several deprecated `@schematics/angular` deprecated options.
- `lintFix` have been removed from all schematics. `ng lint --fix` should be used instead.
- `legacyBrowsers` have been removed from the `application` schematics since IE 11 is no longer supported.
- `configuration` has been removed from the `web-worker` as it was unused.
- `target` has been removed from the `service-worker` as it was unused.
  • Loading branch information
alan-agius4 authored and filipesilva committed Jul 30, 2021
1 parent ac3fc27 commit 5986bef
Show file tree
Hide file tree
Showing 35 changed files with 141 additions and 236 deletions.
1 change: 0 additions & 1 deletion docs/design/analytics.md
Expand Up @@ -58,7 +58,6 @@ Note: There's a limit of 20 custom dimensions.
| 12 | `Flag: --skip-tests` | `boolean` |
| 13 | `Flag: --aot` | `boolean` |
| 14 | `Flag: --minimal` | `boolean` |
| 15 | `Flag: --lint-fix` | `boolean` |
| 16 | `Flag: --optimization` | `boolean` |
| 17 | `Flag: --routing` | `boolean` |
| 18 | `Flag: --skip-import` | `boolean` |
Expand Down
1 change: 0 additions & 1 deletion packages/angular/pwa/pwa/index_spec.ts
Expand Up @@ -18,7 +18,6 @@ describe('PWA Schematic', () => {
const defaultOptions: PwaOptions = {
project: 'bar',
target: 'build',
configuration: 'production',
title: 'Fake Title',
};

Expand Down
5 changes: 0 additions & 5 deletions packages/angular/pwa/pwa/schema.json
Expand Up @@ -16,11 +16,6 @@
"description": "The target to apply service worker to.",
"default": "build"
},
"configuration": {
"type": "string",
"description": "The configuration to apply service worker to.",
"default": "production"
},
"title": {
"type": "string",
"description": "The title of the application."
Expand Down
Expand Up @@ -13,6 +13,4 @@ last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR<% if (legacyBrowsers) { %>
IE 11<% } else { %>
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.<% } %>
Firefox ESR
2 changes: 0 additions & 2 deletions packages/schematics/angular/application/index.ts
Expand Up @@ -27,7 +27,6 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import { Schema as ComponentOptions } from '../component/schema';
import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies';
import { latestVersions } from '../utility/latest-versions';
import { applyLintFix } from '../utility/lint-fix';
import { relativePathToWorkspaceRoot } from '../utility/paths';
import { validateProjectName } from '../utility/validation';
import { getWorkspace, updateWorkspace } from '../utility/workspace';
Expand Down Expand Up @@ -324,7 +323,6 @@ export default function (options: ApplicationOptions): Rule {
MergeStrategy.Overwrite,
),
options.skipPackageJson ? noop() : addDependenciesToPackageJson(options),
options.lintFix ? applyLintFix(appDir) : noop(),
]);
};
}
19 changes: 0 additions & 19 deletions packages/schematics/angular/application/index_spec.ts
Expand Up @@ -525,25 +525,6 @@ describe('Application Schematic', () => {
});
});

it(`should add support for IE 11 in '.browserslistrc' when 'legacyBrowsers' is true`, async () => {
const options: ApplicationOptions = { ...defaultOptions, legacyBrowsers: true };
const tree = await schematicRunner
.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const content = tree.readContent('/projects/foo/.browserslistrc');
expect(content).not.toContain('not IE 11');
expect(content).toContain('IE 11');
});

it(`should not add support for IE 11 in '.browserslistrc' when 'legacyBrowsers' is false`, async () => {
const options: ApplicationOptions = { ...defaultOptions, legacyBrowsers: false };
const tree = await schematicRunner
.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const content = tree.readContent('/projects/foo/.browserslistrc');
expect(content).toContain('not IE 11');
});

it(`should create kebab-case project folder names with camelCase project name`, async () => {
const options: ApplicationOptions = { ...defaultOptions, name: 'myCool' };
const tree = await schematicRunner
Expand Down
12 changes: 0 additions & 12 deletions packages/schematics/angular/application/schema.json
Expand Up @@ -101,23 +101,11 @@
"type": "boolean",
"default": false
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the application.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
},
"strict": {
"description": "Creates an application with stricter bundle budgets settings.",
"type": "boolean",
"default": true,
"x-user-analytics": 7
},
"legacyBrowsers": {
"type": "boolean",
"description": "Add support for legacy browsers like Internet Explorer using differential loading.",
"default": false,
"x-deprecated": "Legacy browsers support is deprecated since version 12. For more information, see https://angular.io/guide/browser-support"
}
},
"required": ["name"]
Expand Down
7 changes: 0 additions & 7 deletions packages/schematics/angular/class/schema.json
Expand Up @@ -38,13 +38,6 @@
"type": "string",
"description": "Adds a developer-defined type to the filename, in the format \"name.type.ts\".",
"default": ""
},
"lintFix": {
"type": "boolean",
"default": false,
"description": "Apply lint fixes after generating the class.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": ["name"]
Expand Down
7 changes: 1 addition & 6 deletions packages/schematics/angular/component/index.ts
Expand Up @@ -26,7 +26,6 @@ import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescri
import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils';
import { InsertChange } from '../utility/change';
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
import { applyLintFix } from '../utility/lint-fix';
import { parseName } from '../utility/parse-name';
import { validateHtmlSelector, validateName } from '../utility/validation';
import { buildDefaultPath, getWorkspace } from '../utility/workspace';
Expand Down Expand Up @@ -158,10 +157,6 @@ export default function (options: ComponentOptions): Rule {
move(parsedPath.path),
]);

return chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
return chain([addDeclarationToNgModule(options), mergeWith(templateSource)]);
};
}
6 changes: 0 additions & 6 deletions packages/schematics/angular/component/schema.json
Expand Up @@ -125,12 +125,6 @@
"default": false,
"description": "The declaring NgModule exports this component.",
"x-user-analytics": 19
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the component.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": ["name"]
Expand Down
7 changes: 1 addition & 6 deletions packages/schematics/angular/directive/index.ts
Expand Up @@ -24,7 +24,6 @@ import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescri
import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils';
import { InsertChange } from '../utility/change';
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
import { applyLintFix } from '../utility/lint-fix';
import { parseName } from '../utility/parse-name';
import { validateHtmlSelector } from '../utility/validation';
import { buildDefaultPath, getWorkspace } from '../utility/workspace';
Expand Down Expand Up @@ -136,10 +135,6 @@ export default function (options: DirectiveOptions): Rule {
move(parsedPath.path),
]);

return chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
return chain([addDeclarationToNgModule(options), mergeWith(templateSource)]);
};
}
6 changes: 0 additions & 6 deletions packages/schematics/angular/directive/schema.json
Expand Up @@ -74,12 +74,6 @@
"default": false,
"description": "The declaring NgModule exports this directive.",
"x-user-analytics": 19
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the directive.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": ["name"]
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/enum/schema.json
Expand Up @@ -31,12 +31,6 @@
"type": {
"type": "string",
"description": "Adds a developer-defined type to the filename, in the format \"name.type.ts\"."
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the enum.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": ["name"]
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/guard/schema.json
Expand Up @@ -39,12 +39,6 @@
"$source": "projectName"
}
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the guard.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
},
"implements": {
"type": "array",
"description": "Specifies which interfaces to implement.",
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/interceptor/schema.json
Expand Up @@ -38,12 +38,6 @@
"description": "Do not create \"spec.ts\" test files for the new interceptor.",
"default": false,
"x-user-analytics": 12
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the interceptor.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": ["name"]
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/interface/schema.json
Expand Up @@ -40,12 +40,6 @@
"$source": "argv",
"index": 1
}
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the interface.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": ["name"]
Expand Down
2 changes: 0 additions & 2 deletions packages/schematics/angular/library/index.ts
Expand Up @@ -25,7 +25,6 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies';
import { JSONFile } from '../utility/json-file';
import { latestVersions } from '../utility/latest-versions';
import { applyLintFix } from '../utility/lint-fix';
import { relativePathToWorkspaceRoot } from '../utility/paths';
import { validateProjectName } from '../utility/validation';
import { getWorkspace, updateWorkspace } from '../utility/workspace';
Expand Down Expand Up @@ -197,7 +196,6 @@ export default function (options: LibraryOptions): Rule {
path: sourceDir,
project: projectName,
}),
options.lintFix ? applyLintFix(sourceDir) : noop(),
(_tree: Tree, context: SchematicContext) => {
if (!options.skipPackageJson && !options.skipInstall) {
context.addTask(new NodePackageInstallTask());
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/library/schema.json
Expand Up @@ -43,12 +43,6 @@
"type": "boolean",
"default": false,
"description": "Do not update \"tsconfig.json\" to add a path mapping for the new library. The path mapping is needed to use the library in an app, but can be disabled here to simplify development."
},
"lintFix": {
"type": "boolean",
"description": "Apply lint fixes after generating the library.",
"x-user-analytics": 15,
"x-deprecated": "Use \"ng lint --fix\" directly instead."
}
},
"required": []
Expand Down
Expand Up @@ -129,6 +129,11 @@
"version": "9999.0.0",
"factory": "./update-12/production-default-config",
"description": "Optional migration to update Angular CLI workspace configurations to 'production' mode by default."
},
"schematic-options-13": {
"version": "13.0.0",
"factory": "./update-13/schematic-options",
"description": "Remove no longer valid Angular schematic options from `angular.json`."
}
}
}
@@ -0,0 +1,55 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import { json } from '@angular-devkit/core';
import { Rule } from '@angular-devkit/schematics';
import { updateWorkspace } from '../../utility/workspace';

export default function (): Rule {
return updateWorkspace((workspace) => {
// Update root level schematics options if present
const rootSchematics = workspace.extensions.schematics;
if (rootSchematics && json.isJsonObject(rootSchematics)) {
updateSchematicsField(rootSchematics);
}

// Update project level schematics options if present
for (const [, project] of workspace.projects) {
const projectSchematics = project.extensions.schematics;
if (projectSchematics && json.isJsonObject(projectSchematics)) {
updateSchematicsField(projectSchematics);
}
}
});
}

function updateSchematicsField(schematics: json.JsonObject): void {
for (const [schematicName, schematicOptions] of Object.entries(schematics)) {
if (!json.isJsonObject(schematicOptions)) {
continue;
}

if (schematicName.startsWith('@schematics/angular')) {
delete schematicOptions.lintFix;
}

switch (schematicName) {
case '@schematics/angular:service-worker':
delete schematicOptions.configuration;
break;
case '@schematics/angular:web-worker':
delete schematicOptions.target;
break;
case '@schematics/angular:application':
delete schematicOptions.legacyBrowsers;
break;
default:
break;
}
}
}

0 comments on commit 5986bef

Please sign in to comment.