@schematics/angular 19.1.5 → 19.2.0-next.0
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 +58 -37
- package/library/index.js +4 -4
- package/package.json +3 -3
- package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +2 -2
- package/server/files/application-builder/standalone-src/app/app.config.server.ts.template +2 -2
- package/utility/latest-versions/package.json +0 -2
- package/utility/latest-versions.d.ts +1 -0
- package/utility/latest-versions.js +5 -4
package/app-shell/index.js
CHANGED
|
@@ -106,6 +106,17 @@ function validateProject(mainPath) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
+
function addRouterModule(mainPath) {
|
|
110
|
+
return (host) => {
|
|
111
|
+
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
|
|
112
|
+
const moduleSource = getSourceFile(host, modulePath);
|
|
113
|
+
const changes = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, 'RouterModule', '@angular/router');
|
|
114
|
+
const recorder = host.beginUpdate(modulePath);
|
|
115
|
+
(0, change_1.applyToUpdateRecorder)(recorder, changes);
|
|
116
|
+
host.commitUpdate(recorder);
|
|
117
|
+
return host;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
109
120
|
function getMetadataProperty(metadata, propertyName) {
|
|
110
121
|
const properties = metadata.properties;
|
|
111
122
|
const property = properties.filter(typescript_1.default.isPropertyAssignment).filter((prop) => {
|
|
@@ -191,7 +202,7 @@ function addStandaloneServerRoute(options) {
|
|
|
191
202
|
if (!host.exists(configFilePath)) {
|
|
192
203
|
throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
|
|
193
204
|
}
|
|
194
|
-
|
|
205
|
+
let recorder = host.beginUpdate(configFilePath);
|
|
195
206
|
let configSourceFile = getSourceFile(host, configFilePath);
|
|
196
207
|
if (!(0, ast_utils_1.isImported)(configSourceFile, 'ROUTES', '@angular/router')) {
|
|
197
208
|
const routesChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'ROUTES', '@angular/router');
|
|
@@ -209,48 +220,62 @@ function addStandaloneServerRoute(options) {
|
|
|
209
220
|
const updatedProvidersString = [
|
|
210
221
|
...providersLiteral.elements.map((element) => ' ' + element.getText()),
|
|
211
222
|
` {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
223
|
+
provide: ROUTES,
|
|
224
|
+
multi: true,
|
|
225
|
+
useValue: [{
|
|
226
|
+
path: '${APP_SHELL_ROUTE}',
|
|
227
|
+
component: AppShellComponent
|
|
228
|
+
}]
|
|
229
|
+
}\n `,
|
|
219
230
|
];
|
|
220
231
|
recorder.insertRight(providersLiteral.getStart(), `[\n${updatedProvidersString.join(',\n')}]`);
|
|
221
|
-
(
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
if (options.serverRouting) {
|
|
233
|
+
host.commitUpdate(recorder);
|
|
234
|
+
configSourceFile = getSourceFile(host, configFilePath);
|
|
235
|
+
const functionCall = (0, ast_utils_1.findNodes)(configSourceFile, typescript_1.default.isCallExpression).find((n) => typescript_1.default.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRoutesConfig');
|
|
236
|
+
if (!functionCall) {
|
|
237
|
+
throw new schematics_1.SchematicsException(`Cannot find the "provideServerRoutesConfig" function call in "${configFilePath}".`);
|
|
238
|
+
}
|
|
239
|
+
recorder = host.beginUpdate(configFilePath);
|
|
240
|
+
recorder.insertLeft(functionCall.end - 1, `, { appShellRoute: '${APP_SHELL_ROUTE}' }`);
|
|
241
|
+
}
|
|
242
|
+
// Add AppShellComponent import
|
|
243
|
+
const appShellImportChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'AppShellComponent', './app-shell/app-shell.component');
|
|
244
|
+
(0, change_1.applyToUpdateRecorder)(recorder, [appShellImportChange]);
|
|
224
245
|
host.commitUpdate(recorder);
|
|
225
246
|
};
|
|
226
247
|
}
|
|
227
|
-
function addServerRoutingConfig(options
|
|
248
|
+
function addServerRoutingConfig(options) {
|
|
228
249
|
return async (host) => {
|
|
229
250
|
const workspace = await (0, workspace_1.getWorkspace)(host);
|
|
230
251
|
const project = workspace.projects.get(options.project);
|
|
231
252
|
if (!project) {
|
|
232
253
|
throw new schematics_1.SchematicsException(`Project name "${options.project}" doesn't not exist.`);
|
|
233
254
|
}
|
|
234
|
-
const configFilePath =
|
|
235
|
-
|
|
236
|
-
: getServerModulePath(host, project.sourceRoot || 'src', 'main.server.ts');
|
|
237
|
-
if (!configFilePath || !host.exists(configFilePath)) {
|
|
255
|
+
const configFilePath = (0, posix_1.join)(project.sourceRoot ?? 'src', 'app/app.routes.server.ts');
|
|
256
|
+
if (!host.exists(configFilePath)) {
|
|
238
257
|
throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
|
|
239
258
|
}
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
259
|
+
const sourceFile = getSourceFile(host, configFilePath);
|
|
260
|
+
const nodes = (0, ast_utils_1.getSourceNodes)(sourceFile);
|
|
261
|
+
// Find the serverRoutes variable declaration
|
|
262
|
+
const serverRoutesNode = nodes.find((node) => typescript_1.default.isVariableDeclaration(node) &&
|
|
263
|
+
node.initializer &&
|
|
264
|
+
typescript_1.default.isArrayLiteralExpression(node.initializer) &&
|
|
265
|
+
node.type &&
|
|
266
|
+
typescript_1.default.isArrayTypeNode(node.type) &&
|
|
267
|
+
node.type.getText().includes('ServerRoute'));
|
|
268
|
+
if (!serverRoutesNode) {
|
|
269
|
+
throw new schematics_1.SchematicsException(`Cannot find the "ServerRoute" configuration in "${configFilePath}".`);
|
|
247
270
|
}
|
|
248
|
-
recorder = host.beginUpdate(configFilePath);
|
|
249
|
-
|
|
250
|
-
(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
271
|
+
const recorder = host.beginUpdate(configFilePath);
|
|
272
|
+
const arrayLiteral = serverRoutesNode.initializer;
|
|
273
|
+
const firstElementPosition = arrayLiteral.elements[0]?.getStart() ?? arrayLiteral.getStart() + 1;
|
|
274
|
+
const newRouteString = `{
|
|
275
|
+
path: '${APP_SHELL_ROUTE}',
|
|
276
|
+
renderMode: RenderMode.AppShell
|
|
277
|
+
},\n`;
|
|
278
|
+
recorder.insertLeft(firstElementPosition, newRouteString);
|
|
254
279
|
host.commitUpdate(recorder);
|
|
255
280
|
};
|
|
256
281
|
}
|
|
@@ -261,14 +286,10 @@ function default_1(options) {
|
|
|
261
286
|
return (0, schematics_1.chain)([
|
|
262
287
|
validateProject(browserEntryPoint),
|
|
263
288
|
(0, schematics_1.schematic)('server', options),
|
|
264
|
-
...(
|
|
265
|
-
? [(
|
|
266
|
-
:
|
|
267
|
-
|
|
268
|
-
: [addServerRoutes(options)]),
|
|
269
|
-
options.serverRouting
|
|
270
|
-
? addServerRoutingConfig(options, isStandalone)
|
|
271
|
-
: addAppShellConfigToWorkspace(options),
|
|
289
|
+
...(isStandalone
|
|
290
|
+
? [addStandaloneServerRoute(options)]
|
|
291
|
+
: [addRouterModule(browserEntryPoint), addServerRoutes(options)]),
|
|
292
|
+
options.serverRouting ? (0, schematics_1.noop)() : addAppShellConfigToWorkspace(options),
|
|
272
293
|
(0, schematics_1.schematic)('component', {
|
|
273
294
|
name: 'app-shell',
|
|
274
295
|
module: 'app.module.server.ts',
|
package/library/index.js
CHANGED
|
@@ -38,13 +38,13 @@ function addDependenciesToPackageJson() {
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
type: dependencies_1.NodeDependencyType.Dev,
|
|
41
|
-
name: '@angular
|
|
42
|
-
version: latest_versions_1.latestVersions.
|
|
41
|
+
name: '@angular/build',
|
|
42
|
+
version: latest_versions_1.latestVersions.AngularBuild,
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
type: dependencies_1.NodeDependencyType.Dev,
|
|
46
46
|
name: 'ng-packagr',
|
|
47
|
-
version: latest_versions_1.latestVersions
|
|
47
|
+
version: latest_versions_1.latestVersions.NgPackagr,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
type: dependencies_1.NodeDependencyType.Default,
|
|
@@ -70,7 +70,7 @@ function addLibToWorkspaceFile(options, projectRoot, projectName) {
|
|
|
70
70
|
prefix: options.prefix,
|
|
71
71
|
targets: {
|
|
72
72
|
build: {
|
|
73
|
-
builder: workspace_models_1.Builders.
|
|
73
|
+
builder: workspace_models_1.Builders.BuildNgPackagr,
|
|
74
74
|
defaultConfiguration: 'production',
|
|
75
75
|
options: {
|
|
76
76
|
project: `${projectRoot}/ng-package.json`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.2.0-next.0",
|
|
4
4
|
"description": "Schematics specific to Angular",
|
|
5
5
|
"homepage": "https://github.com/angular/angular-cli",
|
|
6
6
|
"keywords": [
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"schematics": "./collection.json",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@angular-devkit/core": "19.
|
|
26
|
-
"@angular-devkit/schematics": "19.
|
|
25
|
+
"@angular-devkit/core": "19.2.0-next.0",
|
|
26
|
+
"@angular-devkit/schematics": "19.2.0-next.0",
|
|
27
27
|
"jsonc-parser": "3.3.1"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
2
|
import { ServerModule } from '@angular/platform-server';<% if(serverRouting) { %>
|
|
3
|
-
import {
|
|
3
|
+
import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
|
|
4
4
|
import { AppComponent } from './app.component';
|
|
5
5
|
import { AppModule } from './app.module';<% if(serverRouting) { %>
|
|
6
6
|
import { serverRoutes } from './app.routes.server';<% } %>
|
|
7
7
|
|
|
8
8
|
@NgModule({
|
|
9
9
|
imports: [AppModule, ServerModule],<% if(serverRouting) { %>
|
|
10
|
-
providers: [
|
|
10
|
+
providers: [provideServerRoutesConfig(serverRoutes)],<% } %>
|
|
11
11
|
bootstrap: [AppComponent],
|
|
12
12
|
})
|
|
13
13
|
export class AppServerModule {}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
|
2
2
|
import { provideServerRendering } from '@angular/platform-server';<% if(serverRouting) { %>
|
|
3
|
-
import {
|
|
3
|
+
import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
|
|
4
4
|
import { appConfig } from './app.config';<% if(serverRouting) { %>
|
|
5
5
|
import { serverRoutes } from './app.routes.server';<% } %>
|
|
6
6
|
|
|
7
7
|
const serverConfig: ApplicationConfig = {
|
|
8
8
|
providers: [
|
|
9
9
|
provideServerRendering(),<% if(serverRouting) { %>
|
|
10
|
-
|
|
10
|
+
provideServerRoutesConfig(serverRoutes)<% } %>
|
|
11
11
|
]
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"comment": "This file is needed so that dependencies are synced by Renovate.",
|
|
4
4
|
"private": true,
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@angular/core": "^19.1.0",
|
|
7
6
|
"@types/express": "^4.17.17",
|
|
8
7
|
"@types/jasmine": "~5.1.0",
|
|
9
8
|
"@types/node": "^18.18.0",
|
|
@@ -17,7 +16,6 @@
|
|
|
17
16
|
"karma-jasmine": "~5.1.0",
|
|
18
17
|
"karma": "~6.4.0",
|
|
19
18
|
"less": "^4.2.0",
|
|
20
|
-
"ng-packagr": "^19.1.0",
|
|
21
19
|
"postcss": "^8.4.38",
|
|
22
20
|
"protractor": "~7.0.0",
|
|
23
21
|
"rxjs": "~7.8.0",
|
|
@@ -14,8 +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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
Angular: '^19.2.0-next.0',
|
|
18
|
+
NgPackagr: '^19.1.0-next.0',
|
|
19
|
+
DevkitBuildAngular: '^19.2.0-next.0',
|
|
20
|
+
AngularBuild: '^19.2.0-next.0',
|
|
21
|
+
AngularSSR: '^19.2.0-next.0',
|
|
21
22
|
};
|