@schematics/angular 20.0.0-next.3 → 20.0.0-next.5

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.
Files changed (84) hide show
  1. package/application/files/module-files/src/app/{app.module.ts.template → app-module.ts.template} +1 -1
  2. package/application/files/module-files/src/app/app.ts.template +1 -1
  3. package/application/files/module-files/src/main.ts.template +1 -1
  4. package/application/files/standalone-files/src/app/app.ts.template +1 -1
  5. package/application/index.js +1 -1
  6. package/class/index.js +0 -1
  7. package/component/index.js +10 -1
  8. package/component/schema.d.ts +0 -1
  9. package/component/schema.json +2 -2
  10. package/directive/index.js +10 -3
  11. package/enum/index.d.ts +2 -2
  12. package/enum/index.js +0 -1
  13. package/guard/implements-files/{__name@dasherize__.guard.spec.ts.template → __name@dasherize____typeSeparator__guard.spec.ts.template} +1 -1
  14. package/guard/schema.d.ts +13 -0
  15. package/guard/schema.js +10 -1
  16. package/guard/schema.json +6 -0
  17. package/guard/type-files/{__name@dasherize__.guard.spec.ts.template → __name@dasherize____typeSeparator__guard.spec.ts.template} +1 -1
  18. package/interceptor/class-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.spec.ts.template → __name@dasherize____typeSeparator__interceptor.spec.ts.template} +1 -1
  19. package/interceptor/functional-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.spec.ts.template → __name@dasherize____typeSeparator__interceptor.spec.ts.template} +1 -1
  20. package/interceptor/index.d.ts +2 -2
  21. package/interceptor/index.js +2 -9
  22. package/interceptor/schema.d.ts +13 -0
  23. package/interceptor/schema.js +10 -0
  24. package/interceptor/schema.json +6 -0
  25. package/interface/index.js +0 -1
  26. package/library/files/src/__entryFile__.ts.template +1 -1
  27. package/library/index.js +4 -3
  28. package/migrations/migration-collection.json +10 -0
  29. package/migrations/previous-style-guide/migration.d.ts +9 -0
  30. package/migrations/previous-style-guide/migration.js +42 -0
  31. package/migrations/update-module-resolution/migration.d.ts +9 -0
  32. package/migrations/update-module-resolution/migration.js +52 -0
  33. package/migrations/use-application-builder/migration.js +0 -1
  34. package/module/files/__name@dasherize@if-flat__/{__name@dasherize__.module.ts.template → __name@dasherize____typeSeparator__module.ts.template} +1 -1
  35. package/module/index.js +17 -6
  36. package/module/schema.d.ts +13 -0
  37. package/module/schema.js +10 -1
  38. package/module/schema.json +6 -0
  39. package/package.json +3 -3
  40. package/pipe/files/{__name@dasherize@if-flat__/__name@dasherize__.pipe.spec.ts.template → __name@dasherize____typeSeparator__pipe.spec.ts.template} +1 -1
  41. package/pipe/index.js +12 -11
  42. package/pipe/schema.d.ts +13 -0
  43. package/pipe/schema.js +10 -0
  44. package/pipe/schema.json +6 -0
  45. package/resolver/class-files/{__name@dasherize__.resolver.spec.ts.template → __name@dasherize____typeSeparator__resolver.spec.ts.template} +1 -1
  46. package/resolver/functional-files/{__name@dasherize__.resolver.spec.ts.template → __name@dasherize____typeSeparator__resolver.spec.ts.template} +1 -1
  47. package/resolver/index.d.ts +3 -3
  48. package/resolver/index.js +2 -3
  49. package/resolver/schema.d.ts +13 -0
  50. package/resolver/schema.js +10 -0
  51. package/resolver/schema.json +6 -0
  52. package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +4 -4
  53. package/server/files/application-builder/standalone-src/main.server.ts.template +2 -2
  54. package/server/files/server-builder/ngmodule-src/app/app.module.server.ts.template +4 -4
  55. package/server/files/server-builder/standalone-src/main.server.ts.template +2 -2
  56. package/server/index.js +13 -0
  57. package/service/index.js +1 -8
  58. package/ssr/files/application-builder/server.ts.template +7 -3
  59. package/ssr/files/server-builder/server.ts.template +10 -5
  60. package/ssr/index.js +2 -0
  61. package/utility/add-declaration-to-ng-module.d.ts +1 -0
  62. package/utility/add-declaration-to-ng-module.js +3 -3
  63. package/utility/ast-utils.d.ts +1 -1
  64. package/utility/ast-utils.js +1 -4
  65. package/utility/generate-from-files.js +12 -8
  66. package/utility/latest-versions/package.json +2 -2
  67. package/utility/latest-versions.js +3 -3
  68. package/utility/standalone/app_component.d.ts +29 -0
  69. package/utility/standalone/app_component.js +109 -0
  70. /package/application/files/common-files/src/app/{app.ng.html.template → app.html.template} +0 -0
  71. /package/class/files/{__name@dasherize____type__.spec.ts.template → __name@dasherize__.__type__.spec.ts.template} +0 -0
  72. /package/class/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
  73. /package/enum/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
  74. /package/guard/implements-files/{__name@dasherize__.guard.ts.template → __name@dasherize____typeSeparator__guard.ts.template} +0 -0
  75. /package/guard/type-files/{__name@dasherize__.guard.ts.template → __name@dasherize____typeSeparator__guard.ts.template} +0 -0
  76. /package/interceptor/class-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.ts.template → __name@dasherize____typeSeparator__interceptor.ts.template} +0 -0
  77. /package/interceptor/functional-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.ts.template → __name@dasherize____typeSeparator__interceptor.ts.template} +0 -0
  78. /package/interface/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
  79. /package/module/files/__name@dasherize@if-flat__/{__name@dasherize__-routing.module.ts.template → __name@dasherize__-routing__typeSeparator__module.ts.template} +0 -0
  80. /package/pipe/files/{__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template → __name@dasherize____typeSeparator__pipe.ts.template} +0 -0
  81. /package/resolver/class-files/{__name@dasherize__.resolver.ts.template → __name@dasherize____typeSeparator__resolver.ts.template} +0 -0
  82. /package/resolver/functional-files/{__name@dasherize__.resolver.ts.template → __name@dasherize____typeSeparator__resolver.ts.template} +0 -0
  83. /package/service/files/{__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template → __name@dasherize__.__type@dasherize__.spec.ts.template} +0 -0
  84. /package/service/files/{__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { NgModule<% if(experimentalZoneless) { %>, provideExperimentalZonelessChangeDetection<% } %> } from '@angular/core';
2
2
  import { BrowserModule } from '@angular/platform-browser';
3
3
  <% if (routing) { %>
4
- import { AppRoutingModule } from './app-routing.module';<% } %>
4
+ import { AppRoutingModule } from './app-routing-module';<% } %>
5
5
  import { App } from './app';
