@schematics/angular 15.0.0-next.0 → 15.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/application/files/src/test.ts.template +4 -4
  2. package/library/files/src/test.ts.template +4 -4
  3. package/migrations/migration-collection.json +12 -27
  4. package/migrations/{update-14/remove-default-project-option.d.ts → update-15/remove-browserslist-config.d.ts} +1 -1
  5. package/migrations/update-15/remove-browserslist-config.js +94 -0
  6. package/migrations/{update-14/replace-default-collection-option.d.ts → update-15/remove-platform-server-exports.d.ts} +0 -1
  7. package/migrations/update-15/remove-platform-server-exports.js +102 -0
  8. package/migrations/{update-14/update-tsconfig-target.d.ts → update-15/update-typescript-target.d.ts} +0 -1
  9. package/migrations/update-15/update-typescript-target.js +68 -0
  10. package/package.json +3 -3
  11. package/universal/files/src/__main@stripTsExtension__.ts.template +0 -1
  12. package/workspace/files/tsconfig.json.template +4 -3
  13. package/application/files/.browserslistrc.template +0 -16
  14. package/migrations/update-14/angular-packages-version-prefix.d.ts +0 -29
  15. package/migrations/update-14/angular-packages-version-prefix.js +0 -61
  16. package/migrations/update-14/remove-default-project-option.js +0 -17
  17. package/migrations/update-14/remove-show-circular-dependencies-option.d.ts +0 -10
  18. package/migrations/update-14/remove-show-circular-dependencies-option.js +0 -26
  19. package/migrations/update-14/replace-default-collection-option.js +0 -32
  20. package/migrations/update-14/update-libraries-secondary-entrypoints.d.ts +0 -10
  21. package/migrations/update-14/update-libraries-secondary-entrypoints.js +0 -51
  22. package/migrations/update-14/update-tsconfig-target.js +0 -51
@@ -15,10 +15,10 @@ declare const require: {
15
15
  };
16
16
 
17
17
  // First, initialize the Angular testing environment.
18
- getTestBed().initTestEnvironment(
19
- BrowserDynamicTestingModule,
20
- platformBrowserDynamicTesting(),
21
- );
18
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
19
+ errorOnUnknownElements: true,
20
+ errorOnUnknownProperties: true
21
+ });
22
22
 
23
23
  // Then we find all the tests.
24
24
  const context = require.context('./', true, /\.spec\.ts$/);
@@ -16,10 +16,10 @@ declare const require: {
16
16
  };
17
17
 
18
18
  // First, initialize the Angular testing environment.
19
- getTestBed().initTestEnvironment(
20
- BrowserDynamicTestingModule,
21
- platformBrowserDynamicTesting(),
22
- );
19
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
20
+ errorOnUnknownElements: true,
21
+ errorOnUnknownProperties: true
22
+ });
23
23
 
24
24
  // Then we find all the tests.
25
25
  const context = require.context('./', true, /\.spec\.ts$/);
