@schematics/angular 20.0.0-next.1 → 20.0.0-next.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.
Files changed (65) hide show
  1. package/app-shell/index.js +11 -118
  2. package/app-shell/schema.d.ts +0 -5
  3. package/app-shell/schema.json +0 -5
  4. package/application/files/module-files/src/app/app.module.ts.template +3 -3
  5. package/application/files/module-files/src/app/{app.component.spec.ts.template → app.spec.ts.template} +6 -6
  6. package/application/files/module-files/src/app/{app.component.ts.template → app.ts.template} +3 -3
  7. package/application/files/module-files/src/main.ts.template +2 -2
  8. package/application/files/standalone-files/src/app/{app.component.spec.ts.template → app.spec.ts.template} +6 -6
  9. package/application/files/standalone-files/src/app/{app.component.ts.template → app.ts.template} +3 -3
  10. package/application/files/standalone-files/src/main.ts.template +2 -2
  11. package/application/index.js +0 -4
  12. package/application/schema.d.ts +0 -5
  13. package/application/schema.json +0 -4
  14. package/component/index.js +2 -0
  15. package/component/schema.json +1 -2
  16. package/directive/files/__name@dasherize__.__type@dasherize__.spec.ts.template +8 -0
  17. package/directive/files/{__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +1 -1
  18. package/directive/index.js +4 -10
  19. package/directive/schema.d.ts +5 -0
  20. package/directive/schema.json +4 -0
  21. package/library/files/src/__entryFile__.ts.template +1 -2
  22. package/library/index.js +0 -6
  23. package/migrations/migration-collection.json +10 -0
  24. package/migrations/replace-provide-server-rendering-import/migration.d.ts +9 -0
  25. package/migrations/replace-provide-server-rendering-import/migration.js +133 -0
  26. package/migrations/replace-provide-server-routing/migration.d.ts +9 -0
  27. package/migrations/replace-provide-server-routing/migration.js +122 -0
  28. package/module/files/__name@dasherize@if-flat__/__name@dasherize__-routing.module.ts.template +2 -2
  29. package/module/files/__name@dasherize@if-flat__/__name@dasherize__.module.ts.template +1 -1
  30. package/ng-new/index.js +0 -1
  31. package/ng-new/schema.d.ts +0 -5
  32. package/ng-new/schema.json +0 -4
  33. package/package.json +4 -4
  34. package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +7 -8
  35. package/server/files/application-builder/standalone-src/app/app.config.server.ts.template +4 -6
  36. package/server/files/application-builder/standalone-src/main.server.ts.template +2 -2
  37. package/server/files/server-builder/ngmodule-src/app/app.module.server.ts.template +2 -2
  38. package/server/files/server-builder/standalone-src/app/app.config.server.ts.template +1 -1
  39. package/server/files/server-builder/standalone-src/main.server.ts.template +2 -2
  40. package/server/index.js +5 -11
  41. package/server/schema.d.ts +0 -5
  42. package/server/schema.json +0 -4
  43. package/service/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +16 -0
  44. package/service/files/__name@dasherize@if-flat__/{__name@dasherize__.service.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +1 -1
  45. package/service/index.js +2 -0
  46. package/service/schema.d.ts +5 -0
  47. package/service/schema.json +4 -0
  48. package/ssr/files/application-builder/server.ts.template +2 -4
  49. package/ssr/index.d.ts +1 -3
  50. package/ssr/index.js +14 -100
  51. package/ssr/schema.d.ts +0 -5
  52. package/ssr/schema.json +0 -4
  53. package/utility/find-module.js +1 -1
  54. package/utility/generate-from-files.d.ts +1 -0
  55. package/utility/generate-from-files.js +10 -0
  56. package/utility/latest-versions.js +3 -3
  57. package/utility/project-targets.d.ts +2 -0
  58. package/utility/project-targets.js +7 -0
  59. package/web-worker/index.js +1 -1
  60. package/workspace/files/package.json.template +0 -1
  61. package/workspace/files/tsconfig.json.template +1 -0
  62. package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.spec.ts.template +0 -8
  63. package/service/files/__name@dasherize@if-flat__/__name@dasherize__.service.spec.ts.template +0 -16
  64. package/ssr/files/application-builder-common-engine/server.ts.template +0 -67
  65. /package/application/files/common-files/src/app/{app.component.ng.html.template → app.ng.html.template} +0 -0
@@ -17,10 +17,9 @@ const typescript_1 = __importDefault(require("../third_party/github.com/Microsof
17
17
  const ast_utils_1 = require("../utility/ast-utils");
18
18
  const change_1 = require("../utility/change");
19
19
  const ng_ast_utils_1 = require("../utility/ng-ast-utils");
20
+ const project_targets_1 = require("../utility/project-targets");
20
21
  const util_1 = require("../utility/standalone/util");
21
22
  const workspace_1 = require("../utility/workspace");
22
- const workspace_models_1 = require("../utility/workspace-models");
23
- const APP_SHELL_ROUTE = 'shell';
24
23
  function getSourceFile(host, path) {
25
24
  const content = host.readText(path);
26
25
  const source = typescript_1.default.createSourceFile(path, content, typescript_1.default.ScriptTarget.Latest, true);
@@ -120,110 +119,6 @@ function getMetadataProperty(metadata, propertyName) {
120
119
  })[0];
121
120
  return property;
122
121
  }
123
- function addAppShellConfigToWorkspace(options) {
124
- return (0, workspace_1.updateWorkspace)((workspace) => {
125
- const project = workspace.projects.get(options.project);
126
- if (!project) {
127
- return;
128
- }
129
- const buildTarget = project.targets.get('build');
130
- if (buildTarget?.builder === workspace_models_1.Builders.Application ||
131
- buildTarget?.builder === workspace_models_1.Builders.BuildApplication) {
132
- // Application builder configuration.
133
- const prodConfig = buildTarget.configurations?.production;
134
- if (!prodConfig) {
135
- throw new schematics_1.SchematicsException(`A "production" configuration is not defined for the "build" builder.`);
136
- }
137
- prodConfig.appShell = true;
138
- }
139
- });
140
- }
141
- function addServerRoutes(options) {
142
- return async (host) => {
143
- // The workspace gets updated so this needs to be reloaded
144
- const workspace = await (0, workspace_1.getWorkspace)(host);
145
- const project = workspace.projects.get(options.project);
146
- if (!project) {
147
- throw new schematics_1.SchematicsException(`Invalid project name (${options.project})`);
148
- }
149
- const modulePath = getServerModulePath(host, project.sourceRoot || 'src', 'main.server.ts');
150
- if (modulePath === null) {
151
- throw new schematics_1.SchematicsException('Server module not found.');
152
- }
153
- let moduleSource = getSourceFile(host, modulePath);
154
- if (!(0, ast_utils_1.isImported)(moduleSource, 'Routes', '@angular/router')) {
155
- const recorder = host.beginUpdate(modulePath);
156
- const routesChange = (0, ast_utils_1.insertImport)(moduleSource, modulePath, 'Routes', '@angular/router');
157
- if (routesChange) {
158
- (0, change_1.applyToUpdateRecorder)(recorder, [routesChange]);
159
- }
160
- const imports = (0, ast_utils_1.getSourceNodes)(moduleSource)
161
- .filter((node) => node.kind === typescript_1.default.SyntaxKind.ImportDeclaration)
162
- .sort((a, b) => a.getStart() - b.getStart());
163
- const insertPosition = imports[imports.length - 1].getEnd();
164
- const routeText = `\n\nconst routes: Routes = [ { path: '${APP_SHELL_ROUTE}', component: AppShellComponent }];`;
165
- recorder.insertRight(insertPosition, routeText);
166
- host.commitUpdate(recorder);
167
- }
168
- moduleSource = getSourceFile(host, modulePath);
169
- if (!(0, ast_utils_1.isImported)(moduleSource, 'RouterModule', '@angular/router')) {
170
- const recorder = host.beginUpdate(modulePath);
171
- const routerModuleChange = (0, ast_utils_1.insertImport)(moduleSource, modulePath, 'RouterModule', '@angular/router');
172
- if (routerModuleChange) {
173
- (0, change_1.applyToUpdateRecorder)(recorder, [routerModuleChange]);
174
- }
175
- const metadataChange = (0, ast_utils_1.addSymbolToNgModuleMetadata)(moduleSource, modulePath, 'imports', 'RouterModule.forRoot(routes)');
176
- if (metadataChange) {
177
- (0, change_1.applyToUpdateRecorder)(recorder, metadataChange);
178
- }
179
- host.commitUpdate(recorder);
180
- }
181
- };
182
- }
183
- function addStandaloneServerRoute(options) {
184
- return async (host) => {
185
- const workspace = await (0, workspace_1.getWorkspace)(host);
186
- const project = workspace.projects.get(options.project);
187
- if (!project) {
188
- throw new schematics_1.SchematicsException(`Project name "${options.project}" doesn't not exist.`);
189
- }
190
- const configFilePath = (0, posix_1.join)(project.sourceRoot ?? 'src', 'app/app.config.server.ts');
191
- if (!host.exists(configFilePath)) {
192
- throw new schematics_1.SchematicsException(`Cannot find "${configFilePath}".`);
193
- }
194
- const recorder = host.beginUpdate(configFilePath);
195
- let configSourceFile = getSourceFile(host, configFilePath);
196
- if (!(0, ast_utils_1.isImported)(configSourceFile, 'ROUTES', '@angular/router')) {
197
- const routesChange = (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'ROUTES', '@angular/router');
198
- if (routesChange) {
199
- (0, change_1.applyToUpdateRecorder)(recorder, [routesChange]);
200
- }
201
- }
202
- configSourceFile = getSourceFile(host, configFilePath);
203
- const providersLiteral = (0, ast_utils_1.findNodes)(configSourceFile, typescript_1.default.isPropertyAssignment).find((n) => typescript_1.default.isArrayLiteralExpression(n.initializer) && n.name.getText() === 'providers')?.initializer;
204
- if (!providersLiteral) {
205
- throw new schematics_1.SchematicsException(`Cannot find the "providers" configuration in "${configFilePath}".`);
206
- }
207
- // Add route to providers literal.
208
- recorder.remove(providersLiteral.getStart(), providersLiteral.getWidth());
209
- const updatedProvidersString = [
210
- ...providersLiteral.elements.map((element) => ' ' + element.getText()),
211
- ` {
212
- provide: ROUTES,
213
- multi: true,
214
- useValue: [{
215
- path: '${APP_SHELL_ROUTE}',
216
- component: AppShellComponent
217
- }]
218
- }\n `,
219
- ];
220
- recorder.insertRight(providersLiteral.getStart(), `[\n${updatedProvidersString.join(',\n')}]`);
221
- (0, change_1.applyToUpdateRecorder)(recorder, [
222
- (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'AppShellComponent', './app-shell/app-shell.component'),
223
- ]);
224
- host.commitUpdate(recorder);
225
- };
226
- }
227
122
  function addServerRoutingConfig(options, isStandalone) {
228
123
  return async (host) => {
229
124
  const workspace = await (0, workspace_1.getWorkspace)(host);
@@ -241,15 +136,15 @@ function addServerRoutingConfig(options, isStandalone) {
241
136
  const configSourceFile = getSourceFile(host, configFilePath);
242
137
  const functionCall = (0, ast_utils_1.findNodes)(configSourceFile, typescript_1.default.isCallExpression,
243
138
  /** max */ undefined,
244
- /** recursive */ true).find((n) => typescript_1.default.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRouting');
139
+ /** recursive */ true).find((n) => typescript_1.default.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRendering');
245
140
  if (!functionCall) {
246
- throw new schematics_1.SchematicsException(`Cannot find the "provideServerRouting" function call in "${configFilePath}".`);
141
+ throw new schematics_1.SchematicsException(`Cannot find the "provideServerRendering" function call in "${configFilePath}".`);
247
142
  }
248
143
  recorder = host.beginUpdate(configFilePath);
249
- recorder.insertLeft(functionCall.end - 1, `, withAppShell(AppShellComponent)`);
144
+ recorder.insertLeft(functionCall.end - 1, `, withAppShell(AppShell)`);
250
145
  (0, change_1.applyToUpdateRecorder)(recorder, [
251
146
  (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'withAppShell', '@angular/ssr'),
252
- (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'AppShellComponent', './app-shell/app-shell.component'),
147
+ (0, ast_utils_1.insertImport)(configSourceFile, configFilePath, 'AppShell', './app-shell/app-shell'),
253
148
  ]);
254
149
  host.commitUpdate(recorder);
255
150
  };
@@ -258,17 +153,15 @@ function default_1(options) {
258
153
  return async (tree) => {
259
154
  const browserEntryPoint = await (0, util_1.getMainFilePath)(tree, options.project);
260
155
  const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(tree, browserEntryPoint);
156
+ const workspace = await (0, workspace_1.getWorkspace)(tree);
157
+ const project = workspace.projects.get(options.project);
158
+ if (!project) {
159
+ throw (0, project_targets_1.targetBuildNotFoundError)();
160
+ }
261
161
  return (0, schematics_1.chain)([
262
162
  validateProject(browserEntryPoint),
263
163
  (0, schematics_1.schematic)('server', options),
264
- ...(options.serverRouting
265
- ? [(0, schematics_1.noop)()]
266
- : isStandalone
267
- ? [addStandaloneServerRoute(options)]
268
- : [addServerRoutes(options)]),
269
- options.serverRouting
270
- ? addServerRoutingConfig(options, isStandalone)
271
- : addAppShellConfigToWorkspace(options),
164
+ addServerRoutingConfig(options, isStandalone),
272
165
  (0, schematics_1.schematic)('component', {
273
166
  name: 'app-shell',
274
167
  module: 'app.module.server.ts',
@@ -6,9 +6,4 @@ export type Schema = {
6
6
  * The name of the project where the app-shell should be generated.
7
7
  */
8
8
  project: string;
9
- /**
10
- * Set up a server application using the Server Routing and App Engine APIs (Developer
11
- * Preview).
12
- */
13
- serverRouting?: boolean;
14
9
  };
@@ -12,11 +12,6 @@
12
12
  "$default": {
13
13
  "$source": "projectName"
14
14
  }
15
- },
16
- "serverRouting": {
17
- "description": "Set up a server application using the Server Routing and App Engine APIs (Developer Preview).",
18
- "type": "boolean",
19
- "default": false
20
15
  }
21
16
  },
22
17
  "required": ["project"]
@@ -2,17 +2,17 @@ import { NgModule<% if(experimentalZoneless) { %>, provideExperimentalZonelessCh
2
2
  import { BrowserModule } from '@angular/platform-browser';
3
3
  <% if (routing) { %>
4
4
  import { AppRoutingModule } from './app-routing.module';<% } %>
5
- import { AppComponent } from './app.component';
5
+ import { App } from './app';
6
6
 
7
7
  @NgModule({
8
8
  declarations: [
9
- AppComponent
9
+ App
10
10
  ],
11
11
  imports: [
12
12
  BrowserModule<% if (routing) { %>,
13
13
  AppRoutingModule<% } %>
14
14
  ],
15
15
  providers: [<% if (experimentalZoneless) { %>provideExperimentalZonelessChangeDetection()<% } %>],
16
- bootstrap: [AppComponent]
16
+ bootstrap: [App]
17
17
  })
18
18
  export class AppModule { }
@@ -1,35 +1,35 @@
1
1
  <% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
2
2
  <% } %>import { TestBed } from '@angular/core/testing';<% if (routing) { %>
3
3
  import { RouterModule } from '@angular/router';<% } %>
4
- import { AppComponent } from './app.component';
4
+ import { App } from './app';
5
5
 
6
- describe('AppComponent', () => {
6
+ describe('App', () => {
7
7
  beforeEach(async () => {
8
8
  await TestBed.configureTestingModule({<% if (routing) { %>
9
9
  imports: [
10
10
  RouterModule.forRoot([])
11
11
  ],<% } %>
12
12
  declarations: [
13
- AppComponent
13
+ App
14
14
  ],<% if(experimentalZoneless) { %>
15
15
  providers: [provideExperimentalZonelessChangeDetection()]<% } %>
16
16
  }).compileComponents();
17
17
  });
18
18
 
19
19
  it('should create the app', () => {
20
- const fixture = TestBed.createComponent(AppComponent);
20
+ const fixture = TestBed.createComponent(App);
21
21
  const app = fixture.componentInstance;
22
22
  expect(app).toBeTruthy();
23
23
  });
24
24
 
25
25
  it(`should have as title '<%= name %>'`, () => {
26
- const fixture = TestBed.createComponent(AppComponent);
26
+ const fixture = TestBed.createComponent(App);
27
27
  const app = fixture.componentInstance;
28
28
  expect(app.title).toEqual('<%= name %>');
29
29
  });
30
30
 
31
31
  it('should render title', () => {
32
- const fixture = TestBed.createComponent(AppComponent);
32
+ const fixture = TestBed.createComponent(App);
33
33
  fixture.detectChanges();
34
34
  const compiled = fixture.nativeElement as HTMLElement;
35
35
  expect(compiled.querySelector('h1')?.textContent).toContain('Hello, <%= name %>');
@@ -9,11 +9,11 @@ import { Component } from '@angular/core';
9
9
  %><router-outlet /><%
10
10
  } %>
11
11
  `,<% } else { %>
12
- templateUrl: './app.component.ng.html',<% } %>
12
+ templateUrl: './app.ng.html',<% } %>
13
13
  standalone: false,<% if(inlineStyle) { %>
14
14
  styles: []<% } else { %>
15
- styleUrl: './app.component.<%= style %>'<% } %>
15
+ styleUrl: './app.<%= style %>'<% } %>
16
16
  })
17
- export class AppComponent {
17
+ export class App {
18
18
  title = '<%= name %>';
19
19
  }
@@ -1,8 +1,8 @@
1
1
  <% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';
2
- <% }%>import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2
+ <% }%>import { platformBrowser } from '@angular/platform-browser';
3
3
  import { AppModule } from './app/app.module';
4
4
 
5
- platformBrowserDynamic().bootstrapModule(AppModule, {
5
+ platformBrowser().bootstrapModule(AppModule, {
6
6
  <% if(!experimentalZoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
7
7
  defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
8
8
  })
@@ -1,29 +1,29 @@
1
1
  <% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
2
2
  <% } %>import { TestBed } from '@angular/core/testing';
3
- import { AppComponent } from './app.component';
3
+ import { App } from './app';
4
4
 
5
- describe('AppComponent', () => {
5
+ describe('App', () => {
6
6
  beforeEach(async () => {
7
7
  await TestBed.configureTestingModule({
8
- imports: [AppComponent],<% if(experimentalZoneless) { %>
8
+ imports: [App],<% if(experimentalZoneless) { %>
9
9
  providers: [provideExperimentalZonelessChangeDetection()]<% } %>
10
10
  }).compileComponents();
11
11
  });
12
12
 
13
13
  it('should create the app', () => {
14
- const fixture = TestBed.createComponent(AppComponent);
14
+ const fixture = TestBed.createComponent(App);
15
15
  const app = fixture.componentInstance;
16
16
  expect(app).toBeTruthy();
17
17
  });
18
18
 
19
19
  it(`should have the '<%= name %>' title`, () => {
20
- const fixture = TestBed.createComponent(AppComponent);
20
+ const fixture = TestBed.createComponent(App);
21
21
  const app = fixture.componentInstance;
22
22
  expect(app.title).toEqual('<%= name %>');
23
23
  });
24
24
 
25
25
  it('should render title', () => {
26
- const fixture = TestBed.createComponent(AppComponent);
26
+ const fixture = TestBed.createComponent(App);
27
27
  fixture.detectChanges();
28
28
  const compiled = fixture.nativeElement as HTMLElement;
29
29
  expect(compiled.querySelector('h1')?.textContent).toContain('Hello, <%= name %>');
@@ -11,10 +11,10 @@ import { RouterOutlet } from '@angular/router';<% } %>
11
11
  %><router-outlet /><%
12
12
  } %>
13
13
  `,<% } else { %>
14
- templateUrl: './app.component.ng.html',<% } if(inlineStyle) { %>
14
+ templateUrl: './app.ng.html',<% } if(inlineStyle) { %>
15
15
  styles: [],<% } else { %>
16
- styleUrl: './app.component.<%= style %>'<% } %>
16
+ styleUrl: './app.<%= style %>'<% } %>
17
17
  })
18
- export class AppComponent {
18
+ export class App {
19
19
  title = '<%= name %>';
20
20
  }
@@ -1,6 +1,6 @@
1
1
  import { bootstrapApplication } from '@angular/platform-browser';
2
2
  import { appConfig } from './app/app.config';
3
- import { AppComponent } from './app/app.component';
3
+ import { App } from './app/app';
4
4
 
5
- bootstrapApplication(AppComponent, appConfig)
5
+ bootstrapApplication(App, appConfig)
6
6
  .catch((err) => console.error(err));
@@ -78,7 +78,6 @@ function default_1(options) {
78
78
  options.ssr
79
79
  ? (0, schematics_1.schematic)('ssr', {
80
80
  project: options.name,
81
- serverRouting: options.serverRouting,
82
81
  skipInstall: true,
83
82
  })
84
83
  : (0, schematics_1.noop)(),
@@ -196,7 +195,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
196
195
  builder: workspace_models_1.Builders.BuildApplication,
197
196
  defaultConfiguration: 'production',
198
197
  options: {
199
- outputPath: `dist/${folderName}`,
200
198
  index: `${sourceRoot}/index.html`,
201
199
  browser: `${sourceRoot}/main.ts`,
202
200
  polyfills: options.experimentalZoneless ? [] : ['zone.js'],
@@ -204,7 +202,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
204
202
  inlineStyleLanguage,
205
203
  assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
206
204
  styles: [`${sourceRoot}/styles.${options.style}`],
207
- scripts: [],
208
205
  },
209
206
  configurations: {
210
207
  production: {
@@ -244,7 +241,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
244
241
  inlineStyleLanguage,
245
242
  assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
246
243
  styles: [`${sourceRoot}/styles.${options.style}`],
247
- scripts: [],
248
244
  },
249
245
  },
250
246
  },
@@ -47,11 +47,6 @@ export type Schema = {
47
47
  * and modules for managing navigation between different views in your application.
48
48
  */
49
49
  routing?: boolean;
50
- /**
51
- * Set up a server application using the Server Routing and App Engine APIs (Developer
52
- * Preview).
53
- */
54
- serverRouting?: boolean;
55
50
  /**
56
51
  * Skip the automatic installation of packages. You will need to manually install the
57
52
  * dependencies later.
@@ -118,10 +118,6 @@
118
118
  "default": false,
119
119
  "x-user-analytics": "ep.ng_ssr"
120
120
  },
121
- "serverRouting": {
122
- "description": "Set up a server application using the Server Routing and App Engine APIs (Developer Preview).",
123
- "type": "boolean"
124
- },
125
121
  "experimentalZoneless": {
126
122
  "description": "Generate an application that does not use `zone.js`.",
127
123
  "type": "boolean",
@@ -36,6 +36,8 @@ function default_1(options) {
36
36
  options.path = (0, workspace_1.buildDefaultPath)(project);
37
37
  }
38
38
  options.module = (0, find_module_1.findModuleFromOptions)(host, options);
39
+ // Schematic templates require a defined type value
40
+ options.type ??= '';
39
41
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
40
42
  options.name = parsedPath.name;
41
43
  options.path = parsedPath.path;
@@ -93,8 +93,7 @@
93
93
  },
94
94
  "type": {
95
95
  "type": "string",
96
- "description": "Append a custom type to the component's filename. For example, if you set the type to `container`, the file will be named `my-component.container.ts`.",
97
- "default": "Component"
96
+ "description": "Append a custom type to the component's filename. For example, if you set the type to `container`, the file will be named `my-component.container.ts`."
98
97
  },
99
98
  "skipTests": {
100
99
  "type": "boolean",
@@ -0,0 +1,8 @@
1
+ import { <%= classify(name) %><%= classify(type) %> } from './<%= dasherize(name) %><%= type ? '.' + dasherize(type) : '' %>';
2
+
3
+ describe('<%= classify(name) %><%= classify(type) %>', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new <%= classify(name) %><%= classify(type) %>();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -4,7 +4,7 @@ import { Directive } from '@angular/core';
4
4
  selector: '[<%= selector %>]'<% if(!standalone) {%>,
5
5
  standalone: false<%}%>
6
6
  })
7
- export class <%= classify(name) %>Directive {
7
+ export class <%= classify(name) %><%= classify(type) %> {
8
8
 
9
9
  constructor() { }
10
10
 
@@ -11,6 +11,7 @@ exports.default = default_1;
11
11
  const schematics_1 = require("@angular-devkit/schematics");
12
12
  const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
13
13
  const find_module_1 = require("../utility/find-module");
14
+ const generate_from_files_1 = require("../utility/generate-from-files");
14
15
  const parse_name_1 = require("../utility/parse-name");
15
16
  const validation_1 = require("../utility/validation");
16
17
  const workspace_1 = require("../utility/workspace");
@@ -35,27 +36,20 @@ function default_1(options) {
35
36
  options.path = (0, workspace_1.buildDefaultPath)(project);
36
37
  }
37
38
  options.module = (0, find_module_1.findModuleFromOptions)(host, options);
39
+ // Schematic templates require a defined type value
40
+ options.type ??= '';
38
41
  const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
39
42
  options.name = parsedPath.name;
40
43
  options.path = parsedPath.path;
41
44
  options.selector = options.selector || buildSelector(options, project.prefix || '');
42
45
  (0, validation_1.validateHtmlSelector)(options.selector);
43
46
  (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
44
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
45
- options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
46
- (0, schematics_1.applyTemplates)({
47
- ...schematics_1.strings,
48
- 'if-flat': (s) => (options.flat ? '' : s),
49
- ...options,
50
- }),
51
- (0, schematics_1.move)(parsedPath.path),
52
- ]);
53
47
  return (0, schematics_1.chain)([
54
48
  (0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
55
49
  type: 'directive',
56
50
  ...options,
57
51
  }),
58
- (0, schematics_1.mergeWith)(templateSource),
52
+ (0, generate_from_files_1.generateFromFiles)(options),
59
53
  ]);
60
54
  };
61
55
  }
@@ -59,4 +59,9 @@ export type Schema = {
59
59
  * other standalone components or directives.
60
60
  */
61
61
  standalone?: boolean;
62
+ /**
63
+ * Append a custom type to the directive's filename. For example, if you set the type to
64
+ * `directive`, the file will be named `example.directive.ts`.
65
+ */
66
+ type?: string;
62
67
  };
@@ -80,6 +80,10 @@
80
80
  "type": "boolean",
81
81
  "default": false,
82
82
  "description": "Automatically export the directive from the specified NgModule, making it accessible to other modules in the application."
83
+ },
84
+ "type": {
85
+ "type": "string",
86
+ "description": "Append a custom type to the directive's filename. For example, if you set the type to `directive`, the file will be named `example.directive.ts`."
83
87
  }
84
88
  },
85
89
  "required": ["name", "project"]
@@ -2,6 +2,5 @@
2
2
  * Public API Surface of <%= dasherize(name) %>
3
3
  */
4
4
 
5
- export * from './lib/<%= dasherize(name) %>.service';
6
- export * from './lib/<%= dasherize(name) %>.component';<% if (!standalone) { %>
5
+ export * from './lib/<%= dasherize(name) %>';<% if (!standalone) { %>
7
6
  export * from './lib/<%= dasherize(name) %>.module';<% } %>
package/library/index.js CHANGED
@@ -155,12 +155,6 @@ function default_1(options) {
155
155
  standalone: options.standalone,
156
156
  project: packageName,
157
157
  }),
158
- (0, schematics_1.schematic)('service', {
159
- name: options.name,
160
- flat: true,
161
- path: sourceDir,
162
- project: packageName,
163
- }),
164
158
  (_tree, context) => {
165
159
  if (!options.skipPackageJson && !options.skipInstall) {
166
160
  context.addTask(new tasks_1.NodePackageInstallTask());
@@ -1,5 +1,15 @@
1
1
  {
2
2
  "schematics": {
3
+ "replace-provide-server-rendering-import": {
4
+ "version": "20.0.0",
5
+ "factory": "./replace-provide-server-rendering-import/migration",
6
+ "description": "Migrate imports of 'provideServerRendering' from '@angular/platform-server' to '@angular/ssr'."
7
+ },
8
+ "replace-provide-server-routing": {
9
+ "version": "20.0.0",
10
+ "factory": "./replace-provide-server-routing/migration",
11
+ "description": "Migrate 'provideServerRendering' to use 'withRoutes' and remove 'provideServerRouting' from '@angular/ssr'."
12
+ },
3
13
  "use-application-builder": {
4
14
  "version": "20.0.0",
5
15
  "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 { Rule } from '@angular-devkit/schematics';
9
+ export default function (): Rule;