6
6
 
7
7
  @NgModule({
@@ -9,7 +9,7 @@ import { Component } from '@angular/core';
9
9
  %><router-outlet /><%
10
10
  } %>
11
11
  `,<% } else { %>
12
- templateUrl: './app.ng.html',<% } %>
12
+ templateUrl: './app.html',<% } %>
13
13
  standalone: false,<% if(inlineStyle) { %>
14
14
  styles: []<% } else { %>
15
15
  styleUrl: './app.<%= style %>'<% } %>
@@ -1,6 +1,6 @@
1
1
  <% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';
2
2
  <% }%>import { platformBrowser } from '@angular/platform-browser';
3
- import { AppModule } from './app/app.module';
3
+ import { AppModule } from './app/app-module';
4
4
 
5
5
  platformBrowser().bootstrapModule(AppModule, {
6
6
  <% if(!experimentalZoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
@@ -11,7 +11,7 @@ import { RouterOutlet } from '@angular/router';<% } %>
11
11
  %><router-outlet /><%
12
12
  } %>
13
13
  `,<% } else { %>
14
- templateUrl: './app.ng.html',<% } if(inlineStyle) { %>
14
+ templateUrl: './app.html',<% } if(inlineStyle) { %>
15
15
  styles: [],<% } else { %>
16
16
  styleUrl: './app.<%= style %>'<% } %>
