@schematics/angular 20.0.0-next.4 → 20.0.0-next.6

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 (82) hide show
  1. package/application/files/common-files/tsconfig.app.json.template +5 -4
  2. package/application/files/common-files/tsconfig.spec.json.template +2 -2
  3. package/application/files/module-files/src/app/{app.module.ts.template → app-module.ts.template} +1 -1
  4. package/application/files/module-files/src/app/app.ts.template +1 -1
  5. package/application/files/module-files/src/main.ts.template +1 -1
  6. package/application/files/standalone-files/src/app/app.ts.template +1 -1
  7. package/application/index.js +18 -1
  8. package/class/index.js +0 -1
  9. package/component/index.js +10 -1
  10. package/component/schema.d.ts +0 -1
  11. package/component/schema.json +2 -2
  12. package/directive/index.js +10 -3
  13. package/enum/index.d.ts +2 -2
  14. package/enum/index.js +0 -1
  15. package/guard/implements-files/{__name@dasherize__.guard.spec.ts.template → __name@dasherize____typeSeparator__guard.spec.ts.template} +1 -1
  16. package/guard/schema.d.ts +13 -0
  17. package/guard/schema.js +10 -1
  18. package/guard/schema.json +6 -0
  19. package/guard/type-files/{__name@dasherize__.guard.spec.ts.template → __name@dasherize____typeSeparator__guard.spec.ts.template} +1 -1
  20. package/interceptor/class-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.spec.ts.template → __name@dasherize____typeSeparator__interceptor.spec.ts.template} +1 -1
  21. package/interceptor/functional-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.spec.ts.template → __name@dasherize____typeSeparator__interceptor.spec.ts.template} +1 -1
  22. package/interceptor/index.d.ts +2 -2
  23. package/interceptor/index.js +2 -9
  24. package/interceptor/schema.d.ts +13 -0
  25. package/interceptor/schema.js +10 -0
  26. package/interceptor/schema.json +6 -0
  27. package/interface/index.js +0 -1
  28. package/library/files/src/__entryFile__.ts.template +1 -1
  29. package/library/index.js +4 -3
  30. package/migrations/migration-collection.json +5 -0
  31. package/migrations/previous-style-guide/migration.d.ts +9 -0
  32. package/migrations/previous-style-guide/migration.js +42 -0
  33. package/migrations/use-application-builder/migration.js +8 -0
  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 -4
  57. package/service/index.js +1 -8
  58. package/ssr/index.js +5 -0
  59. package/utility/add-declaration-to-ng-module.d.ts +1 -0
  60. package/utility/add-declaration-to-ng-module.js +3 -3
  61. package/utility/ast-utils.d.ts +1 -1
  62. package/utility/ast-utils.js +1 -4
  63. package/utility/generate-from-files.js +2 -0
  64. package/utility/latest-versions.js +3 -3
  65. package/utility/standalone/app_component.d.ts +29 -0
  66. package/utility/standalone/app_component.js +109 -0
  67. package/workspace/files/tsconfig.json.template +3 -3
  68. /package/application/files/common-files/src/app/{app.ng.html.template → app.html.template} +0 -0
  69. /package/class/files/{__name@dasherize____type__.spec.ts.template → __name@dasherize__.__type__.spec.ts.template} +0 -0
  70. /package/class/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
  71. /package/enum/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
  72. /package/guard/implements-files/{__name@dasherize__.guard.ts.template → __name@dasherize____typeSeparator__guard.ts.template} +0 -0
  73. /package/guard/type-files/{__name@dasherize__.guard.ts.template → __name@dasherize____typeSeparator__guard.ts.template} +0 -0
  74. /package/interceptor/class-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.ts.template → __name@dasherize____typeSeparator__interceptor.ts.template} +0 -0
  75. /package/interceptor/functional-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.ts.template → __name@dasherize____typeSeparator__interceptor.ts.template} +0 -0
  76. /package/interface/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
  77. /package/module/files/__name@dasherize@if-flat__/{__name@dasherize__-routing.module.ts.template → __name@dasherize__-routing__typeSeparator__module.ts.template} +0 -0
  78. /package/pipe/files/{__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template → __name@dasherize____typeSeparator__pipe.ts.template} +0 -0
  79. /package/resolver/class-files/{__name@dasherize__.resolver.ts.template → __name@dasherize____typeSeparator__resolver.ts.template} +0 -0
  80. /package/resolver/functional-files/{__name@dasherize__.resolver.ts.template → __name@dasherize____typeSeparator__resolver.ts.template} +0 -0
  81. /package/service/files/{__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template → __name@dasherize__.__type@dasherize__.spec.ts.template} +0 -0
  82. /package/service/files/{__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +0 -0
@@ -3,13 +3,14 @@
3
3
  {
4
4
  "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json",
5
5
  "compilerOptions": {
6
+ "composite": true,
6
7
  "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/app",
7
8
  "types": []
8
9
  },
9
- "files": [
10
- "src/main.ts"
11
- ],
12
10
  "include": [
13
- "src/**/*.d.ts"
11
+ "src/**/*.ts"
12
+ ],
13
+ "exclude": [
14
+ "src/**/*.spec.ts"
14
15
  ]
15
16
  }
@@ -3,13 +3,13 @@
3
3
  {
4
4
  "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json",
5
5
  "compilerOptions": {
6
+ "composite": true,
6
7
  "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/spec",
7
8
  "types": [
8
9
  "jasmine"
9
10
  ]
10
11
  },
11
12
  "include": [
12
- "src/**/*.spec.ts",
13
- "src/**/*.d.ts"
13
+ "src/**/*.ts"
14
14
  ]
15
15
  }
@@ -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
  })
