@schematics/angular 13.0.2 → 13.1.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.
@@ -25,7 +25,7 @@ module.exports = function (config) {
25
25
  suppressAll: true // removes the duplicated traces
26
26
  },
27
27
  coverageReporter: {
28
- dir: require('path').join(__dirname, '<%= relativePathToWorkspaceRoot %>/coverage/<%= appName%>'),
28
+ dir: require('path').join(__dirname, '<%= relativePathToWorkspaceRoot %>/coverage/<%= folderName%>'),
29
29
  subdir: '.',
30
30
  reporters: [
31
31
  { type: 'html' },
@@ -13,7 +13,6 @@ const tasks_1 = require("@angular-devkit/schematics/tasks");
13
13
  const dependencies_1 = require("../utility/dependencies");
14
14
  const latest_versions_1 = require("../utility/latest-versions");
15
15
  const paths_1 = require("../utility/paths");
16
- const validation_1 = require("../utility/validation");
17
16
  const workspace_1 = require("../utility/workspace");
18
17
  const workspace_models_1 = require("../utility/workspace-models");
19
18
  const schema_1 = require("./schema");
@@ -42,7 +41,7 @@ function addDependenciesToPackageJson(options) {
42
41
  return host;
43
42
  };
44
43
  }
45
- function addAppToWorkspaceFile(options, appDir) {
44
+ function addAppToWorkspaceFile(options, appDir, folderName) {
46
45
  var _a, _b;
47
46
  let projectRoot = appDir;
48
47
  if (projectRoot) {
@@ -121,7 +120,7 @@ function addAppToWorkspaceFile(options, appDir) {
121
120
  builder: workspace_models_1.Builders.Browser,
122
121
  defaultConfiguration: 'production',
123
122
  options: {
124
- outputPath: `dist/${options.name}`,
123
+ outputPath: `dist/${folderName}`,
125
124
  index: `${sourceRoot}/index.html`,
126
125
  main: `${sourceRoot}/main.ts`,
127
126
  polyfills: `${sourceRoot}/polyfills.ts`,
@@ -205,10 +204,6 @@ function minimalPathFilter(path) {
205
204
  function default_1(options) {
206
205
  return async (host) => {
207
206
  var _a, _b;
208
- if (!options.name) {
209
- throw new schematics_1.SchematicsException(`Invalid options, "name" is required.`);
210
- }
211
- (0, validation_1.validateProjectName)(options.name);
212
207
  const appRootSelector = `${options.prefix}-root`;
213
208
  const componentOptions = !options.minimal
214
209
  ? {
@@ -228,12 +223,17 @@ function default_1(options) {
228
223
  const workspace = await (0, workspace_1.getWorkspace)(host);
229
224
  const newProjectRoot = workspace.extensions.newProjectRoot || '';
230
225
  const isRootApp = options.projectRoot !== undefined;
226
+ // If scoped project (i.e. "@foo/bar"), convert dir to "foo/bar".
227
+ let folderName = options.name.startsWith('@') ? options.name.substr(1) : options.name;
228
+ if (/[A-Z]/.test(folderName)) {
229
+ folderName = core_1.strings.dasherize(folderName);
230
+ }
231
231
  const appDir = isRootApp
232
232
  ? (0, core_1.normalize)(options.projectRoot || '')
233
- : (0, core_1.join)((0, core_1.normalize)(newProjectRoot), core_1.strings.dasherize(options.name));
233
+ : (0, core_1.join)((0, core_1.normalize)(newProjectRoot), folderName);
234
234
  const sourceDir = `${appDir}/src/app`;
235
235
  return (0, schematics_1.chain)([
236
- addAppToWorkspaceFile(options, appDir),
236
+ addAppToWorkspaceFile(options, appDir, folderName),
237
237
  (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
238
238
  options.minimal ? (0, schematics_1.filter)(minimalPathFilter) : (0, schematics_1.noop)(),
239
239
  (0, schematics_1.applyTemplates)({
@@ -242,6 +242,7 @@ function default_1(options) {
242
242
  relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(appDir),
243
243
  appName: options.name,
244
244
  isRootApp,
245
+ folderName,
245
246
  }),
246
247
  (0, schematics_1.move)(appDir),
247
248
  ]), schematics_1.MergeStrategy.Overwrite),
@@ -14,6 +14,7 @@
14
14
  "name": {
15
15
  "description": "The name of the new app.",
16
16
  "type": "string",
17
+ "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
17
18
  "$default": {
18
19
  "$source": "argv",
19
20
  "index": 0
@@ -108,7 +108,6 @@ function default_1(options) {
108
108
  options.path = parsedPath.path;
109
109
  options.selector =
110
110
  options.selector || buildSelector(options, (project && project.prefix) || '');
111
- (0, validation_1.validateName)(options.name);
112
111
  (0, validation_1.validateHtmlSelector)(options.selector);
113
112
  const skipStyleFile = options.inlineStyle || options.style === schema_1.Style.None;
114
113
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
package/library/index.js CHANGED
@@ -14,7 +14,6 @@ const dependencies_1 = require("../utility/dependencies");
14
14
  const json_file_1 = require("../utility/json-file");
15
15
  const latest_versions_1 = require("../utility/latest-versions");
16
16
  const paths_1 = require("../utility/paths");
17
- const validation_1 = require("../utility/validation");
18
17
  const workspace_1 = require("../utility/workspace");
19
18
  const workspace_models_1 = require("../utility/workspace-models");
20
19
  function updateTsConfig(packageName, ...paths) {
@@ -101,24 +100,19 @@ function addLibToWorkspaceFile(options, projectRoot, projectName) {
101
100
  }
102
101
  function default_1(options) {
103
102
  return async (host) => {
104
- if (!options.name) {
105
- throw new schematics_1.SchematicsException(`Invalid options, "name" is required.`);
106
- }
107
103
  const prefix = options.prefix;
108
- (0, validation_1.validateProjectName)(options.name);
109
104
  // If scoped project (i.e. "@foo/bar"), convert projectDir to "foo/bar".
110
- const projectName = options.name;
111
- const packageName = core_1.strings.dasherize(projectName);
112
- let scopeName = null;
105
+ const packageName = options.name;
113
106
  if (/^@.*\/.*/.test(options.name)) {
114
- const [scope, name] = options.name.split('/');
115
- scopeName = scope.replace(/^@/, '');
107
+ const [, name] = options.name.split('/');
116
108
  options.name = name;
117
109
  }
118
110
  const workspace = await (0, workspace_1.getWorkspace)(host);
119
111
  const newProjectRoot = workspace.extensions.newProjectRoot || '';
120
- const scopeFolder = scopeName ? core_1.strings.dasherize(scopeName) + '/' : '';
121
- const folderName = `${scopeFolder}${core_1.strings.dasherize(options.name)}`;
112
+ let folderName = packageName.startsWith('@') ? packageName.substr(1) : packageName;
113
+ if (/[A-Z]/.test(folderName)) {
114
+ folderName = core_1.strings.dasherize(folderName);
115
+ }
122
116
  const projectRoot = (0, core_1.join)((0, core_1.normalize)(newProjectRoot), folderName);
123
117
  const distRoot = `dist/${folderName}`;
124
118
  const pathImportLib = `${distRoot}/${folderName.replace('/', '-')}`;
@@ -140,7 +134,7 @@ function default_1(options) {
140
134
  ]);
141
135
  return (0, schematics_1.chain)([
142
136
  (0, schematics_1.mergeWith)(templateSource),
143
- addLibToWorkspaceFile(options, projectRoot, projectName),
137
+ addLibToWorkspaceFile(options, projectRoot, packageName),
144
138
  options.skipPackageJson ? (0, schematics_1.noop)() : addDependenciesToPackageJson(),
145
139
  options.skipTsConfig ? (0, schematics_1.noop)() : updateTsConfig(packageName, pathImportLib, distRoot),
146
140
  (0, schematics_1.schematic)('module', {
@@ -148,7 +142,7 @@ function default_1(options) {
148
142
  commonModule: false,
149
143
  flat: true,
150
144
  path: sourceDir,
151
- project: projectName,
145
+ project: packageName,
152
146
  }),
153
147
  (0, schematics_1.schematic)('component', {
154
148
  name: options.name,
@@ -158,13 +152,13 @@ function default_1(options) {
158
152
  flat: true,
159
153
  path: sourceDir,
160
154
  export: true,
161
- project: projectName,
155
+ project: packageName,
162
156
  }),
163
157
  (0, schematics_1.schematic)('service', {
164
158
  name: options.name,
165
159
  flat: true,
166
160
  path: sourceDir,
167
- project: projectName,
161
+ project: packageName,
168
162
  }),
169
163
  (_tree, context) => {
170
164
  if (!options.skipPackageJson && !options.skipInstall) {
@@ -9,7 +9,7 @@ export interface Schema {
9
9
  /**
10
10
  * The name of the library.
11
11
  */
12
- name?: string;
12
+ name: string;
13
13
  /**
14
14
  * A prefix to apply to generated selectors.
15
15
  */
@@ -10,6 +10,7 @@
10
10
  "name": {
11
11
  "type": "string",
12
12
  "description": "The name of the library.",
13
+ "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
13
14
  "$default": {
14
15
  "$source": "argv",
15
16
  "index": 0
@@ -45,5 +46,5 @@
45
46
  "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."
46
47
  }
47
48
  },
48
- "required": []
49
+ "required": ["name"]
49
50
  }
package/ng-new/index.js CHANGED
@@ -9,14 +9,10 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  const schematics_1 = require("@angular-devkit/schematics");
11
11
  const tasks_1 = require("@angular-devkit/schematics/tasks");
12
- const validation_1 = require("../utility/validation");
13
12
  function default_1(options) {
14
- if (!options.name) {
15
- throw new schematics_1.SchematicsException(`Invalid options, "name" is required.`);
16
- }
17
- (0, validation_1.validateProjectName)(options.name);
18
13
  if (!options.directory) {
19
- options.directory = options.name;
14
+ // If scoped project (i.e. "@foo/bar"), convert directory to "foo/bar".
15
+ options.directory = options.name.startsWith('@') ? options.name.substr(1) : options.name;
20
16
  }
21
17
  const workspaceOptions = {
22
18
  name: options.name,
@@ -13,7 +13,6 @@
13
13
  "name": {
14
14
  "description": "The name of the new workspace and initial project.",
15
15
  "type": "string",
16
- "format": "html-selector",
17
16
  "$default": {
18
17
  "$source": "argv",
19
18
  "index": 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "13.0.2",
3
+ "version": "13.1.0-next.2",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -15,8 +15,8 @@
15
15
  ],
16
16
  "schematics": "./collection.json",
17
17
  "dependencies": {
18
- "@angular-devkit/core": "13.0.2",
19
- "@angular-devkit/schematics": "13.0.2",
18
+ "@angular-devkit/core": "13.1.0-next.2",
19
+ "@angular-devkit/schematics": "13.1.0-next.2",
20
20
  "jsonc-parser": "3.0.0"
21
21
  },
22
22
  "repository": {
@@ -5,7 +5,5 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- export declare function validateName(name: string): void;
9
8
  export declare const htmlSelectorRe: RegExp;
10
9
  export declare function validateHtmlSelector(selector: string): void;
11
- export declare function validateProjectName(projectName: string): void;
@@ -7,16 +7,9 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.validateProjectName = exports.validateHtmlSelector = exports.htmlSelectorRe = exports.validateName = void 0;
10
+ exports.validateHtmlSelector = exports.htmlSelectorRe = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
12
  const schematics_1 = require("@angular-devkit/schematics");
13
- function validateName(name) {
14
- if (name && /^\d/.test(name)) {
15
- throw new schematics_1.SchematicsException(core_1.tags.oneLine `name (${name})
16
- can not start with a digit.`);
17
- }
18
- }
19
- exports.validateName = validateName;
20
13
  // Must start with a letter, and must contain only alphanumeric characters or dashes.
21
14
  // When adding a dash the segment after the dash must also start with a letter.
22
15
  exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*(:?-[a-zA-Z][.0-9a-zA-Z]*)*$/;
@@ -27,47 +20,3 @@ function validateHtmlSelector(selector) {
27
20
  }
28
21
  }
29
22
  exports.validateHtmlSelector = validateHtmlSelector;
30
- function validateProjectName(projectName) {
31
- const errorIndex = getRegExpFailPosition(projectName);
32
- const unsupportedProjectNames = [];
33
- const packageNameRegex = /^(?:@[a-zA-Z0-9_-]+\/)?[a-zA-Z0-9_-]+$/;
34
- if (errorIndex !== null) {
35
- const firstMessage = core_1.tags.oneLine `
36
- Project name "${projectName}" is not valid. New project names must
37
- start with a letter, and must contain only alphanumeric characters or dashes.
38
- When adding a dash the segment after the dash must also start with a letter.
39
- `;
40
- const msg = core_1.tags.stripIndent `
41
- ${firstMessage}
42
- ${projectName}
43
- ${Array(errorIndex + 1).join(' ') + '^'}
44
- `;
45
- throw new schematics_1.SchematicsException(msg);
46
- }
47
- else if (unsupportedProjectNames.indexOf(projectName) !== -1) {
48
- throw new schematics_1.SchematicsException(`Project name ${JSON.stringify(projectName)} is not a supported name.`);
49
- }
50
- else if (!packageNameRegex.test(projectName)) {
51
- throw new schematics_1.SchematicsException(`Project name ${JSON.stringify(projectName)} is invalid.`);
52
- }
53
- }
54
- exports.validateProjectName = validateProjectName;
55
- function getRegExpFailPosition(str) {
56
- const isScope = /^@.*\/.*/.test(str);
57
- if (isScope) {
58
- // Remove starting @
59
- str = str.replace(/^@/, '');
60
- // Change / to - for validation
61
- str = str.replace(/\//g, '-');
62
- }
63
- const parts = str.indexOf('-') >= 0 ? str.split('-') : [str];
64
- const matched = [];
65
- const projectNameRegexp = /^[a-zA-Z][.0-9a-zA-Z]*(-[.0-9a-zA-Z]*)*$/;
66
- parts.forEach((part) => {
67
- if (part.match(projectNameRegexp)) {
68
- matched.push(part);
69
- }
70
- });
71
- const compare = matched.join('-');
72
- return str !== compare ? compare.length : null;
73
- }
@@ -9,7 +9,6 @@
9
9
  "name": {
10
10
  "description": "The name of the workspace.",
11
11
  "type": "string",
12
- "format": "html-selector",
13
12
  "$default": {
14
13
  "$source": "argv",
15
14
  "index": 0