17
17
  })
@@ -63,7 +63,7 @@ function default_1(options) {
63
63
  ? (0, schematics_1.filter)((path) => !path.endsWith('tsconfig.spec.json.template'))
64
64
  : (0, schematics_1.noop)(),
65
65
  componentOptions.inlineTemplate
66
- ? (0, schematics_1.filter)((path) => !path.endsWith('.ng.html.template'))
66
+ ? (0, schematics_1.filter)((path) => !path.endsWith('app.html.template'))
67
67
  : (0, schematics_1.noop)(),
68
68
  (0, schematics_1.applyTemplates)({
69
69
  utils: schematics_1.strings,
package/class/index.js CHANGED
@@ -10,6 +10,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.default = default_1;
11
11
  const generate_from_files_1 = require("../utility/generate-from-files");
12
12
  function default_1(options) {
13
- options.type = options.type ? `.${options.type}` : '';
14
13
  return (0, generate_from_files_1.generateFromFiles)(options);
15
14
  }
@@ -35,7 +35,16 @@ function default_1(options) {
35
35
  if (options.path === undefined) {
36
36
  options.path = (0, workspace_1.buildDefaultPath)(project);
37
37
  }
38
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
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
+ }
39
48
  // Schematic templates require a defined type value
40
49
  options.type ??= '';
41
50
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
@@ -51,7 +51,6 @@ export type Schema = {
51
51
  name: string;
52
52
  /**
53
53
  * Generate component template files with an '.ng.html' file extension instead of '.html'.
54
- * The '.ng.html' file extension is recommended by the Angular style guide.
55
54
  */
56
55
  ngHtml?: boolean;
57
56
  /**
@@ -137,8 +137,8 @@
137
137
  },
138
138
  "ngHtml": {
139
139
  "type": "boolean",
140
- "default": true,
141
- "description": "Generate component template files with an '.ng.html' file extension instead of '.html'. The '.ng.html' file extension is recommended by the Angular style guide."
140
+ "default": false,
141
+ "description": "Generate component template files with an '.ng.html' file extension instead of '.html'."
142
142
  }
143
143
  },
144
144
  "required": ["name", "project"]
@@ -35,9 +35,16 @@ function default_1(options) {
35
35
  if (options.path === undefined) {
36
36
  options.path = (0, workspace_1.buildDefaultPath)(project);
37
37
  }
38
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
39
- // Schematic templates require a defined type value
40
- options.type ??= '';
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
+ }
41
48
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
42
49
  options.name = parsedPath.name;
43
50
  options.path = parsedPath.path;
package/enum/index.d.ts CHANGED
@@ -5,6 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- import { Rule } from '@angular-devkit/schematics';
9
- import { Schema as EnumOptions } from './schema';
8
+ import type { Rule } from '@angular-devkit/schematics';
9
+ import type { Schema as EnumOptions } from './schema';
10
10
  export default function (options: EnumOptions): Rule;
package/enum/index.js CHANGED
@@ -10,6 +10,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.default = default_1;
11
11
  const generate_from_files_1 = require("../utility/generate-from-files");
12
12
  function default_1(options) {
13
- options.type = options.type ? `.${options.type}` : '';
14
13
  return (0, generate_from_files_1.generateFromFiles)(options);
15
14
  }
@@ -1,6 +1,6 @@
1
1
  import { TestBed } from '@angular/core/testing';
2
2
 
3
- import { <%= classify(name) %>Guard } from './<%= dasherize(name) %>.guard';
3
+ import { <%= classify(name) %>Guard } from './<%= dasherize(name) %><%= typeSeparator %>guard';
4
4
 
5
5
  describe('<%= classify(name) %>Guard', () => {
6
6
  let guard: <%= classify(name) %>Guard;
package/guard/schema.d.ts CHANGED
@@ -40,6 +40,11 @@ export type Schema = {
40
40
  * Skip the generation of a unit test file `spec.ts` for the new guard.
41
41
  */
42
42
  skipTests?: boolean;
43
+ /**
44
+ * The separator character to use before the type within the generated file's name. For
45
+ * example, if you set the option to `.`, the file will be named `example.guard.ts`.
46
+ */
47
+ typeSeparator?: TypeSeparator;
43
48
  };
44
49
  export declare enum Implement {
45
50
  CanActivate = "CanActivate",
@@ -47,3 +52,11 @@ export declare enum Implement {
47
52
  CanDeactivate = "CanDeactivate",
48
53
  CanMatch = "CanMatch"
49
54
  }
55
+ /**
56
+ * The separator character to use before the type within the generated file's name. For
57
+ * example, if you set the option to `.`, the file will be named `example.guard.ts`.
58
+ */
59
+ export declare enum TypeSeparator {
60
+ Empty = "-",
61
+ TypeSeparator = "."
62
+ }
package/guard/schema.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
3
3
  // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.Implement = void 0;
5
+ exports.TypeSeparator = exports.Implement = void 0;
6
6
  var Implement;
7
7
  (function (Implement) {
8
8
  Implement["CanActivate"] = "CanActivate";
@@ -10,3 +10,12 @@ var Implement;
10
10
  Implement["CanDeactivate"] = "CanDeactivate";
11
11
  Implement["CanMatch"] = "CanMatch";
12
12
  })(Implement || (exports.Implement = Implement = {}));
13
+ /**
14
+ * The separator character to use before the type within the generated file's name. For
15
+ * example, if you set the option to `.`, the file will be named `example.guard.ts`.
16
+ */
17
+ var TypeSeparator;
18
+ (function (TypeSeparator) {
19
+ TypeSeparator["Empty"] = "-";
20
+ TypeSeparator["TypeSeparator"] = ".";
21
+ })(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {}));
package/guard/schema.json CHANGED
@@ -58,6 +58,12 @@
58
58
  },
59
59
  "default": ["CanActivate"],
60
60
  "x-prompt": "Which type of guard would you like to create?"
61
+ },
62
+ "typeSeparator": {
63
+ "type": "string",
64
+ "default": "-",
65
+ "enum": ["-", "."],
66
+ "description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.guard.ts`."
61
67
  }
62
68
  },