@@ -12,16 +12,33 @@ const core_1 = require("@angular-devkit/core");
12
12
  const schematics_1 = require("@angular-devkit/schematics");
13
13
  const tasks_1 = require("@angular-devkit/schematics/tasks");
14
14
  const dependencies_1 = require("../utility/dependencies");
15
+ const json_file_1 = require("../utility/json-file");
15
16
  const latest_versions_1 = require("../utility/latest-versions");
16
17
  const paths_1 = require("../utility/paths");
17
18
  const workspace_1 = require("../utility/workspace");
18
19
  const workspace_models_1 = require("../utility/workspace-models");
19
20
  const schema_1 = require("./schema");
21
+ function addTsProjectReference(...paths) {
22
+ return (host) => {
23
+ if (!host.exists('tsconfig.json')) {
24
+ return host;
25
+ }
26
+ const newReferences = paths.map((path) => ({ path }));
27
+ const file = new json_file_1.JSONFile(host, 'tsconfig.json');
28
+ const jsonPath = ['references'];
29
+ const value = file.get(jsonPath);
30
+ file.modify(jsonPath, Array.isArray(value) ? [...value, ...newReferences] : newReferences);
31
+ };
32
+ }
20
33
  function default_1(options) {
21
34
  return async (host, context) => {
22
35
  const { appDir, appRootSelector, componentOptions, folderName, sourceDir } = await getAppOptions(host, options);
23
36
  return (0, schematics_1.chain)([
24
37
  addAppToWorkspaceFile(options, appDir, folderName),
38
+ addTsProjectReference((0, core_1.join)((0, core_1.normalize)(appDir), 'tsconfig.app.json')),
39
+ options.skipTests
40
+ ? (0, schematics_1.noop)()
41
+ : addTsProjectReference((0, core_1.join)((0, core_1.normalize)(appDir), 'tsconfig.spec.json')),
25
42
  options.standalone
26
43
  ? (0, schematics_1.noop)()
27
44
  : (0, schematics_1.schematic)('module', {
@@ -63,7 +80,7 @@ function default_1(options) {
63
80
  ? (0, schematics_1.filter)((path) => !path.endsWith('tsconfig.spec.json.template'))
64
81
  : (0, schematics_1.noop)(),
65
82
  componentOptions.inlineTemplate
66
- ? (0, schematics_1.filter)((path) => !path.endsWith('.ng.html.template'))
83
+ ? (0, schematics_1.filter)((path) => !path.endsWith('app.html.template'))
67
84
  : (0, schematics_1.noop)(),
68
85
  (0, schematics_1.applyTemplates)({
69
86
  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) {
@@ -15,6 +15,11 @@
15
15
  "factory": "./update-module-resolution/migration",
16
16
  "description": "Update 'moduleResolution' to 'bundler' in TypeScript configurations. You can read more about this, here: https://www.typescriptlang.org/tsconfig/#moduleResolution"
17
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
+ },
18
23
  "use-application-builder": {
19
24
  "version": "20.0.0",
20
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
+ }
@@ -150,6 +150,7 @@ function updateProjects(tree, context) {
150
150
  case workspace_models_1.Builders.Application:
151
151
  case workspace_models_1.Builders.DevServer:
152
152
  case workspace_models_1.Builders.ExtractI18n:
153
+ case workspace_models_1.Builders.Karma:
153
154
  case workspace_models_1.Builders.NgPackagr:
154
155
  // Ignore application, dev server, and i18n extraction for devkit usage check.
155
156
  // Both will be replaced if no other usage is found.
@@ -173,6 +174,13 @@ function updateProjects(tree, context) {
173
174
  case workspace_models_1.Builders.ExtractI18n:
174
175
  target.builder = '@angular/build:extract-i18n';
175
176
  break;
177
+ case workspace_models_1.Builders.Karma:
178
+ target.builder = '@angular/build:karma';
179
+ // Remove "builderMode" option since the builder will always use "application"
180
+ for (const [, karmaOptions] of (0, workspace_1.allTargetOptions)(target)) {
181
+ delete karmaOptions['builderMode'];
182
+ }
183
+ break;
176
184
  case workspace_models_1.Builders.NgPackagr:
177
185
  target.builder = '@angular/build:ng-packagr';
178
186
  break;
@@ -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 = {}));