@schematics/angular 14.1.0-next.4 → 14.1.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.
@@ -5,7 +5,6 @@
5
5
  "type": "object",
6
6
  "description": "Generates an application shell for running a server-side version of an app.",
7
7
  "additionalProperties": false,
8
- "long-description": "./app-shell-long.md",
9
8
  "properties": {
10
9
  "project": {
11
10
  "type": "string",
@@ -367,7 +367,7 @@
367
367
  </a>
368
368
 
369
369
  <a class="card" target="_blank" rel="noopener" href="https://material.angular.io">
370
- <svg xmlns="http://www.w3.org/2000/svg" style="margin-right: 8px" width="21.813" height="23.453" viewBox="0 0 21.813 23.453"><path d="M4099.584,972.736h0l-10.882,3.9,1.637,14.4,9.245,5.153,9.245-5.153,1.686-14.4Z" transform="translate(-4088.702 -972.736)" fill="#808080"/><path d="M4181.516,972.736v23.453l9.245-5.153,1.686-14.4Z" transform="translate(-4170.633 -972.736)" fill="#808080"/><path d="M4137.529,1076.127l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1058.315)" fill="#ffe0b2"/><path d="M4137.529,1051.705l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1036.757)" fill="#fff3e0"/><path d="M4137.529,1027.283l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1015.199)" fill="#fff"/></svg>
370
+ <svg xmlns="http://www.w3.org/2000/svg" style="margin-right: 8px" width="21.813" height="23.453" viewBox="0 0 179.2 192.7"><path fill="#ffa726" d="M89.4 0 0 32l13.5 118.4 75.9 42.3 76-42.3L179.2 32 89.4 0z"/><path fill="#fb8c00" d="M89.4 0v192.7l76-42.3L179.2 32 89.4 0z"/><path fill="#ffe0b2" d="m102.9 146.3-63.3-30.5 36.3-22.4 63.7 30.6-36.7 22.3z"/><path fill="#fff3e0" d="M102.9 122.8 39.6 92.2l36.3-22.3 63.7 30.6-36.7 22.3z"/><path fill="#fff" d="M102.9 99.3 39.6 68.7l36.3-22.4 63.7 30.6-36.7 22.4z"/></svg>
371
371
  <span>Angular Material</span>
372
372
  <svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
373
373
  </a>
package/e2e/index.js CHANGED
@@ -65,7 +65,10 @@ function default_1(options) {
65
65
  }),
66
66
  (0, schematics_1.move)(e2eRootPath),
67
67
  ])),
68
- ...E2E_DEV_DEPENDENCIES.map((name) => (0, utility_1.addDependency)(name, latest_versions_1.latestVersions[name], { type: utility_1.DependencyType.Dev })),
68
+ ...E2E_DEV_DEPENDENCIES.map((name) => (0, utility_1.addDependency)(name, latest_versions_1.latestVersions[name], {
69
+ type: utility_1.DependencyType.Dev,
70
+ existing: utility_1.ExistingBehavior.Skip,
71
+ })),
69
72
  addScriptsToPackageJson(),
70
73
  ]);
71
74
  });
package/e2e/schema.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
7
  "description": "Generates a new, generic end-to-end test definition for the given or default project.",
