@schematics/angular 13.0.4 → 13.1.0-next.3
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/application/files/karma.conf.js.template +1 -1
- package/application/index.js +10 -9
- package/application/schema.json +1 -0
- package/component/index.js +0 -1
- package/library/index.js +10 -16
- package/library/schema.d.ts +1 -1
- package/library/schema.json +2 -1
- package/ng-new/index.js +2 -6
- package/ng-new/schema.json +0 -1
- package/package.json +3 -3
- package/utility/validation.d.ts +0 -2
- package/utility/validation.js +1 -52
- package/workspace/files/__dot__vscode/extensions.json.template +4 -0
- package/workspace/files/__dot__vscode/launch.json.template +20 -0
- package/workspace/files/__dot__vscode/tasks.json.template +42 -0
- package/workspace/schema.json +0 -1
|
@@ -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/<%=
|
|
28
|
+
dir: require('path').join(__dirname, '<%= relativePathToWorkspaceRoot %>/coverage/<%= folderName%>'),
|
|
29
29
|
subdir: '.',
|
|
30
30
|
reporters: [
|
|
31
31
|
{ type: 'html' },
|
package/application/index.js
CHANGED
|
@@ -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/${
|
|
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),
|
|
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),
|
package/application/schema.json
CHANGED
package/component/index.js
CHANGED
|
@@ -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
|
|
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 [
|
|
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
|
-
|
|
121
|
-
|
|
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,
|
|
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:
|
|
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:
|
|
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:
|
|
161
|
+
project: packageName,
|
|
168
162
|
}),
|
|
169
163
|
(_tree, context) => {
|
|
170
164
|
if (!options.skipPackageJson && !options.skipInstall) {
|
package/library/schema.d.ts
CHANGED
package/library/schema.json
CHANGED
|
@@ -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
|
-
|
|
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,
|
package/ng-new/schema.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.1.0-next.3",
|
|
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.
|
|
19
|
-
"@angular-devkit/schematics": "13.0.
|
|
18
|
+
"@angular-devkit/core": "13.1.0-next.3",
|
|
19
|
+
"@angular-devkit/schematics": "13.1.0-next.3",
|
|
20
20
|
"jsonc-parser": "3.0.0"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
package/utility/validation.d.ts
CHANGED
|
@@ -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;
|
package/utility/validation.js
CHANGED
|
@@ -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.
|
|
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
|
-
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"configurations": [
|
|
5
|
+
{
|
|
6
|
+
"name": "ng serve",
|
|
7
|
+
"type": "pwa-chrome",
|
|
8
|
+
"request": "launch",
|
|
9
|
+
"preLaunchTask": "npm: start",
|
|
10
|
+
"url": "http://localhost:4200/"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "ng test",
|
|
14
|
+
"type": "chrome",
|
|
15
|
+
"request": "launch",
|
|
16
|
+
"preLaunchTask": "npm: test",
|
|
17
|
+
"url": "http://localhost:9876/debug.html"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"tasks": [
|
|
5
|
+
{
|
|
6
|
+
"type": "npm",
|
|
7
|
+
"script": "start",
|
|
8
|
+
"isBackground": true,
|
|
9
|
+
"problemMatcher": {
|
|
10
|
+
"owner": "typescript",
|
|
11
|
+
"pattern": "$tsc",
|
|
12
|
+
"background": {
|
|
13
|
+
"activeOnStart": true,
|
|
14
|
+
"beginsPattern": {
|
|
15
|
+
"regexp": "(.*?)"
|
|
16
|
+
},
|
|
17
|
+
"endsPattern": {
|
|
18
|
+
"regexp": "bundle generation complete"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "npm",
|
|
25
|
+
"script": "test",
|
|
26
|
+
"isBackground": true,
|
|
27
|
+
"problemMatcher": {
|
|
28
|
+
"owner": "typescript",
|
|
29
|
+
"pattern": "$tsc",
|
|
30
|
+
"background": {
|
|
31
|
+
"activeOnStart": true,
|
|
32
|
+
"beginsPattern": {
|
|
33
|
+
"regexp": "(.*?)"
|
|
34
|
+
},
|
|
35
|
+
"endsPattern": {
|
|
36
|
+
"regexp": "bundle generation complete"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|