@schematics/angular 20.2.2 → 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/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/.browserslistrc +5 -5
- 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/migration-collection.json +2 -22
- 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 +4 -4
- 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/{migrations/previous-style-guide/migration.d.ts → tailwind/index.d.ts} +5 -2
- 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 +5 -5
- 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/migrations/previous-style-guide/migration.js +0 -42
- package/migrations/replace-provide-server-rendering-import/migration.d.ts +0 -9
- package/migrations/replace-provide-server-rendering-import/migration.js +0 -98
- package/migrations/replace-provide-server-routing/migration.d.ts +0 -9
- package/migrations/replace-provide-server-routing/migration.js +0 -125
- package/migrations/update-module-resolution/migration.d.ts +0 -9
- package/migrations/update-module-resolution/migration.js +0 -52
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
11
|
+
const utility_1 = require("../utility");
|
|
12
|
+
const latest_versions_1 = require("../utility/latest-versions");
|
|
13
|
+
const project_1 = require("../utility/project");
|
|
14
|
+
const TAILWIND_DEPENDENCIES = ['tailwindcss', '@tailwindcss/postcss', 'postcss'];
|
|
15
|
+
function addTailwindImport(stylesheetPath) {
|
|
16
|
+
return (tree) => {
|
|
17
|
+
let stylesheetText = '';
|
|
18
|
+
if (tree.exists(stylesheetPath)) {
|
|
19
|
+
stylesheetText = tree.readText(stylesheetPath);
|
|
20
|
+
stylesheetText += '\n';
|
|
21
|
+
}
|
|
22
|
+
stylesheetText += '@import "tailwindcss";\n';
|
|
23
|
+
tree.overwrite(stylesheetPath, stylesheetText);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.default = (0, project_1.createProjectSchematic)((options, { project }) => {
|
|
27
|
+
const buildTarget = project.targets.get('build');
|
|
28
|
+
if (!buildTarget) {
|
|
29
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not have a build target.`);
|
|
30
|
+
}
|
|
31
|
+
const styles = buildTarget.options?.['styles'];
|
|
32
|
+
if (!styles || styles.length === 0) {
|
|
33
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not have any global styles.`);
|
|
34
|
+
}
|
|
35
|
+
const stylesheetPath = styles[0];
|
|
36
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
37
|
+
(0, schematics_1.applyTemplates)({
|
|
38
|
+
...schematics_1.strings,
|
|
39
|
+
...options,
|
|
40
|
+
}),
|
|
41
|
+
(0, schematics_1.move)(project.root),
|
|
42
|
+
]);
|
|
43
|
+
return (0, schematics_1.chain)([
|
|
44
|
+
addTailwindImport(stylesheetPath),
|
|
45
|
+
(0, schematics_1.mergeWith)(templateSource),
|
|
46
|
+
...TAILWIND_DEPENDENCIES.map((name) => (0, utility_1.addDependency)(name, latest_versions_1.latestVersions[name], {
|
|
47
|
+
type: utility_1.DependencyType.Dev,
|
|
48
|
+
existing: utility_1.ExistingBehavior.Skip,
|
|
49
|
+
})),
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"title": "Tailwind CSS Schematic",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"project": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "The name of the project.",
|
|
9
|
+
"$default": {
|
|
10
|
+
"$source": "projectName"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": ["project"]
|
|
15
|
+
}
|
package/utility/ast-utils.js
CHANGED
|
@@ -57,7 +57,6 @@ exports.isImported = isImported;
|
|
|
57
57
|
exports.getRouterModuleDeclaration = getRouterModuleDeclaration;
|
|
58
58
|
exports.addRouteDeclarationToModule = addRouteDeclarationToModule;
|
|
59
59
|
exports.hasTopLevelIdentifier = hasTopLevelIdentifier;
|
|
60
|
-
const core_1 = require("@angular-devkit/core");
|
|
61
60
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
62
61
|
const change_1 = require("./change");
|
|
63
62
|
const eol_1 = require("./eol");
|
|
@@ -312,7 +311,11 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbol
|
|
|
312
311
|
let toInsert;
|
|
313
312
|
if (node.properties.length == 0) {
|
|
314
313
|
position = node.getEnd() - 1;
|
|
315
|
-
toInsert =
|
|
314
|
+
toInsert = `
|
|
315
|
+
${metadataField}: [
|
|
316
|
+
${' '.repeat(4)}${symbolName}
|
|
317
|
+
]
|
|
318
|
+
`;
|
|
316
319
|
}
|
|
317
320
|
else {
|
|
318
321
|
const childNode = node.properties[node.properties.length - 1];
|
|
@@ -323,7 +326,7 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbol
|
|
|
323
326
|
if (matches) {
|
|
324
327
|
toInsert =
|
|
325
328
|
`,${matches[0]}${metadataField}: [${matches[1]}` +
|
|
326
|
-
`${
|
|
329
|
+
`${' '.repeat(matches[2].length + 2)}${symbolName}${matches[0]}]`;
|
|
327
330
|
}
|
|
328
331
|
else {
|
|
329
332
|
toInsert = `, ${metadataField}: [${symbolName}]`;
|
|
@@ -349,8 +352,8 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbol
|
|
|
349
352
|
const assignmentInit = assignment.initializer;
|
|
350
353
|
const elements = assignmentInit.elements;
|
|
351
354
|
if (elements.length) {
|
|
352
|
-
const symbolsArray = elements.map((node) =>
|
|
353
|
-
if (symbolsArray.includes(
|
|
355
|
+
const symbolsArray = elements.map((node) => node.getText());
|
|
356
|
+
if (symbolsArray.includes(symbolName)) {
|
|
354
357
|
return [];
|
|
355
358
|
}
|
|
356
359
|
expression = elements[elements.length - 1];
|
|
@@ -363,14 +366,14 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbol
|
|
|
363
366
|
if (ts.isArrayLiteralExpression(expression)) {
|
|
364
367
|
// We found the field but it's empty. Insert it just before the `]`.
|
|
365
368
|
position--;
|
|
366
|
-
toInsert = `\n${
|
|
369
|
+
toInsert = `\n${' '.repeat(4)}${symbolName}\n `;
|
|
367
370
|
}
|
|
368
371
|
else {
|
|
369
372
|
// Get the indentation of the last element, if any.
|
|
370
373
|
const text = expression.getFullText(source);
|
|
371
374
|
const matches = text.match(/^(\r?\n)(\s*)/);
|
|
372
375
|
if (matches) {
|
|
373
|
-
toInsert = `,${matches[1]}${
|
|
376
|
+
toInsert = `,${matches[1]}${' '.repeat(matches[2].length)}${symbolName}`;
|
|
374
377
|
}
|
|
375
378
|
else {
|
|
376
379
|
toInsert = `, ${symbolName}`;
|
|
@@ -14,9 +14,9 @@ const dependencies = require('./latest-versions/package.json')['dependencies'];
|
|
|
14
14
|
exports.latestVersions = {
|
|
15
15
|
...dependencies,
|
|
16
16
|
// As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
|
|
17
|
-
Angular: '^
|
|
18
|
-
NgPackagr: '^
|
|
19
|
-
DevkitBuildAngular: '^
|
|
20
|
-
AngularBuild: '^
|
|
21
|
-
AngularSSR: '^
|
|
17
|
+
Angular: '^21.0.0-next.0',
|
|
18
|
+
NgPackagr: '^21.0.0-next.0',
|
|
19
|
+
DevkitBuildAngular: '^21.0.0-next.1',
|
|
20
|
+
AngularBuild: '^21.0.0-next.1',
|
|
21
|
+
AngularSSR: '^21.0.0-next.1',
|
|
22
22
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
9
|
+
import { ProjectDefinition, WorkspaceDefinition } from './workspace';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a schematic rule factory that provides project information to the given factory function.
|
|
12
|
+
* The project is determined from the `project` option. If the project is not found, an exception is
|
|
13
|
+
* thrown.
|
|
14
|
+
*
|
|
15
|
+
* @param factory The factory function that creates the schematic rule.
|
|
16
|
+
* @returns A schematic rule factory.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createProjectSchematic<S extends {
|
|
19
|
+
project: string;
|
|
20
|
+
}>(factory: (options: S, projectContext: {
|
|
21
|
+
project: ProjectDefinition;
|
|
22
|
+
workspace: WorkspaceDefinition;
|
|
23
|
+
tree: Tree;
|
|
24
|
+
context: SchematicContext;
|
|
25
|
+
}) => Rule | Promise<Rule>): (options: S) => Rule;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createProjectSchematic = createProjectSchematic;
|
|
11
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
|
+
const workspace_1 = require("./workspace");
|
|
13
|
+
/**
|
|
14
|
+
* Creates a schematic rule factory that provides project information to the given factory function.
|
|
15
|
+
* The project is determined from the `project` option. If the project is not found, an exception is
|
|
16
|
+
* thrown.
|
|
17
|
+
*
|
|
18
|
+
* @param factory The factory function that creates the schematic rule.
|
|
19
|
+
* @returns A schematic rule factory.
|
|
20
|
+
*/
|
|
21
|
+
function createProjectSchematic(factory) {
|
|
22
|
+
return (options) => async (tree, context) => {
|
|
23
|
+
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
24
|
+
const project = workspace.projects.get(options.project);
|
|
25
|
+
if (!project) {
|
|
26
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
27
|
+
}
|
|
28
|
+
return factory(options, { project, workspace, tree, context });
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.addRootImport = addRootImport;
|
|
11
11
|
exports.addRootProvider = addRootProvider;
|
|
12
|
-
const core_1 = require("@angular-devkit/core");
|
|
13
12
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
13
|
const ast_utils_1 = require("../ast-utils");
|
|
15
14
|
const change_1 = require("../change");
|
|
@@ -137,7 +136,7 @@ function insertStandaloneRootProvider(tree, mainFilePath, expression) {
|
|
|
137
136
|
addProvidersExpressionToAppConfig(tree, appConfig, expression);
|
|
138
137
|
return;
|
|
139
138
|
}
|
|
140
|
-
const newAppConfig = `, {\n${
|
|
139
|
+
const newAppConfig = `, {\n${' '.repeat(2)}providers: [${expression}]\n}`;
|
|
141
140
|
let targetCall;
|
|
142
141
|
if (bootstrapCall.arguments.length === 1) {
|
|
143
142
|
targetCall = bootstrapCall;
|
|
@@ -170,7 +169,7 @@ function addProvidersExpressionToAppConfig(tree, appConfig, expression) {
|
|
|
170
169
|
]);
|
|
171
170
|
}
|
|
172
171
|
else {
|
|
173
|
-
const prop =
|
|
172
|
+
const prop = `${' '.repeat(2)}providers: [${expression}]`;
|
|
174
173
|
let toInsert;
|
|
175
174
|
let insertPosition;
|
|
176
175
|
if (configProps.length === 0) {
|
package/web-worker/index.d.ts
CHANGED
package/web-worker/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
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
10
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
11
|
+
const posix_1 = require("node:path/posix");
|
|
13
12
|
const parse_name_1 = require("../utility/parse-name");
|
|
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
|
function addSnippet(options) {
|
|
17
17
|
return (host, context) => {
|
|
@@ -33,18 +33,18 @@ function addSnippet(options) {
|
|
|
33
33
|
}
|
|
34
34
|
const siblingModulePath = `${options.path}/${siblingModules[0]}`;
|
|
35
35
|
const logMessage = 'console.log(`page got message: ${data}`);';
|
|
36
|
-
const workerCreationSnippet =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
const workerCreationSnippet = `
|
|
37
|
+
if (typeof Worker !== 'undefined') {
|
|
38
|
+
// Create a new
|
|
39
|
+
const worker = new Worker(new URL('./${options.name}.worker', import.meta.url));
|
|
40
|
+
worker.onmessage = ({ data }) => {
|
|
41
|
+
${logMessage}
|
|
42
|
+
};
|
|
43
|
+
worker.postMessage('hello');
|
|
44
|
+
} else {
|
|
45
|
+
// Web Workers are not supported in this environment.
|
|
46
|
+
// You should add a fallback so that your program still executes correctly.
|
|
47
|
+
}
|
|
48
48
|
`;
|
|
49
49
|
// Append the worker creation snippet.
|
|
50
50
|
const originalContent = host.readText(siblingModulePath);
|
|
@@ -52,59 +52,49 @@ function addSnippet(options) {
|
|
|
52
52
|
return host;
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
}),
|
|
103
|
-
// Create the worker in a sibling module.
|
|
104
|
-
options.snippet ? addSnippet(options) : (0, schematics_1.noop)(),
|
|
105
|
-
// Add the worker.
|
|
106
|
-
(0, schematics_1.mergeWith)(templateSourceWorkerCode),
|
|
107
|
-
(0, schematics_1.mergeWith)(templateSourceWorkerConfig),
|
|
108
|
-
]);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
55
|
+
exports.default = (0, project_1.createProjectSchematic)((options, { project }) => {
|
|
56
|
+
const projectType = project.extensions['projectType'];
|
|
57
|
+
if (projectType !== 'application') {
|
|
58
|
+
throw new schematics_1.SchematicsException(`Web Worker requires a project type of "application".`);
|
|
59
|
+
}
|
|
60
|
+
if (options.path === undefined) {
|
|
61
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
62
|
+
}
|
|
63
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
64
|
+
options.name = parsedPath.name;
|
|
65
|
+
options.path = parsedPath.path;
|
|
66
|
+
const templateSourceWorkerCode = (0, schematics_1.apply)((0, schematics_1.url)('./files/worker'), [
|
|
67
|
+
(0, schematics_1.applyTemplates)({ ...options, ...schematics_1.strings }),
|
|
68
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
69
|
+
]);
|
|
70
|
+
const root = project.root || '';
|
|
71
|
+
const templateSourceWorkerConfig = (0, schematics_1.apply)((0, schematics_1.url)('./files/worker-tsconfig'), [
|
|
72
|
+
(0, schematics_1.applyTemplates)({
|
|
73
|
+
...options,
|
|
74
|
+
relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(root),
|
|
75
|
+
}),
|
|
76
|
+
(0, schematics_1.move)(root),
|
|
77
|
+
]);
|
|
78
|
+
return (0, schematics_1.chain)([
|
|
79
|
+
// Add project configuration.
|
|
80
|
+
(0, workspace_1.updateWorkspace)((workspace) => {
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
82
|
+
const project = workspace.projects.get(options.project);
|
|
83
|
+
const buildTarget = project.targets.get('build');
|
|
84
|
+
const testTarget = project.targets.get('test');
|
|
85
|
+
if (!buildTarget) {
|
|
86
|
+
throw new Error(`Build target is not defined for this project.`);
|
|
87
|
+
}
|
|
88
|
+
const workerConfigPath = (0, posix_1.join)(root, 'tsconfig.worker.json');
|
|
89
|
+
(buildTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;
|
|
90
|
+
if (testTarget) {
|
|
91
|
+
(testTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
// Create the worker in a sibling module.
|
|
95
|
+
options.snippet ? addSnippet(options) : (0, schematics_1.noop)(),
|
|
96
|
+
// Add the worker.
|
|
97
|
+
(0, schematics_1.mergeWith)(templateSourceWorkerCode),
|
|
98
|
+
(0, schematics_1.mergeWith)(templateSourceWorkerConfig),
|
|
99
|
+
]);
|
|
100
|
+
});
|
package/workspace/schema.d.ts
CHANGED
package/workspace/schema.js
CHANGED
package/workspace/schema.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.default = default_1;
|
|
11
|
-
const workspace_1 = require("../../utility/workspace");
|
|
12
|
-
const TYPE_SCHEMATICS = ['component', 'directive', 'service'];
|
|
13
|
-
const SEPARATOR_SCHEMATICS = ['guard', 'interceptor', 'module', 'pipe', 'resolver'];
|
|
14
|
-
function default_1() {
|
|
15
|
-
return (0, workspace_1.updateWorkspace)((workspace) => {
|
|
16
|
-
let schematicsDefaults = workspace.extensions['schematics'];
|
|
17
|
-
// Ensure "schematics" field is an object
|
|
18
|
-
if (!schematicsDefaults ||
|
|
19
|
-
typeof schematicsDefaults !== 'object' ||
|
|
20
|
-
Array.isArray(schematicsDefaults)) {
|
|
21
|
-
schematicsDefaults = workspace.extensions['schematics'] = {};
|
|
22
|
-
}
|
|
23
|
-
// Add "type" value for each schematic to continue generating a type suffix.
|
|
24
|
-
// New default is an empty type value.
|
|
25
|
-
for (const schematicName of TYPE_SCHEMATICS) {
|
|
26
|
-
const schematic = (schematicsDefaults[`@schematics/angular:${schematicName}`] ??= {});
|
|
27
|
-
if (typeof schematic === 'object' && !Array.isArray(schematic) && !('type' in schematic)) {
|
|
28
|
-
schematic['type'] = schematicName;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Add "typeSeparator" value for each schematic to continue generating "." before type.
|
|
32
|
-
// New default is an "-" type value.
|
|
33
|
-
for (const schematicName of SEPARATOR_SCHEMATICS) {
|
|
34
|
-
const schematic = (schematicsDefaults[`@schematics/angular:${schematicName}`] ??= {});
|
|
35
|
-
if (typeof schematic === 'object' &&
|
|
36
|
-
!Array.isArray(schematic) &&
|
|
37
|
-
!('typeSeparator' in schematic)) {
|
|
38
|
-
schematic['typeSeparator'] = '.';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
-
*/
|
|
8
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
9
|
-
export default function (): Rule;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.default = default_1;
|
|
14
|
-
const typescript_1 = __importDefault(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
15
|
-
const dependency_1 = require("../../utility/dependency");
|
|
16
|
-
const latest_versions_1 = require("../../utility/latest-versions");
|
|
17
|
-
function* visit(directory) {
|
|
18
|
-
for (const path of directory.subfiles) {
|
|
19
|
-
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
|
20
|
-
const entry = directory.file(path);
|
|
21
|
-
if (entry) {
|
|
22
|
-
const content = entry.content;
|
|
23
|
-
if (content.includes('provideServerRendering') &&
|
|
24
|
-
content.includes('@angular/platform-server')) {
|
|
25
|
-
// Only need to rename the import so we can just string replacements.
|
|
26
|
-
yield [entry.path, content.toString()];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
for (const path of directory.subdirs) {
|
|
32
|
-
if (path === 'node_modules' || path.startsWith('.')) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
yield* visit(directory.dir(path));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function default_1() {
|
|
39
|
-
return async (tree) => {
|
|
40
|
-
let rule;
|
|
41
|
-
for (const [filePath, content] of visit(tree.root)) {
|
|
42
|
-
let updatedContent = content;
|
|
43
|
-
const ssrImports = new Set();
|
|
44
|
-
const platformServerImports = new Set();
|
|
45
|
-
const sourceFile = typescript_1.default.createSourceFile(filePath, content, typescript_1.default.ScriptTarget.Latest, true);
|
|
46
|
-
sourceFile.forEachChild((node) => {
|
|
47
|
-
if (typescript_1.default.isImportDeclaration(node)) {
|
|
48
|
-
const moduleSpecifier = node.moduleSpecifier.getText(sourceFile);
|
|
49
|
-
if (moduleSpecifier.includes('@angular/platform-server')) {
|
|
50
|
-
const importClause = node.importClause;
|
|
51
|
-
if (importClause &&
|
|
52
|
-
importClause.namedBindings &&
|
|
53
|
-
typescript_1.default.isNamedImports(importClause.namedBindings)) {
|
|
54
|
-
const namedImports = importClause.namedBindings.elements.map((e) => e.getText(sourceFile));
|
|
55
|
-
namedImports.forEach((importName) => {
|
|
56
|
-
if (importName === 'provideServerRendering') {
|
|
57
|
-
ssrImports.add(importName);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
platformServerImports.add(importName);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
updatedContent = updatedContent.replace(node.getFullText(sourceFile), '');
|
|
65
|
-
}
|
|
66
|
-
else if (moduleSpecifier.includes('@angular/ssr')) {
|
|
67
|
-
const importClause = node.importClause;
|
|
68
|
-
if (importClause &&
|
|
69
|
-
importClause.namedBindings &&
|
|
70
|
-
typescript_1.default.isNamedImports(importClause.namedBindings)) {
|
|
71
|
-
importClause.namedBindings.elements.forEach((e) => {
|
|
72
|
-
ssrImports.add(e.getText(sourceFile));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
updatedContent = updatedContent.replace(node.getFullText(sourceFile), '');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (platformServerImports.size > 0) {
|
|
80
|
-
updatedContent =
|
|
81
|
-
`import { ${Array.from(platformServerImports).sort().join(', ')} } from '@angular/platform-server';\n` +
|
|
82
|
-
updatedContent;
|
|
83
|
-
}
|
|
84
|
-
if (ssrImports.size > 0) {
|
|
85
|
-
updatedContent =
|
|
86
|
-
`import { ${Array.from(ssrImports).sort().join(', ')} } from '@angular/ssr';\n` +
|
|
87
|
-
updatedContent;
|
|
88
|
-
}
|
|
89
|
-
if (content !== updatedContent) {
|
|
90
|
-
tree.overwrite(filePath, updatedContent);
|
|
91
|
-
if (rule === undefined) {
|
|
92
|
-
rule = (0, dependency_1.addDependency)('@angular/ssr', latest_versions_1.latestVersions.AngularSSR);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return rule;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
-
*/
|
|
8
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
9
|
-
export default function (): Rule;
|