@@ -1,34 +1,19 @@
1
1
  {
2
2
  "schematics": {
3
- "update-angular-packages-version-prefix": {
4
- "version": "14.0.0",
5
- "factory": "./update-14/angular-packages-version-prefix",
6
- "description": "Update Angular packages 'dependencies' and 'devDependencies' version prefix to '^' instead of '~'."
3
+ "remove-browserslist-config": {
4
+ "version": "15.0.0",
5
+ "factory": "./update-15/remove-browserslist-config",
6
+ "description": "Remove Browserslist configuration files that matches the Angular CLI default configuration."
7
7
  },
8
- "update-tsconfig-target": {
9
- "version": "14.0.0",
10
- "factory": "./update-14/update-tsconfig-target",
11
- "description": "Update TypeScript compilation target to 'ES2020'."
8
+ "remove-platform-server-exports": {
9
+ "version": "15.0.0",
10
+ "factory": "./update-15/remove-platform-server-exports",
11
+ "description": "Remove exported `@angular/platform-server` `renderModule` method. The `renderModule` method is now exported by the Angular CLI."
12
12
  },
13
- "remove-show-circular-dependencies-option": {
14
- "version": "14.0.0",
15
- "factory": "./update-14/remove-show-circular-dependencies-option",
16
- "description": "Remove 'showCircularDependencies' option from browser and server builders."
17
- },
18
- "remove-default-project-option": {
19
- "version": "14.0.0",
20
- "factory": "./update-14/remove-default-project-option",
21
- "description": "Remove 'defaultProject' option from workspace configuration. The project to use will be determined from the current working directory."
22
- },
23
- "replace-default-collection-option": {
24
- "version": "14.0.0",
25
- "factory": "./update-14/replace-default-collection-option",
26
- "description": "Replace 'defaultCollection' option in workspace configuration with 'schematicCollections'."
27
- },
28
- "update-libraries-secondary-entrypoints": {
29
- "version": "14.0.0",
30
- "factory": "./update-14/update-libraries-secondary-entrypoints",
31
- "description": "Remove 'package.json' files from library projects secondary entrypoints."
13
+ "update-typescript-target": {
14
+ "version": "15.0.0",
15
+ "factory": "./update-15/update-typescript-target",
16
+ "description": "Update TypeScript compiler `target` and set `useDefineForClassFields`. These changes are for IDE purposes as TypeScript compiler options `target` and `useDefineForClassFields` are set to `ES2022` and `false` respectively by the Angular CLI. To control ECMA version and features use the Browerslist configuration."
32
17
  }
33
18
  }
34
19
  }
@@ -6,5 +6,5 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
- /** Migration to remove 'defaultProject' option from angular.json. */
9
+ export declare const DEFAULT_BROWSERS: string[];
10
10
  export default function (): Rule;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.DEFAULT_BROWSERS = void 0;
34
+ const core_1 = require("@angular-devkit/core");
35
+ const validBrowserslistConfigFilenames = new Set(['browserslist', '.browserslistrc']);
36
+ exports.DEFAULT_BROWSERS = [
37
+ 'last 1 Chrome version',
38
+ 'last 1 Firefox version',
39
+ 'last 2 Edge major versions',
40
+ 'last 2 Safari major versions',
41
+ 'last 2 iOS major versions',
42
+ 'Firefox ESR',
43
+ ];
44
+ function* visit(directory) {
45
+ for (const path of directory.subfiles) {
46
+ if (validBrowserslistConfigFilenames.has(path)) {
47
+ yield (0, core_1.join)(directory.path, path);
48
+ }
49
+ }
50
+ for (const path of directory.subdirs) {
51
+ if (path === 'node_modules') {
52
+ continue;
53
+ }
54
+ yield* visit(directory.dir(path));
55
+ }
56
+ }
57
+ function default_1() {
58
+ return async (tree, { logger }) => {
59
+ let browserslist;
60
+ try {
61
+ browserslist = (await Promise.resolve().then(() => __importStar(require('browserslist')))).default;
62
+ }
63
+ catch {
64
+ logger.warn('Skipping migration because the "browserslist" package could not be loaded.');
65
+ return;
66
+ }
67
+ // Set the defaults to match the defaults in build-angular.
68
+ browserslist.defaults = exports.DEFAULT_BROWSERS;
69
+ const defaultSupportedBrowsers = new Set(browserslist(exports.DEFAULT_BROWSERS));
70
+ const es5Browsers = new Set(browserslist(['supports es6-module']));
71
+ for (const path of visit(tree.root)) {
72
+ const { defaults: browsersListConfig, ...otherConfigs } = browserslist.parseConfig(tree.readText(path));
73
+ if (Object.keys(otherConfigs).length) {
74
+ // The config contains additional sections.
75
+ continue;
76
+ }
77
+ const browserslistInProject = browserslist(
78
+ // Exclude from the list ES5 browsers which are not supported.
79
+ browsersListConfig.map((s) => `${s} and supports es6-module`), {
80
+ ignoreUnknownVersions: true,
81
+ });
82
+ if (defaultSupportedBrowsers.size !== browserslistInProject.length) {
83
+ continue;
84
+ }
85
+ const shouldDelete = browserslistInProject.every((browser) => defaultSupportedBrowsers.has(browser));
86
+ if (shouldDelete) {
87
+ // All browsers are the same as the default config.
88
+ // Delete file as it's redundant.
89
+ tree.delete(path);
90
+ }
91
+ }
92
+ };
93
+ }
94
+ exports.default = default_1;
@@ -6,5 +6,4 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
- /** Migration to replace 'defaultCollection' option in angular.json. */
10
9
  export default function (): Rule;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
34
+ function* visit(directory) {
35
+ for (const path of directory.subfiles) {
36
+ if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
37
+ const entry = directory.file(path);
38
+ if (entry) {
39
+ const content = entry.content;
40
+ if (content.includes('@angular/platform-server') && content.includes('renderModule')) {
41
+ const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
42
+ yield source;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ for (const path of directory.subdirs) {
48
+ if (path === 'node_modules' || path.startsWith('.')) {
49
+ continue;
50
+ }
51
+ yield* visit(directory.dir(path));
52
+ }
53
+ }
54
+ function default_1() {
55
+ return (tree) => {
56
+ for (const sourceFile of visit(tree.root)) {
57
+ let recorder;
58
+ let printer;
59
+ ts.forEachChild(sourceFile, function analyze(node) {
60
+ if (!(ts.isExportDeclaration(node) &&
61
+ node.moduleSpecifier &&
62
+ ts.isStringLiteral(node.moduleSpecifier) &&
63
+ node.moduleSpecifier.text === '@angular/platform-server' &&
64
+ node.exportClause &&
65
+ ts.isNamedExports(node.exportClause))) {
66
+ // Not a @angular/platform-server named export.
67
+ return;
68
+ }
69
+ const exportClause = node.exportClause;
70
+ const newElements = [];
71
+ for (const element of exportClause.elements) {
72
+ if (element.name.text !== 'renderModule') {
73
+ newElements.push(element);
74
+ }
75
+ }
76
+ if (newElements.length === exportClause.elements.length) {
77
+ // No changes
78
+ return;
79
+ }
80
+ recorder !== null && recorder !== void 0 ? recorder : (recorder = tree.beginUpdate(sourceFile.fileName));
81
+ if (newElements.length) {
82
+ // Update named exports as there are leftovers.
83
+ const newExportClause = ts.factory.updateNamedExports(exportClause, newElements);
84
+ printer !== null && printer !== void 0 ? printer : (printer = ts.createPrinter());
85
+ const fix = printer.printNode(ts.EmitHint.Unspecified, newExportClause, sourceFile);
86
+ const index = exportClause.getStart();
87
+ const length = exportClause.getWidth();
88
+ recorder.remove(index, length).insertLeft(index, fix);
89
+ }
90
+ else {
91
+ // Delete export as no exports remain.
92
+ recorder.remove(node.getStart(), node.getWidth());
93
+ }
94
+ ts.forEachChild(node, analyze);
95
+ });
96
+ if (recorder) {
97
+ tree.commitUpdate(recorder);
98
+ }
99
+ }
100
+ };
101
+ }
102
+ exports.default = default_1;
@@ -6,5 +6,4 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
- /** Migration to update tsconfig compilation target option to es2020. */
10
9
  export default function (): Rule;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ const json_file_1 = require("../../utility/json-file");
11
+ const workspace_1 = require("../../utility/workspace");
12
+ const workspace_models_1 = require("../../utility/workspace-models");
13
+ function default_1() {
14
+ return async (host) => {
15
+ // Workspace level tsconfig
16
+ updateTarget(host, 'tsconfig.json');
17
+ const workspace = await (0, workspace_1.getWorkspace)(host);
18
+ // Find all tsconfig which are refereces used by builders
19
+ for (const [, project] of workspace.projects) {
20
+ for (const [, target] of project.targets) {
21
+ // Update all other known CLI builders that use a tsconfig
22
+ const tsConfigs = [target.options || {}, ...Object.values(target.configurations || {})]
23
+ .filter((opt) => typeof (opt === null || opt === void 0 ? void 0 : opt.tsConfig) === 'string')
24
+ .map((opt) => opt.tsConfig);
25
+ const uniqueTsConfigs = [...new Set(tsConfigs)];
26
+ if (uniqueTsConfigs.length < 1) {
27
+ continue;
28
+ }
29
+ switch (target.builder) {
30
+ case workspace_models_1.Builders.Server:
31
+ case workspace_models_1.Builders.Karma:
32
+ case workspace_models_1.Builders.Browser:
33
+ case workspace_models_1.Builders.NgPackagr:
34
+ for (const tsConfig of uniqueTsConfigs) {
35
+ removeOrUpdateTarget(host, tsConfig);
36
+ }
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ };
42
+ }
43
+ exports.default = default_1;
44
+ function removeOrUpdateTarget(host, tsConfigPath) {
45
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
46
+ if (typeof json.get(['extends']) === 'string') {
47
+ json.remove(['compilerOptions', 'target']);
48
+ }
49
+ else {
50
+ updateTarget(host, tsConfigPath);
51
+ }
52
+ }
53
+ const ESNEXT_ES2022_REGEXP = /^es(?:next|2022)$/i;
54
+ function updateTarget(host, tsConfigPath) {
55
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
56
+ const jsonPath = ['compilerOptions'];
57
+ const compilerOptions = json.get(jsonPath);
58
+ if (compilerOptions && typeof compilerOptions === 'object') {
59
+ const { target } = compilerOptions;
60
+ if (typeof target === 'string' && !ESNEXT_ES2022_REGEXP.test(target)) {
61
+ json.modify(jsonPath, {
62
+ ...compilerOptions,
63
+ 'target': 'ES2022',
64
+ 'useDefineForClassFields': false,
65
+ });
66
+ }
67
+ }
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "15.0.0-next.0",
3
+ "version": "15.0.0-next.2",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "15.0.0-next.0",
27
- "@angular-devkit/schematics": "15.0.0-next.0",
26
+ "@angular-devkit/core": "15.0.0-next.2",
27
+ "@angular-devkit/schematics": "15.0.0-next.2",
28
28
  "jsonc-parser": "3.2.0"
29
29
  },
30
30
  "repository": {
@@ -21,4 +21,3 @@ if (environment.production) {
21
21
  }
22
22
 
23
23
  export { <%= rootModuleClassName %> } from './app/<%= stripTsExtension(rootModuleFileName) %>';
24
- export { renderModule } from '@angular/platform-server';
@@ -16,10 +16,11 @@
16
16
  "experimentalDecorators": true,
17
17
  "moduleResolution": "node",
18
18
  "importHelpers": true,
19
- "target": "es2020",
20
- "module": "es2020",
19
+ "target": "ES2022",
20
+ "module": "ES2022",
21
+ "useDefineForClassFields": false,
21
22
  "lib": [
22
- "es2020",
23
+ "ES2022",
23
24
  "dom"
24
25
  ]
25
26
  },
@@ -1,16 +0,0 @@
1
- # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
- # For additional information regarding the format and rule options, please see:
3
- # https://github.com/browserslist/browserslist#queries
4
-
5
- # For the full list of supported browsers by the Angular framework, please see:
6
- # https://angular.io/guide/browser-support
7
-
8
- # You can see what browsers were selected by your queries by running:
9
- # npx browserslist
10
-
11
- last 1 Chrome version
12
- last 1 Firefox version
13
- last 2 Edge major versions
14
- last 2 Safari major versions
15
- last 2 iOS major versions
16
- Firefox ESR
@@ -1,29 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Rule } from '@angular-devkit/schematics';
9
- /**
10
- * This migrations updates Angular packages 'dependencies' and 'devDependencies' version prefix to '^' instead of '~'.
11
- *
12
- * @example
13
- * **Before**
14
- * ```json
15
- * dependencies: {
16
- * "@angular/animations": "~13.1.0",
17
- * "@angular/common": "~13.1.0"
18
- * }
19
- * ```
20
- *
21
- * **After**
22
- * ```json
23
- * dependencies: {
24
- * "@angular/animations": "^13.1.0",
25
- * "@angular/common": "^13.1.0"
26
- * }
27
- * ```
28
- */
29
- export default function (): Rule;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const tasks_1 = require("@angular-devkit/schematics/tasks");
11
- const dependencies_1 = require("../../utility/dependencies");
12
- const json_file_1 = require("../../utility/json-file");
13
- const PACKAGES_REGEXP = /^@(?:angular|nguniversal|schematics|angular-devkit)\/|^ng-packagr$/;
14
- /**
15
- * This migrations updates Angular packages 'dependencies' and 'devDependencies' version prefix to '^' instead of '~'.
16
- *
17
- * @example
18
- * **Before**
19
- * ```json
20
- * dependencies: {
21
- * "@angular/animations": "~13.1.0",
22
- * "@angular/common": "~13.1.0"
23
- * }
24
- * ```
25
- *
26
- * **After**
27
- * ```json
28
- * dependencies: {
29
- * "@angular/animations": "^13.1.0",
30
- * "@angular/common": "^13.1.0"
31
- * }
32
- * ```
33
- */
34
- function default_1() {
35
- return (tree, context) => {
36
- const json = new json_file_1.JSONFile(tree, '/package.json');
37
- updateVersionPrefixToTilde(json, dependencies_1.NodeDependencyType.Default);
38
- updateVersionPrefixToTilde(json, dependencies_1.NodeDependencyType.Dev);
39
- context.addTask(new tasks_1.NodePackageInstallTask());
40
- };
41
- }
42
- exports.default = default_1;
43
- function updateVersionPrefixToTilde(json, dependencyType) {
44
- const dependencyTypePath = [dependencyType];
45
- const dependencies = json.get(dependencyTypePath);
46
- if (!dependencies || typeof dependencies !== 'object') {
47
- return;
48
- }
49
- const updatedDependencies = new Map();
50
- for (const [name, version] of Object.entries(dependencies)) {
51
- if (typeof version === 'string' && version.charAt(0) === '~' && PACKAGES_REGEXP.test(name)) {
52
- updatedDependencies.set(name, `^${version.substring(1)}`);
53
- }
54
- }
55
- if (updatedDependencies.size) {
56
- json.modify(dependencyTypePath, {
57
- ...dependencies,
58
- ...Object.fromEntries(updatedDependencies),
59
- });
60
- }
61
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const workspace_1 = require("../../utility/workspace");
11
- /** Migration to remove 'defaultProject' option from angular.json. */
12
- function default_1() {
13
- return (0, workspace_1.updateWorkspace)((workspace) => {
14
- delete workspace.extensions['defaultProject'];
15
- });
16
- }
17
- exports.default = default_1;
@@ -1,10 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Rule } from '@angular-devkit/schematics';
9
- /** Migration to remove 'showCircularDependencies' option from browser and server builders. */
10
- export default function (): Rule;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const workspace_1 = require("../../utility/workspace");
11
- /** Migration to remove 'showCircularDependencies' option from browser and server builders. */
12
- function default_1() {
13
- return (0, workspace_1.updateWorkspace)((workspace) => {
14
- for (const project of workspace.projects.values()) {
15
- for (const target of project.targets.values()) {
16
- if (target.builder === '@angular-devkit/build-angular:server' ||
17
- target.builder === '@angular-devkit/build-angular:browser') {
18
- for (const [, options] of (0, workspace_1.allTargetOptions)(target)) {
19
- delete options.showCircularDependencies;
20
- }
21
- }
22
- }
23
- }
24
- });
25
- }
26
- exports.default = default_1;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const core_1 = require("@angular-devkit/core");
11
- const workspace_1 = require("../../utility/workspace");
12
- /** Migration to replace 'defaultCollection' option in angular.json. */
13
- function default_1() {
14
- return (0, workspace_1.updateWorkspace)((workspace) => {
15
- // workspace level
16
- replaceDefaultCollection(workspace.extensions['cli']);
17
- // Project level
18
- for (const project of workspace.projects.values()) {
19
- replaceDefaultCollection(project.extensions['cli']);
20
- }
21
- });
22
- }
23
- exports.default = default_1;
24
- function replaceDefaultCollection(cliExtension) {
25
- if (cliExtension && (0, core_1.isJsonObject)(cliExtension) && cliExtension['defaultCollection']) {
26
- // If `schematicsCollection` defined `defaultCollection` is ignored hence no need to warn.
27
- if (!cliExtension['schematicCollections']) {
28
- cliExtension['schematicCollections'] = [cliExtension['defaultCollection']];
29
- }
30
- delete cliExtension['defaultCollection'];
31
- }
32
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Rule } from '@angular-devkit/schematics';
9
- /** Migration to remove secondary entrypoints 'package.json' files and migrate ng-packagr configurations. */
10
- export default function (): Rule;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const core_1 = require("@angular-devkit/core");
11
- const workspace_1 = require("../../utility/workspace");
12
- function* visitPackageJsonFiles(directory, includedInLookup = false) {
13
- if (includedInLookup) {
14
- for (const path of directory.subfiles) {
15
- if (path !== 'package.json') {
16
- continue;
17
- }
18
- yield (0, core_1.join)(directory.path, path);
19
- }
20
- }
21
- for (const path of directory.subdirs) {
22
- if (path === 'node_modules' || path.startsWith('.')) {
23
- continue;
24
- }
25
- yield* visitPackageJsonFiles(directory.dir(path), true);
26
- }
27
- }
28
- /** Migration to remove secondary entrypoints 'package.json' files and migrate ng-packagr configurations. */
29
- function default_1() {
30
- return async (tree) => {
31
- const workspace = await (0, workspace_1.getWorkspace)(tree);
32
- for (const project of workspace.projects.values()) {
33
- if (project.extensions['projectType'] !== 'library' ||
34
- ![...project.targets.values()].some(({ builder }) => builder === '@angular-devkit/build-angular:ng-packagr')) {
35
- // Project is not a library or doesn't use ng-packagr, skip.
36
- continue;
37
- }
38
- for (const path of visitPackageJsonFiles(tree.getDir(project.root))) {
39
- const json = tree.readJson(path);
40
- if ((0, core_1.isJsonObject)(json) && json['ngPackage']) {
41
- // Migrate ng-packagr config to an ng-packagr config file.
42
- const configFilePath = (0, core_1.join)((0, core_1.dirname)((0, core_1.normalize)(path)), 'ng-package.json');
43
- tree.create(configFilePath, JSON.stringify(json['ngPackage'], undefined, 2));
44
- }
45
- // Delete package.json as it is no longer needed in APF 14.
46
- tree.delete(path);
47
- }
48
- }
49
- };
50
- }
51
- exports.default = default_1;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const json_file_1 = require("../../utility/json-file");
11
- const workspace_1 = require("../../utility/workspace");
12
- const workspace_models_1 = require("../../utility/workspace-models");
13
- /** Migration to update tsconfig compilation target option to es2020. */
14
- function default_1() {
15
- return async (host) => {
16
- var _a, _b;
17
- /** Builders for which the migration will run. */
18
- const supportedBuilders = [workspace_models_1.Builders.Karma, workspace_models_1.Builders.NgPackagr, workspace_models_1.Builders.Browser];
19
- /** Compilation targets values that should not be amended. */
20
- const skipTargets = ['es2020', 'es2021', 'es2022', 'esnext'];
21
- const uniqueTsConfigs = new Set(['/tsconfig.json']);
22
- // Find all tsconfig files which are refereced by the builders.
23
- const workspace = await (0, workspace_1.getWorkspace)(host);
24
- for (const project of workspace.projects.values()) {
25
- for (const target of project.targets.values()) {
26
- if (!supportedBuilders.includes(target.builder)) {
27
- // Unknown builder.
28
- continue;
29
- }
30
- // Update all other known CLI builders that use a tsconfig.
31
- const allOptions = [(_a = target.options) !== null && _a !== void 0 ? _a : {}, ...Object.values((_b = target.configurations) !== null && _b !== void 0 ? _b : {})];
32
- for (const opt of allOptions) {
33
- if (typeof (opt === null || opt === void 0 ? void 0 : opt.tsConfig) === 'string') {
34
- uniqueTsConfigs.add(opt.tsConfig);
35
- }
36
- }
37
- }
38
- }
39
- // Modify tsconfig files
40
- const targetJsonPath = ['compilerOptions', 'target'];
41
- for (const tsConfigPath of uniqueTsConfigs) {
42
- const json = new json_file_1.JSONFile(host, tsConfigPath);
43
- const target = json.get(targetJsonPath);
44
- // Update compilation target when it's current set lower than es2020.
45
- if (typeof target === 'string' && !skipTargets.includes(target.toLowerCase())) {
46
- json.modify(targetJsonPath, 'es2020');
47
- }
48
- }
49
- };
50
- }
51
- exports.default = default_1;