@schematics/angular 14.0.0-next.11 → 14.0.0-next.12
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/app-shell/index.js +4 -8
- package/application/index.js +3 -3
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +1 -1
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +2 -1
- package/component/index.js +9 -14
- package/component/schema.d.ts +4 -0
- package/component/schema.json +6 -0
- package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template +2 -1
- package/directive/index.js +9 -18
- package/directive/schema.d.ts +4 -0
- package/directive/schema.json +6 -0
- package/e2e/index.js +1 -1
- package/library/index.js +2 -2
- package/module/index.js +8 -16
- package/package.json +3 -3
- package/pipe/files/__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template +2 -1
- package/pipe/index.js +8 -17
- package/pipe/schema.d.ts +4 -0
- package/pipe/schema.json +6 -0
- package/service-worker/index.js +1 -5
- package/universal/index.js +3 -7
- package/utility/find-module.d.ts +1 -0
- package/utility/find-module.js +1 -2
- package/utility/generate-from-files.js +2 -3
- package/utility/json-file.js +1 -7
- package/utility/ng-ast-utils.js +2 -10
- package/utility/parse-name.js +0 -1
- package/utility/validation.js +1 -3
- package/utility/workspace.js +1 -5
- package/web-worker/index.js +2 -2
- package/workspace/index.js +1 -2
package/app-shell/index.js
CHANGED
|
@@ -40,11 +40,7 @@ const project_targets_1 = require("../utility/project-targets");
|
|
|
40
40
|
const workspace_1 = require("../utility/workspace");
|
|
41
41
|
const workspace_models_1 = require("../utility/workspace-models");
|
|
42
42
|
function getSourceFile(host, path) {
|
|
43
|
-
const
|
|
44
|
-
if (!buffer) {
|
|
45
|
-
throw new schematics_1.SchematicsException(`Could not find ${path}.`);
|
|
46
|
-
}
|
|
47
|
-
const content = buffer.toString();
|
|
43
|
+
const content = host.readText(path);
|
|
48
44
|
const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
49
45
|
return source;
|
|
50
46
|
}
|
|
@@ -76,10 +72,10 @@ function getComponentTemplate(host, compPath, tmplInfo) {
|
|
|
76
72
|
const templateUrl = tmplInfo.templateUrlProp.initializer.text;
|
|
77
73
|
const dir = (0, core_1.dirname)((0, core_1.normalize)(compPath));
|
|
78
74
|
const templatePath = (0, core_1.join)(dir, templateUrl);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
template = buffer.toString();
|
|
75
|
+
try {
|
|
76
|
+
template = host.readText(templatePath);
|
|
82
77
|
}
|
|
78
|
+
catch { }
|
|
83
79
|
}
|
|
84
80
|
return template;
|
|
85
81
|
}
|
package/application/index.js
CHANGED
|
@@ -233,7 +233,7 @@ function default_1(options) {
|
|
|
233
233
|
// If scoped project (i.e. "@foo/bar"), convert dir to "foo/bar".
|
|
234
234
|
let folderName = options.name.startsWith('@') ? options.name.slice(1) : options.name;
|
|
235
235
|
if (/[A-Z]/.test(folderName)) {
|
|
236
|
-
folderName =
|
|
236
|
+
folderName = schematics_1.strings.dasherize(folderName);
|
|
237
237
|
}
|
|
238
238
|
const appDir = isRootApp
|
|
239
239
|
? (0, core_1.normalize)(options.projectRoot || '')
|
|
@@ -244,7 +244,7 @@ function default_1(options) {
|
|
|
244
244
|
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
245
245
|
options.minimal ? (0, schematics_1.filter)(minimalPathFilter) : (0, schematics_1.noop)(),
|
|
246
246
|
(0, schematics_1.applyTemplates)({
|
|
247
|
-
utils:
|
|
247
|
+
utils: schematics_1.strings,
|
|
248
248
|
...options,
|
|
249
249
|
relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(appDir),
|
|
250
250
|
appName: options.name,
|
|
@@ -280,7 +280,7 @@ function default_1(options) {
|
|
|
280
280
|
? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template'))
|
|
281
281
|
: (0, schematics_1.noop)(),
|
|
282
282
|
(0, schematics_1.applyTemplates)({
|
|
283
|
-
utils:
|
|
283
|
+
utils: schematics_1.strings,
|
|
284
284
|
...options,
|
|
285
285
|
selector: appRootSelector,
|
|
286
286
|
...componentOptions,
|
|
@@ -8,7 +8,7 @@ describe('<%= classify(name) %><%= classify(type) %>', () => {
|
|
|
8
8
|
|
|
9
9
|
beforeEach(async () => {
|
|
10
10
|
await TestBed.configureTestingModule({
|
|
11
|
-
|
|
11
|
+
<%= standalone ? 'imports' : 'declarations' %>: [ <%= classify(name) %><%= classify(type) %> ]
|
|
12
12
|
})
|
|
13
13
|
.compileComponents();
|
|
14
14
|
|
package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Component, OnInit<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
@Component({<% if(!skipSelector) {%>
|
|
4
|
-
selector: '<%= selector %>',<%}%><% if(
|
|
4
|
+
selector: '<%= selector %>',<%}%><% if(standalone) {%>
|
|
5
|
+
standalone: true,<%}%><% if(inlineTemplate) { %>
|
|
5
6
|
template: `
|
|
6
7
|
<p>
|
|
7
8
|
<%= dasherize(name) %> works!
|
package/component/index.js
CHANGED
|
@@ -30,7 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
const core_1 = require("@angular-devkit/core");
|
|
34
33
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
35
34
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
36
35
|
const ast_utils_1 = require("../utility/ast-utils");
|
|
@@ -41,28 +40,24 @@ const validation_1 = require("../utility/validation");
|
|
|
41
40
|
const workspace_1 = require("../utility/workspace");
|
|
42
41
|
const schema_1 = require("./schema");
|
|
43
42
|
function readIntoSourceFile(host, modulePath) {
|
|
44
|
-
const
|
|
45
|
-
if (text === null) {
|
|
46
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
47
|
-
}
|
|
48
|
-
const sourceText = text.toString('utf-8');
|
|
43
|
+
const sourceText = host.readText(modulePath);
|
|
49
44
|
return ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
50
45
|
}
|
|
51
46
|
function addDeclarationToNgModule(options) {
|
|
52
47
|
return (host) => {
|
|
53
|
-
if (options.skipImport || !options.module) {
|
|
48
|
+
if (options.skipImport || options.standalone || !options.module) {
|
|
54
49
|
return host;
|
|
55
50
|
}
|
|
56
51
|
options.type = options.type != null ? options.type : 'Component';
|
|
57
52
|
const modulePath = options.module;
|
|
58
53
|
const source = readIntoSourceFile(host, modulePath);
|
|
59
54
|
const componentPath = `/${options.path}/` +
|
|
60
|
-
(options.flat ? '' :
|
|
61
|
-
|
|
55
|
+
(options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
|
|
56
|
+
schematics_1.strings.dasherize(options.name) +
|
|
62
57
|
(options.type ? '.' : '') +
|
|
63
|
-
|
|
58
|
+
schematics_1.strings.dasherize(options.type);
|
|
64
59
|
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
|
|
65
|
-
const classifiedName =
|
|
60
|
+
const classifiedName = schematics_1.strings.classify(options.name) + schematics_1.strings.classify(options.type);
|
|
66
61
|
const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
|
|
67
62
|
const declarationRecorder = host.beginUpdate(modulePath);
|
|
68
63
|
for (const change of declarationChanges) {
|
|
@@ -75,7 +70,7 @@ function addDeclarationToNgModule(options) {
|
|
|
75
70
|
// Need to refresh the AST because we overwrote the file in the host.
|
|
76
71
|
const source = readIntoSourceFile(host, modulePath);
|
|
77
72
|
const exportRecorder = host.beginUpdate(modulePath);
|
|
78
|
-
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath,
|
|
73
|
+
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, schematics_1.strings.classify(options.name) + schematics_1.strings.classify(options.type), relativePath);
|
|
79
74
|
for (const change of exportChanges) {
|
|
80
75
|
if (change instanceof change_1.InsertChange) {
|
|
81
76
|
exportRecorder.insertLeft(change.pos, change.toAdd);
|
|
@@ -87,7 +82,7 @@ function addDeclarationToNgModule(options) {
|
|
|
87
82
|
};
|
|
88
83
|
}
|
|
89
84
|
function buildSelector(options, projectPrefix) {
|
|
90
|
-
let selector =
|
|
85
|
+
let selector = schematics_1.strings.dasherize(options.name);
|
|
91
86
|
if (options.prefix) {
|
|
92
87
|
selector = `${options.prefix}-${selector}`;
|
|
93
88
|
}
|
|
@@ -119,7 +114,7 @@ function default_1(options) {
|
|
|
119
114
|
skipStyleFile ? (0, schematics_1.filter)((path) => !path.endsWith('.__style__.template')) : (0, schematics_1.noop)(),
|
|
120
115
|
options.inlineTemplate ? (0, schematics_1.filter)((path) => !path.endsWith('.html.template')) : (0, schematics_1.noop)(),
|
|
121
116
|
(0, schematics_1.applyTemplates)({
|
|
122
|
-
...
|
|
117
|
+
...schematics_1.strings,
|
|
123
118
|
'if-flat': (s) => (options.flat ? '' : s),
|
|
124
119
|
...options,
|
|
125
120
|
}),
|
package/component/schema.d.ts
CHANGED
|
@@ -65,6 +65,10 @@ export interface Schema {
|
|
|
65
65
|
* Do not create "spec.ts" test files for the new component.
|
|
66
66
|
*/
|
|
67
67
|
skipTests?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the generated component is standalone.
|
|
70
|
+
*/
|
|
71
|
+
standalone?: boolean;
|
|
68
72
|
/**
|
|
69
73
|
* The file extension or preprocessor to use for style files, or 'none' to skip generating
|
|
70
74
|
* the style file.
|
package/component/schema.json
CHANGED
|
@@ -48,6 +48,12 @@
|
|
|
48
48
|
"alias": "t",
|
|
49
49
|
"x-user-analytics": 10
|
|
50
50
|
},
|
|
51
|
+
"standalone": {
|
|
52
|
+
"description": "Whether the generated component is standalone.",
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"default": false,
|
|
55
|
+
"x-user-analytics": 15
|
|
56
|
+
},
|
|
51
57
|
"viewEncapsulation": {
|
|
52
58
|
"description": "The view encapsulation strategy to use in the new component.",
|
|
53
59
|
"enum": ["Emulated", "None", "ShadowDom"],
|
package/directive/index.js
CHANGED
|
@@ -30,7 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
const core_1 = require("@angular-devkit/core");
|
|
34
33
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
35
34
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
36
35
|
const ast_utils_1 = require("../utility/ast-utils");
|
|
@@ -41,22 +40,18 @@ const validation_1 = require("../utility/validation");
|
|
|
41
40
|
const workspace_1 = require("../utility/workspace");
|
|
42
41
|
function addDeclarationToNgModule(options) {
|
|
43
42
|
return (host) => {
|
|
44
|
-
if (options.skipImport || !options.module) {
|
|
43
|
+
if (options.skipImport || options.standalone || !options.module) {
|
|
45
44
|
return host;
|
|
46
45
|
}
|
|
47
46
|
const modulePath = options.module;
|
|
48
|
-
const
|
|
49
|
-
if (text === null) {
|
|
50
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
51
|
-
}
|
|
52
|
-
const sourceText = text.toString('utf-8');
|
|
47
|
+
const sourceText = host.readText(modulePath);
|
|
53
48
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
54
49
|
const directivePath = `/${options.path}/` +
|
|
55
|
-
(options.flat ? '' :
|
|
56
|
-
|
|
50
|
+
(options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
|
|
51
|
+
schematics_1.strings.dasherize(options.name) +
|
|
57
52
|
'.directive';
|
|
58
53
|
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, directivePath);
|
|
59
|
-
const classifiedName =
|
|
54
|
+
const classifiedName = schematics_1.strings.classify(`${options.name}Directive`);
|
|
60
55
|
const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
|
|
61
56
|
const declarationRecorder = host.beginUpdate(modulePath);
|
|
62
57
|
for (const change of declarationChanges) {
|
|
@@ -67,14 +62,10 @@ function addDeclarationToNgModule(options) {
|
|
|
67
62
|
host.commitUpdate(declarationRecorder);
|
|
68
63
|
if (options.export) {
|
|
69
64
|
// Need to refresh the AST because we overwrote the file in the host.
|
|
70
|
-
const
|
|
71
|
-
if (text === null) {
|
|
72
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
73
|
-
}
|
|
74
|
-
const sourceText = text.toString('utf-8');
|
|
65
|
+
const sourceText = host.readText(modulePath);
|
|
75
66
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
76
67
|
const exportRecorder = host.beginUpdate(modulePath);
|
|
77
|
-
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath,
|
|
68
|
+
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Directive`), relativePath);
|
|
78
69
|
for (const change of exportChanges) {
|
|
79
70
|
if (change instanceof change_1.InsertChange) {
|
|
80
71
|
exportRecorder.insertLeft(change.pos, change.toAdd);
|
|
@@ -93,7 +84,7 @@ function buildSelector(options, projectPrefix) {
|
|
|
93
84
|
else if (options.prefix === undefined && projectPrefix) {
|
|
94
85
|
selector = `${projectPrefix}-${selector}`;
|
|
95
86
|
}
|
|
96
|
-
return
|
|
87
|
+
return schematics_1.strings.camelize(selector);
|
|
97
88
|
}
|
|
98
89
|
function default_1(options) {
|
|
99
90
|
return async (host) => {
|
|
@@ -114,7 +105,7 @@ function default_1(options) {
|
|
|
114
105
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
115
106
|
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
116
107
|
(0, schematics_1.applyTemplates)({
|
|
117
|
-
...
|
|
108
|
+
...schematics_1.strings,
|
|
118
109
|
'if-flat': (s) => (options.flat ? '' : s),
|
|
119
110
|
...options,
|
|
120
111
|
}),
|
package/directive/schema.d.ts
CHANGED
package/directive/schema.json
CHANGED
|
@@ -59,6 +59,12 @@
|
|
|
59
59
|
"format": "html-selector",
|
|
60
60
|
"description": "The HTML selector to use for this directive."
|
|
61
61
|
},
|
|
62
|
+
"standalone": {
|
|
63
|
+
"description": "Whether the generated directive is standalone.",
|
|
64
|
+
"type": "boolean",
|
|
65
|
+
"default": false,
|
|
66
|
+
"x-user-analytics": 15
|
|
67
|
+
},
|
|
62
68
|
"flat": {
|
|
63
69
|
"type": "boolean",
|
|
64
70
|
"description": "When true (the default), creates the new files at the top level of the current project.",
|
package/e2e/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function default_1(options) {
|
|
|
53
53
|
(0, workspace_1.updateWorkspace)(workspace),
|
|
54
54
|
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
55
55
|
(0, schematics_1.applyTemplates)({
|
|
56
|
-
utils:
|
|
56
|
+
utils: schematics_1.strings,
|
|
57
57
|
...options,
|
|
58
58
|
relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(root),
|
|
59
59
|
}),
|
package/library/index.js
CHANGED
|
@@ -108,7 +108,7 @@ function default_1(options) {
|
|
|
108
108
|
const newProjectRoot = workspace.extensions.newProjectRoot || '';
|
|
109
109
|
let folderName = packageName.startsWith('@') ? packageName.slice(1) : packageName;
|
|
110
110
|
if (/[A-Z]/.test(folderName)) {
|
|
111
|
-
folderName =
|
|
111
|
+
folderName = schematics_1.strings.dasherize(folderName);
|
|
112
112
|
}
|
|
113
113
|
const projectRoot = (0, core_1.join)((0, core_1.normalize)(newProjectRoot), folderName);
|
|
114
114
|
const distRoot = `dist/${folderName}`;
|
|
@@ -116,7 +116,7 @@ function default_1(options) {
|
|
|
116
116
|
const sourceDir = `${projectRoot}/src/lib`;
|
|
117
117
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
118
118
|
(0, schematics_1.applyTemplates)({
|
|
119
|
-
...
|
|
119
|
+
...schematics_1.strings,
|
|
120
120
|
...options,
|
|
121
121
|
packageName,
|
|
122
122
|
projectRoot,
|
package/module/index.js
CHANGED
|
@@ -41,8 +41,8 @@ const workspace_1 = require("../utility/workspace");
|
|
|
41
41
|
const schema_1 = require("./schema");
|
|
42
42
|
function buildRelativeModulePath(options, modulePath) {
|
|
43
43
|
const importModulePath = (0, core_1.normalize)(`/${options.path}/` +
|
|
44
|
-
(options.flat ? '' :
|
|
45
|
-
|
|
44
|
+
(options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
|
|
45
|
+
schematics_1.strings.dasherize(options.name) +
|
|
46
46
|
'.module');
|
|
47
47
|
return (0, find_module_1.buildRelativePath)(modulePath, importModulePath);
|
|
48
48
|
}
|
|
@@ -52,14 +52,10 @@ function addDeclarationToNgModule(options) {
|
|
|
52
52
|
return host;
|
|
53
53
|
}
|
|
54
54
|
const modulePath = options.module;
|
|
55
|
-
const
|
|
56
|
-
if (text === null) {
|
|
57
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
58
|
-
}
|
|
59
|
-
const sourceText = text.toString();
|
|
55
|
+
const sourceText = host.readText(modulePath);
|
|
60
56
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
61
57
|
const relativePath = buildRelativeModulePath(options, modulePath);
|
|
62
|
-
const changes = (0, ast_utils_1.addImportToModule)(source, modulePath,
|
|
58
|
+
const changes = (0, ast_utils_1.addImportToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Module`), relativePath);
|
|
63
59
|
const recorder = host.beginUpdate(modulePath);
|
|
64
60
|
for (const change of changes) {
|
|
65
61
|
if (change instanceof change_1.InsertChange) {
|
|
@@ -85,11 +81,7 @@ function addRouteDeclarationToNgModule(options, routingModulePath) {
|
|
|
85
81
|
else {
|
|
86
82
|
path = options.module;
|
|
87
83
|
}
|
|
88
|
-
const
|
|
89
|
-
if (!text) {
|
|
90
|
-
throw new Error(`Couldn't find the module nor its routing module.`);
|
|
91
|
-
}
|
|
92
|
-
const sourceText = text.toString();
|
|
84
|
+
const sourceText = host.readText(path);
|
|
93
85
|
const addDeclaration = (0, ast_utils_1.addRouteDeclarationToModule)(ts.createSourceFile(path, sourceText, ts.ScriptTarget.Latest, true), path, buildRoute(options, options.module));
|
|
94
86
|
const recorder = host.beginUpdate(path);
|
|
95
87
|
recorder.insertLeft(addDeclaration.pos, addDeclaration.toAdd);
|
|
@@ -105,7 +97,7 @@ function getRoutingModulePath(host, modulePath) {
|
|
|
105
97
|
}
|
|
106
98
|
function buildRoute(options, modulePath) {
|
|
107
99
|
const relativeModulePath = buildRelativeModulePath(options, modulePath);
|
|
108
|
-
const moduleName = `${
|
|
100
|
+
const moduleName = `${schematics_1.strings.classify(options.name)}Module`;
|
|
109
101
|
const loadChildren = `() => import('${relativeModulePath}').then(m => m.${moduleName})`;
|
|
110
102
|
return `{ path: '${options.route}', loadChildren: ${loadChildren} }`;
|
|
111
103
|
}
|
|
@@ -131,7 +123,7 @@ function default_1(options) {
|
|
|
131
123
|
? (0, schematics_1.noop)()
|
|
132
124
|
: (0, schematics_1.filter)((path) => !path.endsWith('-routing.module.ts.template')),
|
|
133
125
|
(0, schematics_1.applyTemplates)({
|
|
134
|
-
...
|
|
126
|
+
...schematics_1.strings,
|
|
135
127
|
'if-flat': (s) => (options.flat ? '' : s),
|
|
136
128
|
lazyRoute: isLazyLoadedModuleGen,
|
|
137
129
|
lazyRouteWithoutRouteModule: isLazyLoadedModuleGen && !routingModulePath,
|
|
@@ -140,7 +132,7 @@ function default_1(options) {
|
|
|
140
132
|
}),
|
|
141
133
|
(0, schematics_1.move)(parsedPath.path),
|
|
142
134
|
]);
|
|
143
|
-
const moduleDasherized =
|
|
135
|
+
const moduleDasherized = schematics_1.strings.dasherize(options.name);
|
|
144
136
|
const modulePath = `${!options.flat ? moduleDasherized + '/' : ''}${moduleDasherized}.module.ts`;
|
|
145
137
|
const componentOptions = {
|
|
146
138
|
module: modulePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "14.0.0-next.
|
|
3
|
+
"version": "14.0.0-next.12",
|
|
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": "14.0.0-next.
|
|
19
|
-
"@angular-devkit/schematics": "14.0.0-next.
|
|
18
|
+
"@angular-devkit/core": "14.0.0-next.12",
|
|
19
|
+
"@angular-devkit/schematics": "14.0.0-next.12",
|
|
20
20
|
"jsonc-parser": "3.0.0"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
package/pipe/index.js
CHANGED
|
@@ -30,7 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
const core_1 = require("@angular-devkit/core");
|
|
34
33
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
35
34
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
36
35
|
const ast_utils_1 = require("../utility/ast-utils");
|
|
@@ -40,22 +39,18 @@ const parse_name_1 = require("../utility/parse-name");
|
|
|
40
39
|
const workspace_1 = require("../utility/workspace");
|
|
41
40
|
function addDeclarationToNgModule(options) {
|
|
42
41
|
return (host) => {
|
|
43
|
-
if (options.skipImport || !options.module) {
|
|
42
|
+
if (options.skipImport || options.standalone || !options.module) {
|
|
44
43
|
return host;
|
|
45
44
|
}
|
|
46
45
|
const modulePath = options.module;
|
|
47
|
-
const
|
|
48
|
-
if (text === null) {
|
|
49
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
50
|
-
}
|
|
51
|
-
const sourceText = text.toString('utf-8');
|
|
46
|
+
const sourceText = host.readText(modulePath);
|
|
52
47
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
53
48
|
const pipePath = `/${options.path}/` +
|
|
54
|
-
(options.flat ? '' :
|
|
55
|
-
|
|
49
|
+
(options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
|
|
50
|
+
schematics_1.strings.dasherize(options.name) +
|
|
56
51
|
'.pipe';
|
|
57
52
|
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, pipePath);
|
|
58
|
-
const changes = (0, ast_utils_1.addDeclarationToModule)(source, modulePath,
|
|
53
|
+
const changes = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Pipe`), relativePath);
|
|
59
54
|
const recorder = host.beginUpdate(modulePath);
|
|
60
55
|
for (const change of changes) {
|
|
61
56
|
if (change instanceof change_1.InsertChange) {
|
|
@@ -64,14 +59,10 @@ function addDeclarationToNgModule(options) {
|
|
|
64
59
|
}
|
|
65
60
|
host.commitUpdate(recorder);
|
|
66
61
|
if (options.export) {
|
|
67
|
-
const
|
|
68
|
-
if (text === null) {
|
|
69
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
70
|
-
}
|
|
71
|
-
const sourceText = text.toString('utf-8');
|
|
62
|
+
const sourceText = host.readText(modulePath);
|
|
72
63
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
73
64
|
const exportRecorder = host.beginUpdate(modulePath);
|
|
74
|
-
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath,
|
|
65
|
+
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Pipe`), relativePath);
|
|
75
66
|
for (const change of exportChanges) {
|
|
76
67
|
if (change instanceof change_1.InsertChange) {
|
|
77
68
|
exportRecorder.insertLeft(change.pos, change.toAdd);
|
|
@@ -94,7 +85,7 @@ function default_1(options) {
|
|
|
94
85
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
95
86
|
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
96
87
|
(0, schematics_1.applyTemplates)({
|
|
97
|
-
...
|
|
88
|
+
...schematics_1.strings,
|
|
98
89
|
'if-flat': (s) => (options.flat ? '' : s),
|
|
99
90
|
...options,
|
|
100
91
|
}),
|
package/pipe/schema.d.ts
CHANGED
package/pipe/schema.json
CHANGED
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
"description": "Do not import this pipe into the owning NgModule.",
|
|
46
46
|
"x-user-analytics": 18
|
|
47
47
|
},
|
|
48
|
+
"standalone": {
|
|
49
|
+
"description": "Whether the generated pipe is standalone.",
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"default": false,
|
|
52
|
+
"x-user-analytics": 15
|
|
53
|
+
},
|
|
48
54
|
"module": {
|
|
49
55
|
"type": "string",
|
|
50
56
|
"description": "The declaring NgModule.",
|
package/service-worker/index.js
CHANGED
|
@@ -113,11 +113,7 @@ function updateAppModule(mainPath) {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
function getTsSourceFile(host, path) {
|
|
116
|
-
const
|
|
117
|
-
if (!buffer) {
|
|
118
|
-
throw new schematics_1.SchematicsException(`Could not read file (${path}).`);
|
|
119
|
-
}
|
|
120
|
-
const content = buffer.toString();
|
|
116
|
+
const content = host.readText(path);
|
|
121
117
|
const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
122
118
|
return source;
|
|
123
119
|
}
|
package/universal/index.js
CHANGED
|
@@ -96,11 +96,7 @@ function updateConfigFile(options, tsConfigDirectory) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
function findBrowserModuleImport(host, modulePath) {
|
|
99
|
-
const
|
|
100
|
-
if (!moduleBuffer) {
|
|
101
|
-
throw new schematics_1.SchematicsException(`Module file (${modulePath}) not found`);
|
|
102
|
-
}
|
|
103
|
-
const moduleFileText = moduleBuffer.toString('utf-8');
|
|
99
|
+
const moduleFileText = host.readText(modulePath);
|
|
104
100
|
const source = ts.createSourceFile(modulePath, moduleFileText, ts.ScriptTarget.Latest, true);
|
|
105
101
|
const decoratorMetadata = (0, ast_utils_1.getDecoratorMetadata)(source, 'NgModule', '@angular/core')[0];
|
|
106
102
|
const browserModuleNode = (0, ast_utils_1.findNode)(decoratorMetadata, ts.SyntaxKind.Identifier, 'BrowserModule');
|
|
@@ -230,7 +226,7 @@ function default_1(options) {
|
|
|
230
226
|
}
|
|
231
227
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files/src'), [
|
|
232
228
|
(0, schematics_1.applyTemplates)({
|
|
233
|
-
...
|
|
229
|
+
...schematics_1.strings,
|
|
234
230
|
...options,
|
|
235
231
|
stripTsExtension: (s) => s.replace(/\.ts$/, ''),
|
|
236
232
|
hasLocalizePackage: !!(0, dependencies_1.getPackageJsonDependency)(host, '@angular/localize'),
|
|
@@ -239,7 +235,7 @@ function default_1(options) {
|
|
|
239
235
|
]);
|
|
240
236
|
const rootSource = (0, schematics_1.apply)((0, schematics_1.url)('./files/root'), [
|
|
241
237
|
(0, schematics_1.applyTemplates)({
|
|
242
|
-
...
|
|
238
|
+
...schematics_1.strings,
|
|
243
239
|
...options,
|
|
244
240
|
stripTsExtension: (s) => s.replace(/\.ts$/, ''),
|
|
245
241
|
tsConfigExtends,
|
package/utility/find-module.d.ts
CHANGED
package/utility/find-module.js
CHANGED
|
@@ -15,8 +15,7 @@ exports.ROUTING_MODULE_EXT = '-routing.module.ts';
|
|
|
15
15
|
* Find the module referred by a set of options passed to the schematics.
|
|
16
16
|
*/
|
|
17
17
|
function findModuleFromOptions(host, options) {
|
|
18
|
-
|
|
19
|
-
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
18
|
+
if (options.standalone || options.skipImport) {
|
|
20
19
|
return undefined;
|
|
21
20
|
}
|
|
22
21
|
const moduleExt = options.moduleExt || exports.MODULE_EXT;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.generateFromFiles = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
12
|
const parse_name_1 = require("./parse-name");
|
|
14
13
|
const workspace_1 = require("./workspace");
|
|
@@ -24,11 +23,11 @@ function generateFromFiles(options, extraTemplateValues = {}) {
|
|
|
24
23
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
25
24
|
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
26
25
|
(0, schematics_1.applyTemplates)({
|
|
27
|
-
...
|
|
26
|
+
...schematics_1.strings,
|
|
28
27
|
...options,
|
|
29
28
|
...extraTemplateValues,
|
|
30
29
|
}),
|
|
31
|
-
(0, schematics_1.move)(parsedPath.path + (options.flat ? '' : '/' +
|
|
30
|
+
(0, schematics_1.move)(parsedPath.path + (options.flat ? '' : '/' + schematics_1.strings.dasherize(options.name))),
|
|
32
31
|
]);
|
|
33
32
|
return (0, schematics_1.chain)([(0, schematics_1.mergeWith)(templateSource)]);
|
|
34
33
|
};
|
package/utility/json-file.js
CHANGED
|
@@ -14,13 +14,7 @@ class JSONFile {
|
|
|
14
14
|
constructor(host, path) {
|
|
15
15
|
this.host = host;
|
|
16
16
|
this.path = path;
|
|
17
|
-
|
|
18
|
-
if (buffer) {
|
|
19
|
-
this.content = buffer.toString();
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
throw new Error(`Could not read '${path}'.`);
|
|
23
|
-
}
|
|
17
|
+
this.content = this.host.readText(this.path);
|
|
24
18
|
}
|
|
25
19
|
get JsonAst() {
|
|
26
20
|
if (this._jsonAst) {
|
package/utility/ng-ast-utils.js
CHANGED
|
@@ -37,11 +37,7 @@ const path_1 = require("path");
|
|
|
37
37
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
38
38
|
const ast_utils_1 = require("../utility/ast-utils");
|
|
39
39
|
function findBootstrapModuleCall(host, mainPath) {
|
|
40
|
-
const
|
|
41
|
-
if (!mainBuffer) {
|
|
42
|
-
throw new schematics_1.SchematicsException(`Main file (${mainPath}) not found`);
|
|
43
|
-
}
|
|
44
|
-
const mainText = mainBuffer.toString('utf-8');
|
|
40
|
+
const mainText = host.readText(mainPath);
|
|
45
41
|
const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
|
|
46
42
|
const allNodes = (0, ast_utils_1.getSourceNodes)(source);
|
|
47
43
|
let bootstrapCall = null;
|
|
@@ -70,11 +66,7 @@ function findBootstrapModulePath(host, mainPath) {
|
|
|
70
66
|
throw new schematics_1.SchematicsException('Bootstrap call not found');
|
|
71
67
|
}
|
|
72
68
|
const bootstrapModule = bootstrapCall.arguments[0];
|
|
73
|
-
const
|
|
74
|
-
if (!mainBuffer) {
|
|
75
|
-
throw new schematics_1.SchematicsException(`Client application main file (${mainPath}) not found`);
|
|
76
|
-
}
|
|
77
|
-
const mainText = mainBuffer.toString('utf-8');
|
|
69
|
+
const mainText = host.readText(mainPath);
|
|
78
70
|
const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
|
|
79
71
|
const allNodes = (0, ast_utils_1.getSourceNodes)(source);
|
|
80
72
|
const bootstrapModuleRelativePath = allNodes
|
package/utility/parse-name.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.parseName = void 0;
|
|
11
|
-
// import { relative, Path } from "../../../angular_devkit/core/src/virtual-fs";
|
|
12
11
|
const core_1 = require("@angular-devkit/core");
|
|
13
12
|
function parseName(path, name) {
|
|
14
13
|
const nameWithoutPath = (0, core_1.basename)((0, core_1.normalize)(name));
|
package/utility/validation.js
CHANGED
|
@@ -8,15 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.validateHtmlSelector = exports.htmlSelectorRe = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
12
|
// Must start with a letter, and must contain only alphanumeric characters or dashes.
|
|
14
13
|
// When adding a dash the segment after the dash must also start with a letter.
|
|
15
14
|
exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*(:?-[a-zA-Z][.0-9a-zA-Z]*)*$/;
|
|
16
15
|
function validateHtmlSelector(selector) {
|
|
17
16
|
if (selector && !exports.htmlSelectorRe.test(selector)) {
|
|
18
|
-
throw new schematics_1.SchematicsException(
|
|
19
|
-
is invalid.`);
|
|
17
|
+
throw new schematics_1.SchematicsException(`Selector (${selector}) is invalid.`);
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
exports.validateHtmlSelector = validateHtmlSelector;
|
package/utility/workspace.js
CHANGED
|
@@ -14,11 +14,7 @@ const workspace_models_1 = require("./workspace-models");
|
|
|
14
14
|
function createHost(tree) {
|
|
15
15
|
return {
|
|
16
16
|
async readFile(path) {
|
|
17
|
-
|
|
18
|
-
if (!data) {
|
|
19
|
-
throw new Error('File not found.');
|
|
20
|
-
}
|
|
21
|
-
return core_1.virtualFs.fileBufferToString(data);
|
|
17
|
+
return tree.readText(path);
|
|
22
18
|
},
|
|
23
19
|
async writeFile(path, data) {
|
|
24
20
|
return tree.overwrite(path, data);
|
package/web-worker/index.js
CHANGED
|
@@ -46,7 +46,7 @@ function addSnippet(options) {
|
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
48
|
// Append the worker creation snippet.
|
|
49
|
-
const originalContent = host.
|
|
49
|
+
const originalContent = host.readText(siblingModulePath);
|
|
50
50
|
host.overwrite(siblingModulePath, originalContent + '\n' + workerCreationSnippet);
|
|
51
51
|
return host;
|
|
52
52
|
};
|
|
@@ -72,7 +72,7 @@ function default_1(options) {
|
|
|
72
72
|
options.name = parsedPath.name;
|
|
73
73
|
options.path = parsedPath.path;
|
|
74
74
|
const templateSourceWorkerCode = (0, schematics_1.apply)((0, schematics_1.url)('./files/worker'), [
|
|
75
|
-
(0, schematics_1.applyTemplates)({ ...options, ...
|
|
75
|
+
(0, schematics_1.applyTemplates)({ ...options, ...schematics_1.strings }),
|
|
76
76
|
(0, schematics_1.move)(parsedPath.path),
|
|
77
77
|
]);
|
|
78
78
|
const root = project.root || '';
|
package/workspace/index.js
CHANGED
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const core_1 = require("@angular-devkit/core");
|
|
11
10
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
11
|
const latest_versions_1 = require("../utility/latest-versions");
|
|
13
12
|
function default_1(options) {
|
|
14
13
|
return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
15
14
|
options.minimal ? (0, schematics_1.filter)((path) => !path.endsWith('editorconfig.template')) : (0, schematics_1.noop)(),
|
|
16
15
|
(0, schematics_1.applyTemplates)({
|
|
17
|
-
utils:
|
|
16
|
+
utils: schematics_1.strings,
|
|
18
17
|
...options,
|
|
19
18
|
'dot': '.',
|
|
20
19
|
latestVersions: latest_versions_1.latestVersions,
|