@schematics/angular 17.0.0-rc.2 → 17.0.0-rc.3

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.
@@ -11,14 +11,12 @@ import { CommonModule } from '@angular/common';<% } %>
11
11
  </p>
12
12
  `<% } else { %>
13
13
  templateUrl: './<%= dasherize(name) %><%= type ? '.' + dasherize(type): '' %>.html'<% } if(inlineStyle) { %>,
14
- styles: [<% if(displayBlock){ %>
15
- `
16
- :host {
17
- display: block;
18
- }
19
- `<% } %>
20
- ]<% } else if (style !== 'none') { %>,
21
- styleUrls: ['./<%= dasherize(name) %><%= type ? '.' + dasherize(type): '' %>.<%= style %>']<% } %><% if(!!viewEncapsulation) { %>,
14
+ styles: `<% if(displayBlock){ %>
15
+ :host {
16
+ display: block;
17
+ }
18
+ <% } %>`<% } else if (style !== 'none') { %>,
19
+ styleUrl: './<%= dasherize(name) %><%= type ? '.' + dasherize(type): '' %>.<%= style %>'<% } %><% if(!!viewEncapsulation) { %>,
22
20
  encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
23
21
  changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
24
22
  })
@@ -7,6 +7,7 @@
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");
10
11
  const schematics_1 = require("@angular-devkit/schematics");
11
12
  const utility_1 = require("../../utility");
12
13
  const dependencies_1 = require("../../utility/dependencies");
@@ -69,17 +70,34 @@ function default_1() {
69
70
  }
70
71
  }
71
72
  }
72
- // Replace server file
73
+ // Replace all import specifiers in all files.
74
+ let hasExpressTokens = false;
75
+ const root = project.sourceRoot ?? `${project.root}/src`;
76
+ const tokensFilePath = `/${root}/express.tokens.ts`;
77
+ for (const file of visit(tree.getDir(root))) {
78
+ const [path, content] = file;
79
+ let updatedContent = content;
80
+ // Check if file is importing tokens
81
+ if (content.includes('@nguniversal/express-engine/tokens')) {
82
+ hasExpressTokens ||= true;
83
+ let tokensFileRelativePath = (0, core_1.relative)((0, core_1.dirname)((0, core_1.normalize)(path)), (0, core_1.normalize)(tokensFilePath));
84
+ if (tokensFileRelativePath.charAt(0) !== '.') {
85
+ tokensFileRelativePath = './' + tokensFileRelativePath;
86
+ }
87
+ updatedContent = updatedContent.replaceAll('@nguniversal/express-engine/tokens', tokensFileRelativePath.slice(0, -3));
88
+ }
89
+ updatedContent = updatedContent.replaceAll(NGUNIVERSAL_PACKAGE_REGEXP, '@angular/ssr');
90
+ tree.overwrite(path, updatedContent);
91
+ }
92
+ // Replace server file and add tokens file if needed
73
93
  for (const [path, outputPath] of serverMainFiles.entries()) {
74
94
  tree.rename(path, path + '.bak');
75
- tree.create(path, getServerFileContents(outputPath));
95
+ tree.create(path, getServerFileContents(outputPath, hasExpressTokens));
96
+ if (hasExpressTokens) {
97
+ tree.create(tokensFilePath, TOKENS_FILE_CONTENT);
98
+ }
76
99
  }
77
100
  }
78
- // Replace all import specifiers in all files.
79
- for (const file of visit(tree.root)) {
80
- const [path, content] = file;
81
- tree.overwrite(path, content.replaceAll(NGUNIVERSAL_PACKAGE_REGEXP, '@angular/ssr'));
82
- }
83
101
  // Remove universal packages from deps.
84
102
  for (const name of UNIVERSAL_PACKAGES) {
85
103
  (0, dependencies_1.removePackageJsonDependency)(tree, name);
@@ -90,8 +108,15 @@ function default_1() {
90
108
  };
91
109
  }
92
110
  exports.default = default_1;
93
- function getServerFileContents(outputPath) {
94
- return `
111
+ const TOKENS_FILE_CONTENT = `
112
+ import { InjectionToken } from '@angular/core';
113
+ import { Request, Response } from 'express';
114
+
115
+ export const REQUEST = new InjectionToken<Request>('REQUEST');
116
+ export const RESPONSE = new InjectionToken<Response>('RESPONSE');
117
+ `;
118
+ function getServerFileContents(outputPath, hasExpressTokens) {
119
+ return (`
95
120
  import 'zone.js/node';
96
121
 
97
122
  import { APP_BASE_HREF } from '@angular/common';
@@ -99,7 +124,9 @@ import { CommonEngine } from '@angular/ssr';
99
124
  import * as express from 'express';
100
125
  import { existsSync } from 'node:fs';
101
126
  import { join } from 'node:path';
102
- import bootstrap from './src/main.server';
127
+ import bootstrap from './src/main.server';` +
128
+ (hasExpressTokens ? `\nimport { REQUEST, RESPONSE } from './src/express.tokens';` : '') +
129
+ `
103
130
 
104
131
  // The Express app is exported so that it can be used by serverless Functions.
105
132
  export function app(): express.Express {
@@ -131,7 +158,12 @@ export function app(): express.Express {
131
158
  documentFilePath: indexHtml,
132
159
  url: \`\${protocol}://\${headers.host}\${originalUrl}\`,
133
160
  publicPath: distFolder,
134
- providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
161
+ providers: [
162
+ { provide: APP_BASE_HREF, useValue: baseUrl },` +
163
+ (hasExpressTokens
164
+ ? '\n { provide: RESPONSE, useValue: res },\n { provide: REQUEST, useValue: req }\n'
165
+ : '') +
166
+ `],
135
167
  })
136
168
  .then((html) => res.send(html))
137
169
  .catch((err) => next(err));
@@ -161,5 +193,5 @@ if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
161
193
  }
162
194
 
163
195
  export default bootstrap;
164
- `;
196
+ `);
165
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "17.0.0-rc.2",
3
+ "version": "17.0.0-rc.3",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "17.0.0-rc.2",
27
- "@angular-devkit/schematics": "17.0.0-rc.2",
26
+ "@angular-devkit/core": "17.0.0-rc.3",
27
+ "@angular-devkit/schematics": "17.0.0-rc.3",
28
28
  "jsonc-parser": "3.2.0"
29
29
  },
30
30
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "url": "https://github.com/angular/angular-cli.git"
33
33
  },
34
34
  "engines": {
35
- "node": ">=18.13.0",
35
+ "node": "^18.13.0 || >=20.9.0",
36
36
  "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
37
37
  "yarn": ">= 1.13.0"
38
38
  },
@@ -14,6 +14,6 @@ exports.latestVersions = {
14
14
  ...require('./latest-versions/package.json')['dependencies'],
15
15
  // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
16
16
  Angular: '^17.0.0-next.0',
17
- DevkitBuildAngular: '^17.0.0-rc.2',
18
- AngularSSR: '^17.0.0-rc.2',
17
+ DevkitBuildAngular: '^17.0.0-rc.3',
18
+ AngularSSR: '^17.0.0-rc.3',
19
19
  };
@@ -9,7 +9,7 @@
9
9
  "noPropertyAccessFromIndexSignature": true,
10
10
  "noImplicitReturns": true,
11
11
  "noFallthroughCasesInSwitch": true,<% } %>
12
- "allowSyntheticDefaultImports": true,
12
+ "esModuleInterop": true,
13
13
  "sourceMap": true,
14
14
  "declaration": false,
15
15
  "downlevelIteration": true,