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

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.
@@ -1,34 +1,9 @@
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 '~'."
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'."
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."
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."
32
7
  }
33
8
  }
34
9
  }
@@ -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;
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.1",
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.1",
27
+ "@angular-devkit/schematics": "15.0.0-next.1",
28
28
  "jsonc-parser": "3.2.0"
29
29
  },
30
30
  "repository": {
@@ -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,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 replace 'defaultCollection' option in angular.json. */
10
- export default function (): Rule;
@@ -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,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 update tsconfig compilation target option to es2020. */
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 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;