@schematics/angular 20.0.0-next.0 → 20.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-shell/index.js +11 -118
- package/app-shell/schema.d.ts +0 -5
- package/app-shell/schema.json +0 -5
- package/application/files/module-files/src/app/app.module.ts.template +3 -3
- package/application/files/module-files/src/app/{app.component.spec.ts.template → app.spec.ts.template} +6 -6
- package/application/files/module-files/src/app/{app.component.ts.template → app.ts.template} +3 -3
- package/application/files/module-files/src/main.ts.template +2 -2
- package/application/files/standalone-files/src/app/{app.component.spec.ts.template → app.spec.ts.template} +6 -6
- package/application/files/standalone-files/src/app/{app.component.ts.template → app.ts.template} +3 -3
- package/application/files/standalone-files/src/main.ts.template +2 -2
- package/application/index.js +1 -2
- package/application/schema.d.ts +0 -5
- package/application/schema.json +0 -4
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +1 -1
- package/component/index.js +3 -0
- package/component/schema.d.ts +5 -0
- package/component/schema.json +6 -2
- package/directive/files/__name@dasherize__.__type@dasherize__.spec.ts.template +8 -0
- package/directive/files/{__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +1 -1
- package/directive/index.js +4 -10
- package/directive/schema.d.ts +5 -0
- package/directive/schema.json +4 -0
- package/library/files/src/__entryFile__.ts.template +1 -2
- package/library/index.js +0 -6
- package/migrations/migration-collection.json +11 -11
- package/migrations/{update-ssr-imports → replace-provide-server-rendering-import}/migration.d.ts +0 -6
- package/migrations/replace-provide-server-rendering-import/migration.js +133 -0
- package/migrations/replace-provide-server-routing/migration.d.ts +9 -0
- package/migrations/replace-provide-server-routing/migration.js +122 -0
- package/module/files/__name@dasherize@if-flat__/__name@dasherize__-routing.module.ts.template +2 -2
- package/module/files/__name@dasherize@if-flat__/__name@dasherize__.module.ts.template +1 -1
- package/ng-new/index.js +0 -1
- package/ng-new/schema.d.ts +0 -5
- package/ng-new/schema.json +0 -4
- package/package.json +4 -3
- package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +7 -8
- package/server/files/application-builder/standalone-src/app/app.config.server.ts.template +4 -6
- package/server/files/application-builder/standalone-src/main.server.ts.template +2 -2
- package/server/files/server-builder/ngmodule-src/app/app.module.server.ts.template +2 -2
- package/server/files/server-builder/standalone-src/app/app.config.server.ts.template +1 -1
- package/server/files/server-builder/standalone-src/main.server.ts.template +2 -2
- package/server/index.js +5 -11
- package/server/schema.d.ts +0 -5
- package/server/schema.json +0 -4
- package/service/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +16 -0
- package/service/files/__name@dasherize@if-flat__/{__name@dasherize__.service.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +1 -1
- package/service/index.js +2 -0
- package/service/schema.d.ts +5 -0
- package/service/schema.json +4 -0
- package/ssr/index.d.ts +1 -3
- package/ssr/index.js +11 -96
- package/ssr/schema.d.ts +0 -5
- package/ssr/schema.json +0 -4
- package/utility/find-module.js +1 -1
- package/utility/generate-from-files.d.ts +1 -0
- package/utility/generate-from-files.js +10 -0
- package/utility/latest-versions.js +3 -3
- package/utility/project-targets.d.ts +2 -0
- package/utility/project-targets.js +7 -0
- package/web-worker/index.js +1 -1
- package/workspace/files/tsconfig.json.template +1 -3
- package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.spec.ts.template +0 -8
- package/migrations/update-ssr-imports/migration.js +0 -107
- package/migrations/update-workspace-config/migration.d.ts +0 -33
- package/migrations/update-workspace-config/migration.js +0 -77
- package/service/files/__name@dasherize@if-flat__/__name@dasherize__.service.spec.ts.template +0 -16
- package/ssr/files/application-builder-common-engine/server.ts.template +0 -67
- /package/application/files/common-files/src/app/{app.component.html.template → app.ng.html.template} +0 -0
- /package/component/files/__name@dasherize@if-flat__/{__name@dasherize__.__type@dasherize__.html.template → __name@dasherize__.__type@dasherize____ngext__.html.template} +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.default = default_1;
|
|
44
|
+
const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
45
|
+
const dependencies_1 = require("../../utility/dependencies");
|
|
46
|
+
const latest_versions_1 = require("../../utility/latest-versions");
|
|
47
|
+
function* visit(directory) {
|
|
48
|
+
for (const path of directory.subfiles) {
|
|
49
|
+
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
|
50
|
+
const entry = directory.file(path);
|
|
51
|
+
if (entry) {
|
|
52
|
+
const content = entry.content;
|
|
53
|
+
if (content.includes('provideServerRendering') &&
|
|
54
|
+
content.includes('@angular/platform-server')) {
|
|
55
|
+
// Only need to rename the import so we can just string replacements.
|
|
56
|
+
yield [entry.path, content.toString()];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const path of directory.subdirs) {
|
|
62
|
+
if (path === 'node_modules' || path.startsWith('.')) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
yield* visit(directory.dir(path));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function default_1() {
|
|
69
|
+
return async (tree) => {
|
|
70
|
+
let angularSSRAdded = false;
|
|
71
|
+
for (const [filePath, content] of visit(tree.root)) {
|
|
72
|
+
let updatedContent = content;
|
|
73
|
+
const ssrImports = new Set();
|
|
74
|
+
const platformServerImports = new Set();
|
|
75
|
+
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
76
|
+
sourceFile.forEachChild((node) => {
|
|
77
|
+
if (ts.isImportDeclaration(node)) {
|
|
78
|
+
const moduleSpecifier = node.moduleSpecifier.getText(sourceFile);
|
|
79
|
+
if (moduleSpecifier.includes('@angular/platform-server')) {
|
|
80
|
+
const importClause = node.importClause;
|
|
81
|
+
if (importClause &&
|
|
82
|
+
importClause.namedBindings &&
|
|
83
|
+
ts.isNamedImports(importClause.namedBindings)) {
|
|
84
|
+
const namedImports = importClause.namedBindings.elements.map((e) => e.getText(sourceFile));
|
|
85
|
+
namedImports.forEach((importName) => {
|
|
86
|
+
if (importName === 'provideServerRendering') {
|
|
87
|
+
ssrImports.add(importName);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
platformServerImports.add(importName);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
updatedContent = updatedContent.replace(node.getFullText(sourceFile), '');
|
|
95
|
+
}
|
|
96
|
+
else if (moduleSpecifier.includes('@angular/ssr')) {
|
|
97
|
+
const importClause = node.importClause;
|
|
98
|
+
if (importClause &&
|
|
99
|
+
importClause.namedBindings &&
|
|
100
|
+
ts.isNamedImports(importClause.namedBindings)) {
|
|
101
|
+
importClause.namedBindings.elements.forEach((e) => {
|
|
102
|
+
ssrImports.add(e.getText(sourceFile));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
updatedContent = updatedContent.replace(node.getFullText(sourceFile), '');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (platformServerImports.size > 0) {
|
|
110
|
+
updatedContent =
|
|
111
|
+
`import { ${Array.from(platformServerImports).sort().join(', ')} } from '@angular/platform-server';\n` +
|
|
112
|
+
updatedContent;
|
|
113
|
+
}
|
|
114
|
+
if (ssrImports.size > 0) {
|
|
115
|
+
updatedContent =
|
|
116
|
+
`import { ${Array.from(ssrImports).sort().join(', ')} } from '@angular/ssr';\n` +
|
|
117
|
+
updatedContent;
|
|
118
|
+
}
|
|
119
|
+
if (content !== updatedContent) {
|
|
120
|
+
tree.overwrite(filePath, updatedContent);
|
|
121
|
+
if (!angularSSRAdded) {
|
|
122
|
+
(0, dependencies_1.addPackageJsonDependency)(tree, {
|
|
123
|
+
name: '@angular/ssr',
|
|
124
|
+
version: latest_versions_1.latestVersions.AngularSSR,
|
|
125
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
126
|
+
overwrite: false,
|
|
127
|
+
});
|
|
128
|
+
angularSSRAdded = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,122 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.default = default_1;
|
|
44
|
+
const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
45
|
+
const dependencies_1 = require("../../utility/dependencies");
|
|
46
|
+
function* visit(directory) {
|
|
47
|
+
for (const path of directory.subfiles) {
|
|
48
|
+
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
|
49
|
+
const entry = directory.file(path);
|
|
50
|
+
if (entry) {
|
|
51
|
+
const content = entry.content;
|
|
52
|
+
if (content.includes('provideServerRouting') && content.includes('@angular/ssr')) {
|
|
53
|
+
// Only need to rename the import so we can just string replacements.
|
|
54
|
+
yield [entry.path, content.toString()];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const path of directory.subdirs) {
|
|
60
|
+
if (path === 'node_modules' || path.startsWith('.')) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
yield* visit(directory.dir(path));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function default_1() {
|
|
67
|
+
return async (tree) => {
|
|
68
|
+
if (!(0, dependencies_1.getPackageJsonDependency)(tree, '@angular/ssr')) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
for (const [filePath, content] of visit(tree.root)) {
|
|
72
|
+
const recorder = tree.beginUpdate(filePath);
|
|
73
|
+
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
74
|
+
function visit(node) {
|
|
75
|
+
if (ts.isPropertyAssignment(node) &&
|
|
76
|
+
ts.isIdentifier(node.name) &&
|
|
77
|
+
node.name.text === 'providers' &&
|
|
78
|
+
ts.isArrayLiteralExpression(node.initializer)) {
|
|
79
|
+
const providersArray = node.initializer;
|
|
80
|
+
const newProviders = providersArray.elements
|
|
81
|
+
.filter((el) => {
|
|
82
|
+
return !(ts.isCallExpression(el) &&
|
|
83
|
+
ts.isIdentifier(el.expression) &&
|
|
84
|
+
el.expression.text === 'provideServerRendering');
|
|
85
|
+
})
|
|
86
|
+
.map((el) => {
|
|
87
|
+
if (ts.isCallExpression(el) &&
|
|
88
|
+
ts.isIdentifier(el.expression) &&
|
|
89
|
+
el.expression.text === 'provideServerRouting') {
|
|
90
|
+
const [withRouteVal, ...others] = el.arguments.map((arg) => arg.getText());
|
|
91
|
+
return `provideServerRendering(withRoutes(${withRouteVal})${others.length ? ', ' + others.join(', ') : ''})`;
|
|
92
|
+
}
|
|
93
|
+
return el.getText();
|
|
94
|
+
});
|
|
95
|
+
// Update the 'providers' array in the source file
|
|
96
|
+
recorder.remove(providersArray.getStart(), providersArray.getWidth());
|
|
97
|
+
recorder.insertRight(providersArray.getStart(), `[${newProviders.join(', ')}]`);
|
|
98
|
+
}
|
|
99
|
+
ts.forEachChild(node, visit);
|
|
100
|
+
}
|
|
101
|
+
// Visit all nodes to update 'providers'
|
|
102
|
+
visit(sourceFile);
|
|
103
|
+
// Update imports by removing 'provideServerRouting'
|
|
104
|
+
const importDecl = sourceFile.statements.find((stmt) => ts.isImportDeclaration(stmt) &&
|
|
105
|
+
ts.isStringLiteral(stmt.moduleSpecifier) &&
|
|
106
|
+
stmt.moduleSpecifier.text === '@angular/ssr');
|
|
107
|
+
if (importDecl?.importClause?.namedBindings) {
|
|
108
|
+
const namedBindings = importDecl?.importClause.namedBindings;
|
|
109
|
+
if (ts.isNamedImports(namedBindings)) {
|
|
110
|
+
const elements = namedBindings.elements;
|
|
111
|
+
const updatedElements = elements
|
|
112
|
+
.map((el) => el.getText())
|
|
113
|
+
.filter((x) => x !== 'provideServerRouting');
|
|
114
|
+
updatedElements.push('withRoutes');
|
|
115
|
+
recorder.remove(namedBindings.getStart(), namedBindings.getWidth());
|
|
116
|
+
recorder.insertLeft(namedBindings.getStart(), `{ ${updatedElements.sort().join(', ')} }`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
tree.commitUpdate(recorder);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
package/module/files/__name@dasherize@if-flat__/__name@dasherize__-routing.module.ts.template
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
2
|
import { RouterModule, Routes } from '@angular/router';<% if (lazyRoute) { %>
|
|
3
|
-
import { <%= classify(name) %>
|
|
3
|
+
import { <%= classify(name) %> } from './<%= dasherize(name) %>';<% } %>
|
|
4
4
|
|
|
5
|
-
const routes: Routes = [<% if (lazyRoute) { %>{ path: '', component: <%= classify(name) %>
|
|
5
|
+
const routes: Routes = [<% if (lazyRoute) { %>{ path: '', component: <%= classify(name) %> }<% } %>];
|
|
6
6
|
|
|
7
7
|
@NgModule({
|
|
8
8
|
imports: [RouterModule.for<%= routingScope %>(routes)],
|
|
@@ -5,7 +5,7 @@ import { Routes, RouterModule } from '@angular/router';<% } %>
|
|
|
5
5
|
import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing.module';<% } %>
|
|
6
6
|
<% if (lazyRouteWithoutRouteModule) { %>
|
|
7
7
|
const routes: Routes = [
|
|
8
|
-
{ path: '', component: <%= classify(name) %>
|
|
8
|
+
{ path: '', component: <%= classify(name) %> }
|
|
9
9
|
];<% } %>
|
|
10
10
|
|
|
11
11
|
@NgModule({
|
package/ng-new/index.js
CHANGED
package/ng-new/schema.d.ts
CHANGED
|
@@ -66,11 +66,6 @@ export type Schema = {
|
|
|
66
66
|
* modules for managing navigation between different views in your application.
|
|
67
67
|
*/
|
|
68
68
|
routing?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Create a server application in the initial project using the Server Routing and App
|
|
71
|
-
* Engine APIs (Developer Preview).
|
|
72
|
-
*/
|
|
73
|
-
serverRouting?: boolean;
|
|
74
69
|
/**
|
|
75
70
|
* Do not initialize a Git repository in the new workspace. By default, a Git repository is
|
|
76
71
|
* initialized to help you track changes to your project.
|
package/ng-new/schema.json
CHANGED
|
@@ -139,10 +139,6 @@
|
|
|
139
139
|
"type": "boolean",
|
|
140
140
|
"x-user-analytics": "ep.ng_ssr"
|
|
141
141
|
},
|
|
142
|
-
"serverRouting": {
|
|
143
|
-
"description": "Create a server application in the initial project using the Server Routing and App Engine APIs (Developer Preview).",
|
|
144
|
-
"type": "boolean"
|
|
145
|
-
},
|
|
146
142
|
"experimentalZoneless": {
|
|
147
143
|
"description": "Create an initial application that does not utilize `zone.js`.",
|
|
148
144
|
"type": "boolean",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "20.0.0-next.
|
|
3
|
+
"version": "20.0.0-next.2",
|
|
4
4
|
"description": "Schematics specific to Angular",
|
|
5
5
|
"homepage": "https://github.com/angular/angular-cli",
|
|
6
6
|
"keywords": [
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"schematics": "./collection.json",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@angular-devkit/core": "20.0.0-next.
|
|
26
|
-
"@angular-devkit/schematics": "20.0.0-next.
|
|
25
|
+
"@angular-devkit/core": "20.0.0-next.2",
|
|
26
|
+
"@angular-devkit/schematics": "20.0.0-next.2",
|
|
27
27
|
"jsonc-parser": "3.3.1"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
31
|
"url": "https://github.com/angular/angular-cli.git"
|
|
32
32
|
},
|
|
33
|
+
"packageManager": "pnpm@9.15.6",
|
|
33
34
|
"engines": {
|
|
34
35
|
"node": "^20.11.1 || >=22.0.0",
|
|
35
36
|
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { serverRoutes } from './app.routes.server';<% } %>
|
|
2
|
+
import { provideServerRendering, withRoutes } from '@angular/ssr';
|
|
3
|
+
import { App } from './app';
|
|
4
|
+
import { AppModule } from './app.module';
|
|
5
|
+
import { serverRoutes } from './app.routes.server';
|
|
7
6
|
|
|
8
7
|
@NgModule({
|
|
9
|
-
imports: [AppModule,
|
|
10
|
-
providers: [
|
|
11
|
-
bootstrap: [
|
|
8
|
+
imports: [AppModule],
|
|
9
|
+
providers: [provideServerRendering(withRoutes(serverRoutes))],
|
|
10
|
+
bootstrap: [App],
|
|
12
11
|
})
|
|
13
12
|
export class AppServerModule {}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
|
2
|
-
import { provideServerRendering } from '@angular/
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { serverRoutes } from './app.routes.server';<% } %>
|
|
2
|
+
import { provideServerRendering, withRoutes } from '@angular/ssr';
|
|
3
|
+
import { appConfig } from './app.config';
|
|
4
|
+
import { serverRoutes } from './app.routes.server';
|
|
6
5
|
|
|
7
6
|
const serverConfig: ApplicationConfig = {
|
|
8
7
|
providers: [
|
|
9
|
-
provideServerRendering(
|
|
10
|
-
provideServerRouting(serverRoutes)<% } %>
|
|
8
|
+
provideServerRendering(withRoutes(serverRoutes))
|
|
11
9
|
]
|
|
12
10
|
};
|
|
13
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
2
|
-
import {
|
|
2
|
+
import { App } from './app/app';
|
|
3
3
|
import { config } from './app/app.config.server';
|
|
4
4
|
|
|
5
|
-
const bootstrap = () => bootstrapApplication(
|
|
5
|
+
const bootstrap = () => bootstrapApplication(App, config);
|
|
6
6
|
|
|
7
7
|
export default bootstrap;
|
|
@@ -2,13 +2,13 @@ import { NgModule } from '@angular/core';
|
|
|
2
2
|
import { ServerModule } from '@angular/platform-server';
|
|
3
3
|
|
|
4
4
|
import { AppModule } from './app.module';
|
|
5
|
-
import {
|
|
5
|
+
import { App } from './app';
|
|
6
6
|
|
|
7
7
|
@NgModule({
|
|
8
8
|
imports: [
|
|
9
9
|
AppModule,
|
|
10
10
|
ServerModule,
|
|
11
11
|
],
|
|
12
|
-
bootstrap: [
|
|
12
|
+
bootstrap: [App],
|
|
13
13
|
})
|
|
14
14
|
export class AppServerModule {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
|
2
|
-
import { provideServerRendering } from '@angular/
|
|
2
|
+
import { provideServerRendering } from '@angular/ssr';
|
|
3
3
|
import { appConfig } from './app.config';
|
|
4
4
|
|
|
5
5
|
const serverConfig: ApplicationConfig = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
2
|
-
import {
|
|
2
|
+
import { App } from './app/app';
|
|
3
3
|
import { config } from './app/app.config.server';
|
|
4
4
|
|
|
5
|
-
const bootstrap = () => bootstrapApplication(
|
|
5
|
+
const bootstrap = () => bootstrapApplication(App, config);
|
|
6
6
|
|
|
7
7
|
export default bootstrap;
|
package/server/index.js
CHANGED
|
@@ -88,9 +88,7 @@ function updateConfigFileApplicationBuilder(options) {
|
|
|
88
88
|
}
|
|
89
89
|
buildTarget.options ??= {};
|
|
90
90
|
buildTarget.options['server'] = node_path_1.posix.join(project.sourceRoot ?? node_path_1.posix.join(project.root, 'src'), serverMainEntryName);
|
|
91
|
-
|
|
92
|
-
buildTarget.options['outputMode'] = 'static';
|
|
93
|
-
}
|
|
91
|
+
buildTarget.options['outputMode'] = 'static';
|
|
94
92
|
});
|
|
95
93
|
}
|
|
96
94
|
function updateTsConfigFile(tsConfigPath) {
|
|
@@ -140,10 +138,9 @@ function default_1(options) {
|
|
|
140
138
|
if (!clientBuildTarget) {
|
|
141
139
|
throw (0, project_targets_1.targetBuildNotFoundError)();
|
|
142
140
|
}
|
|
143
|
-
const
|
|
144
|
-
clientBuildTarget.builder === workspace_models_1.Builders.BuildApplication;
|
|
141
|
+
const usingApplicationBuilder = (0, project_targets_1.isUsingApplicationBuilder)(clientProject);
|
|
145
142
|
if (clientProject.targets.has('server') ||
|
|
146
|
-
(
|
|
143
|
+
(usingApplicationBuilder && clientBuildTarget.options?.server !== undefined)) {
|
|
147
144
|
// Server has already been added.
|
|
148
145
|
return;
|
|
149
146
|
}
|
|
@@ -151,12 +148,9 @@ function default_1(options) {
|
|
|
151
148
|
const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
|
|
152
149
|
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint);
|
|
153
150
|
const sourceRoot = clientProject.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src');
|
|
154
|
-
let filesUrl = `./files/${
|
|
151
|
+
let filesUrl = `./files/${usingApplicationBuilder ? 'application-builder/' : 'server-builder/'}`;
|
|
155
152
|
filesUrl += isStandalone ? 'standalone-src' : 'ngmodule-src';
|
|
156
153
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(filesUrl), [
|
|
157
|
-
options.serverRouting
|
|
158
|
-
? (0, schematics_1.noop)()
|
|
159
|
-
: (0, schematics_1.filter)((path) => !path.endsWith('app.routes.server.ts.template')),
|
|
160
154
|
(0, schematics_1.applyTemplates)({
|
|
161
155
|
...schematics_1.strings,
|
|
162
156
|
...options,
|
|
@@ -168,7 +162,7 @@ function default_1(options) {
|
|
|
168
162
|
const tsConfigDirectory = (0, core_1.dirname)(clientTsConfig);
|
|
169
163
|
return (0, schematics_1.chain)([
|
|
170
164
|
(0, schematics_1.mergeWith)(templateSource),
|
|
171
|
-
...(
|
|
165
|
+
...(usingApplicationBuilder
|
|
172
166
|
? [
|
|
173
167
|
updateConfigFileApplicationBuilder(options),
|
|
174
168
|
updateTsConfigFile(clientBuildOptions.tsConfig),
|
package/server/schema.d.ts
CHANGED
|
@@ -8,11 +8,6 @@ export type Schema = {
|
|
|
8
8
|
* The name of the project to enable server-side rendering for.
|
|
9
9
|
*/
|
|
10
10
|
project: string;
|
|
11
|
-
/**
|
|
12
|
-
* Configure the server application to use the Server Routing and App Engine APIs (Developer
|
|
13
|
-
* Preview).
|
|
14
|
-
*/
|
|
15
|
-
serverRouting?: boolean;
|
|
16
11
|
/**
|
|
17
12
|
* Skip the automatic installation of packages. You will need to manually install the
|
|
18
13
|
* dependencies later.
|
package/server/schema.json
CHANGED
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"description": "Skip the automatic installation of packages. You will need to manually install the dependencies later.",
|
|
18
18
|
"type": "boolean",
|
|
19
19
|
"default": false
|
|
20
|
-
},
|
|
21
|
-
"serverRouting": {
|
|
22
|
-
"description": "Configure the server application to use the Server Routing and App Engine APIs (Developer Preview).",
|
|
23
|
-
"type": "boolean"
|
|
24
20
|
}
|
|
25
21
|
},
|
|
26
22
|
"required": ["project"]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { <%= classify(name) %><%= classify(type) %> } from './<%= dasherize(name) %><%= type ? '.' + dasherize(type) : '' %>';
|
|
4
|
+
|
|
5
|
+
describe('<%= classify(name) %><%= classify(type) %>', () => {
|
|
6
|
+
let service: <%= classify(name) %><%= classify(type) %>;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(<%= classify(name) %><%= classify(type) %>);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
package/service/index.js
CHANGED
|
@@ -13,6 +13,8 @@ function default_1(options) {
|
|
|
13
13
|
// This schematic uses an older method to implement the flat option
|
|
14
14
|
const flat = options.flat;
|
|
15
15
|
options.flat = true;
|
|
16
|
+
// Schematic templates require a defined type value
|
|
17
|
+
options.type ??= '';
|
|
16
18
|
return (0, generate_from_files_1.generateFromFiles)(options, {
|
|
17
19
|
'if-flat': (s) => (flat ? '' : s),
|
|
18
20
|
});
|
package/service/schema.d.ts
CHANGED
|
@@ -28,4 +28,9 @@ export type Schema = {
|
|
|
28
28
|
* Skip the generation of a unit test file `spec.ts` for the service.
|
|
29
29
|
*/
|
|
30
30
|
skipTests?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Append a custom type to the service's filename. For example, if you set the type to
|
|
33
|
+
* `service`, the file will be named `my-service.service.ts`.
|
|
34
|
+
*/
|
|
35
|
+
type?: string;
|
|
31
36
|
};
|
package/service/schema.json
CHANGED
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"type": "boolean",
|
|
40
40
|
"description": "Skip the generation of a unit test file `spec.ts` for the service.",
|
|
41
41
|
"default": false
|
|
42
|
+
},
|
|
43
|
+
"type": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Append a custom type to the service's filename. For example, if you set the type to `service`, the file will be named `my-service.service.ts`."
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
"required": ["name", "project"]
|
package/ssr/index.d.ts
CHANGED
|
@@ -7,6 +7,4 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Rule } from '@angular-devkit/schematics';
|
|
9
9
|
import { Schema as SSROptions } from './schema';
|
|
10
|
-
export default function (
|
|
11
|
-
export type Prompt = (message: string, defaultValue: boolean) => Promise<boolean>;
|
|
12
|
-
export declare function setPrompterForTestOnly(prompter?: Prompt): void;
|
|
10
|
+
export default function (options: SSROptions): Rule;
|