@schematics/angular 20.0.1 → 20.0.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.
@@ -31,10 +31,10 @@ function addTsProjectReference(...paths) {
31
31
  };
32
32
  }
33
33
  function default_1(options) {
34
- return async (host, context) => {
34
+ return async (host) => {
35
35
  const { appDir, appRootSelector, componentOptions, folderName, sourceDir } = await getAppOptions(host, options);
36
36
  return (0, schematics_1.chain)([
37
- addAppToWorkspaceFile(options, appDir, folderName),
37
+ addAppToWorkspaceFile(options, appDir),
38
38
  addTsProjectReference('./' + (0, core_1.join)((0, core_1.normalize)(appDir), 'tsconfig.app.json')),
39
39
  options.skipTests || options.minimal
40
40
  ? (0, schematics_1.noop)()
@@ -128,13 +128,20 @@ function addDependenciesToPackageJson(options) {
128
128
  version: latest_versions_1.latestVersions['zone.js'],
129
129
  });
130
130
  }
131
+ if (options.style === schema_1.Style.Less) {
132
+ (0, dependencies_1.addPackageJsonDependency)(host, {
133
+ type: dependencies_1.NodeDependencyType.Dev,
134
+ name: 'less',
135
+ version: latest_versions_1.latestVersions['less'],
136
+ });
137
+ }
131
138
  if (!options.skipInstall) {
132
139
  context.addTask(new tasks_1.NodePackageInstallTask());
133
140
  }
134
141
  return host;
135
142
  };
136
143
  }
137
- function addAppToWorkspaceFile(options, appDir, folderName) {
144
+ function addAppToWorkspaceFile(options, appDir) {
138
145
  let projectRoot = appDir;
139
146
  if (projectRoot) {
140
147
  projectRoot += '/';
@@ -35,16 +35,7 @@ function default_1(options) {
35
35
  if (options.path === undefined) {
36
36
  options.path = (0, workspace_1.buildDefaultPath)(project);
37
37
  }
38
- try {
39
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
40
- }
41
- catch {
42
- options.module = (0, find_module_1.findModuleFromOptions)(host, {
43
- ...options,
44
- moduleExt: '-module.ts',
45
- routingModuleExt: '-routing-module.ts',
46
- });
47
- }
38
+ options.module = (0, find_module_1.findModuleFromOptions)(host, options);
48
39
  // Schematic templates require a defined type value
49
40
  options.type ??= '';
50
41
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
@@ -35,16 +35,7 @@ function default_1(options) {
35
35
  if (options.path === undefined) {
36
36
  options.path = (0, workspace_1.buildDefaultPath)(project);
37
37
  }
38
- try {
39
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
40
- }
41
- catch {
42
- options.module = (0, find_module_1.findModuleFromOptions)(host, {
43
- ...options,
44
- moduleExt: '-module.ts',
45
- routingModuleExt: '-routing-module.ts',
46
- });
47
- }
38
+ options.module = (0, find_module_1.findModuleFromOptions)(host, options);
48
39
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
49
40
  options.name = parsedPath.name;
50
41
  options.path = parsedPath.path;
package/module/index.js CHANGED
@@ -99,11 +99,11 @@ function addRouteDeclarationToNgModule(options, routingModulePath) {
99
99
  };
100
100
  }
101
101
  function getRoutingModulePath(host, modulePath) {
102
- const routingModulePath = modulePath.endsWith(find_module_1.ROUTING_MODULE_EXT) || modulePath.endsWith('-routing-module.ts')
102
+ const routingModulePath = modulePath.endsWith(find_module_1.ROUTING_MODULE_EXT_LEGACY) || modulePath.endsWith(find_module_1.ROUTING_MODULE_EXT)
103
103
  ? modulePath
104
104
  : modulePath
105
- .replace(find_module_1.MODULE_EXT, find_module_1.ROUTING_MODULE_EXT)
106
- .replace('-module.ts', '-routing-module.ts');
105
+ .replace(find_module_1.MODULE_EXT_LEGACY, find_module_1.ROUTING_MODULE_EXT_LEGACY)
106
+ .replace(find_module_1.MODULE_EXT, find_module_1.ROUTING_MODULE_EXT);
107
107
  return host.exists(routingModulePath) ? routingModulePath : undefined;
108
108
  }
109
109
  function buildRoute(options, modulePath) {
@@ -118,16 +118,7 @@ function default_1(options) {
118
118
  options.path = await (0, workspace_1.createDefaultPath)(host, options.project);
119
119
  }
120
120
  if (options.module) {
121
- try {
122
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
123
- }
124
- catch {
125
- options.module = (0, find_module_1.findModuleFromOptions)(host, {
126
- ...options,
127
- moduleExt: '-module.ts',
128
- routingModuleExt: '-routing-module.ts',
129
- });
130
- }
121
+ options.module = (0, find_module_1.findModuleFromOptions)(host, options);
131
122
  }
132
123
  let routingModulePath;
133
124
  const isLazyLoadedModuleGen = !!(options.route && options.module);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "20.0.1",
3
+ "version": "20.0.2",
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": "20.0.1",
26
- "@angular-devkit/schematics": "20.0.1",
25
+ "@angular-devkit/core": "20.0.2",
26
+ "@angular-devkit/schematics": "20.0.2",
27
27
  "jsonc-parser": "3.3.1"
28
28
  },
29
29
  "repository": {
package/pipe/index.js CHANGED
@@ -18,16 +18,7 @@ const workspace_1 = require("../utility/workspace");
18
18
  function default_1(options) {
19
19
  return async (host) => {
20
20
  options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project);
21
- try {
22
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
23
- }
24
- catch {
25
- options.module = (0, find_module_1.findModuleFromOptions)(host, {
26
- ...options,
27
- moduleExt: '-module.ts',
28
- routingModuleExt: '-routing-module.ts',
29
- });
30
- }
21
+ options.module = (0, find_module_1.findModuleFromOptions)(host, options);
31
22
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
32
23
  options.name = parsedPath.name;
33
24
  options.path = parsedPath.path;
@@ -17,8 +17,10 @@ export interface ModuleOptions {
17
17
  routingModuleExt?: string;
18
18
  standalone?: boolean;
19
19
  }
20
- export declare const MODULE_EXT = ".module.ts";
21
- export declare const ROUTING_MODULE_EXT = "-routing.module.ts";
20
+ export declare const MODULE_EXT = "-module.ts";
21
+ export declare const ROUTING_MODULE_EXT = "-routing-module.ts";
22
+ export declare const MODULE_EXT_LEGACY = ".module.ts";
23
+ export declare const ROUTING_MODULE_EXT_LEGACY = "-routing.module.ts";
22
24
  /**
23
25
  * Find the module referred by a set of options passed to the schematics.
24
26
  */
@@ -7,13 +7,15 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ROUTING_MODULE_EXT = exports.MODULE_EXT = void 0;
10
+ exports.ROUTING_MODULE_EXT_LEGACY = exports.MODULE_EXT_LEGACY = exports.ROUTING_MODULE_EXT = exports.MODULE_EXT = void 0;
11
11
  exports.findModuleFromOptions = findModuleFromOptions;
12
12
  exports.findModule = findModule;
13
13
  exports.buildRelativePath = buildRelativePath;
14
14
  const core_1 = require("@angular-devkit/core");
15
- exports.MODULE_EXT = '.module.ts';
16
- exports.ROUTING_MODULE_EXT = '-routing.module.ts';
15
+ exports.MODULE_EXT = '-module.ts';
16
+ exports.ROUTING_MODULE_EXT = '-routing-module.ts';
17
+ exports.MODULE_EXT_LEGACY = '.module.ts';
18
+ exports.ROUTING_MODULE_EXT_LEGACY = '-routing.module.ts';
17
19
  /**
18
20
  * Find the module referred by a set of options passed to the schematics.
19
21
  */
@@ -21,11 +23,9 @@ function findModuleFromOptions(host, options) {
21
23
  if (options.standalone || options.skipImport) {
22
24
  return undefined;
23
25
  }
24
- const moduleExt = options.moduleExt || exports.MODULE_EXT;
25
- const routingModuleExt = options.routingModuleExt || exports.ROUTING_MODULE_EXT;
26
26
  if (!options.module) {
27
27
  const pathToCheck = (options.path || '') + '/' + options.name;
28
- return (0, core_1.normalize)(findModule(host, pathToCheck, moduleExt, routingModuleExt));
28
+ return (0, core_1.normalize)(findModule(host, pathToCheck, options.moduleExt, options.routingModuleExt));
29
29
  }
30
30
  else {
31
31
  const modulePath = (0, core_1.normalize)(`/${options.path}/${options.module}`);
@@ -39,11 +39,18 @@ function findModuleFromOptions(host, options) {
39
39
  candidateSet.add(dir);
40
40
  }
41
41
  const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
42
+ const candidateFiles = ['', `${moduleBaseName}.ts`];
43
+ if (options.moduleExt) {
44
+ candidateFiles.push(`${moduleBaseName}${options.moduleExt}`);
45
+ }
46
+ else {
47
+ candidateFiles.push(`${moduleBaseName}${exports.MODULE_EXT}`, `${moduleBaseName}${exports.MODULE_EXT_LEGACY}`);
48
+ }
42
49
  for (const c of candidatesDirs) {
43
- const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map((x) => (0, core_1.join)(c, x));
44
50
  for (const sc of candidateFiles) {
45
- if (host.exists(sc) && host.readText(sc).includes('@NgModule')) {
46
- return (0, core_1.normalize)(sc);
51
+ const scPath = (0, core_1.join)(c, sc);
52
+ if (host.exists(scPath) && host.readText(scPath).includes('@NgModule')) {
53
+ return (0, core_1.normalize)(scPath);
47
54
  }
48
55
  }
49
56
  }
@@ -54,12 +61,16 @@ function findModuleFromOptions(host, options) {
54
61
  /**
55
62
  * Function to find the "closest" module to a generated file's path.
56
63
  */
57
- function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingModuleExt = exports.ROUTING_MODULE_EXT) {
64
+ function findModule(host, generateDir, moduleExt, routingModuleExt) {
58
65
  let dir = host.getDir('/' + generateDir);
59
66
  let foundRoutingModule = false;
67
+ const moduleExtensions = moduleExt ? [moduleExt] : [exports.MODULE_EXT, exports.MODULE_EXT_LEGACY];
68
+ const routingModuleExtensions = routingModuleExt
69
+ ? [routingModuleExt]
70
+ : [exports.ROUTING_MODULE_EXT, exports.ROUTING_MODULE_EXT_LEGACY];
60
71
  while (dir) {
61
- const allMatches = dir.subfiles.filter((p) => p.endsWith(moduleExt));
62
- const filteredMatches = allMatches.filter((p) => !p.endsWith(routingModuleExt));
72
+ const allMatches = dir.subfiles.filter((p) => moduleExtensions.some((m) => p.endsWith(m)));
73
+ const filteredMatches = allMatches.filter((p) => !routingModuleExtensions.some((m) => p.endsWith(m)));
63
74
  foundRoutingModule = foundRoutingModule || allMatches.length !== filteredMatches.length;
64
75
  if (filteredMatches.length == 1) {
65
76
  return (0, core_1.join)(dir.path, filteredMatches[0]);
@@ -16,7 +16,7 @@ exports.latestVersions = {
16
16
  // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
17
17
  Angular: '^20.0.0',
18
18
  NgPackagr: '^20.0.0',
19
- DevkitBuildAngular: '^20.0.1',
20
- AngularBuild: '^20.0.1',
21
- AngularSSR: '^20.0.1',
19
+ DevkitBuildAngular: '^20.0.2',
20
+ AngularBuild: '^20.0.2',
21
+ AngularSSR: '^20.0.2',
22
22
  };