@schematics/angular 14.1.0 → 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.
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",
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,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "14.1.0",
27
- "@angular-devkit/schematics": "14.1.0",
26
+ "@angular-devkit/core": "14.1.1",
27
+ "@angular-devkit/schematics": "14.1.1",
28
28
  "jsonc-parser": "3.1.0"
29
29
  },
30
30
  "repository": {
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)({
@@ -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,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;