63
69
  "required": ["name", "project"]
@@ -1,7 +1,7 @@
1
1
  import { TestBed } from '@angular/core/testing';
2
2
  import { <%= guardType %> } from '@angular/router';
3
3
 
4
- import { <%= camelize(name) %>Guard } from './<%= dasherize(name) %>.guard';
4
+ import { <%= camelize(name) %>Guard } from './<%= dasherize(name) %><%= typeSeparator %>guard';
5
5
 
6
6
  describe('<%= camelize(name) %>Guard', () => {
7
7
  const executeGuard: <%= guardType %><% if (guardType === 'CanDeactivateFn') { %><unknown><% } %> = (...guardParameters) =>
@@ -1,6 +1,6 @@
1
1
  import { TestBed } from '@angular/core/testing';
2
2
 
3
- import { <%= classify(name) %>Interceptor } from './<%= dasherize(name) %>.interceptor';
3
+ import { <%= classify(name) %>Interceptor } from './<%= dasherize(name) %><%= typeSeparator %>interceptor';
4
4
 
5
5
  describe('<%= classify(name) %>Interceptor', () => {
6
6
  beforeEach(() => TestBed.configureTestingModule({
@@ -1,7 +1,7 @@
1
1
  import { TestBed } from '@angular/core/testing';
2
2
  import { HttpInterceptorFn } from '@angular/common/http';
3
3
 
4
- import { <%= camelize(name) %>Interceptor } from './<%= dasherize(name) %>.interceptor';
4
+ import { <%= camelize(name) %>Interceptor } from './<%= dasherize(name) %><%= typeSeparator %>interceptor';
5
5
 
6
6
  describe('<%= camelize(name) %>Interceptor', () => {
7
7
  const interceptor: HttpInterceptorFn = (req, next) =>
@@ -5,6 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- import { Rule } from '@angular-devkit/schematics';
9
- import { Schema as InterceptorOptions } from './schema';
8
+ import type { Rule } from '@angular-devkit/schematics';
9
+ import type { Schema as InterceptorOptions } from './schema';
10
10
  export default function (options: InterceptorOptions): Rule;
@@ -10,13 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.default = default_1;
11
11
  const generate_from_files_1 = require("../utility/generate-from-files");
12
12
  function default_1(options) {
13
- // This schematic uses an older method to implement the flat option
14
- const flat = options.flat;
15
- options.flat = true;
16
- const extraTemplateValues = {
17
- 'if-flat': (s) => (flat ? '' : s),
18
- };
19
- return options.functional
20
- ? (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './functional-files' }, extraTemplateValues)
21
- : (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './class-files' }, extraTemplateValues);
13
+ const templateFilesDirectory = options.functional ? './functional-files' : './class-files';
14
+ return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory });
22
15
  }
@@ -35,4 +35,17 @@ export type Schema = {
35
35
  * Skip the generation of a unit test file `spec.ts` for the new interceptor.
36
36
  */
37
37
  skipTests?: boolean;
38
+ /**
39
+ * The separator character to use before the type within the generated file's name. For
40
+ * example, if you set the option to `.`, the file will be named `example.interceptor.ts`.
41
+ */
42
+ typeSeparator?: TypeSeparator;
38
43
  };
44
+ /**
45
+ * The separator character to use before the type within the generated file's name. For
46
+ * example, if you set the option to `.`, the file will be named `example.interceptor.ts`.
47
+ */
48
+ export declare enum TypeSeparator {
49
+ Empty = "-",
50
+ TypeSeparator = "."
51
+ }
@@ -2,3 +2,13 @@
2
2
  // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
3
3
  // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.TypeSeparator = void 0;
6
+ /**
7
+ * The separator character to use before the type within the generated file's name. For
8
+ * example, if you set the option to `.`, the file will be named `example.interceptor.ts`.
9
+ */
10
+ var TypeSeparator;
11
+ (function (TypeSeparator) {
12
+ TypeSeparator["Empty"] = "-";
13
+ TypeSeparator["TypeSeparator"] = ".";
14
+ })(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {}));
@@ -45,6 +45,12 @@
45
45
  "type": "boolean",
46
46
  "description": "Creates the interceptor as a function `HttpInterceptorFn` instead of a class. Functional interceptors can be simpler for basic scenarios.",
47
47
  "default": true
48
+ },
49
+ "typeSeparator": {
50
+ "type": "string",
51
+ "default": "-",
52
+ "enum": ["-", "."],
53
+ "description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.interceptor.ts`."
48
54
  }
49
55
  },
50
56
  "required": ["name", "project"]
@@ -10,6 +10,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.default = default_1;
11
11
  const generate_from_files_1 = require("../utility/generate-from-files");
12
12
  function default_1(options) {
13
- options.type = options.type ? `.${options.type}` : '';
14
13
  return (0, generate_from_files_1.generateFromFiles)(options);
15
14
  }
@@ -3,4 +3,4 @@
3
3
  */
4
4
 
5
5
  export * from './lib/<%= dasherize(name) %>';<% if (!standalone) { %>
6
- export * from './lib/<%= dasherize(name) %>.module';<% } %>
6
+ export * from './lib/<%= dasherize(name) %>-module';<% } %>
package/library/index.js CHANGED
@@ -72,9 +72,6 @@ function addLibToWorkspaceFile(options, projectRoot, projectName) {
72
72
  build: {
73
73
  builder: workspace_models_1.Builders.BuildNgPackagr,
74
74
  defaultConfiguration: 'production',
75
- options: {
76
- project: `${projectRoot}/ng-package.json`,
77
- },
78
75
  configurations: {
79
76
  production: {
80
77
  tsConfig: `${projectRoot}/tsconfig.lib.prod.json`,
@@ -154,6 +151,10 @@ function default_1(options) {
154
151
  export: true,
155
152
  standalone: options.standalone,
156
153
  project: packageName,
154
+ // Explicitly set an empty `type` since it doesn't necessarily make sense in a library.
155
+ // This also ensures that the generated files are valid even if the `component` schematic
156
+ // inherits its `type` from the workspace.
157
+ type: '',
157
158
  }),
158
159
  (_tree, context) => {
159
160
  if (!options.skipPackageJson && !options.skipInstall) {
@@ -10,6 +10,16 @@
10
10
  "factory": "./replace-provide-server-routing/migration",
11
11
  "description": "Migrate 'provideServerRendering' to use 'withRoutes' and remove 'provideServerRouting' from '@angular/ssr'."
12
12
  },
13
+ "update-module-resolution": {
14
+ "version": "20.0.0",
15
+ "factory": "./update-module-resolution/migration",
16
+ "description": "Update 'moduleResolution' to 'bundler' in TypeScript configurations. You can read more about this, here: https://www.typescriptlang.org/tsconfig/#moduleResolution"
17
+ },
18
+ "previous-style-guide": {
19
+ "version": "20.0.0",
20
+ "factory": "./previous-style-guide/migration",
21
+ "description": "Update workspace generation defaults to maintain previous style guide behavior."
22
+ },
13
23
  "use-application-builder": {
14
24
  "version": "20.0.0",
15
25
  "factory": "./use-application-builder/migration",
@@ -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 type { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;
@@ -0,0 +1,42 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
11
+ const workspace_1 = require("../../utility/workspace");
12
+ const TYPE_SCHEMATICS = ['component', 'directive', 'service'];
13
+ const SEPARATOR_SCHEMATICS = ['guard', 'interceptor', 'module', 'pipe', 'resolver'];
14
+ function default_1() {
15
+ return (0, workspace_1.updateWorkspace)((workspace) => {
16
+ let schematicsDefaults = workspace.extensions['schematics'];
17
+ // Ensure "schematics" field is an object
18
+ if (!schematicsDefaults ||
19
+ typeof schematicsDefaults !== 'object' ||
20
+ Array.isArray(schematicsDefaults)) {
21
+ schematicsDefaults = workspace.extensions['schematics'] = {};
22
+ }
23
+ // Add "type" value for each schematic to continue generating a type suffix.
24
+ // New default is an empty type value.
25
+ for (const schematicName of TYPE_SCHEMATICS) {
26
+ const schematic = (schematicsDefaults[`@schematics/angular:${schematicName}`] ??= {});
27
+ if (typeof schematic === 'object' && !Array.isArray(schematic) && !('type' in schematic)) {
28
+ schematic['type'] = schematicName;
29
+ }
30
+ }
31
+ // Add "typeSeparator" value for each schematic to continue generating "." before type.
32
+ // New default is an "-" type value.
33
+ for (const schematicName of SEPARATOR_SCHEMATICS) {
34
+ const schematic = (schematicsDefaults[`@schematics/angular:${schematicName}`] ??= {});
35
+ if (typeof schematic === 'object' &&
36
+ !Array.isArray(schematic) &&
37
+ !('typeSeparator' in schematic)) {
38
+ schematic['typeSeparator'] = '.';
39
+ }
40
+ }
41
+ });
42
+ }
@@ -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,52 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
11
+ const json_file_1 = require("../../utility/json-file");
12
+ const workspace_1 = require("../../utility/workspace");
13
+ function default_1() {
14
+ return async (host) => {
15
+ const uniqueTsConfigs = new Set();
16
+ if (host.exists('tsconfig.json')) {
17
+ // Workspace level tsconfig
18
+ uniqueTsConfigs.add('tsconfig.json');
19
+ }
20
+ const workspace = await (0, workspace_1.getWorkspace)(host);
21
+ for (const [, target] of (0, workspace_1.allWorkspaceTargets)(workspace)) {
22
+ for (const [, opt] of (0, workspace_1.allTargetOptions)(target)) {
23
+ if (typeof opt?.tsConfig === 'string') {
24
+ uniqueTsConfigs.add(opt.tsConfig);
25
+ }
26
+ }
27
+ }
28
+ for (const tsConfig of uniqueTsConfigs) {
29
+ if (host.exists(tsConfig)) {
30
+ updateModuleResolution(host, tsConfig);
31
+ }
32
+ }
33
+ };
34
+ }
35
+ function updateModuleResolution(host, tsConfigPath) {
36
+ const json = new json_file_1.JSONFile(host, tsConfigPath);
37
+ const jsonPath = ['compilerOptions'];
38
+ const compilerOptions = json.get(jsonPath);
39
+ if (compilerOptions && typeof compilerOptions === 'object') {
40
+ const { moduleResolution, module } = compilerOptions;
41
+ if (typeof moduleResolution !== 'string' || moduleResolution.toLowerCase() === 'bundler') {
42
+ return;
43
+ }
44
+ if (typeof module === 'string' && module.toLowerCase() === 'preserve') {
45
+ return;
46
+ }
47
+ json.modify(jsonPath, {
48
+ ...compilerOptions,
49
+ 'moduleResolution': 'bundler',
50
+ });
51
+ }
52
+ }
@@ -105,7 +105,6 @@ function* updateBuildTarget(projectName, buildTarget, serverTarget, tree, contex
105
105
  }
106
106
  yield (0, schematics_1.externalSchematic)('@schematics/angular', 'ssr', {
107
107
  project: projectName,
108
- skipInstall: true,
109
108
  });
110
109
  }
111
110
  }
@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';<% if (commonModule) { %>
2
2
  import { CommonModule } from '@angular/common';<% } %><% if (lazyRouteWithoutRouteModule) { %>
3
3
  import { Routes, RouterModule } from '@angular/router';<% } %>
4
4
  <% if ((!lazyRoute && routing) || lazyRouteWithRouteModule) { %>
5
- import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing.module';<% } %>
5
+ import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing<%= typeSeparator %>module';<% } %>
6
6
  <% if (lazyRouteWithoutRouteModule) { %>
7
7
  const routes: Routes = [
8
8
  { path: '', component: <%= classify(name) %> }
package/module/index.js CHANGED
@@ -52,7 +52,7 @@ const validation_1 = require("../utility/validation");
52
52
  const workspace_1 = require("../utility/workspace");
53
53
  const schema_1 = require("./schema");
54
54
  function buildRelativeModulePath(options, modulePath) {
55
- const importModulePath = (0, posix_1.join)(options.path ?? '', options.flat ? '' : schematics_1.strings.dasherize(options.name), schematics_1.strings.dasherize(options.name) + '.module');
55
+ const importModulePath = (0, posix_1.join)(options.path ?? '', options.flat ? '' : schematics_1.strings.dasherize(options.name), schematics_1.strings.dasherize(options.name) + options.typeSeparator + 'module');
56
56
  return (0, find_module_1.buildRelativePath)(modulePath, importModulePath);
57
57
  }
58
58
  function addImportToNgModule(options) {
@@ -99,9 +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)
102
+ const routingModulePath = modulePath.endsWith(find_module_1.ROUTING_MODULE_EXT) || modulePath.endsWith('-routing-module.ts')
103
103
  ? modulePath
104
- : modulePath.replace(find_module_1.MODULE_EXT, find_module_1.ROUTING_MODULE_EXT);
104
+ : modulePath
105
+ .replace(find_module_1.MODULE_EXT, find_module_1.ROUTING_MODULE_EXT)
106
+ .replace('-module.ts', '-routing-module.ts');
105
107
  return host.exists(routingModulePath) ? routingModulePath : undefined;
106
108
  }
107
109
  function buildRoute(options, modulePath) {
@@ -116,7 +118,16 @@ function default_1(options) {
116
118
  options.path = await (0, workspace_1.createDefaultPath)(host, options.project);
117
119
  }
118
120
  if (options.module) {
119
- options.module = (0, find_module_1.findModuleFromOptions)(host, options);
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
+ }
120
131
  }
121
132
  let routingModulePath;
122
133
  const isLazyLoadedModuleGen = !!(options.route && options.module);
@@ -131,7 +142,7 @@ function default_1(options) {
131
142
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
132
143
  options.routing || (isLazyLoadedModuleGen && routingModulePath)
133
144
  ? (0, schematics_1.noop)()
134
- : (0, schematics_1.filter)((path) => !path.endsWith('-routing.module.ts.template')),
145
+ : (0, schematics_1.filter)((path) => !path.includes('-routing')),
135
146
  (0, schematics_1.applyTemplates)({
136
147
  ...schematics_1.strings,
137
148
  'if-flat': (s) => (options.flat ? '' : s),
@@ -143,7 +154,7 @@ function default_1(options) {
143
154
  (0, schematics_1.move)(parsedPath.path),
144
155
  ]);
145
156
  const moduleDasherized = schematics_1.strings.dasherize(options.name);
146
- const modulePath = `${!options.flat ? moduleDasherized + '/' : ''}${moduleDasherized}.module.ts`;
157
+ const modulePath = `${!options.flat ? moduleDasherized + '/' : ''}${moduleDasherized}${options.typeSeparator}module.ts`;
147
158
  const componentOptions = {
148
159
  module: modulePath,
149
160
  flat: options.flat,
@@ -40,6 +40,11 @@ export type Schema = {
40
40
  * The scope for the new routing module.
41
41
  */
42
42
  routingScope?: RoutingScope;
43
+ /**
44
+ * The separator character to use before the type within the generated file's name. For
45
+ * example, if you set the option to `.`, the file will be named `example.module.ts`.
46
+ */
47
+ typeSeparator?: TypeSeparator;
43
48
  };
44
49
  /**
45
50
  * The scope for the new routing module.
@@ -48,3 +53,11 @@ export declare enum RoutingScope {
48
53
  Child = "Child",
49
54
  Root = "Root"
50
55
  }
56
+ /**
57
+ * The separator character to use before the type within the generated file's name. For
58
+ * example, if you set the option to `.`, the file will be named `example.module.ts`.
59
+ */
60
+ export declare enum TypeSeparator {
61
+ Empty = "-",
62
+ TypeSeparator = "."
63
+ }
package/module/schema.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
3
3
  // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.RoutingScope = void 0;
5
+ exports.TypeSeparator = exports.RoutingScope = void 0;
6
6
  /**
7
7
  * The scope for the new routing module.
8
8
  */
@@ -11,3 +11,12 @@ var RoutingScope;
11
11
  RoutingScope["Child"] = "Child";
12
12
  RoutingScope["Root"] = "Root";
13
13
  })(RoutingScope || (exports.RoutingScope = RoutingScope = {}));
14
+ /**
15
+ * The separator character to use before the type within the generated file's name. For
16
+ * example, if you set the option to `.`, the file will be named `example.module.ts`.
17
+ */
18
+ var TypeSeparator;
19
+ (function (TypeSeparator) {
20
+ TypeSeparator["Empty"] = "-";
21
+ TypeSeparator["TypeSeparator"] = ".";
22
+ })(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {}));
@@ -62,6 +62,12 @@
62
62
  "type": "string",
63
63
  "description": "The declaring NgModule.",
64
64
  "alias": "m"
65
+ },
66
+ "typeSeparator": {
67
+ "type": "string",
68
+ "default": "-",
69
+ "enum": ["-", "."],
70
+ "description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.module.ts`."
65
71
  }
66
72
  },
67
73
  "required": ["name", "project"]