@schematics/angular 18.0.0-next.5 → 18.0.0-rc.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.
@@ -232,9 +232,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
232
232
  },
233
233
  'extract-i18n': {
234
234
  builder: workspace_models_1.Builders.ExtractI18n,
235
- options: {
236
- buildTarget: `${options.name}:build`,
237
- },
238
235
  },
239
236
  test: options.minimal
240
237
  ? undefined
@@ -174,14 +174,77 @@ function updateProjects(tree, context) {
174
174
  // Add direct @angular/build dependencies and remove @angular-devkit/build-angular
175
175
  rules.push((0, dependency_1.addDependency)('@angular/build', latest_versions_1.latestVersions.DevkitBuildAngular, {
176
176
  type: dependency_1.DependencyType.Dev,
177
+ // Always is set here since removePackageJsonDependency below does not automatically
178
+ // trigger the package manager execution.
177
179
  install: dependency_1.InstallBehavior.Always,
178
180
  existing: dependency_1.ExistingBehavior.Replace,
179
181
  }));
180
182
  (0, dependencies_1.removePackageJsonDependency)(tree, '@angular-devkit/build-angular');
183
+ // Add less dependency if any projects contain a Less stylesheet file.
184
+ // This check does not consider Node.js packages due to the performance
185
+ // cost of searching such a large directory structure. A build time error
186
+ // will provide instructions to install the package in this case.
187
+ if (hasLessStylesheets(tree)) {
188
+ rules.push((0, dependency_1.addDependency)('less', latest_versions_1.latestVersions['less'], {
189
+ type: dependency_1.DependencyType.Dev,
190
+ existing: dependency_1.ExistingBehavior.Skip,
191
+ }));
192
+ }
193
+ // Add postcss dependency if any projects have a custom postcss configuration file.
194
+ // The build system only supports files in a project root or workspace root with
195
+ // names of either 'postcss.config.json' or '.postcssrc.json'.
196
+ if (hasPostcssConfiguration(tree, workspace)) {
197
+ rules.push((0, dependency_1.addDependency)('postcss', latest_versions_1.latestVersions['postcss'], {
198
+ type: dependency_1.DependencyType.Dev,
199
+ existing: dependency_1.ExistingBehavior.Replace,
200
+ }));
201
+ }
181
202
  }
182
203
  return (0, schematics_1.chain)(rules);
183
204
  });
184
205
  }
206
+ /**
207
+ * Searches the schematic tree for files that have a `.less` extension.
208
+ *
209
+ * @param tree A Schematics tree instance to search
210
+ * @returns true if Less stylesheet files are found; otherwise, false
211
+ */
212
+ function hasLessStylesheets(tree) {
213
+ const directories = [tree.getDir('/')];
214
+ let current;
215
+ while ((current = directories.pop())) {
216
+ for (const path of current.subfiles) {
217
+ if (path.endsWith('.less')) {
218
+ return true;
219
+ }
220
+ }
221
+ for (const path of current.subdirs) {
222
+ if (path === 'node_modules' || path.startsWith('.')) {
223
+ continue;
224
+ }
225
+ directories.push(current.dir(path));
226
+ }
227
+ }
228
+ }
229
+ /**
230
+ * Searches for a Postcss configuration file within the workspace root
231
+ * or any of the project roots.
232
+ *
233
+ * @param tree A Schematics tree instance to search
234
+ * @param workspace A Workspace to check for projects
235
+ * @returns true, if a Postcss configuration file is found; otherwise, false
236
+ */
237
+ function hasPostcssConfiguration(tree, workspace) {
238
+ // Add workspace root
239
+ const searchDirectories = [''];
240
+ // Add each project root
241
+ for (const { root } of workspace.projects.values()) {
242
+ if (root) {
243
+ searchDirectories.push(root);
244
+ }
245
+ }
246
+ return searchDirectories.some((dir) => tree.exists((0, posix_1.join)(dir, 'postcss.config.json')) || tree.exists((0, posix_1.join)(dir, '.postcssrc.json')));
247
+ }
185
248
  function* visit(directory) {
186
249
  for (const path of directory.subfiles) {
187
250
  const sass = path.endsWith('.scss');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "18.0.0-next.5",
3
+ "version": "18.0.0-rc.1",
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": "18.0.0-next.5",
26
- "@angular-devkit/schematics": "18.0.0-next.5",
25
+ "@angular-devkit/core": "18.0.0-rc.1",
26
+ "@angular-devkit/schematics": "18.0.0-rc.1",
27
27
  "jsonc-parser": "3.2.1"
28
28
  },
29
29
  "repository": {
@@ -16,7 +16,9 @@
16
16
  "karma-jasmine-html-reporter": "~2.1.0",
17
17
  "karma-jasmine": "~5.1.0",
18
18
  "karma": "~6.4.0",
19
+ "less": "^4.2.0",
19
20
  "ng-packagr": "^18.0.0-next.0",
21
+ "postcss": "^8.4.38",
20
22
  "protractor": "~7.0.0",
21
23
  "rxjs": "~7.8.0",
22
24
  "tslib": "^2.3.0",
@@ -15,6 +15,6 @@ 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
17
  Angular: dependencies['@angular/core'],
18
- DevkitBuildAngular: '^18.0.0-next.5',
19
- AngularSSR: '^18.0.0-next.5',
18
+ DevkitBuildAngular: '^18.0.0-rc.1',
19
+ AngularSSR: '^18.0.0-rc.1',
20
20
  };