8
- "long-description": "e2e-long.md",
9
8
  "properties": {
10
9
  "rootSelector": {
11
10
  "description": "The HTML selector for the root component of the test app.",
@@ -4,7 +4,6 @@
4
4
  "title": "Library Options Schema",
5
5
  "type": "object",
6
6
  "description": "Creates a new, generic library project in the current workspace.",
7
- "long-description": "./library-long.md",
8
7
  "additionalProperties": false,
9
8
  "properties": {
10
9
  "name": {
package/module/index.js CHANGED
@@ -37,6 +37,7 @@ const ast_utils_1 = require("../utility/ast-utils");
37
37
  const change_1 = require("../utility/change");
38
38
  const find_module_1 = require("../utility/find-module");
39
39
  const parse_name_1 = require("../utility/parse-name");
40
+ const validation_1 = require("../utility/validation");
40
41
  const workspace_1 = require("../utility/workspace");
41
42
  const schema_1 = require("./schema");
42
43
  function buildRelativeModulePath(options, modulePath) {
@@ -118,6 +119,7 @@ function default_1(options) {
118
119
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
119
120
  options.name = parsedPath.name;
120
121
  options.path = parsedPath.path;
122
+ (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
121
123
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
122
124
  options.routing || (isLazyLoadedModuleGen && routingModulePath)
123
125
  ? (0, schematics_1.noop)()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "14.1.0-next.4",
3
+ "version": "14.1.1",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "14.1.0-next.4",
27
- "@angular-devkit/schematics": "14.1.0-next.4",
28
- "jsonc-parser": "3.0.0"
26
+ "@angular-devkit/core": "14.1.1",
27
+ "@angular-devkit/schematics": "14.1.1",
28
+ "jsonc-parser": "3.1.0"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
package/pipe/index.js CHANGED
@@ -36,6 +36,7 @@ const ast_utils_1 = require("../utility/ast-utils");
36
36
  const change_1 = require("../utility/change");
37
37
  const find_module_1 = require("../utility/find-module");
38
38
  const parse_name_1 = require("../utility/parse-name");
39
+ const validation_1 = require("../utility/validation");
39
40
  const workspace_1 = require("../utility/workspace");
40
41
  function addDeclarationToNgModule(options) {
41
42
  return (host) => {
@@ -75,13 +76,13 @@ function addDeclarationToNgModule(options) {
75
76
  }
76
77
  function default_1(options) {
77
78
  return async (host) => {
78
- if (options.path === undefined) {
79
- options.path = await (0, workspace_1.createDefaultPath)(host, options.project);
80
- }
79
+ var _a;
80
+ (_a = options.path) !== null && _a !== void 0 ? _a : (options.path = await (0, workspace_1.createDefaultPath)(host, options.project));
81
81
  options.module = (0, find_module_1.findModuleFromOptions)(host, options);
82
82
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
83
83
  options.name = parsedPath.name;
84
84
  options.path = parsedPath.path;
85
+ (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
85
86
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
86
87
  options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
87
88
  (0, schematics_1.applyTemplates)({
@@ -38,6 +38,23 @@ export declare enum InstallBehavior {
38
38
  */
39
39
  Always = 2
40
40
  }
41
+ /**
42
+ * An enum used to specify the existing dependency behavior for the {@link addDependency}
43
+ * schematics rule. The existing behavior affects whether the named dependency will be added
44
+ * to the `package.json` when the dependency is already present with a differing specifier.
45
+ */
46
+ export declare enum ExistingBehavior {
47
+ /**
48
+ * The dependency will not be added or otherwise changed if it already exists.
49
+ */
50
+ Skip = 0,
51
+ /**
52
+ * The dependency's existing specifier will be replaced with the specifier provided in the
53
+ * {@link addDependency} call. A warning will also be shown during schematic execution to
54
+ * notify the user of the replacement.
55
+ */
56
+ Replace = 1
57
+ }
41
58
  /**
42
59
  * Adds a package as a dependency to a `package.json`. By default the `package.json` located
43
60
  * at the schematic's root will be used. The `manifestPath` option can be used to explicitly specify
@@ -71,4 +88,9 @@ export declare function addDependency(name: string, specifier: string, options?:
71
88
  * Defaults to {@link InstallBehavior.Auto}.
72
89
  */
73
90
  install?: InstallBehavior;
91
+ /**
92
+ * The behavior to use when the dependency already exists within the `package.json`.
93
+ * Defaults to {@link ExistingBehavior.Replace}.
94
+ */
95
+ existing?: ExistingBehavior;
74
96
  }): Rule;
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.addDependency = exports.InstallBehavior = exports.DependencyType = void 0;
33
+ exports.addDependency = exports.ExistingBehavior = exports.InstallBehavior = exports.DependencyType = void 0;
34
34
  const tasks_1 = require("@angular-devkit/schematics/tasks");
35
35
  const path = __importStar(require("path"));
36
36
  const installTasks = new WeakMap();
@@ -68,6 +68,24 @@ var InstallBehavior;
68
68
  */
69
69
  InstallBehavior[InstallBehavior["Always"] = 2] = "Always";
70
70
  })(InstallBehavior = exports.InstallBehavior || (exports.InstallBehavior = {}));
71
+ /**
72
+ * An enum used to specify the existing dependency behavior for the {@link addDependency}
73
+ * schematics rule. The existing behavior affects whether the named dependency will be added
74
+ * to the `package.json` when the dependency is already present with a differing specifier.
75
+ */
76
+ var ExistingBehavior;
77
+ (function (ExistingBehavior) {
78
+ /**
79
+ * The dependency will not be added or otherwise changed if it already exists.
80
+ */
81
+ ExistingBehavior[ExistingBehavior["Skip"] = 0] = "Skip";
82
+ /**
83
+ * The dependency's existing specifier will be replaced with the specifier provided in the
84
+ * {@link addDependency} call. A warning will also be shown during schematic execution to
85
+ * notify the user of the replacement.
86
+ */
87
+ ExistingBehavior[ExistingBehavior["Replace"] = 1] = "Replace";
88
+ })(ExistingBehavior = exports.ExistingBehavior || (exports.ExistingBehavior = {}));
71
89
  /**
72
90
  * Adds a package as a dependency to a `package.json`. By default the `package.json` located
73
91
  * at the schematic's root will be used. The `manifestPath` option can be used to explicitly specify
@@ -85,7 +103,7 @@ var InstallBehavior;
85
103
  * @returns A Schematics {@link Rule}
86
104
  */
87
105
  function addDependency(name, specifier, options = {}) {
88
- const { type = DependencyType.Default, packageJsonPath = '/package.json', install = InstallBehavior.Auto, } = options;
106
+ const { type = DependencyType.Default, packageJsonPath = '/package.json', install = InstallBehavior.Auto, existing = ExistingBehavior.Replace, } = options;
89
107
  return (tree, context) => {
90
108
  var _a;
91
109
  const manifest = tree.readJson(packageJsonPath);
@@ -94,15 +112,21 @@ function addDependency(name, specifier, options = {}) {
94
112
  // Section is not present. The dependency can be added to a new object literal for the section.
95
113
  manifest[type] = { [name]: specifier };
96
114
  }
97
- else if (dependencySection[name] === specifier) {
98
- // Already present with same specifier
99
- return;
100
- }
101
- else if (dependencySection[name]) {
102
- // Already present but different specifier
103
- throw new Error(`Package dependency "${name}" already exists with a different specifier.`);
104
- }
105
115
  else {
116
+ const existingSpecifier = dependencySection[name];
117
+ if (existingSpecifier === specifier) {
118
+ // Already present with same specifier
119
+ return;
120
+ }
121
+ if (existingSpecifier) {
122
+ // Already present but different specifier
123
+ if (existing === ExistingBehavior.Skip) {
124
+ return;
125
+ }
126
+ // ExistingBehavior.Replace is the only other behavior currently
127
+ context.logger.warn(`Package dependency "${name}" already exists with a different specifier. ` +
128
+ `"${existingSpecifier}" will be replaced with "${specifier}".`);
129
+ }
106
130
  // Add new dependency in alphabetical order
107
131
  const entries = Object.entries(dependencySection);
108
132
  entries.push([name, specifier]);
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.generateFromFiles = void 0;
11
11
  const schematics_1 = require("@angular-devkit/schematics");
12
12
  const parse_name_1 = require("./parse-name");
13
+ const validation_1 = require("./validation");
13
14
  const workspace_1 = require("./workspace");
14
15
  function generateFromFiles(options, extraTemplateValues = {}) {
15
16
  return async (host) => {
@@ -20,6 +21,7 @@ function generateFromFiles(options, extraTemplateValues = {}) {
20
21
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
21
22
  options.name = parsedPath.name;
22
23
  options.path = parsedPath.path;
24
+ (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
23
25
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
24
26
  options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
25
27
  (0, schematics_1.applyTemplates)({
@@ -7,4 +7,4 @@
7
7
  */
8
8
  export { ProjectDefinition, TargetDefinition, WorkspaceDefinition, getWorkspace as readWorkspace, updateWorkspace, writeWorkspace, } from './workspace';
9
9
  export { Builders as AngularBuilder } from './workspace-models';
10
- export { DependencyType, InstallBehavior, addDependency } from './dependency';
10
+ export { DependencyType, ExistingBehavior, InstallBehavior, addDependency } from './dependency';
package/utility/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.addDependency = exports.InstallBehavior = exports.DependencyType = exports.AngularBuilder = exports.writeWorkspace = exports.updateWorkspace = exports.readWorkspace = void 0;
10
+ exports.addDependency = exports.InstallBehavior = exports.ExistingBehavior = exports.DependencyType = exports.AngularBuilder = exports.writeWorkspace = exports.updateWorkspace = exports.readWorkspace = void 0;
11
11
  // Workspace related rules and types
12
12
  var workspace_1 = require("./workspace");
13
13
  Object.defineProperty(exports, "readWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } });
@@ -18,5 +18,6 @@ Object.defineProperty(exports, "AngularBuilder", { enumerable: true, get: functi
18
18
  // Package dependency related rules and types
19
19
  var dependency_1 = require("./dependency");
20
20
  Object.defineProperty(exports, "DependencyType", { enumerable: true, get: function () { return dependency_1.DependencyType; } });
21
+ Object.defineProperty(exports, "ExistingBehavior", { enumerable: true, get: function () { return dependency_1.ExistingBehavior; } });
21
22
  Object.defineProperty(exports, "InstallBehavior", { enumerable: true, get: function () { return dependency_1.InstallBehavior; } });
22
23
  Object.defineProperty(exports, "addDependency", { enumerable: true, get: function () { return dependency_1.addDependency; } });
@@ -12,11 +12,11 @@
12
12
  "karma-jasmine-html-reporter": "~2.0.0",
13
13
  "karma-jasmine": "~5.1.0",
14
14
  "karma": "~6.4.0",
15
- "ng-packagr": "^14.0.0-next.8",
15
+ "ng-packagr": "^14.1.0",
16
16
  "protractor": "~7.0.0",
17
17
  "rxjs": "~7.5.0",
18
18
  "tslib": "^2.3.0",
19
- "ts-node": "~10.8.0",
19
+ "ts-node": "~10.9.0",
20
20
  "typescript": "~4.7.2",
21
21
  "zone.js": "~0.11.4"
22
22
  }
@@ -13,7 +13,7 @@ exports.latestVersions = {
13
13
  // but ts_library doesn't support JSON inputs.
14
14
  ...require('./latest-versions/package.json')['dependencies'],
15
15
  // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
16
- Angular: '^14.0.0-next.0',
16
+ Angular: '^14.1.0',
17
17
  // Since @angular-devkit/build-angular and @schematics/angular are always
18
18
  // published together from the same monorepo, and they are both
19
19
  // non-experimental, they will always have the same version.
@@ -7,3 +7,4 @@
7
7
  */
8
8
  export declare const htmlSelectorRe: RegExp;
9
9
  export declare function validateHtmlSelector(selector: string): void;
10
+ export declare function validateClassName(className: string): void;
@@ -7,14 +7,22 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.validateHtmlSelector = exports.htmlSelectorRe = void 0;
10
+ exports.validateClassName = exports.validateHtmlSelector = exports.htmlSelectorRe = void 0;
11
11
  const schematics_1 = require("@angular-devkit/schematics");
12
12
  // Must start with a letter, and must contain only alphanumeric characters or dashes.
13
13
  // When adding a dash the segment after the dash must also start with a letter.
14
14
  exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*(:?-[a-zA-Z][.0-9a-zA-Z]*)*$/;
15
+ // See: https://github.com/tc39/proposal-regexp-unicode-property-escapes/blob/fe6d07fad74cd0192d154966baa1e95e7cda78a1/README.md#other-examples
16
+ const ecmaIdentifierNameRegExp = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;
15
17
  function validateHtmlSelector(selector) {
16
18
  if (selector && !exports.htmlSelectorRe.test(selector)) {
17
- throw new schematics_1.SchematicsException(`Selector (${selector}) is invalid.`);
19
+ throw new schematics_1.SchematicsException(`Selector "${selector}" is invalid.`);
18
20
  }
19
21
  }
20
22
  exports.validateHtmlSelector = validateHtmlSelector;
23
+ function validateClassName(className) {
24
+ if (!ecmaIdentifierNameRegExp.test(className)) {
25
+ throw new schematics_1.SchematicsException(`Class name "${className}" is invalid.`);
26
+ }
27
+ }
28
+ exports.validateClassName = validateClassName;
@@ -1,47 +0,0 @@
1
- An app shell lets Universal render a portion of your application via a route at build time.
2
- This gives users a meaningful first paint of your application that appears quickly
3
- because the browser can simply render the HTML without the need to initialize any JavaScript.
4
-
5
- Use this command with a routing app that is accompanied by a Universal server-side app.
6
-
7
- To create an app shell, use the following command.
8
-
9
- <code-example format="." language="bash">
10
- ng generate app-shell my-app
11
- </code-example>
12
-
13
- - `my-app` is the name of your client application
14
- - `server-app` is the name of the Universal (server) application
15
-
16
- The command adds two new architect build targets to your `angular.json` configuration file (along with a few other changes).
17
-
18
- <code-example format="." language="none" linenums="false">
19
- "server": {
20
- "builder": "@angular-devkit/build-angular:server",
21
- "options": {
22
- "outputPath": "dist/my-app-server",
23
- "main": "src/main.server.ts",
24
- "tsConfig": "src/tsconfig.server.json"
25
- }
26
- },
27
- "app-shell": {
28
- "builder": "@angular-devkit/build-angular:app-shell",
29
- "options": {
30
- "browserTarget": "my-app:build",
31
- "serverTarget": "my-app:server",
32
- "route": "shell"
33
- }
34
- }
35
- </code-example>
36
-
37
- To verify the that the app has been built with the default shell content:
38
-
39
- 1. Run the app-shell target.
40
-
41
- <code-example format="." language="bash">
42
- ng run my-app:app-shell
43
- </code-example>
44
-
45
- 1. Open `dist/app-shell/index.html` in your browser.
46
-
47
- The default text "app-shell works!" verifies that the app-shell route was rendered as part of the output.
package/e2e/e2e-long.md DELETED
@@ -1,2 +0,0 @@
1
- The e2e tests are created in a separate application in the `projects` folder of the workspace,
2
- next to the project being tested.
@@ -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,5 +0,0 @@
1
- A library is a type of project that does not run independently.
2
- The library skeleton created by this command is placed by default in the `/projects` folder, and has `type` of "library".
3
-
4
- You can build a new library using the `ng build` command, run unit tests for it using the `ng test` command,
5
- and lint it using the `ng lint` command.