@schematics/angular 21.0.0-next.0 → 21.0.0-next.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/ai-config/index.js +5 -3
- package/ai-config/schema.json +1 -17
- package/app-shell/index.d.ts +2 -1
- package/app-shell/index.js +16 -24
- package/application/index.js +9 -0
- package/application/schema.d.ts +2 -1
- package/application/schema.js +1 -0
- package/application/schema.json +6 -2
- package/collection.json +7 -0
- package/component/index.d.ts +2 -1
- package/component/index.js +45 -53
- package/config/index.d.ts +2 -1
- package/config/index.js +12 -19
- package/directive/index.d.ts +2 -1
- package/directive/index.js +20 -27
- package/migrations/karma/karma-config-comparer.js +1 -1
- package/migrations/migration-collection.json +1 -0
- package/module/index.d.ts +2 -1
- package/module/index.js +48 -50
- package/ng-new/schema.d.ts +2 -2
- package/ng-new/schema.js +1 -1
- package/ng-new/schema.json +2 -2
- package/package.json +3 -3
- package/pipe/index.d.ts +2 -2
- package/pipe/index.js +16 -18
- package/server/index.d.ts +2 -1
- package/server/index.js +67 -71
- package/service-worker/index.d.ts +2 -1
- package/service-worker/index.js +44 -81
- package/ssr/index.d.ts +2 -1
- package/ssr/index.js +32 -40
- package/tailwind/files/.postcssrc.json.template +5 -0
- package/tailwind/index.d.ts +12 -0
- package/tailwind/index.js +51 -0
- package/tailwind/schema.d.ts +7 -0
- package/tailwind/schema.js +4 -0
- package/tailwind/schema.json +15 -0
- package/utility/ast-utils.js +10 -7
- package/utility/latest-versions/package.json +2 -0
- package/utility/latest-versions.js +3 -3
- package/utility/project.d.ts +25 -0
- package/utility/project.js +30 -0
- package/utility/standalone/rules.js +2 -3
- package/web-worker/index.d.ts +2 -1
- package/web-worker/index.js +60 -70
- package/workspace/schema.d.ts +0 -1
- package/workspace/schema.js +0 -1
- package/workspace/schema.json +1 -1
package/ai-config/index.js
CHANGED
|
@@ -39,11 +39,13 @@ const AI_TOOLS = {
|
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
function default_1({ tool }) {
|
|
42
|
-
if (!tool
|
|
42
|
+
if (!tool) {
|
|
43
43
|
return (0, schematics_1.noop)();
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const rules = tool
|
|
46
|
+
.filter((tool) => tool !== schema_1.Tool.None)
|
|
47
|
+
.map((selectedTool) => AI_TOOLS[selectedTool])
|
|
48
|
+
.map(({ rulesName, directory, frontmatter }) => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
47
49
|
(0, schematics_1.applyTemplates)({
|
|
48
50
|
...schematics_1.strings,
|
|
49
51
|
rulesName,
|
package/ai-config/schema.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"tool": {
|
|
10
10
|
"type": "array",
|
|
11
11
|
"uniqueItems": true,
|
|
12
|
-
"default": "none",
|
|
12
|
+
"default": ["none"],
|
|
13
13
|
"x-prompt": {
|
|
14
14
|
"message": "Which AI tools do you want to configure with Angular best practices? https://angular.dev/ai/develop-with-ai",
|
|
15
15
|
"type": "list",
|
|
@@ -50,21 +50,5 @@
|
|
|
50
50
|
"enum": ["none", "gemini", "copilot", "claude", "cursor", "jetbrains", "windsurf"]
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
},
|
|
54
|
-
"if": {
|
|
55
|
-
"properties": {
|
|
56
|
-
"tool": {
|
|
57
|
-
"contains": {
|
|
58
|
-
"const": "none"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"then": {
|
|
64
|
-
"properties": {
|
|
65
|
-
"tool": {
|
|
66
|
-
"maxItems": 1
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
53
|
}
|
|
70
54
|
}
|
package/app-shell/index.d.ts
CHANGED
package/app-shell/index.js
CHANGED
|
@@ -10,14 +10,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.default = default_1;
|
|
14
13
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
15
14
|
const posix_1 = require("node:path/posix");
|
|
16
15
|
const typescript_1 = __importDefault(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
17
16
|
const ast_utils_1 = require("../utility/ast-utils");
|
|
18
17
|
const change_1 = require("../utility/change");
|
|
19
18
|
const ng_ast_utils_1 = require("../utility/ng-ast-utils");
|
|
20
|
-
const
|
|
19
|
+
const project_1 = require("../utility/project");
|
|
21
20
|
const util_1 = require("../utility/standalone/util");
|
|
22
21
|
const workspace_1 = require("../utility/workspace");
|
|
23
22
|
function getSourceFile(host, path) {
|
|
@@ -149,25 +148,18 @@ function addServerRoutingConfig(options, isStandalone) {
|
|
|
149
148
|
host.commitUpdate(recorder);
|
|
150
149
|
};
|
|
151
150
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
module: 'app.module.server.ts',
|
|
168
|
-
project: options.project,
|
|
169
|
-
standalone: isStandalone,
|
|
170
|
-
}),
|
|
171
|
-
]);
|
|
172
|
-
};
|
|
173
|
-
}
|
|
151
|
+
exports.default = (0, project_1.createProjectSchematic)(async (options, { tree }) => {
|
|
152
|
+
const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
|
|
153
|
+
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(tree, browserEntryPoint);
|
|
154
|
+
return (0, schematics_1.chain)([
|
|
155
|
+
validateProject(browserEntryPoint),
|
|
156
|
+
(0, schematics_1.schematic)('server', options),
|
|
157
|
+
addServerRoutingConfig(options, isStandalone),
|
|
158
|
+
(0, schematics_1.schematic)('component', {
|
|
159
|
+
name: 'app-shell',
|
|
160
|
+
module: 'app.module.server.ts',
|
|
161
|
+
project: options.project,
|
|
162
|
+
standalone: isStandalone,
|
|
163
|
+
}),
|
|
164
|
+
]);
|
|
165
|
+
});
|
package/application/index.js
CHANGED
|
@@ -36,6 +36,10 @@ function addTsProjectReference(...paths) {
|
|
|
36
36
|
}
|
|
37
37
|
function default_1(options) {
|
|
38
38
|
return async (host) => {
|
|
39
|
+
const isTailwind = options.style === schema_1.Style.Tailwind;
|
|
40
|
+
if (isTailwind) {
|
|
41
|
+
options.style = schema_1.Style.Css;
|
|
42
|
+
}
|
|
39
43
|
const { appDir, appRootSelector, componentOptions, folderName, sourceDir } = await getAppOptions(host, options);
|
|
40
44
|
return (0, schematics_1.chain)([
|
|
41
45
|
addAppToWorkspaceFile(options, appDir),
|
|
@@ -104,6 +108,11 @@ function default_1(options) {
|
|
|
104
108
|
})
|
|
105
109
|
: (0, schematics_1.noop)(),
|
|
106
110
|
options.skipPackageJson ? (0, schematics_1.noop)() : addDependenciesToPackageJson(options),
|
|
111
|
+
isTailwind
|
|
112
|
+
? (0, schematics_1.schematic)('tailwind', {
|
|
113
|
+
project: options.name,
|
|
114
|
+
})
|
|
115
|
+
: (0, schematics_1.noop)(),
|
|
107
116
|
]);
|
|
108
117
|
};
|
|
109
118
|
}
|
package/application/schema.d.ts
CHANGED
package/application/schema.js
CHANGED
|
@@ -12,6 +12,7 @@ var Style;
|
|
|
12
12
|
Style["Less"] = "less";
|
|
13
13
|
Style["Sass"] = "sass";
|
|
14
14
|
Style["Scss"] = "scss";
|
|
15
|
+
Style["Tailwind"] = "tailwind";
|
|
15
16
|
})(Style || (exports.Style = Style = {}));
|
|
16
17
|
/**
|
|
17
18
|
* Sets the view encapsulation mode for the application's components. This determines how
|
package/application/schema.json
CHANGED
|
@@ -54,15 +54,19 @@
|
|
|
54
54
|
"description": "The type of stylesheet files to be created for components in the application.",
|
|
55
55
|
"type": "string",
|
|
56
56
|
"default": "css",
|
|
57
|
-
"enum": ["css", "scss", "sass", "less"],
|
|
57
|
+
"enum": ["css", "scss", "sass", "less", "tailwind"],
|
|
58
58
|
"x-prompt": {
|
|
59
|
-
"message": "Which stylesheet
|
|
59
|
+
"message": "Which stylesheet system would you like to use?",
|
|
60
60
|
"type": "list",
|
|
61
61
|
"items": [
|
|
62
62
|
{
|
|
63
63
|
"value": "css",
|
|
64
64
|
"label": "CSS [ https://developer.mozilla.org/docs/Web/CSS ]"
|
|
65
65
|
},
|
|
66
|
+
{
|
|
67
|
+
"value": "tailwind",
|
|
68
|
+
"label": "Tailwind CSS [ https://tailwindcss.com ]"
|
|
69
|
+
},
|
|
66
70
|
{
|
|
67
71
|
"value": "scss",
|
|
68
72
|
"label": "Sass (SCSS) [ https://sass-lang.com/documentation/syntax#scss ]"
|
package/collection.json
CHANGED
|
@@ -136,6 +136,13 @@
|
|
|
136
136
|
"factory": "./ai-config",
|
|
137
137
|
"schema": "./ai-config/schema.json",
|
|
138
138
|
"description": "Generates an AI tool configuration file."
|
|
139
|
+
},
|
|
140
|
+
"tailwind": {
|
|
141
|
+
"factory": "./tailwind",
|
|
142
|
+
"schema": "./tailwind/schema.json",
|
|
143
|
+
"hidden": true,
|
|
144
|
+
"private": true,
|
|
145
|
+
"description": "[INTERNAL] Adds tailwind to a project. Intended for use for ng new/add."
|
|
139
146
|
}
|
|
140
147
|
}
|
|
141
148
|
}
|
package/component/index.d.ts
CHANGED
package/component/index.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.default = default_1;
|
|
11
10
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
11
|
const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
|
|
13
12
|
const find_module_1 = require("../utility/find-module");
|
|
14
13
|
const parse_name_1 = require("../utility/parse-name");
|
|
14
|
+
const project_1 = require("../utility/project");
|
|
15
15
|
const validation_1 = require("../utility/validation");
|
|
16
16
|
const workspace_1 = require("../utility/workspace");
|
|
17
17
|
const schema_1 = require("./schema");
|
|
@@ -25,55 +25,47 @@ function buildSelector(options, projectPrefix) {
|
|
|
25
25
|
}
|
|
26
26
|
return selector;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
options.path
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(0,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
options
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(0, schematics_1.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
|
|
73
|
-
type: 'component',
|
|
74
|
-
...options,
|
|
75
|
-
}),
|
|
76
|
-
(0, schematics_1.mergeWith)(templateSource),
|
|
77
|
-
]);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
28
|
+
exports.default = (0, project_1.createProjectSchematic)((options, { project, tree }) => {
|
|
29
|
+
if (options.path === undefined) {
|
|
30
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
31
|
+
}
|
|
32
|
+
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
|
33
|
+
// Schematic templates require a defined type value
|
|
34
|
+
options.type ??= '';
|
|
35
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
36
|
+
options.name = parsedPath.name;
|
|
37
|
+
options.path = parsedPath.path;
|
|
38
|
+
options.selector = options.selector || buildSelector(options, (project && project.prefix) || '');
|
|
39
|
+
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
40
|
+
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
|
41
|
+
const skipStyleFile = options.inlineStyle || options.style === schema_1.Style.None;
|
|
42
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
43
|
+
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
44
|
+
skipStyleFile ? (0, schematics_1.filter)((path) => !path.endsWith('.__style__.template')) : (0, schematics_1.noop)(),
|
|
45
|
+
options.inlineTemplate ? (0, schematics_1.filter)((path) => !path.endsWith('.html.template')) : (0, schematics_1.noop)(),
|
|
46
|
+
(0, schematics_1.applyTemplates)({
|
|
47
|
+
...schematics_1.strings,
|
|
48
|
+
'if-flat': (s) => (options.flat ? '' : s),
|
|
49
|
+
'ngext': options.ngHtml ? '.ng' : '',
|
|
50
|
+
...options,
|
|
51
|
+
}),
|
|
52
|
+
!options.type
|
|
53
|
+
? (0, schematics_1.forEach)(((file) => {
|
|
54
|
+
return file.path.includes('..')
|
|
55
|
+
? {
|
|
56
|
+
content: file.content,
|
|
57
|
+
path: file.path.replace('..', '.'),
|
|
58
|
+
}
|
|
59
|
+
: file;
|
|
60
|
+
}))
|
|
61
|
+
: (0, schematics_1.noop)(),
|
|
62
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
63
|
+
]);
|
|
64
|
+
return (0, schematics_1.chain)([
|
|
65
|
+
(0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
|
|
66
|
+
type: 'component',
|
|
67
|
+
...options,
|
|
68
|
+
}),
|
|
69
|
+
(0, schematics_1.mergeWith)(templateSource),
|
|
70
|
+
]);
|
|
71
|
+
});
|
package/config/index.d.ts
CHANGED
package/config/index.js
CHANGED
|
@@ -7,39 +7,32 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.default = default_1;
|
|
11
10
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
11
|
const promises_1 = require("node:fs/promises");
|
|
13
12
|
const node_path_1 = require("node:path");
|
|
14
13
|
const paths_1 = require("../utility/paths");
|
|
14
|
+
const project_1 = require("../utility/project");
|
|
15
15
|
const workspace_1 = require("../utility/workspace");
|
|
16
16
|
const workspace_models_1 = require("../utility/workspace-models");
|
|
17
17
|
const schema_1 = require("./schema");
|
|
18
|
-
|
|
18
|
+
exports.default = (0, project_1.createProjectSchematic)((options, { project }) => {
|
|
19
19
|
switch (options.type) {
|
|
20
20
|
case schema_1.Type.Karma:
|
|
21
21
|
return addKarmaConfig(options);
|
|
22
22
|
case schema_1.Type.Browserslist:
|
|
23
|
-
return addBrowserslistConfig(
|
|
23
|
+
return addBrowserslistConfig(project.root);
|
|
24
24
|
default:
|
|
25
25
|
throw new schematics_1.SchematicsException(`"${options.type}" is an unknown configuration file type.`);
|
|
26
26
|
}
|
|
27
|
-
}
|
|
28
|
-
function addBrowserslistConfig(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const config = await (0, promises_1.readFile)(node_path_1.posix.join(__dirname, '.browserslistrc'), 'utf8');
|
|
37
|
-
return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
38
|
-
(0, schematics_1.filter)((p) => p.endsWith('.browserslistrc.template')),
|
|
39
|
-
(0, schematics_1.applyTemplates)({ config }),
|
|
40
|
-
(0, schematics_1.move)(project.root),
|
|
41
|
-
]));
|
|
42
|
-
};
|
|
27
|
+
});
|
|
28
|
+
async function addBrowserslistConfig(projectRoot) {
|
|
29
|
+
// Read Angular's default vendored `.browserslistrc` file.
|
|
30
|
+
const config = await (0, promises_1.readFile)(node_path_1.posix.join(__dirname, '.browserslistrc'), 'utf8');
|
|
31
|
+
return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
32
|
+
(0, schematics_1.filter)((p) => p.endsWith('.browserslistrc.template')),
|
|
33
|
+
(0, schematics_1.applyTemplates)({ config }),
|
|
34
|
+
(0, schematics_1.move)(projectRoot),
|
|
35
|
+
]));
|
|
43
36
|
}
|
|
44
37
|
function addKarmaConfig(options) {
|
|
45
38
|
return (0, workspace_1.updateWorkspace)((workspace) => {
|
package/directive/index.d.ts
CHANGED
package/directive/index.js
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.default = default_1;
|
|
11
10
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
11
|
const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
|
|
13
12
|
const find_module_1 = require("../utility/find-module");
|
|
14
13
|
const generate_from_files_1 = require("../utility/generate-from-files");
|
|
15
14
|
const parse_name_1 = require("../utility/parse-name");
|
|
15
|
+
const project_1 = require("../utility/project");
|
|
16
16
|
const validation_1 = require("../utility/validation");
|
|
17
17
|
const workspace_1 = require("../utility/workspace");
|
|
18
18
|
function buildSelector(options, projectPrefix) {
|
|
@@ -25,29 +25,22 @@ function buildSelector(options, projectPrefix) {
|
|
|
25
25
|
}
|
|
26
26
|
return schematics_1.strings.camelize(selector);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(0,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
type: 'directive',
|
|
48
|
-
...options,
|
|
49
|
-
}),
|
|
50
|
-
(0, generate_from_files_1.generateFromFiles)(options),
|
|
51
|
-
]);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
28
|
+
exports.default = (0, project_1.createProjectSchematic)((options, { project, tree }) => {
|
|
29
|
+
if (options.path === undefined) {
|
|
30
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
31
|
+
}
|
|
32
|
+
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
|
33
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
34
|
+
options.name = parsedPath.name;
|
|
35
|
+
options.path = parsedPath.path;
|
|
36
|
+
options.selector = options.selector || buildSelector(options, project.prefix || '');
|
|
37
|
+
(0, validation_1.validateHtmlSelector)(options.selector);
|
|
38
|
+
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
|
39
|
+
return (0, schematics_1.chain)([
|
|
40
|
+
(0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
|
|
41
|
+
type: 'directive',
|
|
42
|
+
...options,
|
|
43
|
+
}),
|
|
44
|
+
(0, generate_from_files_1.generateFromFiles)(options),
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
@@ -27,7 +27,7 @@ const karma_config_analyzer_1 = require("./karma-config-analyzer");
|
|
|
27
27
|
* @returns The content of the default `karma.conf.js` file.
|
|
28
28
|
*/
|
|
29
29
|
async function generateDefaultKarmaConfig(relativePathToWorkspaceRoot, projectName, needDevkitPlugin) {
|
|
30
|
-
const templatePath =
|
|
30
|
+
const templatePath = require.resolve('../../config/files/karma.conf.js.template');
|
|
31
31
|
let template = await (0, promises_1.readFile)(templatePath, 'utf-8');
|
|
32
32
|
// TODO: Replace this with the actual schematic templating logic.
|
|
33
33
|
template = template
|
package/module/index.d.ts
CHANGED
package/module/index.js
CHANGED
|
@@ -40,7 +40,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.default = default_1;
|
|
44
43
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
45
44
|
const posix_1 = require("node:path/posix");
|
|
46
45
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
@@ -48,6 +47,7 @@ const ast_utils_1 = require("../utility/ast-utils");
|
|
|
48
47
|
const change_1 = require("../utility/change");
|
|
49
48
|
const find_module_1 = require("../utility/find-module");
|
|
50
49
|
const parse_name_1 = require("../utility/parse-name");
|
|
50
|
+
const project_1 = require("../utility/project");
|
|
51
51
|
const validation_1 = require("../utility/validation");
|
|
52
52
|
const workspace_1 = require("../utility/workspace");
|
|
53
53
|
const schema_1 = require("./schema");
|
|
@@ -112,53 +112,51 @@ function buildRoute(options, modulePath) {
|
|
|
112
112
|
const loadChildren = `() => import('${relativeModulePath}').then(m => m.${moduleName})`;
|
|
113
113
|
return `{ path: '${options.route}', loadChildren: ${loadChildren} }`;
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
standalone: false,
|
|
156
|
-
};
|
|
157
|
-
return (0, schematics_1.chain)([
|
|
158
|
-
!isLazyLoadedModuleGen ? addImportToNgModule(options) : (0, schematics_1.noop)(),
|
|
159
|
-
addRouteDeclarationToNgModule(options, routingModulePath),
|
|
160
|
-
(0, schematics_1.mergeWith)(templateSource),
|
|
161
|
-
isLazyLoadedModuleGen ? (0, schematics_1.schematic)('component', componentOptions) : (0, schematics_1.noop)(),
|
|
162
|
-
]);
|
|
115
|
+
exports.default = (0, project_1.createProjectSchematic)(async (options, { tree }) => {
|
|
116
|
+
if (options.path === undefined) {
|
|
117
|
+
options.path = await (0, workspace_1.createDefaultPath)(tree, options.project);
|
|
118
|
+
}
|
|
119
|
+
if (options.module) {
|
|
120
|
+
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
|
121
|
+
}
|
|
122
|
+
let routingModulePath;
|
|
123
|
+
const isLazyLoadedModuleGen = !!(options.route && options.module);
|
|
124
|
+
if (isLazyLoadedModuleGen) {
|
|
125
|
+
options.routingScope = schema_1.RoutingScope.Child;
|
|
126
|
+
routingModulePath = getRoutingModulePath(tree, options.module);
|
|
127
|
+
}
|
|
128
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
129
|
+
options.name = parsedPath.name;
|
|
130
|
+
options.path = parsedPath.path;
|
|
131
|
+
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
|
132
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
133
|
+
options.routing || (isLazyLoadedModuleGen && routingModulePath)
|
|
134
|
+
? (0, schematics_1.noop)()
|
|
135
|
+
: (0, schematics_1.filter)((path) => !path.includes('-routing')),
|
|
136
|
+
(0, schematics_1.applyTemplates)({
|
|
137
|
+
...schematics_1.strings,
|
|
138
|
+
'if-flat': (s) => (options.flat ? '' : s),
|
|
139
|
+
lazyRoute: isLazyLoadedModuleGen,
|
|
140
|
+
lazyRouteWithoutRouteModule: isLazyLoadedModuleGen && !routingModulePath,
|
|
141
|
+
lazyRouteWithRouteModule: isLazyLoadedModuleGen && !!routingModulePath,
|
|
142
|
+
...options,
|
|
143
|
+
}),
|
|
144
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
145
|
+
]);
|
|
146
|
+
const moduleDasherized = schematics_1.strings.dasherize(options.name);
|
|
147
|
+
const modulePath = `${!options.flat ? moduleDasherized + '/' : ''}${moduleDasherized}${options.typeSeparator}module.ts`;
|
|
148
|
+
const componentOptions = {
|
|
149
|
+
module: modulePath,
|
|
150
|
+
flat: options.flat,
|
|
151
|
+
name: options.name,
|
|
152
|
+
path: options.path,
|
|
153
|
+
project: options.project,
|
|
154
|
+
standalone: false,
|
|
163
155
|
};
|
|
164
|
-
|
|
156
|
+
return (0, schematics_1.chain)([
|
|
157
|
+
!isLazyLoadedModuleGen ? addImportToNgModule(options) : (0, schematics_1.noop)(),
|
|
158
|
+
addRouteDeclarationToNgModule(options, routingModulePath),
|
|
159
|
+
(0, schematics_1.mergeWith)(templateSource),
|
|
160
|
+
isLazyLoadedModuleGen ? (0, schematics_1.schematic)('component', componentOptions) : (0, schematics_1.noop)(),
|
|
161
|
+
]);
|
|
162
|
+
});
|
package/ng-new/schema.d.ts
CHANGED
|
@@ -140,7 +140,6 @@ export type CommitObject = {
|
|
|
140
140
|
*/
|
|
141
141
|
export declare enum PackageManager {
|
|
142
142
|
Bun = "bun",
|
|
143
|
-
Cnpm = "cnpm",
|
|
144
143
|
Npm = "npm",
|
|
145
144
|
Pnpm = "pnpm",
|
|
146
145
|
Yarn = "yarn"
|
|
@@ -152,7 +151,8 @@ export declare enum Style {
|
|
|
152
151
|
Css = "css",
|
|
153
152
|
Less = "less",
|
|
154
153
|
Sass = "sass",
|
|
155
|
-
Scss = "scss"
|
|
154
|
+
Scss = "scss",
|
|
155
|
+
Tailwind = "tailwind"
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Sets the view encapsulation mode for components in the initial project. This determines
|