├── LICENSE ├── README.md ├── app-shell ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── application ├── files │ ├── common-files │ │ ├── public │ │ │ └── favicon.ico.template │ │ ├── src │ │ │ ├── app │ │ │ │ └── app.html.template │ │ │ ├── index.html.template │ │ │ └── styles.__style__.template │ │ ├── tsconfig.app.json.template │ │ └── tsconfig.spec.json.template │ ├── module-files │ │ └── src │ │ │ ├── app │ │ │ ├── app-module.ts.template │ │ │ ├── app.spec.ts.template │ │ │ └── app.ts.template │ │ │ └── main.ts.template │ └── standalone-files │ │ └── src │ │ ├── app │ │ ├── app.config.ts.template │ │ ├── app.routes.ts.template │ │ ├── app.spec.ts.template │ │ └── app.ts.template │ │ └── main.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── class ├── files │ ├── __name@dasherize__.__type__.spec.ts.template │ └── __name@dasherize__.__type__.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── collection.json ├── component ├── files │ └── __name@dasherize@if-flat__ │ │ ├── __name@dasherize__.__type@dasherize__.__style__.template │ │ ├── __name@dasherize__.__type@dasherize__.spec.ts.template │ │ ├── __name@dasherize__.__type@dasherize__.ts.template │ │ └── __name@dasherize__.__type@dasherize____ngext__.html.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── config ├── .browserslistrc ├── files │ ├── .browserslistrc.template │ └── karma.conf.js.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── directive ├── files │ ├── __name@dasherize__.__type@dasherize__.spec.ts.template │ └── __name@dasherize__.__type@dasherize__.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── e2e ├── files │ ├── protractor.conf.js.template │ ├── src │ │ ├── app.e2e-spec.ts.template │ │ └── app.po.ts.template │ └── tsconfig.json.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── enum ├── files │ └── __name@dasherize__.__type__.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── environments ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── guard ├── implements-files │ ├── __name@dasherize____typeSeparator__guard.spec.ts.template │ └── __name@dasherize____typeSeparator__guard.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js ├── schema.json └── type-files │ ├── __name@dasherize____typeSeparator__guard.spec.ts.template │ └── __name@dasherize____typeSeparator__guard.ts.template ├── interceptor ├── class-files │ ├── __name@dasherize____typeSeparator__interceptor.spec.ts.template │ └── __name@dasherize____typeSeparator__interceptor.ts.template ├── functional-files │ ├── __name@dasherize____typeSeparator__interceptor.spec.ts.template │ └── __name@dasherize____typeSeparator__interceptor.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── interface ├── files │ └── __name@dasherize__.__type__.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── library ├── files │ ├── README.md.template │ ├── ng-package.json.template │ ├── package.json.template │ ├── src │ │ └── __entryFile__.ts.template │ ├── tsconfig.lib.json.template │ ├── tsconfig.lib.prod.json.template │ └── tsconfig.spec.json.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── migrations ├── migration-collection.json ├── previous-style-guide │ ├── migration.d.ts │ └── migration.js ├── replace-provide-server-rendering-import │ ├── migration.d.ts │ └── migration.js ├── replace-provide-server-routing │ ├── migration.d.ts │ └── migration.js ├── update-module-resolution │ ├── migration.d.ts │ └── migration.js └── use-application-builder │ ├── css-import-lexer.d.ts │ ├── css-import-lexer.js │ ├── migration.d.ts │ └── migration.js ├── module ├── files │ └── __name@dasherize@if-flat__ │ │ ├── __name@dasherize__-routing__typeSeparator__module.ts.template │ │ └── __name@dasherize____typeSeparator__module.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── ng-new ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── package.json ├── pipe ├── files │ ├── __name@dasherize____typeSeparator__pipe.spec.ts.template │ └── __name@dasherize____typeSeparator__pipe.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── resolver ├── class-files │ ├── __name@dasherize____typeSeparator__resolver.spec.ts.template │ └── __name@dasherize____typeSeparator__resolver.ts.template ├── functional-files │ ├── __name@dasherize____typeSeparator__resolver.spec.ts.template │ └── __name@dasherize____typeSeparator__resolver.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── server ├── files │ ├── application-builder │ │ ├── ngmodule-src │ │ │ ├── app │ │ │ │ ├── app.module.server.ts.template │ │ │ │ └── app.routes.server.ts.template │ │ │ └── main.server.ts.template │ │ └── standalone-src │ │ │ ├── app │ │ │ ├── app.config.server.ts.template │ │ │ └── app.routes.server.ts.template │ │ │ └── main.server.ts.template │ └── server-builder │ │ ├── ngmodule-src │ │ ├── app │ │ │ └── app.module.server.ts.template │ │ └── main.server.ts.template │ │ ├── root │ │ └── tsconfig.server.json.template │ │ └── standalone-src │ │ ├── app │ │ └── app.config.server.ts.template │ │ └── main.server.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── service-worker ├── files │ └── ngsw-config.json.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── service ├── files │ ├── __name@dasherize__.__type@dasherize__.spec.ts.template │ └── __name@dasherize__.__type@dasherize__.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json ├── ssr ├── files │ ├── application-builder │ │ └── server.ts.template │ └── server-builder │ │ └── server.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js ├── schema.json ├── tty.d.ts └── tty.js ├── third_party └── github.com │ └── Microsoft │ └── TypeScript │ ├── LICENSE │ └── lib │ ├── typescript.d.ts │ └── typescript.js ├── uniqueId ├── utility ├── add-declaration-to-ng-module.d.ts ├── add-declaration-to-ng-module.js ├── ast-utils.d.ts ├── ast-utils.js ├── change.d.ts ├── change.js ├── dependencies.d.ts ├── dependencies.js ├── dependency.d.ts ├── dependency.js ├── eol.d.ts ├── eol.js ├── find-module.d.ts ├── find-module.js ├── generate-from-files.d.ts ├── generate-from-files.js ├── index.d.ts ├── index.js ├── json-file.d.ts ├── json-file.js ├── latest-versions.d.ts ├── latest-versions.js ├── latest-versions │ └── package.json ├── ng-ast-utils.d.ts ├── ng-ast-utils.js ├── parse-name.d.ts ├── parse-name.js ├── paths.d.ts ├── paths.js ├── project-targets.d.ts ├── project-targets.js ├── standalone │ ├── app_component.d.ts │ ├── app_component.js │ ├── app_config.d.ts │ ├── app_config.js │ ├── code_block.d.ts │ ├── code_block.js │ ├── index.d.ts │ ├── index.js │ ├── rules.d.ts │ ├── rules.js │ ├── util.d.ts │ └── util.js ├── validation.d.ts ├── validation.js ├── workspace-models.d.ts ├── workspace-models.js ├── workspace.d.ts └── workspace.js ├── web-worker ├── files │ ├── worker-tsconfig │ │ └── tsconfig.worker.json.template │ └── worker │ │ └── __name@dasherize__.worker.ts.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json └── workspace ├── files ├── README.md.template ├── __dot__editorconfig.template ├── __dot__gitignore.template ├── __dot__vscode │ ├── extensions.json.template │ ├── launch.json.template │ └── tasks.json.template ├── angular.json.template ├── package.json.template └── tsconfig.json.template ├── index.d.ts ├── index.js ├── schema.d.ts ├── schema.js └── schema.json /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2025 Google LLC. https://angular.dev/license 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /app-shell/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as AppShellOptions } from './schema'; 10 | export default function (options: AppShellOptions): Rule; 11 | -------------------------------------------------------------------------------- /app-shell/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Configures your project to generate an app-shell during build time. 3 | */ 4 | export type Schema = { 5 | /** 6 | * The name of the project where the app-shell should be generated. 7 | */ 8 | project: string; 9 | }; 10 | -------------------------------------------------------------------------------- /app-shell/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /app-shell/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularAppShell", 4 | "title": "Angular AppShell Options Schema", 5 | "type": "object", 6 | "description": "Configures your project to generate an app-shell during build time.", 7 | "additionalProperties": false, 8 | "properties": { 9 | "project": { 10 | "type": "string", 11 | "description": "The name of the project where the app-shell should be generated.", 12 | "$default": { 13 | "$source": "projectName" 14 | } 15 | } 16 | }, 17 | "required": ["project"] 18 | } 19 | -------------------------------------------------------------------------------- /application/files/common-files/public/favicon.ico.template: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/schematics-angular-builds/03910c59362df24355fe2b31467b23fafcb01f00/application/files/common-files/public/favicon.ico.template -------------------------------------------------------------------------------- /application/files/common-files/src/index.html.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= utils.classify(name) %> 6 | 7 | 8 | 9 | 10 | 11 | <<%= selector %>>> 12 | 13 | 14 | -------------------------------------------------------------------------------- /application/files/common-files/src/styles.__style__.template: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /application/files/common-files/tsconfig.app.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/app", 7 | "types": [] 8 | }, 9 | "include": [ 10 | "src/**/*.ts" 11 | ], 12 | "exclude": [ 13 | "src/**/*.spec.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /application/files/common-files/tsconfig.spec.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/spec", 7 | "types": [ 8 | "jasmine" 9 | ] 10 | }, 11 | "include": [ 12 | "src/**/*.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /application/files/module-files/src/app/app-module.ts.template: -------------------------------------------------------------------------------- 1 | import { NgModule, provideBrowserGlobalErrorListeners<% if(zoneless) { %>, provideZonelessChangeDetection<% } %> } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | <% if (routing) { %> 4 | import { AppRoutingModule } from './app-routing-module';<% } %> 5 | import { App } from './app'; 6 | 7 | @NgModule({ 8 | declarations: [ 9 | App 10 | ], 11 | imports: [ 12 | BrowserModule<% if (routing) { %>, 13 | AppRoutingModule<% } %> 14 | ], 15 | providers: [ 16 | provideBrowserGlobalErrorListeners()<% if (zoneless) { %>, 17 | provideZonelessChangeDetection()<% } %> 18 | ], 19 | bootstrap: [App] 20 | }) 21 | export class AppModule { } 22 | -------------------------------------------------------------------------------- /application/files/module-files/src/app/app.spec.ts.template: -------------------------------------------------------------------------------- 1 | <% if(zoneless) { %>import { provideZonelessChangeDetection } from '@angular/core'; 2 | <% } %>import { TestBed } from '@angular/core/testing';<% if (routing) { %> 3 | import { RouterModule } from '@angular/router';<% } %> 4 | import { App } from './app'; 5 | 6 | describe('App', () => { 7 | beforeEach(async () => { 8 | await TestBed.configureTestingModule({<% if (routing) { %> 9 | imports: [ 10 | RouterModule.forRoot([]) 11 | ],<% } %> 12 | declarations: [ 13 | App 14 | ],<% if(zoneless) { %> 15 | providers: [provideZonelessChangeDetection()]<% } %> 16 | }).compileComponents(); 17 | }); 18 | 19 | it('should create the app', () => { 20 | const fixture = TestBed.createComponent(App); 21 | const app = fixture.componentInstance; 22 | expect(app).toBeTruthy(); 23 | }); 24 | 25 | it('should render title', () => { 26 | const fixture = TestBed.createComponent(App); 27 | fixture.detectChanges(); 28 | const compiled = fixture.nativeElement as HTMLElement; 29 | expect(compiled.querySelector('h1')?.textContent).toContain('Hello, <%= name %>'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /application/files/module-files/src/app/app.ts.template: -------------------------------------------------------------------------------- 1 | import { Component, signal } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: '<%= selector %>',<% if(inlineTemplate) { %> 5 | template: ` 6 |

Welcome to {{ title() }}!

7 | 8 | <% if (routing) { 9 | %><% 10 | } %> 11 | `,<% } else { %> 12 | templateUrl: './app.html',<% } %> 13 | standalone: false,<% if(inlineStyle) { %> 14 | styles: []<% } else { %> 15 | styleUrl: './app.<%= style %>'<% } %> 16 | }) 17 | export class App { 18 | protected readonly title = signal('<%= name %>'); 19 | } 20 | -------------------------------------------------------------------------------- /application/files/module-files/src/main.ts.template: -------------------------------------------------------------------------------- 1 | <% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core'; 2 | <% }%>import { platformBrowser } from '@angular/platform-browser'; 3 | import { AppModule } from './app/app-module'; 4 | 5 | platformBrowser().bootstrapModule(AppModule, { 6 | <% if(!zoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %> 7 | defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %> 8 | }) 9 | .catch(err => console.error(err)); 10 | -------------------------------------------------------------------------------- /application/files/standalone-files/src/app/app.config.ts.template: -------------------------------------------------------------------------------- 1 | import { ApplicationConfig, provideBrowserGlobalErrorListeners, <% if(!zoneless) { %>provideZoneChangeDetection<% } else { %>provideZonelessChangeDetection<% } %> } from '@angular/core';<% if (routing) { %> 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { routes } from './app.routes';<% } %> 5 | 6 | export const appConfig: ApplicationConfig = { 7 | providers: [ 8 | provideBrowserGlobalErrorListeners(), 9 | <% if(zoneless) { %>provideZonelessChangeDetection()<% } else { %>provideZoneChangeDetection({ eventCoalescing: true })<% } %>, 10 | <% if (routing) {%>provideRouter(routes)<% } %> 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /application/files/standalone-files/src/app/app.routes.ts.template: -------------------------------------------------------------------------------- 1 | import { Routes } from '@angular/router'; 2 | 3 | export const routes: Routes = []; 4 | -------------------------------------------------------------------------------- /application/files/standalone-files/src/app/app.spec.ts.template: -------------------------------------------------------------------------------- 1 | <% if(zoneless) { %>import { provideZonelessChangeDetection } from '@angular/core'; 2 | <% } %>import { TestBed } from '@angular/core/testing'; 3 | import { App } from './app'; 4 | 5 | describe('App', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [App],<% if(zoneless) { %> 9 | providers: [provideZonelessChangeDetection()]<% } %> 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(App); 15 | const app = fixture.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it('should render title', () => { 20 | const fixture = TestBed.createComponent(App); 21 | fixture.detectChanges(); 22 | const compiled = fixture.nativeElement as HTMLElement; 23 | expect(compiled.querySelector('h1')?.textContent).toContain('Hello, <%= name %>'); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /application/files/standalone-files/src/app/app.ts.template: -------------------------------------------------------------------------------- 1 | import { Component, signal } from '@angular/core';<% if(routing) { %> 2 | import { RouterOutlet } from '@angular/router';<% } %> 3 | 4 | @Component({ 5 | selector: '<%= selector %>', 6 | imports: [<% if(routing) { %>RouterOutlet<% } %>],<% if(inlineTemplate) { %> 7 | template: ` 8 |

Welcome to {{ title() }}!

9 | 10 | <% if (routing) { 11 | %><% 12 | } %> 13 | `,<% } else { %> 14 | templateUrl: './app.html',<% } if(inlineStyle) { %> 15 | styles: [],<% } else { %> 16 | styleUrl: './app.<%= style %>'<% } %> 17 | }) 18 | export class App { 19 | protected readonly title = signal('<%= name %>'); 20 | } 21 | -------------------------------------------------------------------------------- /application/files/standalone-files/src/main.ts.template: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { appConfig } from './app/app.config'; 3 | import { App } from './app/app'; 4 | 5 | bootstrapApplication(App, appConfig) 6 | .catch((err) => console.error(err)); 7 | -------------------------------------------------------------------------------- /application/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ApplicationOptions } from './schema'; 10 | export default function (options: ApplicationOptions): Rule; 11 | -------------------------------------------------------------------------------- /application/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.ViewEncapsulation = exports.Style = void 0; 6 | /** 7 | * The type of stylesheet files to be created for components in the application. 8 | */ 9 | var Style; 10 | (function (Style) { 11 | Style["Css"] = "css"; 12 | Style["Less"] = "less"; 13 | Style["Sass"] = "sass"; 14 | Style["Scss"] = "scss"; 15 | })(Style || (exports.Style = Style = {})); 16 | /** 17 | * Sets the view encapsulation mode for the application's components. This determines how 18 | * component styles are scoped and applied. 19 | */ 20 | var ViewEncapsulation; 21 | (function (ViewEncapsulation) { 22 | ViewEncapsulation["Emulated"] = "Emulated"; 23 | ViewEncapsulation["None"] = "None"; 24 | ViewEncapsulation["ShadowDom"] = "ShadowDom"; 25 | })(ViewEncapsulation || (exports.ViewEncapsulation = ViewEncapsulation = {})); 26 | -------------------------------------------------------------------------------- /class/files/__name@dasherize__.__type__.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { <%= classify(name) %> } from './<%= dasherize(name) %><%= type %>'; 2 | 3 | describe('<%= classify(name) %>', () => { 4 | it('should create an instance', () => { 5 | expect(new <%= classify(name) %>()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /class/files/__name@dasherize__.__type__.ts.template: -------------------------------------------------------------------------------- 1 | export class <%= classify(name) %> { 2 | } 3 | -------------------------------------------------------------------------------- /class/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ClassOptions } from './schema'; 10 | export default function (options: ClassOptions): Rule; 11 | -------------------------------------------------------------------------------- /class/index.js: -------------------------------------------------------------------------------- 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 generate_from_files_1 = require("../utility/generate-from-files"); 12 | function default_1(options) { 13 | return (0, generate_from_files_1.generateFromFiles)(options); 14 | } 15 | -------------------------------------------------------------------------------- /class/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new class in your project. Classes are the fundamental building blocks for 3 | * object-oriented programming in TypeScript. They provide a blueprint for creating objects 4 | * with properties and methods. This schematic helps you generate a new class with the basic 5 | * structure and optional test files. 6 | */ 7 | export type Schema = { 8 | /** 9 | * The name for the new class. This will be used to create the class file (e.g., 10 | * `my-class.ts`) and, if enabled, the corresponding test file `my-class.spec.ts`. 11 | */ 12 | name: string; 13 | /** 14 | * The path where the class file should be created, relative to the workspace root. If not 15 | * specified, the class will be created in the current directory. 16 | */ 17 | path?: string; 18 | /** 19 | * The name of the project where the class should be added. If not specified, the CLI will 20 | * determine the project from the current directory. 21 | */ 22 | project: string; 23 | /** 24 | * Skip the generation of a unit test file `spec.ts` for the new class. 25 | */ 26 | skipTests?: boolean; 27 | /** 28 | * Adds a custom type to the filename, allowing you to create more descriptive class names. 29 | * For example, if you set the type to `helper`, the filename will be `my-class.helper.ts`. 30 | */ 31 | type?: string; 32 | }; 33 | -------------------------------------------------------------------------------- /class/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /class/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularClass", 4 | "title": "Angular Class Options Schema", 5 | "type": "object", 6 | "description": "Creates a new class in your project. Classes are the fundamental building blocks for object-oriented programming in TypeScript. They provide a blueprint for creating objects with properties and methods. This schematic helps you generate a new class with the basic structure and optional test files.", 7 | "additionalProperties": false, 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new class. This will be used to create the class file (e.g., `my-class.ts`) and, if enabled, the corresponding test file `my-class.spec.ts`.", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the class?" 17 | }, 18 | "path": { 19 | "type": "string", 20 | "format": "path", 21 | "$default": { 22 | "$source": "workingDirectory" 23 | }, 24 | "description": "The path where the class file should be created, relative to the workspace root. If not specified, the class will be created in the current directory.", 25 | "visible": false 26 | }, 27 | "project": { 28 | "type": "string", 29 | "description": "The name of the project where the class should be added. If not specified, the CLI will determine the project from the current directory.", 30 | "$default": { 31 | "$source": "projectName" 32 | } 33 | }, 34 | "skipTests": { 35 | "type": "boolean", 36 | "description": "Skip the generation of a unit test file `spec.ts` for the new class.", 37 | "default": false 38 | }, 39 | "type": { 40 | "type": "string", 41 | "description": "Adds a custom type to the filename, allowing you to create more descriptive class names. For example, if you set the type to `helper`, the filename will be `my-class.helper.ts`." 42 | } 43 | }, 44 | "required": ["name", "project"] 45 | } 46 | -------------------------------------------------------------------------------- /component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.__style__.template: -------------------------------------------------------------------------------- 1 | <% if(displayBlock){ if(style != 'sass') { %>:host { 2 | display: block; 3 | } 4 | <% } else { %>\:host 5 | display: block; 6 | <% }} %> -------------------------------------------------------------------------------- /component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import <% if(!exportDefault) { %>{ <% }%><%= classify(name) %><%= classify(type) %> <% if(!exportDefault) {%>} <% }%>from './<%= dasherize(name) %><%= type ? '.' + dasherize(type): '' %>'; 4 | 5 | describe('<%= classify(name) %><%= classify(type) %>', () => { 6 | let component: <%= classify(name) %><%= classify(type) %>; 7 | let fixture: ComponentFixture<<%= classify(name) %><%= classify(type) %>>; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | <%= standalone ? 'imports' : 'declarations' %>: [<%= classify(name) %><%= classify(type) %>] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(<%= classify(name) %><%= classify(type) %>); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template: -------------------------------------------------------------------------------- 1 | import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core'; 2 | 3 | @Component({<% if(!skipSelector) {%> 4 | selector: '<%= selector %>',<%}%><% if(standalone) {%> 5 | imports: [],<%} else { %> 6 | standalone: false,<% }%><% if(inlineTemplate) { %> 7 | template: ` 8 |

9 | <%= dasherize(name) %> works! 10 |

11 | `<% } else { %> 12 | templateUrl: './<%= dasherize(name) %><%= type ? '.' + dasherize(type): '' %><%= ngext %>.html'<% } if(inlineStyle) { %>, 13 | styles: `<% if(displayBlock){ %> 14 | :host { 15 | display: block; 16 | } 17 | <% } %>`<% } else if (style !== 'none') { %>, 18 | styleUrl: './<%= dasherize(name) %><%= type ? '.' + dasherize(type): '' %>.<%= style %>'<% } %><% if(!!viewEncapsulation) { %>, 19 | encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>, 20 | changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %> 21 | }) 22 | export <% if(exportDefault) {%>default <%}%>class <%= classify(name) %><%= classify(type) %> { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize____ngext__.html.template: -------------------------------------------------------------------------------- 1 |

<%= dasherize(name) %> works!

2 | -------------------------------------------------------------------------------- /component/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ComponentOptions } from './schema'; 10 | export default function (options: ComponentOptions): Rule; 11 | -------------------------------------------------------------------------------- /component/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.ViewEncapsulation = exports.Style = exports.ChangeDetection = void 0; 6 | /** 7 | * Configures the change detection strategy for the component. 8 | */ 9 | var ChangeDetection; 10 | (function (ChangeDetection) { 11 | ChangeDetection["Default"] = "Default"; 12 | ChangeDetection["OnPush"] = "OnPush"; 13 | })(ChangeDetection || (exports.ChangeDetection = ChangeDetection = {})); 14 | /** 15 | * Specify the type of stylesheet to be created for the component, or `none` to skip 16 | * creating a stylesheet. 17 | */ 18 | var Style; 19 | (function (Style) { 20 | Style["Css"] = "css"; 21 | Style["Less"] = "less"; 22 | Style["None"] = "none"; 23 | Style["Sass"] = "sass"; 24 | Style["Scss"] = "scss"; 25 | })(Style || (exports.Style = Style = {})); 26 | /** 27 | * Sets the view encapsulation mode for the component. This determines how the component's 28 | * styles are scoped and applied. 29 | */ 30 | var ViewEncapsulation; 31 | (function (ViewEncapsulation) { 32 | ViewEncapsulation["Emulated"] = "Emulated"; 33 | ViewEncapsulation["None"] = "None"; 34 | ViewEncapsulation["ShadowDom"] = "ShadowDom"; 35 | })(ViewEncapsulation || (exports.ViewEncapsulation = ViewEncapsulation = {})); 36 | -------------------------------------------------------------------------------- /config/.browserslistrc: -------------------------------------------------------------------------------- 1 | Chrome >= 107 2 | ChromeAndroid >= 107 3 | Edge >= 107 4 | Firefox >= 104 5 | FirefoxAndroid >= 104 6 | Safari >= 16 7 | iOS >= 16 8 | -------------------------------------------------------------------------------- /config/files/.browserslistrc.template: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For Angular's browser support policy, please see: 6 | # https://angular.dev/reference/versions#browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | <%= config %> 12 | -------------------------------------------------------------------------------- /config/files/karma.conf.js.template: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine'<% if (needDevkitPlugin) { %>, '@angular-devkit/build-angular'<% } %>], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'),<% if (needDevkitPlugin) { %> 13 | require('@angular-devkit/build-angular/plugins/karma')<% } %> 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | }, 23 | jasmineHtmlReporter: { 24 | suppressAll: true // removes the duplicated traces 25 | }, 26 | coverageReporter: { 27 | dir: require('path').join(__dirname, '<%= relativePathToWorkspaceRoot %>/coverage/<%= folderName %>'), 28 | subdir: '.', 29 | reporters: [ 30 | { type: 'html' }, 31 | { type: 'text-summary' } 32 | ] 33 | }, 34 | reporters: ['progress', 'kjhtml'], 35 | browsers: ['Chrome'], 36 | restartOnFileChange: true 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /config/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ConfigOptions } from './schema'; 10 | export default function (options: ConfigOptions): Rule; 11 | -------------------------------------------------------------------------------- /config/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Generates configuration files for your project. These files control various aspects of 3 | * your project's build process, testing, and browser compatibility. This schematic helps 4 | * you create or update essential configuration files with ease. 5 | */ 6 | export type Schema = { 7 | /** 8 | * The name of the project where the configuration file should be created or updated. 9 | */ 10 | project: string; 11 | /** 12 | * Specifies the type of configuration file to generate. 13 | */ 14 | type: Type; 15 | }; 16 | /** 17 | * Specifies the type of configuration file to generate. 18 | */ 19 | export declare enum Type { 20 | Browserslist = "browserslist", 21 | Karma = "karma" 22 | } 23 | -------------------------------------------------------------------------------- /config/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.Type = void 0; 6 | /** 7 | * Specifies the type of configuration file to generate. 8 | */ 9 | var Type; 10 | (function (Type) { 11 | Type["Browserslist"] = "browserslist"; 12 | Type["Karma"] = "karma"; 13 | })(Type || (exports.Type = Type = {})); 14 | -------------------------------------------------------------------------------- /config/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularConfig", 4 | "title": "Angular Config File Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Generates configuration files for your project. These files control various aspects of your project's build process, testing, and browser compatibility. This schematic helps you create or update essential configuration files with ease.", 8 | "properties": { 9 | "project": { 10 | "type": "string", 11 | "description": "The name of the project where the configuration file should be created or updated.", 12 | "$default": { 13 | "$source": "projectName" 14 | } 15 | }, 16 | "type": { 17 | "type": "string", 18 | "description": "Specifies the type of configuration file to generate.", 19 | "enum": ["karma", "browserslist"], 20 | "x-prompt": "Which type of configuration file would you like to create?", 21 | "$default": { 22 | "$source": "argv", 23 | "index": 0 24 | } 25 | } 26 | }, 27 | "required": ["project", "type"] 28 | } 29 | -------------------------------------------------------------------------------- /directive/files/__name@dasherize__.__type@dasherize__.spec.ts.template: -------------------------------------------------------------------------------- 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 | }); 9 | -------------------------------------------------------------------------------- /directive/files/__name@dasherize__.__type@dasherize__.ts.template: -------------------------------------------------------------------------------- 1 | import { Directive } from '@angular/core'; 2 | 3 | @Directive({ 4 | selector: '[<%= selector %>]'<% if(!standalone) {%>, 5 | standalone: false<%}%> 6 | }) 7 | export class <%= classify(name) %><%= classify(type) %> { 8 | 9 | constructor() { } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /directive/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as DirectiveOptions } from './schema'; 10 | export default function (options: DirectiveOptions): Rule; 11 | -------------------------------------------------------------------------------- /directive/index.js: -------------------------------------------------------------------------------- 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 schematics_1 = require("@angular-devkit/schematics"); 12 | const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module"); 13 | const find_module_1 = require("../utility/find-module"); 14 | const generate_from_files_1 = require("../utility/generate-from-files"); 15 | const parse_name_1 = require("../utility/parse-name"); 16 | const validation_1 = require("../utility/validation"); 17 | const workspace_1 = require("../utility/workspace"); 18 | function buildSelector(options, projectPrefix) { 19 | let selector = options.name; 20 | if (options.prefix) { 21 | selector = `${options.prefix}-${selector}`; 22 | } 23 | else if (options.prefix === undefined && projectPrefix) { 24 | selector = `${projectPrefix}-${selector}`; 25 | } 26 | return schematics_1.strings.camelize(selector); 27 | } 28 | function default_1(options) { 29 | return async (host) => { 30 | const workspace = await (0, workspace_1.getWorkspace)(host); 31 | const project = workspace.projects.get(options.project); 32 | if (!project) { 33 | throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`); 34 | } 35 | if (options.path === undefined) { 36 | options.path = (0, workspace_1.buildDefaultPath)(project); 37 | } 38 | options.module = (0, find_module_1.findModuleFromOptions)(host, options); 39 | const parsedPath = (0, parse_name_1.parseName)(options.path, options.name); 40 | options.name = parsedPath.name; 41 | options.path = parsedPath.path; 42 | options.selector = options.selector || buildSelector(options, project.prefix || ''); 43 | (0, validation_1.validateHtmlSelector)(options.selector); 44 | (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name)); 45 | return (0, schematics_1.chain)([ 46 | (0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({ 47 | type: 'directive', 48 | ...options, 49 | }), 50 | (0, generate_from_files_1.generateFromFiles)(options), 51 | ]); 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /directive/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new directive in your project. Directives are used to extend the behavior or 3 | * appearance of HTML elements and components. They allow you to manipulate the DOM, add 4 | * custom attributes, and respond to events. This schematic generates the necessary files 5 | * and boilerplate code for a new directive. 6 | */ 7 | export type Schema = { 8 | /** 9 | * Automatically export the directive from the specified NgModule, making it accessible to 10 | * other modules in the application. 11 | */ 12 | export?: boolean; 13 | /** 14 | * Creates the new directive files at the top level of the current project. If set to false, 15 | * a new folder with the directive's name will be created to contain the files. 16 | */ 17 | flat?: boolean; 18 | /** 19 | * Specify the NgModule where the directive should be declared. If not provided, the CLI 20 | * will attempt to find the closest NgModule in the directive's path. 21 | */ 22 | module?: string; 23 | /** 24 | * The name for the new directive. This will be used to create the directive's class and 25 | * spec files (e.g., `my-directive.directive.ts` and `my-directive.directive.spec.ts`). 26 | */ 27 | name: string; 28 | /** 29 | * The path where the directive files should be created, relative to the workspace root. If 30 | * not provided, the directive will be created in the current directory. 31 | */ 32 | path?: string; 33 | /** 34 | * A prefix to be added to the directive's selector. For example, if the prefix is `app` and 35 | * the directive name is `highlight`, the selector will be `appHighlight`. 36 | */ 37 | prefix?: string; 38 | /** 39 | * The name of the project where the directive should be added. If not specified, the CLI 40 | * will determine the project from the current directory. 41 | */ 42 | project: string; 43 | /** 44 | * The HTML selector to use for this directive. If not provided, a selector will be 45 | * generated based on the directive's name (e.g., `appHighlight`). 46 | */ 47 | selector?: string; 48 | /** 49 | * Do not automatically import the new directive into its closest NgModule. 50 | */ 51 | skipImport?: boolean; 52 | /** 53 | * Skip the generation of a unit test file `spec.ts` for the new directive. 54 | */ 55 | skipTests?: boolean; 56 | /** 57 | * Generate a standalone directive. Standalone directives are self-contained and don't need 58 | * to be declared in an NgModule. They can be used independently or imported directly into 59 | * other standalone components or directives. 60 | */ 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; 67 | }; 68 | -------------------------------------------------------------------------------- /directive/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /e2e/files/protractor.conf.js.template: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | SELENIUM_PROMISE_MANAGER: false, 20 | baseUrl: 'http://localhost:4200/', 21 | framework: 'jasmine', 22 | jasmineNodeOpts: { 23 | showColors: true, 24 | defaultTimeoutInterval: 30000, 25 | print: function() {} 26 | }, 27 | onPrepare() { 28 | require('ts-node').register({ 29 | project: require('path').join(__dirname, './tsconfig.json') 30 | }); 31 | jasmine.getEnv().addReporter(new SpecReporter({ 32 | spec: { 33 | displayStacktrace: StacktraceOption.PRETTY 34 | } 35 | })); 36 | } 37 | }; -------------------------------------------------------------------------------- /e2e/files/src/app.e2e-spec.ts.template: -------------------------------------------------------------------------------- 1 | import { browser, logging } from 'protractor'; 2 | import { AppPage } from './app.po'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', async () => { 12 | await page.navigateTo(); 13 | expect(await page.getTitleText()).toEqual('Hello, <%= relatedAppName %>'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /e2e/files/src/app.po.ts.template: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | async navigateTo(): Promise { 5 | return browser.get(browser.baseUrl); 6 | } 7 | 8 | async getTitleText(): Promise { 9 | return element(by.css('h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/files/tsconfig.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/e2e", 7 | "module": "commonjs", 8 | "target": "es2019", 9 | "types": [ 10 | "jasmine", 11 | "node" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /e2e/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as E2eOptions } from './schema'; 10 | export default function (options: E2eOptions): Rule; 11 | -------------------------------------------------------------------------------- /e2e/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Generates a new, generic end-to-end test definition in the given project. 3 | */ 4 | export type Schema = { 5 | /** 6 | * The name of the application being tested. 7 | */ 8 | relatedAppName: string; 9 | /** 10 | * The HTML selector for the root component of the test app. 11 | */ 12 | rootSelector?: string; 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /e2e/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularE2eApp", 4 | "title": "Angular e2e Application Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Generates a new, generic end-to-end test definition in the given project.", 8 | "properties": { 9 | "rootSelector": { 10 | "description": "The HTML selector for the root component of the test app.", 11 | "type": "string", 12 | "default": "app-root" 13 | }, 14 | "relatedAppName": { 15 | "description": "The name of the application being tested.", 16 | "type": "string" 17 | } 18 | }, 19 | "required": ["relatedAppName"] 20 | } 21 | -------------------------------------------------------------------------------- /enum/files/__name@dasherize__.__type__.ts.template: -------------------------------------------------------------------------------- 1 | export enum <%= classify(name) %> { 2 | } 3 | -------------------------------------------------------------------------------- /enum/index.d.ts: -------------------------------------------------------------------------------- 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 | import type { Schema as EnumOptions } from './schema'; 10 | export default function (options: EnumOptions): Rule; 11 | -------------------------------------------------------------------------------- /enum/index.js: -------------------------------------------------------------------------------- 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 generate_from_files_1 = require("../utility/generate-from-files"); 12 | function default_1(options) { 13 | return (0, generate_from_files_1.generateFromFiles)(options); 14 | } 15 | -------------------------------------------------------------------------------- /enum/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new enum in your project. Enums (enumerations) are a way to define a set of 3 | * named constants, making your code more readable and maintainable. This schematic 4 | * generates a new enum with the specified name and type. 5 | */ 6 | export type Schema = { 7 | /** 8 | * The name for the new enum. This will be used to create the enum file (e.g., 9 | * `my-enum.enum.ts`). 10 | */ 11 | name: string; 12 | /** 13 | * The path where the enum file should be created, relative to the current workspace. If not 14 | * specified, the enum will be created in the current directory. 15 | */ 16 | path?: string; 17 | /** 18 | * The name of the project where the enum should be created. If not specified, the CLI will 19 | * determine the project from the current directory. 20 | */ 21 | project: string; 22 | /** 23 | * Adds a custom type to the filename, allowing you to create more descriptive enum names. 24 | * For example, if you set the type to `status`, the filename will be `my-enum.status.ts`. 25 | */ 26 | type?: string; 27 | }; 28 | -------------------------------------------------------------------------------- /enum/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /enum/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularEnum", 4 | "title": "Angular Enum Options Schema", 5 | "type": "object", 6 | "description": "Creates a new enum in your project. Enums (enumerations) are a way to define a set of named constants, making your code more readable and maintainable. This schematic generates a new enum with the specified name and type.", 7 | "additionalProperties": false, 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new enum. This will be used to create the enum file (e.g., `my-enum.enum.ts`).", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the enum?" 17 | }, 18 | "path": { 19 | "type": "string", 20 | "format": "path", 21 | "$default": { 22 | "$source": "workingDirectory" 23 | }, 24 | "description": "The path where the enum file should be created, relative to the current workspace. If not specified, the enum will be created in the current directory.", 25 | "visible": false 26 | }, 27 | "project": { 28 | "type": "string", 29 | "description": "The name of the project where the enum should be created. If not specified, the CLI will determine the project from the current directory.", 30 | "$default": { 31 | "$source": "projectName" 32 | } 33 | }, 34 | "type": { 35 | "type": "string", 36 | "description": "Adds a custom type to the filename, allowing you to create more descriptive enum names. For example, if you set the type to `status`, the filename will be `my-enum.status.ts`." 37 | } 38 | }, 39 | "required": ["name", "project"] 40 | } 41 | -------------------------------------------------------------------------------- /environments/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as EnvironmentOptions } from './schema'; 10 | export default function (options: EnvironmentOptions): Rule; 11 | -------------------------------------------------------------------------------- /environments/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Generates and configures environment files for your project. Environment files allow you 3 | * to define different settings and configurations for various environments, such as 4 | * development, testing, and production. This schematic helps you create and manage these 5 | * files, making it easier to customize your application's behavior for each environment. 6 | */ 7 | export type Schema = { 8 | /** 9 | * The name of the project where the environment files should be created or updated. 10 | */ 11 | project: string; 12 | }; 13 | -------------------------------------------------------------------------------- /environments/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /environments/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularEnvironment", 4 | "title": "Angular Environments Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Generates and configures environment files for your project. Environment files allow you to define different settings and configurations for various environments, such as development, testing, and production. This schematic helps you create and manage these files, making it easier to customize your application's behavior for each environment.", 8 | "properties": { 9 | "project": { 10 | "type": "string", 11 | "description": "The name of the project where the environment files should be created or updated.", 12 | "$default": { 13 | "$source": "projectName" 14 | } 15 | } 16 | }, 17 | "required": ["project"] 18 | } 19 | -------------------------------------------------------------------------------- /guard/implements-files/__name@dasherize____typeSeparator__guard.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { <%= classify(name) %>Guard } from './<%= dasherize(name) %><%= typeSeparator %>guard'; 4 | 5 | describe('<%= classify(name) %>Guard', () => { 6 | let guard: <%= classify(name) %>Guard; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | guard = TestBed.inject(<%= classify(name) %>Guard); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(guard).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /guard/implements-files/__name@dasherize____typeSeparator__guard.ts.template: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { <%= routerImports %> } from '@angular/router'; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class <%= classify(name) %>Guard implements <%= implementations %> { 8 | <% if (implements.includes('CanActivate')) { %>canActivate( 9 | route: ActivatedRouteSnapshot, 10 | state: RouterStateSnapshot): MaybeAsync { 11 | return true; 12 | } 13 | <% } %><% if (implements.includes('CanActivateChild')) { %>canActivateChild( 14 | childRoute: ActivatedRouteSnapshot, 15 | state: RouterStateSnapshot): MaybeAsync { 16 | return true; 17 | } 18 | <% } %><% if (implements.includes('CanDeactivate')) { %>canDeactivate( 19 | component: unknown, 20 | currentRoute: ActivatedRouteSnapshot, 21 | currentState: RouterStateSnapshot, 22 | nextState?: RouterStateSnapshot): MaybeAsync { 23 | return true; 24 | } 25 | <% } %><% if (implements.includes('CanMatch')) { %>canMatch( 26 | route: Route, 27 | segments: UrlSegment[]): MaybeAsync { 28 | return true; 29 | }<% } %> 30 | } 31 | -------------------------------------------------------------------------------- /guard/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as GuardOptions } from './schema'; 10 | export default function (options: GuardOptions): Rule; 11 | -------------------------------------------------------------------------------- /guard/index.js: -------------------------------------------------------------------------------- 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 schematics_1 = require("@angular-devkit/schematics"); 12 | const generate_from_files_1 = require("../utility/generate-from-files"); 13 | const schema_1 = require("./schema"); 14 | function default_1(options) { 15 | if (!options.implements) { 16 | throw new schematics_1.SchematicsException('Option "implements" is required.'); 17 | } 18 | if (options.implements.length > 1 && options.functional) { 19 | throw new schematics_1.SchematicsException('Can only specify one value for implements when generating a functional guard.'); 20 | } 21 | if (options.functional) { 22 | const guardType = options.implements[0] + 'Fn'; 23 | return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './type-files' }, { guardType }); 24 | } 25 | else { 26 | const implementations = options.implements 27 | .map((implement) => (implement === 'CanDeactivate' ? 'CanDeactivate' : implement)) 28 | .join(', '); 29 | const commonRouterNameImports = ['ActivatedRouteSnapshot', 'RouterStateSnapshot']; 30 | const routerNamedImports = [...options.implements, 'MaybeAsync', 'GuardResult']; 31 | if (options.implements.includes(schema_1.Implement.CanMatch)) { 32 | routerNamedImports.push('Route', 'subPath'); 33 | if (options.implements.length > 1) { 34 | routerNamedImports.push(...commonRouterNameImports); 35 | } 36 | } 37 | else { 38 | routerNamedImports.push(...commonRouterNameImports); 39 | } 40 | routerNamedImports.sort(); 41 | const routerImports = routerNamedImports.join(', '); 42 | return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './implements-files' }, { 43 | implementations, 44 | routerImports, 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /guard/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new route guard in your project. Route guards are used to control access to 3 | * parts of your application by checking certain conditions before a route is activated. 4 | * This schematic generates a new guard with the specified name, type, and options. 5 | */ 6 | export type Schema = { 7 | /** 8 | * Creates the new guard files at the top level of the current project. If set to false, a 9 | * new folder with the guard's name will be created to contain the files. 10 | */ 11 | flat?: boolean; 12 | /** 13 | * Generate the guard as a function instead of a class. Functional guards can be simpler for 14 | * basic scenarios. 15 | */ 16 | functional?: boolean; 17 | /** 18 | * Specifies the type(s) of guard to create. You can choose one or more of the following: 19 | * `CanActivate` (controls access to a route), `CanActivateChild` (controls access to child 20 | * routes), `CanDeactivate` (asks for confirmation before leaving a route), `CanMatch` 21 | * (determines if a route can be matched). 22 | */ 23 | implements?: Implement[]; 24 | /** 25 | * The name for the new route guard. This will be used to create the guard's class and spec 26 | * files (e.g., `my-guard.guard.ts` and `my-guard.guard.spec.ts`). 27 | */ 28 | name: string; 29 | /** 30 | * The path where the guard files should be created, relative to the current workspace. If 31 | * not provided, the guard will be created in the current directory. 32 | */ 33 | path?: string; 34 | /** 35 | * The name of the project where the guard should be created. If not specified, the CLI will 36 | * determine the project from the current directory. 37 | */ 38 | project: string; 39 | /** 40 | * Skip the generation of a unit test file `spec.ts` for the new guard. 41 | */ 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; 48 | }; 49 | export declare enum Implement { 50 | CanActivate = "CanActivate", 51 | CanActivateChild = "CanActivateChild", 52 | CanDeactivate = "CanDeactivate", 53 | CanMatch = "CanMatch" 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 | } 63 | -------------------------------------------------------------------------------- /guard/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.TypeSeparator = exports.Implement = void 0; 6 | var Implement; 7 | (function (Implement) { 8 | Implement["CanActivate"] = "CanActivate"; 9 | Implement["CanActivateChild"] = "CanActivateChild"; 10 | Implement["CanDeactivate"] = "CanDeactivate"; 11 | Implement["CanMatch"] = "CanMatch"; 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 = {})); 22 | -------------------------------------------------------------------------------- /guard/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularGuard", 4 | "title": "Angular Guard Options Schema", 5 | "type": "object", 6 | "description": "Creates a new route guard in your project. Route guards are used to control access to parts of your application by checking certain conditions before a route is activated. This schematic generates a new guard with the specified name, type, and options.", 7 | "additionalProperties": false, 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new route guard. This will be used to create the guard's class and spec files (e.g., `my-guard.guard.ts` and `my-guard.guard.spec.ts`).", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the guard?" 17 | }, 18 | "skipTests": { 19 | "type": "boolean", 20 | "description": "Skip the generation of a unit test file `spec.ts` for the new guard.", 21 | "default": false 22 | }, 23 | "flat": { 24 | "type": "boolean", 25 | "description": "Creates the new guard files at the top level of the current project. If set to false, a new folder with the guard's name will be created to contain the files.", 26 | "default": true 27 | }, 28 | "path": { 29 | "type": "string", 30 | "format": "path", 31 | "$default": { 32 | "$source": "workingDirectory" 33 | }, 34 | "description": "The path where the guard files should be created, relative to the current workspace. If not provided, the guard will be created in the current directory.", 35 | "visible": false 36 | }, 37 | "project": { 38 | "type": "string", 39 | "description": "The name of the project where the guard should be created. If not specified, the CLI will determine the project from the current directory.", 40 | "$default": { 41 | "$source": "projectName" 42 | } 43 | }, 44 | "functional": { 45 | "type": "boolean", 46 | "description": "Generate the guard as a function instead of a class. Functional guards can be simpler for basic scenarios.", 47 | "default": true 48 | }, 49 | "implements": { 50 | "alias": "guardType", 51 | "type": "array", 52 | "description": "Specifies the type(s) of guard to create. You can choose one or more of the following: `CanActivate` (controls access to a route), `CanActivateChild` (controls access to child routes), `CanDeactivate` (asks for confirmation before leaving a route), `CanMatch` (determines if a route can be matched).", 53 | "uniqueItems": true, 54 | "minItems": 1, 55 | "items": { 56 | "enum": ["CanActivate", "CanActivateChild", "CanDeactivate", "CanMatch"], 57 | "type": "string" 58 | }, 59 | "default": ["CanActivate"], 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`." 67 | } 68 | }, 69 | "required": ["name", "project"] 70 | } 71 | -------------------------------------------------------------------------------- /guard/type-files/__name@dasherize____typeSeparator__guard.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { <%= guardType %> } from '@angular/router'; 3 | 4 | import { <%= camelize(name) %>Guard } from './<%= dasherize(name) %><%= typeSeparator %>guard'; 5 | 6 | describe('<%= camelize(name) %>Guard', () => { 7 | const executeGuard: <%= guardType %><% if (guardType === 'CanDeactivateFn') { %><% } %> = (...guardParameters) => 8 | TestBed.runInInjectionContext(() => <%= camelize(name) %>Guard(...guardParameters)); 9 | 10 | beforeEach(() => { 11 | TestBed.configureTestingModule({}); 12 | }); 13 | 14 | it('should be created', () => { 15 | expect(executeGuard).toBeTruthy(); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /guard/type-files/__name@dasherize____typeSeparator__guard.ts.template: -------------------------------------------------------------------------------- 1 | import { <%= guardType %> } from '@angular/router'; 2 | 3 | export const <%= camelize(name) %>Guard: <%= guardType %><% if (guardType === 'CanDeactivateFn') { %><% } %> = <% 4 | if (guardType === 'CanMatchFn') { %>(route, segments)<% } 5 | %><% if (guardType === 'CanActivateFn') { %>(route, state)<% } 6 | %><% if (guardType === 'CanActivateChildFn') { %>(childRoute, state)<% } 7 | %><% if (guardType === 'CanDeactivateFn') { %>(component, currentRoute, currentState, nextState)<% } %> => { 8 | return true; 9 | }; 10 | -------------------------------------------------------------------------------- /interceptor/class-files/__name@dasherize____typeSeparator__interceptor.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { <%= classify(name) %>Interceptor } from './<%= dasherize(name) %><%= typeSeparator %>interceptor'; 4 | 5 | describe('<%= classify(name) %>Interceptor', () => { 6 | beforeEach(() => TestBed.configureTestingModule({ 7 | providers: [ 8 | <%= classify(name) %>Interceptor 9 | ] 10 | })); 11 | 12 | it('should be created', () => { 13 | const interceptor: <%= classify(name) %>Interceptor = TestBed.inject(<%= classify(name) %>Interceptor); 14 | expect(interceptor).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /interceptor/class-files/__name@dasherize____typeSeparator__interceptor.ts.template: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { 3 | HttpRequest, 4 | HttpHandler, 5 | HttpEvent, 6 | HttpInterceptor 7 | } from '@angular/common/http'; 8 | import { Observable } from 'rxjs'; 9 | 10 | @Injectable() 11 | export class <%= classify(name) %>Interceptor implements HttpInterceptor { 12 | 13 | constructor() {} 14 | 15 | intercept(request: HttpRequest, next: HttpHandler): Observable> { 16 | return next.handle(request); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /interceptor/functional-files/__name@dasherize____typeSeparator__interceptor.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { HttpInterceptorFn } from '@angular/common/http'; 3 | 4 | import { <%= camelize(name) %>Interceptor } from './<%= dasherize(name) %><%= typeSeparator %>interceptor'; 5 | 6 | describe('<%= camelize(name) %>Interceptor', () => { 7 | const interceptor: HttpInterceptorFn = (req, next) => 8 | TestBed.runInInjectionContext(() => <%= camelize(name) %>Interceptor(req, next)); 9 | 10 | beforeEach(() => { 11 | TestBed.configureTestingModule({}); 12 | }); 13 | 14 | it('should be created', () => { 15 | expect(interceptor).toBeTruthy(); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /interceptor/functional-files/__name@dasherize____typeSeparator__interceptor.ts.template: -------------------------------------------------------------------------------- 1 | import { HttpInterceptorFn } from '@angular/common/http'; 2 | 3 | export const <%= camelize(name) %>Interceptor: HttpInterceptorFn = (req, next) => { 4 | return next(req); 5 | }; 6 | -------------------------------------------------------------------------------- /interceptor/index.d.ts: -------------------------------------------------------------------------------- 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 | import type { Schema as InterceptorOptions } from './schema'; 10 | export default function (options: InterceptorOptions): Rule; 11 | -------------------------------------------------------------------------------- /interceptor/index.js: -------------------------------------------------------------------------------- 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 generate_from_files_1 = require("../utility/generate-from-files"); 12 | function default_1(options) { 13 | const templateFilesDirectory = options.functional ? './functional-files' : './class-files'; 14 | return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory }); 15 | } 16 | -------------------------------------------------------------------------------- /interceptor/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new interceptor in your project. Interceptors are used to intercept and modify 3 | * HTTP requests and responses before they reach their destination. This allows you to 4 | * perform tasks like adding authentication headers, handling errors, or logging requests. 5 | * This schematic generates the necessary files and boilerplate code for a new interceptor. 6 | */ 7 | export type Schema = { 8 | /** 9 | * Creates the new interceptor files at the top level of the current project. If set to 10 | * false, a new folder with the interceptor's name will be created to contain the files. 11 | */ 12 | flat?: boolean; 13 | /** 14 | * Creates the interceptor as a function `HttpInterceptorFn` instead of a class. Functional 15 | * interceptors can be simpler for basic scenarios. 16 | */ 17 | functional?: boolean; 18 | /** 19 | * The name for the new interceptor. This will be used to create the interceptor's class and 20 | * spec files (e.g., `my-interceptor.interceptor.ts` and 21 | * `my-interceptor.interceptor.spec.ts`). 22 | */ 23 | name: string; 24 | /** 25 | * The path where the interceptor files should be created, relative to the workspace root. 26 | * If not provided, the interceptor will be created in the current directory. 27 | */ 28 | path?: string; 29 | /** 30 | * The name of the project where the interceptor should be created. If not specified, the 31 | * CLI will determine the project from the current directory. 32 | */ 33 | project: string; 34 | /** 35 | * Skip the generation of a unit test file `spec.ts` for the new interceptor. 36 | */ 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; 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 | } 52 | -------------------------------------------------------------------------------- /interceptor/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 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 = {})); 15 | -------------------------------------------------------------------------------- /interceptor/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularInterceptor", 4 | "title": "Angular Interceptor Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Creates a new interceptor in your project. Interceptors are used to intercept and modify HTTP requests and responses before they reach their destination. This allows you to perform tasks like adding authentication headers, handling errors, or logging requests. This schematic generates the necessary files and boilerplate code for a new interceptor.", 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new interceptor. This will be used to create the interceptor's class and spec files (e.g., `my-interceptor.interceptor.ts` and `my-interceptor.interceptor.spec.ts`).", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the interceptor?" 17 | }, 18 | "path": { 19 | "type": "string", 20 | "format": "path", 21 | "$default": { 22 | "$source": "workingDirectory" 23 | }, 24 | "description": "The path where the interceptor files should be created, relative to the workspace root. If not provided, the interceptor will be created in the current directory.", 25 | "visible": false 26 | }, 27 | "project": { 28 | "type": "string", 29 | "description": "The name of the project where the interceptor should be created. If not specified, the CLI will determine the project from the current directory.", 30 | "$default": { 31 | "$source": "projectName" 32 | } 33 | }, 34 | "flat": { 35 | "type": "boolean", 36 | "default": true, 37 | "description": "Creates the new interceptor files at the top level of the current project. If set to false, a new folder with the interceptor's name will be created to contain the files." 38 | }, 39 | "skipTests": { 40 | "type": "boolean", 41 | "description": "Skip the generation of a unit test file `spec.ts` for the new interceptor.", 42 | "default": false 43 | }, 44 | "functional": { 45 | "type": "boolean", 46 | "description": "Creates the interceptor as a function `HttpInterceptorFn` instead of a class. Functional interceptors can be simpler for basic scenarios.", 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`." 54 | } 55 | }, 56 | "required": ["name", "project"] 57 | } 58 | -------------------------------------------------------------------------------- /interface/files/__name@dasherize__.__type__.ts.template: -------------------------------------------------------------------------------- 1 | export interface <%= prefix %><%= classify(name) %> { 2 | } 3 | -------------------------------------------------------------------------------- /interface/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as InterfaceOptions } from './schema'; 10 | export default function (options: InterfaceOptions): Rule; 11 | -------------------------------------------------------------------------------- /interface/index.js: -------------------------------------------------------------------------------- 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 generate_from_files_1 = require("../utility/generate-from-files"); 12 | function default_1(options) { 13 | return (0, generate_from_files_1.generateFromFiles)(options); 14 | } 15 | -------------------------------------------------------------------------------- /interface/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new interface in your project. Interfaces define the structure of objects in 3 | * TypeScript, ensuring type safety and code clarity. This schematic generates a new 4 | * interface with the specified name and type. 5 | */ 6 | export type Schema = { 7 | /** 8 | * The name for the new interface. This will be used to create the interface file (e.g., 9 | * `my-interface.interface.ts`). 10 | */ 11 | name: string; 12 | /** 13 | * The path where the interface file should be created, relative to the workspace root. If 14 | * not provided, the interface will be created in the current directory. 15 | */ 16 | path?: string; 17 | /** 18 | * A prefix to be added to the interface name. This is typically not used for interfaces, as 19 | * they don't have selectors like components or directives. 20 | */ 21 | prefix?: string; 22 | /** 23 | * The name of the project where the interface should be created. If not specified, the CLI 24 | * will determine the project from the current directory. 25 | */ 26 | project: string; 27 | /** 28 | * Adds a custom type to the filename, allowing you to create more descriptive interface 29 | * names. For example, if you set the type to `data`, the filename will be 30 | * `my-interface.data.ts`. 31 | */ 32 | type?: string; 33 | }; 34 | -------------------------------------------------------------------------------- /interface/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /interface/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularInterface", 4 | "title": "Angular Interface Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Creates a new interface in your project. Interfaces define the structure of objects in TypeScript, ensuring type safety and code clarity. This schematic generates a new interface with the specified name and type.", 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new interface. This will be used to create the interface file (e.g., `my-interface.interface.ts`).", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the interface?" 17 | }, 18 | "path": { 19 | "type": "string", 20 | "format": "path", 21 | "$default": { 22 | "$source": "workingDirectory" 23 | }, 24 | "description": "The path where the interface file should be created, relative to the workspace root. If not provided, the interface will be created in the current directory.", 25 | "visible": false 26 | }, 27 | "project": { 28 | "type": "string", 29 | "description": "The name of the project where the interface should be created. If not specified, the CLI will determine the project from the current directory.", 30 | "$default": { 31 | "$source": "projectName" 32 | } 33 | }, 34 | "prefix": { 35 | "type": "string", 36 | "description": "A prefix to be added to the interface name. This is typically not used for interfaces, as they don't have selectors like components or directives." 37 | }, 38 | "type": { 39 | "type": "string", 40 | "description": "Adds a custom type to the filename, allowing you to create more descriptive interface names. For example, if you set the type to `data`, the filename will be `my-interface.data.ts`.", 41 | "$default": { 42 | "$source": "argv", 43 | "index": 1 44 | } 45 | } 46 | }, 47 | "required": ["name", "project"] 48 | } 49 | -------------------------------------------------------------------------------- /library/files/README.md.template: -------------------------------------------------------------------------------- 1 | # <%= classify(name) %> 2 | 3 | This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version <%= angularLatestVersion %>. 4 | 5 | ## Code scaffolding 6 | 7 | Angular CLI includes powerful code scaffolding tools. To generate a new component, run: 8 | 9 | ```bash 10 | ng generate component component-name 11 | ``` 12 | 13 | For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run: 14 | 15 | ```bash 16 | ng generate --help 17 | ``` 18 | 19 | ## Building 20 | 21 | To build the library, run: 22 | 23 | ```bash 24 | ng build <%= name %> 25 | ``` 26 | 27 | This command will compile your project, and the build artifacts will be placed in the `dist/` directory. 28 | 29 | ### Publishing the Library 30 | 31 | Once the project is built, you can publish your library by following these steps: 32 | 33 | 1. Navigate to the `dist` directory: 34 | ```bash 35 | cd dist/<%= dasherize(name) %> 36 | ``` 37 | 38 | 2. Run the `npm publish` command to publish your library to the npm registry: 39 | ```bash 40 | npm publish 41 | ``` 42 | 43 | ## Running unit tests 44 | 45 | To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command: 46 | 47 | ```bash 48 | ng test 49 | ``` 50 | 51 | ## Running end-to-end tests 52 | 53 | For end-to-end (e2e) testing, run: 54 | 55 | ```bash 56 | ng e2e 57 | ``` 58 | 59 | Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs. 60 | 61 | ## Additional Resources 62 | 63 | For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. 64 | -------------------------------------------------------------------------------- /library/files/ng-package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "<%= relativePathToWorkspaceRoot %>/node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "<%= relativePathToWorkspaceRoot %>/<%= distRoot %>", 4 | "lib": { 5 | "entryFile": "src/<%= entryFile %>.ts" 6 | } 7 | } -------------------------------------------------------------------------------- /library/files/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= dasherize(packageName) %>", 3 | "version": "0.0.1", 4 | "peerDependencies": { 5 | "@angular/common": "^<%= angularLatestVersion %>", 6 | "@angular/core": "^<%= angularLatestVersion %>" 7 | }, 8 | "dependencies": { 9 | "tslib": "^<%= tsLibLatestVersion %>" 10 | }, 11 | "sideEffects": false 12 | } 13 | -------------------------------------------------------------------------------- /library/files/src/__entryFile__.ts.template: -------------------------------------------------------------------------------- 1 | /* 2 | * Public API Surface of <%= dasherize(name) %> 3 | */ 4 | 5 | export * from './lib/<%= dasherize(name) %>';<% if (!standalone) { %> 6 | export * from './lib/<%= dasherize(name) %>-module';<% } %> 7 | -------------------------------------------------------------------------------- /library/files/tsconfig.lib.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/lib", 7 | "declaration": true, 8 | "declarationMap": true, 9 | "inlineSources": true, 10 | "types": [] 11 | }, 12 | "include": [ 13 | "src/**/*.ts" 14 | ], 15 | "exclude": [ 16 | "**/*.spec.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /library/files/tsconfig.lib.prod.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.lib.json", 5 | "compilerOptions": { 6 | "declarationMap": false 7 | }, 8 | "angularCompilerOptions": { 9 | "compilationMode": "partial" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/files/tsconfig.spec.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/spec", 7 | "types": [ 8 | "jasmine" 9 | ] 10 | }, 11 | "include": [ 12 | "src/**/*.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /library/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as LibraryOptions } from './schema'; 10 | export default function (options: LibraryOptions): Rule; 11 | -------------------------------------------------------------------------------- /library/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new library project in your Angular workspace. Libraries are reusable 3 | * collections of components, services, and other Angular artifacts that can be shared 4 | * across multiple applications. This schematic simplifies the process of generating a new 5 | * library with the necessary files and configurations. 6 | */ 7 | export type Schema = { 8 | /** 9 | * The path to the library's public API file, relative to the workspace root. This file 10 | * defines what parts of the library are accessible to applications that import it. 11 | */ 12 | entryFile?: string; 13 | /** 14 | * The name for the new library. This name will be used for the project directory and 15 | * various identifiers within the library's code. 16 | */ 17 | name: string; 18 | /** 19 | * A prefix to be added to the selectors of components generated within this library. For 20 | * example, if the prefix is `my-lib` and you generate a component named `my-component`, the 21 | * selector will be `my-lib-my-component`. 22 | */ 23 | prefix?: string; 24 | /** 25 | * The root directory for the new library, relative to the workspace root. If not specified, 26 | * the library will be created in a subfolder within the `projects` directory, using the 27 | * library's name. 28 | */ 29 | projectRoot?: string; 30 | /** 31 | * Skip the automatic installation of packages. You will need to manually install the 32 | * dependencies later. 33 | */ 34 | skipInstall?: boolean; 35 | /** 36 | * Do not automatically add dependencies to the `package.json` file. 37 | */ 38 | skipPackageJson?: boolean; 39 | /** 40 | * Do not update the workspace `tsconfig.json` file to add a path mapping for the new 41 | * library. The path mapping is needed to use the library in an application, but can be 42 | * disabled here to simplify development. 43 | */ 44 | skipTsConfig?: boolean; 45 | /** 46 | * Create a library that utilizes the standalone API, eliminating the need for NgModules. 47 | * This can simplify the structure of your library and its usage in applications. 48 | */ 49 | standalone?: boolean; 50 | }; 51 | -------------------------------------------------------------------------------- /library/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /library/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsLibrary", 4 | "title": "Library Options Schema", 5 | "type": "object", 6 | "description": "Creates a new library project in your Angular workspace. Libraries are reusable collections of components, services, and other Angular artifacts that can be shared across multiple applications. This schematic simplifies the process of generating a new library with the necessary files and configurations.", 7 | "additionalProperties": false, 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new library. This name will be used for the project directory and various identifiers within the library's code.", 12 | "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$", 13 | "$default": { 14 | "$source": "argv", 15 | "index": 0 16 | }, 17 | "x-prompt": "What name would you like to use for the library?" 18 | }, 19 | "entryFile": { 20 | "type": "string", 21 | "format": "path", 22 | "description": "The path to the library's public API file, relative to the workspace root. This file defines what parts of the library are accessible to applications that import it.", 23 | "default": "public-api" 24 | }, 25 | "prefix": { 26 | "type": "string", 27 | "format": "html-selector", 28 | "description": "A prefix to be added to the selectors of components generated within this library. For example, if the prefix is `my-lib` and you generate a component named `my-component`, the selector will be `my-lib-my-component`.", 29 | "default": "lib", 30 | "alias": "p" 31 | }, 32 | "skipPackageJson": { 33 | "type": "boolean", 34 | "default": false, 35 | "description": "Do not automatically add dependencies to the `package.json` file." 36 | }, 37 | "skipInstall": { 38 | "description": "Skip the automatic installation of packages. You will need to manually install the dependencies later.", 39 | "type": "boolean", 40 | "default": false 41 | }, 42 | "skipTsConfig": { 43 | "type": "boolean", 44 | "default": false, 45 | "description": "Do not update the workspace `tsconfig.json` file to add a path mapping for the new library. The path mapping is needed to use the library in an application, but can be disabled here to simplify development." 46 | }, 47 | "projectRoot": { 48 | "type": "string", 49 | "description": "The root directory for the new library, relative to the workspace root. If not specified, the library will be created in a subfolder within the `projects` directory, using the library's name." 50 | }, 51 | "standalone": { 52 | "description": "Create a library that utilizes the standalone API, eliminating the need for NgModules. This can simplify the structure of your library and its usage in applications.", 53 | "type": "boolean", 54 | "default": true, 55 | "x-user-analytics": "ep.ng_standalone" 56 | } 57 | }, 58 | "required": ["name"] 59 | } 60 | -------------------------------------------------------------------------------- /migrations/migration-collection.json: -------------------------------------------------------------------------------- 1 | { 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' and 'provideServerRoutesConfig' from '@angular/ssr'." 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 | }, 23 | "use-application-builder": { 24 | "version": "20.0.0", 25 | "factory": "./use-application-builder/migration", 26 | "description": "Migrate application projects to the new build system. Application projects that are using the '@angular-devkit/build-angular' package's 'browser' and/or 'browser-esbuild' builders will be migrated to use the new 'application' builder. You can read more about this, including known issues and limitations, here: https://angular.dev/tools/cli/build-system-migration", 27 | "optional": true, 28 | "recommended": true, 29 | "documentation": "tools/cli/build-system-migration" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /migrations/previous-style-guide/migration.d.ts: -------------------------------------------------------------------------------- 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; 10 | -------------------------------------------------------------------------------- /migrations/previous-style-guide/migration.js: -------------------------------------------------------------------------------- 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 | } 43 | -------------------------------------------------------------------------------- /migrations/replace-provide-server-rendering-import/migration.d.ts: -------------------------------------------------------------------------------- 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; 10 | -------------------------------------------------------------------------------- /migrations/replace-provide-server-routing/migration.d.ts: -------------------------------------------------------------------------------- 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; 10 | -------------------------------------------------------------------------------- /migrations/update-module-resolution/migration.d.ts: -------------------------------------------------------------------------------- 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; 10 | -------------------------------------------------------------------------------- /migrations/update-module-resolution/migration.js: -------------------------------------------------------------------------------- 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 | } 53 | -------------------------------------------------------------------------------- /migrations/use-application-builder/css-import-lexer.d.ts: -------------------------------------------------------------------------------- 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 | /** 9 | * Scans a CSS or Sass file and locates all valid import/use directive values as defined by the 10 | * syntax specification. 11 | * @param contents A string containing a CSS or Sass file to scan. 12 | * @returns An iterable that yields each CSS directive value found. 13 | */ 14 | export declare function findImports(contents: string, sass: boolean): Iterable<{ 15 | start: number; 16 | end: number; 17 | specifier: string; 18 | fromUse?: boolean; 19 | }>; 20 | -------------------------------------------------------------------------------- /migrations/use-application-builder/migration.d.ts: -------------------------------------------------------------------------------- 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 | /** 10 | * Migration main entrypoint 11 | */ 12 | export default function (): Rule; 13 | -------------------------------------------------------------------------------- /module/files/__name@dasherize@if-flat__/__name@dasherize__-routing__typeSeparator__module.ts.template: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router';<% if (lazyRoute) { %> 3 | import { <%= classify(name) %> } from './<%= dasherize(name) %>';<% } %> 4 | 5 | const routes: Routes = [<% if (lazyRoute) { %>{ path: '', component: <%= classify(name) %> }<% } %>]; 6 | 7 | @NgModule({ 8 | imports: [RouterModule.for<%= routingScope %>(routes)], 9 | exports: [RouterModule] 10 | }) 11 | export class <%= classify(name) %>RoutingModule { } 12 | -------------------------------------------------------------------------------- /module/files/__name@dasherize@if-flat__/__name@dasherize____typeSeparator__module.ts.template: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core';<% if (commonModule) { %> 2 | import { CommonModule } from '@angular/common';<% } %><% if (lazyRouteWithoutRouteModule) { %> 3 | import { Routes, RouterModule } from '@angular/router';<% } %> 4 | <% if ((!lazyRoute && routing) || lazyRouteWithRouteModule) { %> 5 | import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing<%= typeSeparator %>module';<% } %> 6 | <% if (lazyRouteWithoutRouteModule) { %> 7 | const routes: Routes = [ 8 | { path: '', component: <%= classify(name) %> } 9 | ];<% } %> 10 | 11 | @NgModule({ 12 | declarations: [], 13 | imports: [<% if (commonModule) { %> 14 | CommonModule<% } %><% if ((!lazyRoute && routing) || lazyRouteWithRouteModule) { %>, 15 | <%= classify(name) %>RoutingModule<% } %><% if (lazyRouteWithoutRouteModule) { %>, 16 | RouterModule.forChild(routes)<% } %> 17 | ] 18 | }) 19 | export class <%= classify(name) %>Module { } 20 | -------------------------------------------------------------------------------- /module/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ModuleOptions } from './schema'; 10 | export default function (options: ModuleOptions): Rule; 11 | -------------------------------------------------------------------------------- /module/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new, generic NgModule definition in the given project. 3 | */ 4 | export type Schema = { 5 | /** 6 | * The new NgModule imports "CommonModule". 7 | */ 8 | commonModule?: boolean; 9 | /** 10 | * Create the new files at the top level of the current project root. 11 | */ 12 | flat?: boolean; 13 | /** 14 | * The declaring NgModule. 15 | */ 16 | module?: string; 17 | /** 18 | * The name of the NgModule. 19 | */ 20 | name: string; 21 | /** 22 | * The path at which to create the NgModule, relative to the workspace root. 23 | */ 24 | path?: string; 25 | /** 26 | * The name of the project. 27 | */ 28 | project: string; 29 | /** 30 | * The route path for a lazy-loaded module. When supplied, creates a component in the new 31 | * module, and adds the route to that component in the `Routes` array declared in the module 32 | * provided in the `--module` option. 33 | */ 34 | route?: string; 35 | /** 36 | * Create a routing module. 37 | */ 38 | routing?: boolean; 39 | /** 40 | * The scope for the new routing module. 41 | */ 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; 48 | }; 49 | /** 50 | * The scope for the new routing module. 51 | */ 52 | export declare enum RoutingScope { 53 | Child = "Child", 54 | Root = "Root" 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 | } 64 | -------------------------------------------------------------------------------- /module/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.TypeSeparator = exports.RoutingScope = void 0; 6 | /** 7 | * The scope for the new routing module. 8 | */ 9 | var RoutingScope; 10 | (function (RoutingScope) { 11 | RoutingScope["Child"] = "Child"; 12 | RoutingScope["Root"] = "Root"; 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 = {})); 23 | -------------------------------------------------------------------------------- /module/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularModule", 4 | "title": "Angular Module Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Creates a new, generic NgModule definition in the given project.", 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name of the NgModule.", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the NgModule?" 17 | }, 18 | "path": { 19 | "type": "string", 20 | "format": "path", 21 | "$default": { 22 | "$source": "workingDirectory" 23 | }, 24 | "description": "The path at which to create the NgModule, relative to the workspace root.", 25 | "visible": false 26 | }, 27 | "project": { 28 | "type": "string", 29 | "description": "The name of the project.", 30 | "$default": { 31 | "$source": "projectName" 32 | } 33 | }, 34 | "routing": { 35 | "type": "boolean", 36 | "description": "Create a routing module.", 37 | "default": false, 38 | "x-user-analytics": "ep.ng_routing" 39 | }, 40 | "routingScope": { 41 | "enum": ["Child", "Root"], 42 | "type": "string", 43 | "description": "The scope for the new routing module.", 44 | "default": "Child" 45 | }, 46 | "route": { 47 | "type": "string", 48 | "description": "The route path for a lazy-loaded module. When supplied, creates a component in the new module, and adds the route to that component in the `Routes` array declared in the module provided in the `--module` option." 49 | }, 50 | "flat": { 51 | "type": "boolean", 52 | "description": "Create the new files at the top level of the current project root. ", 53 | "default": false 54 | }, 55 | "commonModule": { 56 | "type": "boolean", 57 | "description": "The new NgModule imports \"CommonModule\". ", 58 | "default": true, 59 | "visible": false 60 | }, 61 | "module": { 62 | "type": "string", 63 | "description": "The declaring NgModule.", 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`." 71 | } 72 | }, 73 | "required": ["name", "project"] 74 | } 75 | -------------------------------------------------------------------------------- /ng-new/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as NgNewOptions } from './schema'; 10 | export default function (options: NgNewOptions): Rule; 11 | -------------------------------------------------------------------------------- /ng-new/index.js: -------------------------------------------------------------------------------- 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 schematics_1 = require("@angular-devkit/schematics"); 12 | const tasks_1 = require("@angular-devkit/schematics/tasks"); 13 | function default_1(options) { 14 | if (!options.directory) { 15 | // If scoped project (i.e. "@foo/bar"), convert directory to "foo/bar". 16 | options.directory = options.name.startsWith('@') ? options.name.slice(1) : options.name; 17 | } 18 | const workspaceOptions = { 19 | name: options.name, 20 | version: options.version, 21 | newProjectRoot: options.newProjectRoot, 22 | minimal: options.minimal, 23 | strict: options.strict, 24 | packageManager: options.packageManager, 25 | }; 26 | const applicationOptions = { 27 | projectRoot: '', 28 | name: options.name, 29 | inlineStyle: options.inlineStyle, 30 | inlineTemplate: options.inlineTemplate, 31 | prefix: options.prefix, 32 | viewEncapsulation: options.viewEncapsulation, 33 | routing: options.routing, 34 | style: options.style, 35 | skipTests: options.skipTests, 36 | skipPackageJson: false, 37 | // always 'skipInstall' here, so that we do it after the move 38 | skipInstall: true, 39 | strict: options.strict, 40 | minimal: options.minimal, 41 | standalone: options.standalone, 42 | ssr: options.ssr, 43 | zoneless: options.zoneless, 44 | }; 45 | return (0, schematics_1.chain)([ 46 | (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.empty)(), [ 47 | (0, schematics_1.schematic)('workspace', workspaceOptions), 48 | options.createApplication ? (0, schematics_1.schematic)('application', applicationOptions) : schematics_1.noop, 49 | (0, schematics_1.move)(options.directory), 50 | ])), 51 | (_host, context) => { 52 | let packageTask; 53 | if (!options.skipInstall) { 54 | packageTask = context.addTask(new tasks_1.NodePackageInstallTask({ 55 | workingDirectory: options.directory, 56 | packageManager: options.packageManager, 57 | })); 58 | } 59 | if (!options.skipGit) { 60 | const commit = typeof options.commit == 'object' ? options.commit : options.commit ? {} : false; 61 | context.addTask(new tasks_1.RepositoryInitializerTask(options.directory, commit), packageTask ? [packageTask] : []); 62 | } 63 | }, 64 | ]); 65 | } 66 | -------------------------------------------------------------------------------- /ng-new/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.ViewEncapsulation = exports.Style = exports.PackageManager = void 0; 6 | /** 7 | * The package manager used to install dependencies. 8 | */ 9 | var PackageManager; 10 | (function (PackageManager) { 11 | PackageManager["Bun"] = "bun"; 12 | PackageManager["Cnpm"] = "cnpm"; 13 | PackageManager["Npm"] = "npm"; 14 | PackageManager["Pnpm"] = "pnpm"; 15 | PackageManager["Yarn"] = "yarn"; 16 | })(PackageManager || (exports.PackageManager = PackageManager = {})); 17 | /** 18 | * The type of stylesheet files to be created for components in the initial project. 19 | */ 20 | var Style; 21 | (function (Style) { 22 | Style["Css"] = "css"; 23 | Style["Less"] = "less"; 24 | Style["Sass"] = "sass"; 25 | Style["Scss"] = "scss"; 26 | })(Style || (exports.Style = Style = {})); 27 | /** 28 | * Sets the view encapsulation mode for components in the initial project. This determines 29 | * how component styles are scoped and applied. Options include: `Emulated` (default, styles 30 | * are scoped to the component), `None` (styles are global), and `ShadowDom` (styles are 31 | * encapsulated using Shadow DOM). 32 | */ 33 | var ViewEncapsulation; 34 | (function (ViewEncapsulation) { 35 | ViewEncapsulation["Emulated"] = "Emulated"; 36 | ViewEncapsulation["None"] = "None"; 37 | ViewEncapsulation["ShadowDom"] = "ShadowDom"; 38 | })(ViewEncapsulation || (exports.ViewEncapsulation = ViewEncapsulation = {})); 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@schematics/angular", 3 | "version": "20.1.0-next.1+sha-ef742db", 4 | "description": "Schematics specific to Angular", 5 | "homepage": "https://github.com/angular/angular-cli", 6 | "keywords": [ 7 | "Angular CLI", 8 | "Angular DevKit", 9 | "angular", 10 | "blueprints", 11 | "code generation", 12 | "devkit", 13 | "schematics", 14 | "sdk" 15 | ], 16 | "exports": { 17 | "./package.json": "./package.json", 18 | "./utility": "./utility/index.js", 19 | "./utility/*": "./utility/*.js", 20 | "./migrations/migration-collection.json": "./migrations/migration-collection.json", 21 | "./*": "./*.js" 22 | }, 23 | "schematics": "./collection.json", 24 | "dependencies": { 25 | "@angular-devkit/core": "github:angular/angular-devkit-core-builds#ef742db", 26 | "@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#ef742db", 27 | "jsonc-parser": "3.3.1" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "https://github.com/angular/angular-cli.git" 32 | }, 33 | "packageManager": "pnpm@9.15.9", 34 | "engines": { 35 | "node": "^20.19.0 || ^22.12.0 || >=24.0.0", 36 | "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", 37 | "yarn": ">= 1.13.0" 38 | }, 39 | "author": "Angular Authors", 40 | "license": "MIT", 41 | "bugs": { 42 | "url": "https://github.com/angular/angular-cli/issues" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /pipe/files/__name@dasherize____typeSeparator__pipe.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { <%= classify(name) %>Pipe } from './<%= dasherize(name) %><%= typeSeparator %>pipe'; 2 | 3 | describe('<%= classify(name) %>Pipe', () => { 4 | it('create an instance', () => { 5 | const pipe = new <%= classify(name) %>Pipe(); 6 | expect(pipe).toBeTruthy(); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /pipe/files/__name@dasherize____typeSeparator__pipe.ts.template: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | @Pipe({ 4 | name: '<%= camelize(name) %>'<% if(!standalone) {%>, 5 | standalone: false<%}%> 6 | }) 7 | export class <%= classify(name) %>Pipe implements PipeTransform { 8 | 9 | transform(value: unknown, ...args: unknown[]): unknown { 10 | return null; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /pipe/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as PipeOptions } from './schema'; 10 | export default function (options: PipeOptions): Rule; 11 | -------------------------------------------------------------------------------- /pipe/index.js: -------------------------------------------------------------------------------- 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 schematics_1 = require("@angular-devkit/schematics"); 12 | const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module"); 13 | const find_module_1 = require("../utility/find-module"); 14 | const generate_from_files_1 = require("../utility/generate-from-files"); 15 | const parse_name_1 = require("../utility/parse-name"); 16 | const validation_1 = require("../utility/validation"); 17 | const workspace_1 = require("../utility/workspace"); 18 | function default_1(options) { 19 | return async (host) => { 20 | options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project); 21 | options.module = (0, find_module_1.findModuleFromOptions)(host, options); 22 | const parsedPath = (0, parse_name_1.parseName)(options.path, options.name); 23 | options.name = parsedPath.name; 24 | options.path = parsedPath.path; 25 | (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name)); 26 | return (0, schematics_1.chain)([ 27 | (0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({ 28 | type: 'pipe', 29 | ...options, 30 | }), 31 | (0, generate_from_files_1.generateFromFiles)(options), 32 | ]); 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /pipe/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new pipe in your project. Pipes are used to transform data for display in 3 | * templates. They take input values and apply a specific transformation, such as formatting 4 | * dates, currency, or filtering arrays. This schematic generates the necessary files and 5 | * boilerplate code for a new pipe. 6 | */ 7 | export type Schema = { 8 | /** 9 | * Automatically export the pipe from the specified NgModule, making it accessible to other 10 | * modules in the application. 11 | */ 12 | export?: boolean; 13 | /** 14 | * Creates the new pipe files at the top level of the current project. If set to false, a 15 | * new folder with the pipe's name will be created to contain the files. 16 | */ 17 | flat?: boolean; 18 | /** 19 | * Specify the NgModule where the pipe should be declared. If not provided, the CLI will 20 | * attempt to find the closest NgModule in the pipe's path. 21 | */ 22 | module?: string; 23 | /** 24 | * The name for the new pipe. This will be used to create the pipe's class and spec files 25 | * (e.g., `my-pipe.pipe.ts` and `my-pipe.pipe.spec.ts`). 26 | */ 27 | name: string; 28 | /** 29 | * The path where the pipe files should be created, relative to the workspace root. If not 30 | * provided, the pipe will be created in the current directory. 31 | */ 32 | path?: string; 33 | /** 34 | * The name of the project where the pipe should be created. If not specified, the CLI will 35 | * determine the project from the current directory. 36 | */ 37 | project: string; 38 | /** 39 | * Do not automatically import the new pipe into its closest NgModule. 40 | */ 41 | skipImport?: boolean; 42 | /** 43 | * Prevent the generation of a unit test file `spec.ts` for the new pipe. 44 | */ 45 | skipTests?: boolean; 46 | /** 47 | * Generate a standalone pipe. Standalone pipes are self-contained and don't need to be 48 | * declared in an NgModule. They can be used independently or imported directly into other 49 | * standalone components, directives, or pipes. 50 | */ 51 | standalone?: boolean; 52 | /** 53 | * The separator character to use before the type within the generated file's name. For 54 | * example, if you set the option to `.`, the file will be named `example.pipe.ts`. 55 | */ 56 | typeSeparator?: TypeSeparator; 57 | }; 58 | /** 59 | * The separator character to use before the type within the generated file's name. For 60 | * example, if you set the option to `.`, the file will be named `example.pipe.ts`. 61 | */ 62 | export declare enum TypeSeparator { 63 | Empty = "-", 64 | TypeSeparator = "." 65 | } 66 | -------------------------------------------------------------------------------- /pipe/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 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.pipe.ts`. 9 | */ 10 | var TypeSeparator; 11 | (function (TypeSeparator) { 12 | TypeSeparator["Empty"] = "-"; 13 | TypeSeparator["TypeSeparator"] = "."; 14 | })(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {})); 15 | -------------------------------------------------------------------------------- /resolver/class-files/__name@dasherize____typeSeparator__resolver.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { <%= classify(name) %>Resolver } from './<%= dasherize(name) %><%= typeSeparator %>resolver'; 4 | 5 | describe('<%= classify(name) %>Resolver', () => { 6 | let resolver: <%= classify(name) %>Resolver; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | resolver = TestBed.inject(<%= classify(name) %>Resolver); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(resolver).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /resolver/class-files/__name@dasherize____typeSeparator__resolver.ts.template: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { 3 | Router, Resolve, 4 | RouterStateSnapshot, 5 | ActivatedRouteSnapshot 6 | } from '@angular/router'; 7 | import { Observable, of } from 'rxjs'; 8 | 9 | @Injectable({ 10 | providedIn: 'root' 11 | }) 12 | export class <%= classify(name) %>Resolver implements Resolve { 13 | resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { 14 | return of(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /resolver/functional-files/__name@dasherize____typeSeparator__resolver.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { ResolveFn } from '@angular/router'; 3 | 4 | import { <%= camelize(name) %>Resolver } from './<%= dasherize(name) %><%= typeSeparator %>resolver'; 5 | 6 | describe('<%= camelize(name) %>Resolver', () => { 7 | const executeResolver: ResolveFn = (...resolverParameters) => 8 | TestBed.runInInjectionContext(() => <%= camelize(name) %>Resolver(...resolverParameters)); 9 | 10 | beforeEach(() => { 11 | TestBed.configureTestingModule({}); 12 | }); 13 | 14 | it('should be created', () => { 15 | expect(executeResolver).toBeTruthy(); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /resolver/functional-files/__name@dasherize____typeSeparator__resolver.ts.template: -------------------------------------------------------------------------------- 1 | import { ResolveFn } from '@angular/router'; 2 | 3 | export const <%= camelize(name) %>Resolver: ResolveFn = (route, state) => { 4 | return true; 5 | }; 6 | -------------------------------------------------------------------------------- /resolver/index.d.ts: -------------------------------------------------------------------------------- 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 | import type { Schema as ResolverOptions } from './schema'; 10 | export default function (options: ResolverOptions): Rule; 11 | -------------------------------------------------------------------------------- /resolver/index.js: -------------------------------------------------------------------------------- 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 generate_from_files_1 = require("../utility/generate-from-files"); 12 | function default_1(options) { 13 | const templateFilesDirectory = options.functional ? './functional-files' : './class-files'; 14 | return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory }); 15 | } 16 | -------------------------------------------------------------------------------- /resolver/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new resolver in your project. Resolvers are used to pre-fetch data before a 3 | * route is activated, ensuring that the necessary data is available before the component is 4 | * displayed. This can improve the user experience by preventing delays and loading states. 5 | * This schematic generates a new resolver with the specified name and options. 6 | */ 7 | export type Schema = { 8 | /** 9 | * Creates the new resolver files at the top level of the current project. If set to false, 10 | * a new folder with the resolver's name will be created to contain the files. 11 | */ 12 | flat?: boolean; 13 | /** 14 | * Creates the resolver as a function `ResolveFn` instead of a class. Functional resolvers 15 | * can be simpler for basic scenarios. 16 | */ 17 | functional?: boolean; 18 | /** 19 | * The name for the new resolver. This will be used to create the resolver's class and spec 20 | * files (e.g., `my-resolver.resolver.ts` and `my-resolver.resolver.spec.ts`). 21 | */ 22 | name: string; 23 | /** 24 | * The path where the resolver files should be created, relative to the current workspace. 25 | * If not provided, the resolver will be created in the current directory. 26 | */ 27 | path?: string; 28 | /** 29 | * The name of the project where the resolver should be created. If not specified, the CLI 30 | * will determine the project from the current directory. 31 | */ 32 | project: string; 33 | /** 34 | * Skip the generation of a unit test file `spec.ts` for the new resolver. 35 | */ 36 | skipTests?: boolean; 37 | /** 38 | * The separator character to use before the type within the generated file's name. For 39 | * example, if you set the option to `.`, the file will be named `example.resolver.ts`. 40 | */ 41 | typeSeparator?: TypeSeparator; 42 | }; 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.resolver.ts`. 46 | */ 47 | export declare enum TypeSeparator { 48 | Empty = "-", 49 | TypeSeparator = "." 50 | } 51 | -------------------------------------------------------------------------------- /resolver/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 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.resolver.ts`. 9 | */ 10 | var TypeSeparator; 11 | (function (TypeSeparator) { 12 | TypeSeparator["Empty"] = "-"; 13 | TypeSeparator["TypeSeparator"] = "."; 14 | })(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {})); 15 | -------------------------------------------------------------------------------- /resolver/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularResolver", 4 | "title": "Angular Resolver Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Creates a new resolver in your project. Resolvers are used to pre-fetch data before a route is activated, ensuring that the necessary data is available before the component is displayed. This can improve the user experience by preventing delays and loading states. This schematic generates a new resolver with the specified name and options.", 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new resolver. This will be used to create the resolver's class and spec files (e.g., `my-resolver.resolver.ts` and `my-resolver.resolver.spec.ts`).", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the resolver?" 17 | }, 18 | "skipTests": { 19 | "type": "boolean", 20 | "description": "Skip the generation of a unit test file `spec.ts` for the new resolver.", 21 | "default": false 22 | }, 23 | "flat": { 24 | "type": "boolean", 25 | "description": "Creates the new resolver files at the top level of the current project. If set to false, a new folder with the resolver's name will be created to contain the files.", 26 | "default": true 27 | }, 28 | "functional": { 29 | "type": "boolean", 30 | "description": "Creates the resolver as a function `ResolveFn` instead of a class. Functional resolvers can be simpler for basic scenarios.", 31 | "default": true 32 | }, 33 | "path": { 34 | "type": "string", 35 | "format": "path", 36 | "$default": { 37 | "$source": "workingDirectory" 38 | }, 39 | "description": "The path where the resolver files should be created, relative to the current workspace. If not provided, the resolver will be created in the current directory.", 40 | "visible": false 41 | }, 42 | "project": { 43 | "type": "string", 44 | "description": "The name of the project where the resolver should be created. If not specified, the CLI will determine the project from the current directory.", 45 | "$default": { 46 | "$source": "projectName" 47 | } 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.resolver.ts`." 54 | } 55 | }, 56 | "required": ["name", "project"] 57 | } 58 | -------------------------------------------------------------------------------- /server/files/application-builder/ngmodule-src/app/app.module.server.ts.template: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { provideServerRendering, withRoutes } from '@angular/ssr'; 3 | import { <%= appComponentName %> } from '<%= appComponentPath %>'; 4 | import { <%= appModuleName %> } from '<%= appModulePath %>'; 5 | import { serverRoutes } from './app.routes.server'; 6 | 7 | @NgModule({ 8 | imports: [<%= appModuleName %>], 9 | providers: [provideServerRendering(withRoutes(serverRoutes))], 10 | bootstrap: [<%= appComponentName %>], 11 | }) 12 | export class AppServerModule {} 13 | -------------------------------------------------------------------------------- /server/files/application-builder/ngmodule-src/app/app.routes.server.ts.template: -------------------------------------------------------------------------------- 1 | import { RenderMode, ServerRoute } from '@angular/ssr'; 2 | 3 | export const serverRoutes: ServerRoute[] = [ 4 | { 5 | path: '**', 6 | renderMode: RenderMode.Prerender 7 | } 8 | ]; 9 | -------------------------------------------------------------------------------- /server/files/application-builder/ngmodule-src/main.server.ts.template: -------------------------------------------------------------------------------- 1 | export { AppServerModule as default } from './app/app.module.server'; 2 | -------------------------------------------------------------------------------- /server/files/application-builder/standalone-src/app/app.config.server.ts.template: -------------------------------------------------------------------------------- 1 | import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; 2 | import { provideServerRendering, withRoutes } from '@angular/ssr'; 3 | import { appConfig } from './app.config'; 4 | import { serverRoutes } from './app.routes.server'; 5 | 6 | const serverConfig: ApplicationConfig = { 7 | providers: [ 8 | provideServerRendering(withRoutes(serverRoutes)) 9 | ] 10 | }; 11 | 12 | export const config = mergeApplicationConfig(appConfig, serverConfig); 13 | -------------------------------------------------------------------------------- /server/files/application-builder/standalone-src/app/app.routes.server.ts.template: -------------------------------------------------------------------------------- 1 | import { RenderMode, ServerRoute } from '@angular/ssr'; 2 | 3 | export const serverRoutes: ServerRoute[] = [ 4 | { 5 | path: '**', 6 | renderMode: RenderMode.Prerender 7 | } 8 | ]; 9 | -------------------------------------------------------------------------------- /server/files/application-builder/standalone-src/main.server.ts.template: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { <%= appComponentName %> } from '<%= appComponentPath %>'; 3 | import { config } from './app/app.config.server'; 4 | 5 | const bootstrap = () => bootstrapApplication(<%= appComponentName %>, config); 6 | 7 | export default bootstrap; 8 | -------------------------------------------------------------------------------- /server/files/server-builder/ngmodule-src/app/app.module.server.ts.template: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { ServerModule } from '@angular/platform-server'; 3 | 4 | import { <%= appModuleName %> } from '<%= appModulePath %>'; 5 | import { <%= appComponentName %> } from '<%= appComponentPath %>'; 6 | 7 | @NgModule({ 8 | imports: [ 9 | <%= appModuleName %>, 10 | ServerModule, 11 | ], 12 | bootstrap: [<%= appComponentName %>], 13 | }) 14 | export class AppServerModule {} 15 | -------------------------------------------------------------------------------- /server/files/server-builder/ngmodule-src/main.server.ts.template: -------------------------------------------------------------------------------- 1 | export { AppServerModule as default } from './app/app.module.server'; 2 | -------------------------------------------------------------------------------- /server/files/server-builder/root/tsconfig.server.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./<%= tsConfigExtends %>", 5 | "compilerOptions": { 6 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/server", 7 | "types": [ 8 | "node"<% if (hasLocalizePackage) { %>, 9 | "@angular/localize"<% } %> 10 | ] 11 | }, 12 | "files": [ 13 | "src/main.server.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /server/files/server-builder/standalone-src/app/app.config.server.ts.template: -------------------------------------------------------------------------------- 1 | import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; 2 | import { provideServerRendering } from '@angular/ssr'; 3 | import { appConfig } from './app.config'; 4 | 5 | const serverConfig: ApplicationConfig = { 6 | providers: [ 7 | provideServerRendering() 8 | ] 9 | }; 10 | 11 | export const config = mergeApplicationConfig(appConfig, serverConfig); 12 | -------------------------------------------------------------------------------- /server/files/server-builder/standalone-src/main.server.ts.template: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { <%= appComponentName %> } from '<%= appComponentPath %>'; 3 | import { config } from './app/app.config.server'; 4 | 5 | const bootstrap = () => bootstrapApplication(<%= appComponentName %>, config); 6 | 7 | export default bootstrap; 8 | -------------------------------------------------------------------------------- /server/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ServerOptions } from './schema'; 10 | export default function (options: ServerOptions): Rule; 11 | -------------------------------------------------------------------------------- /server/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Sets up server-side rendering (SSR) for your Angular application. SSR allows your app to 3 | * be rendered on the server, improving initial load performance and SEO. This schematic 4 | * configures your project for SSR and generates the necessary files. 5 | */ 6 | export type Schema = { 7 | /** 8 | * The name of the project to enable server-side rendering for. 9 | */ 10 | project: string; 11 | /** 12 | * Skip the automatic installation of packages. You will need to manually install the 13 | * dependencies later. 14 | */ 15 | skipInstall?: boolean; 16 | }; 17 | -------------------------------------------------------------------------------- /server/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /server/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularServerApp", 4 | "title": "Angular Server App Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Sets up server-side rendering (SSR) for your Angular application. SSR allows your app to be rendered on the server, improving initial load performance and SEO. This schematic configures your project for SSR and generates the necessary files.", 8 | "properties": { 9 | "project": { 10 | "type": "string", 11 | "description": "The name of the project to enable server-side rendering for.", 12 | "$default": { 13 | "$source": "projectName" 14 | } 15 | }, 16 | "skipInstall": { 17 | "description": "Skip the automatic installation of packages. You will need to manually install the dependencies later.", 18 | "type": "boolean", 19 | "default": false 20 | } 21 | }, 22 | "required": ["project"] 23 | } 24 | -------------------------------------------------------------------------------- /service-worker/files/ngsw-config.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "<%= relativePathToWorkspaceRoot %>/node_modules/@angular/service-worker/config/schema.json", 3 | "index": "/index.html", 4 | "assetGroups": [ 5 | { 6 | "name": "app", 7 | "installMode": "prefetch", 8 | "resources": { 9 | "files": [ 10 | "/favicon.ico", 11 | "/index.csr.html", 12 | "/index.html", 13 | "/manifest.webmanifest", 14 | "/*.css", 15 | "/*.js" 16 | ] 17 | } 18 | }, 19 | { 20 | "name": "assets", 21 | "installMode": "lazy", 22 | "updateMode": "prefetch", 23 | "resources": { 24 | "files": [ 25 | "/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)" 26 | ] 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /service-worker/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ServiceWorkerOptions } from './schema'; 10 | export default function (options: ServiceWorkerOptions): Rule; 11 | -------------------------------------------------------------------------------- /service-worker/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Adds a service worker to your project. Service workers enable your application to work 3 | * offline or on low-quality networks by caching assets and intercepting network requests. 4 | * This schematic configures your project to use a service worker. 5 | */ 6 | export type Schema = { 7 | /** 8 | * The name of the project to add the service worker to. If not specified, the CLI will 9 | * determine the project from the current directory. 10 | */ 11 | project: string; 12 | /** 13 | * The build target to apply the service worker to. This is typically `build`, indicating 14 | * that the service worker should be generated during the standard build process. 15 | */ 16 | target?: string; 17 | }; 18 | -------------------------------------------------------------------------------- /service-worker/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /service-worker/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularServiceWorker", 4 | "title": "Angular Service Worker Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Adds a service worker to your project. Service workers enable your application to work offline or on low-quality networks by caching assets and intercepting network requests. This schematic configures your project to use a service worker.", 8 | "properties": { 9 | "project": { 10 | "type": "string", 11 | "description": "The name of the project to add the service worker to. If not specified, the CLI will determine the project from the current directory.", 12 | "$default": { 13 | "$source": "projectName" 14 | } 15 | }, 16 | "target": { 17 | "type": "string", 18 | "description": "The build target to apply the service worker to. This is typically `build`, indicating that the service worker should be generated during the standard build process.", 19 | "default": "build" 20 | } 21 | }, 22 | "required": ["project"] 23 | } 24 | -------------------------------------------------------------------------------- /service/files/__name@dasherize__.__type@dasherize__.spec.ts.template: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { <%= classify(name) %><%= classify(type) %> } from './<%= dasherize(name) %><%= type ? '.' + dasherize(type) : '' %>'; 4 | 5 | describe('<%= classify(name) %><%= classify(type) %>', () => { 6 | let service: <%= classify(name) %><%= classify(type) %>; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(<%= classify(name) %><%= classify(type) %>); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /service/files/__name@dasherize__.__type@dasherize__.ts.template: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class <%= classify(name) %><%= classify(type) %> { 7 | 8 | constructor() { } 9 | } 10 | -------------------------------------------------------------------------------- /service/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as ServiceOptions } from './schema'; 10 | export default function (options: ServiceOptions): Rule; 11 | -------------------------------------------------------------------------------- /service/index.js: -------------------------------------------------------------------------------- 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 generate_from_files_1 = require("../utility/generate-from-files"); 12 | function default_1(options) { 13 | return (0, generate_from_files_1.generateFromFiles)(options); 14 | } 15 | -------------------------------------------------------------------------------- /service/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new service in your project. Services are used to encapsulate reusable logic, 3 | * such as data access, API calls, or utility functions. This schematic simplifies the 4 | * process of generating a new service with the necessary files and boilerplate code. 5 | */ 6 | export type Schema = { 7 | /** 8 | * Creates files at the top level of the project or the given path. If set to false, a new 9 | * folder with the service's name will be created to contain the files. 10 | */ 11 | flat?: boolean; 12 | /** 13 | * The name for the new service. This will be used to create the service's class and spec 14 | * files (e.g., `my-service.service.ts` and `my-service.service.spec.ts`). 15 | */ 16 | name: string; 17 | /** 18 | * The path where the service files should be created, relative to the workspace root. If 19 | * not provided, the service will be created in the project's `src/app` directory. 20 | */ 21 | path?: string; 22 | /** 23 | * The name of the project where the service should be added. If not specified, the CLI will 24 | * determine the project from the current directory. 25 | */ 26 | project: string; 27 | /** 28 | * Skip the generation of a unit test file `spec.ts` for the service. 29 | */ 30 | skipTests?: boolean; 31 | /** 32 | * Append a custom type to the service's filename. For example, if you set the type to 33 | * `service`, the file will be named `my-service.service.ts`. 34 | */ 35 | type?: string; 36 | }; 37 | -------------------------------------------------------------------------------- /service/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /service/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularService", 4 | "title": "Angular Service Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Creates a new service in your project. Services are used to encapsulate reusable logic, such as data access, API calls, or utility functions. This schematic simplifies the process of generating a new service with the necessary files and boilerplate code.", 8 | "properties": { 9 | "name": { 10 | "type": "string", 11 | "description": "The name for the new service. This will be used to create the service's class and spec files (e.g., `my-service.service.ts` and `my-service.service.spec.ts`).", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | }, 16 | "x-prompt": "What name would you like to use for the service?" 17 | }, 18 | "path": { 19 | "type": "string", 20 | "$default": { 21 | "$source": "workingDirectory" 22 | }, 23 | "description": "The path where the service files should be created, relative to the workspace root. If not provided, the service will be created in the project's `src/app` directory.", 24 | "visible": false 25 | }, 26 | "project": { 27 | "type": "string", 28 | "description": "The name of the project where the service should be added. If not specified, the CLI will determine the project from the current directory.", 29 | "$default": { 30 | "$source": "projectName" 31 | } 32 | }, 33 | "flat": { 34 | "type": "boolean", 35 | "default": true, 36 | "description": "Creates files at the top level of the project or the given path. If set to false, a new folder with the service's name will be created to contain the files." 37 | }, 38 | "skipTests": { 39 | "type": "boolean", 40 | "description": "Skip the generation of a unit test file `spec.ts` for the service.", 41 | "default": false 42 | }, 43 | "type": { 44 | "type": "string", 45 | "description": "Append a custom type to the service's filename. For example, if you set the type to `service`, the file will be named `my-service.service.ts`." 46 | } 47 | }, 48 | "required": ["name", "project"] 49 | } 50 | -------------------------------------------------------------------------------- /ssr/files/application-builder/server.ts.template: -------------------------------------------------------------------------------- 1 | import { 2 | AngularNodeAppEngine, 3 | createNodeRequestHandler, 4 | isMainModule, 5 | writeResponseToNodeResponse, 6 | } from '@angular/ssr/node'; 7 | import express from 'express'; 8 | import { join } from 'node:path'; 9 | 10 | const browserDistFolder = join(import.meta.dirname, '../<%= browserDistDirectory %>'); 11 | 12 | const app = express(); 13 | const angularApp = new AngularNodeAppEngine(); 14 | 15 | /** 16 | * Example Express Rest API endpoints can be defined here. 17 | * Uncomment and define endpoints as necessary. 18 | * 19 | * Example: 20 | * ```ts 21 | * app.get('/api/{*splat}', (req, res) => { 22 | * // Handle API request 23 | * }); 24 | * ``` 25 | */ 26 | 27 | /** 28 | * Serve static files from /<%= browserDistDirectory %> 29 | */ 30 | app.use( 31 | express.static(browserDistFolder, { 32 | maxAge: '1y', 33 | index: false, 34 | redirect: false, 35 | }), 36 | ); 37 | 38 | /** 39 | * Handle all other requests by rendering the Angular application. 40 | */ 41 | app.use((req, res, next) => { 42 | angularApp 43 | .handle(req) 44 | .then((response) => 45 | response ? writeResponseToNodeResponse(response, res) : next(), 46 | ) 47 | .catch(next); 48 | }); 49 | 50 | /** 51 | * Start the server if this module is the main entry point. 52 | * The server listens on the port defined by the `PORT` environment variable, or defaults to 4000. 53 | */ 54 | if (isMainModule(import.meta.url)) { 55 | const port = process.env['PORT'] || 4000; 56 | app.listen(port, (error) => { 57 | if (error) { 58 | throw error; 59 | } 60 | 61 | console.log(`Node Express server listening on http://localhost:${port}`); 62 | }); 63 | } 64 | 65 | /** 66 | * Request handler used by the Angular CLI (for dev-server and during build) or Firebase Cloud Functions. 67 | */ 68 | export const reqHandler = createNodeRequestHandler(app); 69 | -------------------------------------------------------------------------------- /ssr/files/server-builder/server.ts.template: -------------------------------------------------------------------------------- 1 | import 'zone.js/node'; 2 | 3 | import { APP_BASE_HREF } from '@angular/common'; 4 | import { CommonEngine } from '@angular/ssr/node'; 5 | import express from 'express'; 6 | import { existsSync } from 'node:fs'; 7 | import { join } from 'node:path'; 8 | import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './main.server'; 9 | 10 | // The Express app is exported so that it can be used by serverless Functions. 11 | export function app(): express.Express { 12 | const server = express(); 13 | const distFolder = join(process.cwd(), '<%= browserDistDirectory %>'); 14 | const indexHtml = existsSync(join(distFolder, 'index.original.html')) 15 | ? join(distFolder, 'index.original.html') 16 | : join(distFolder, 'index.html'); 17 | 18 | const commonEngine = new CommonEngine(); 19 | 20 | server.set('view engine', 'html'); 21 | server.set('views', distFolder); 22 | 23 | // Example Express Rest API endpoints 24 | // server.get('/api/{*splat}', (req, res) => { }); 25 | // Serve static files from /browser 26 | server.use(express.static(distFolder, { 27 | maxAge: '1y', 28 | index: false, 29 | })); 30 | 31 | // All regular routes use the Angular engine 32 | server.use((req, res, next) => { 33 | const { protocol, originalUrl, baseUrl, headers } = req; 34 | 35 | commonEngine 36 | .render({ 37 | <% if (isStandalone) { %>bootstrap<% } else { %>bootstrap: AppServerModule<% } %>, 38 | documentFilePath: indexHtml, 39 | url: `${protocol}://${headers.host}${originalUrl}`, 40 | publicPath: distFolder, 41 | providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], 42 | }) 43 | .then((html) => res.send(html)) 44 | .catch((err) => next(err)); 45 | }); 46 | 47 | return server; 48 | } 49 | 50 | function run(): void { 51 | const port = process.env['PORT'] || 4000; 52 | 53 | // Start up the Node server 54 | const server = app(); 55 | server.listen(port, (error) => { 56 | if (error) { 57 | throw error; 58 | } 59 | 60 | console.log(`Node Express server listening on http://localhost:${port}`); 61 | }); 62 | } 63 | 64 | // Webpack will replace 'require' with '__webpack_require__' 65 | // '__non_webpack_require__' is a proxy to Node 'require' 66 | // The below code is to ensure that the server is run only when not requiring the bundle. 67 | declare const __non_webpack_require__: NodeRequire; 68 | const mainModule = __non_webpack_require__.main; 69 | const moduleFilename = mainModule && mainModule.filename || ''; 70 | if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { 71 | run(); 72 | } 73 | 74 | export default <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %>; 75 | -------------------------------------------------------------------------------- /ssr/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as SSROptions } from './schema'; 10 | export default function (options: SSROptions): Rule; 11 | -------------------------------------------------------------------------------- /ssr/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Enables Server-Side Rendering (SSR) for your Angular application. SSR allows your app to 3 | * be rendered on the server, which can significantly improve its initial load performance 4 | * and Search Engine Optimization (SEO). This schematic configures your project for SSR, 5 | * generating the necessary files and making the required modifications to your project's 6 | * structure. 7 | */ 8 | export type Schema = { 9 | /** 10 | * The name of the project you want to enable SSR for. 11 | */ 12 | project: string; 13 | /** 14 | * Skip the automatic installation of packages. You will need to manually install the 15 | * dependencies later. 16 | */ 17 | skipInstall?: boolean; 18 | }; 19 | -------------------------------------------------------------------------------- /ssr/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /ssr/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularSSR", 4 | "title": "Angular SSR Options Schema", 5 | "type": "object", 6 | "description": "Enables Server-Side Rendering (SSR) for your Angular application. SSR allows your app to be rendered on the server, which can significantly improve its initial load performance and Search Engine Optimization (SEO). This schematic configures your project for SSR, generating the necessary files and making the required modifications to your project's structure.", 7 | "properties": { 8 | "project": { 9 | "type": "string", 10 | "description": "The name of the project you want to enable SSR for.", 11 | "$default": { 12 | "$source": "projectName" 13 | } 14 | }, 15 | "skipInstall": { 16 | "description": "Skip the automatic installation of packages. You will need to manually install the dependencies later.", 17 | "type": "boolean", 18 | "default": false 19 | } 20 | }, 21 | "required": ["project"], 22 | "additionalProperties": false 23 | } 24 | -------------------------------------------------------------------------------- /ssr/tty.d.ts: -------------------------------------------------------------------------------- 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 | export declare function isTTY(): boolean; 9 | -------------------------------------------------------------------------------- /ssr/tty.js: -------------------------------------------------------------------------------- 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.isTTY = isTTY; 11 | function _isTruthy(value) { 12 | // Returns true if value is a string that is anything but 0 or false. 13 | return value !== undefined && value !== '0' && value.toUpperCase() !== 'FALSE'; 14 | } 15 | function isTTY() { 16 | // If we force TTY, we always return true. 17 | const force = process.env['NG_FORCE_TTY']; 18 | if (force !== undefined) { 19 | return _isTruthy(force); 20 | } 21 | return !!process.stdout.isTTY && !_isTruthy(process.env['CI']); 22 | } 23 | -------------------------------------------------------------------------------- /uniqueId: -------------------------------------------------------------------------------- 1 | Thu Jun 12 2025 15:18:45 GMT+0000 (Coordinated Universal Time) -------------------------------------------------------------------------------- /utility/add-declaration-to-ng-module.d.ts: -------------------------------------------------------------------------------- 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 interface DeclarationToNgModuleOptions { 10 | module?: string; 11 | path?: string; 12 | name: string; 13 | flat?: boolean; 14 | export?: boolean; 15 | type: string; 16 | typeSeparator?: '.' | '-'; 17 | skipImport?: boolean; 18 | standalone?: boolean; 19 | } 20 | export declare function addDeclarationToNgModule(options: DeclarationToNgModuleOptions): Rule; 21 | -------------------------------------------------------------------------------- /utility/change.d.ts: -------------------------------------------------------------------------------- 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 { UpdateRecorder } from '@angular-devkit/schematics'; 9 | export interface Host { 10 | write(path: string, content: string): Promise; 11 | read(path: string): Promise; 12 | } 13 | export interface Change { 14 | apply(host: Host): Promise; 15 | readonly path: string | null; 16 | readonly order: number; 17 | readonly description: string; 18 | } 19 | /** 20 | * An operation that does nothing. 21 | */ 22 | export declare class NoopChange implements Change { 23 | description: string; 24 | order: number; 25 | path: null; 26 | apply(): Promise; 27 | } 28 | /** 29 | * Will add text to the source code. 30 | */ 31 | export declare class InsertChange implements Change { 32 | path: string; 33 | pos: number; 34 | toAdd: string; 35 | order: number; 36 | description: string; 37 | constructor(path: string, pos: number, toAdd: string); 38 | /** 39 | * This method does not insert spaces if there is none in the original string. 40 | */ 41 | apply(host: Host): Promise; 42 | } 43 | /** 44 | * Will remove text from the source code. 45 | */ 46 | export declare class RemoveChange implements Change { 47 | path: string; 48 | private pos; 49 | toRemove: string; 50 | order: number; 51 | description: string; 52 | constructor(path: string, pos: number, toRemove: string); 53 | apply(host: Host): Promise; 54 | } 55 | /** 56 | * Will replace text from the source code. 57 | */ 58 | export declare class ReplaceChange implements Change { 59 | path: string; 60 | private pos; 61 | oldText: string; 62 | newText: string; 63 | order: number; 64 | description: string; 65 | constructor(path: string, pos: number, oldText: string, newText: string); 66 | apply(host: Host): Promise; 67 | } 68 | export declare function applyToUpdateRecorder(recorder: UpdateRecorder, changes: Change[]): void; 69 | -------------------------------------------------------------------------------- /utility/dependencies.d.ts: -------------------------------------------------------------------------------- 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 { Tree } from '@angular-devkit/schematics'; 9 | export declare enum NodeDependencyType { 10 | Default = "dependencies", 11 | Dev = "devDependencies", 12 | Peer = "peerDependencies", 13 | Optional = "optionalDependencies" 14 | } 15 | export interface NodeDependency { 16 | type: NodeDependencyType; 17 | name: string; 18 | version: string; 19 | overwrite?: boolean; 20 | } 21 | export declare function addPackageJsonDependency(tree: Tree, dependency: NodeDependency, pkgJsonPath?: string): void; 22 | export declare function removePackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): void; 23 | export declare function getPackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): NodeDependency | null; 24 | -------------------------------------------------------------------------------- /utility/dependencies.js: -------------------------------------------------------------------------------- 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.NodeDependencyType = void 0; 11 | exports.addPackageJsonDependency = addPackageJsonDependency; 12 | exports.removePackageJsonDependency = removePackageJsonDependency; 13 | exports.getPackageJsonDependency = getPackageJsonDependency; 14 | const json_file_1 = require("./json-file"); 15 | const PKG_JSON_PATH = '/package.json'; 16 | var NodeDependencyType; 17 | (function (NodeDependencyType) { 18 | NodeDependencyType["Default"] = "dependencies"; 19 | NodeDependencyType["Dev"] = "devDependencies"; 20 | NodeDependencyType["Peer"] = "peerDependencies"; 21 | NodeDependencyType["Optional"] = "optionalDependencies"; 22 | })(NodeDependencyType || (exports.NodeDependencyType = NodeDependencyType = {})); 23 | const ALL_DEPENDENCY_TYPE = [ 24 | NodeDependencyType.Default, 25 | NodeDependencyType.Dev, 26 | NodeDependencyType.Optional, 27 | NodeDependencyType.Peer, 28 | ]; 29 | function addPackageJsonDependency(tree, dependency, pkgJsonPath = PKG_JSON_PATH) { 30 | const json = new json_file_1.JSONFile(tree, pkgJsonPath); 31 | const { overwrite, type, name, version } = dependency; 32 | const path = [type, name]; 33 | if (overwrite || !json.get(path)) { 34 | json.modify(path, version); 35 | } 36 | } 37 | function removePackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) { 38 | const json = new json_file_1.JSONFile(tree, pkgJsonPath); 39 | for (const depType of ALL_DEPENDENCY_TYPE) { 40 | json.remove([depType, name]); 41 | } 42 | } 43 | function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) { 44 | const json = new json_file_1.JSONFile(tree, pkgJsonPath); 45 | for (const depType of ALL_DEPENDENCY_TYPE) { 46 | const version = json.get([depType, name]); 47 | if (typeof version === 'string') { 48 | return { 49 | type: depType, 50 | name: name, 51 | version, 52 | }; 53 | } 54 | } 55 | return null; 56 | } 57 | -------------------------------------------------------------------------------- /utility/eol.d.ts: -------------------------------------------------------------------------------- 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 | export declare function getEOL(content: string): string; 9 | -------------------------------------------------------------------------------- /utility/eol.js: -------------------------------------------------------------------------------- 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.getEOL = getEOL; 11 | const node_os_1 = require("node:os"); 12 | const CRLF = '\r\n'; 13 | const LF = '\n'; 14 | function getEOL(content) { 15 | const newlines = content.match(/(?:\r?\n)/g); 16 | if (newlines?.length) { 17 | const crlf = newlines.filter((l) => l === CRLF).length; 18 | const lf = newlines.length - crlf; 19 | return crlf > lf ? CRLF : LF; 20 | } 21 | return node_os_1.EOL; 22 | } 23 | -------------------------------------------------------------------------------- /utility/find-module.d.ts: -------------------------------------------------------------------------------- 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 { Path } from '@angular-devkit/core'; 9 | import { Tree } from '@angular-devkit/schematics'; 10 | export interface ModuleOptions { 11 | module?: string; 12 | name: string; 13 | flat?: boolean; 14 | path?: string; 15 | skipImport?: boolean; 16 | moduleExt?: string; 17 | routingModuleExt?: string; 18 | standalone?: boolean; 19 | } 20 | export declare const MODULE_EXT = "-module.ts"; 21 | export declare const ROUTING_MODULE_EXT = "-routing-module.ts"; 22 | export declare const MODULE_EXT_LEGACY = ".module.ts"; 23 | export declare const ROUTING_MODULE_EXT_LEGACY = "-routing.module.ts"; 24 | /** 25 | * Find the module referred by a set of options passed to the schematics. 26 | */ 27 | export declare function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined; 28 | /** 29 | * Function to find the "closest" module to a generated file's path. 30 | */ 31 | export declare function findModule(host: Tree, generateDir: string, moduleExt?: string, routingModuleExt?: string): Path; 32 | /** 33 | * Build a relative path from one file path to another file path. 34 | */ 35 | export declare function buildRelativePath(from: string, to: string): string; 36 | -------------------------------------------------------------------------------- /utility/generate-from-files.d.ts: -------------------------------------------------------------------------------- 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 interface GenerateFromFilesOptions { 10 | flat?: boolean; 11 | name: string; 12 | path?: string; 13 | prefix?: string; 14 | project: string; 15 | skipTests?: boolean; 16 | templateFilesDirectory?: string; 17 | type?: string; 18 | } 19 | export declare function generateFromFiles(options: GenerateFromFilesOptions, extraTemplateValues?: Record string)>): Rule; 20 | -------------------------------------------------------------------------------- /utility/generate-from-files.js: -------------------------------------------------------------------------------- 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.generateFromFiles = generateFromFiles; 11 | const schematics_1 = require("@angular-devkit/schematics"); 12 | const parse_name_1 = require("./parse-name"); 13 | const validation_1 = require("./validation"); 14 | const workspace_1 = require("./workspace"); 15 | function generateFromFiles(options, extraTemplateValues = {}) { 16 | return async (host) => { 17 | options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project); 18 | options.prefix ??= ''; 19 | options.flat ??= true; 20 | // Schematic templates require a defined type value 21 | options.type ??= ''; 22 | const parsedPath = (0, parse_name_1.parseName)(options.path, options.name); 23 | options.name = parsedPath.name; 24 | options.path = parsedPath.path; 25 | (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name)); 26 | const templateFilesDirectory = options.templateFilesDirectory ?? './files'; 27 | const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(templateFilesDirectory), [ 28 | options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(), 29 | (0, schematics_1.applyTemplates)({ 30 | ...schematics_1.strings, 31 | ...options, 32 | ...extraTemplateValues, 33 | }), 34 | !options.type 35 | ? (0, schematics_1.forEach)((file) => { 36 | let filePath = file.path; 37 | while (filePath.includes('..')) { 38 | filePath = filePath.replaceAll('..', '.'); 39 | } 40 | return { 41 | content: file.content, 42 | path: filePath, 43 | }; 44 | }) 45 | : (0, schematics_1.noop)(), 46 | (0, schematics_1.move)(parsedPath.path + (options.flat ? '' : '/' + schematics_1.strings.dasherize(options.name))), 47 | ]); 48 | return (0, schematics_1.chain)([(0, schematics_1.mergeWith)(templateSource)]); 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /utility/index.d.ts: -------------------------------------------------------------------------------- 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 | export { type ProjectDefinition, type TargetDefinition, type WorkspaceDefinition, getWorkspace as readWorkspace, updateWorkspace, writeWorkspace, } from './workspace'; 9 | export { Builders as AngularBuilder } from './workspace-models'; 10 | export * from './standalone'; 11 | export { DependencyType, ExistingBehavior, InstallBehavior, addDependency } from './dependency'; 12 | -------------------------------------------------------------------------------- /utility/index.js: -------------------------------------------------------------------------------- 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 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | var desc = Object.getOwnPropertyDescriptor(m, k); 12 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 13 | desc = { enumerable: true, get: function() { return m[k]; } }; 14 | } 15 | Object.defineProperty(o, k2, desc); 16 | }) : (function(o, m, k, k2) { 17 | if (k2 === undefined) k2 = k; 18 | o[k2] = m[k]; 19 | })); 20 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 21 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 22 | }; 23 | Object.defineProperty(exports, "__esModule", { value: true }); 24 | exports.addDependency = exports.InstallBehavior = exports.ExistingBehavior = exports.DependencyType = exports.AngularBuilder = exports.writeWorkspace = exports.updateWorkspace = exports.readWorkspace = void 0; 25 | // Workspace related rules and types 26 | var workspace_1 = require("./workspace"); 27 | Object.defineProperty(exports, "readWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } }); 28 | Object.defineProperty(exports, "updateWorkspace", { enumerable: true, get: function () { return workspace_1.updateWorkspace; } }); 29 | Object.defineProperty(exports, "writeWorkspace", { enumerable: true, get: function () { return workspace_1.writeWorkspace; } }); 30 | var workspace_models_1 = require("./workspace-models"); 31 | Object.defineProperty(exports, "AngularBuilder", { enumerable: true, get: function () { return workspace_models_1.Builders; } }); 32 | __exportStar(require("./standalone"), exports); 33 | // Package dependency related rules and types 34 | var dependency_1 = require("./dependency"); 35 | Object.defineProperty(exports, "DependencyType", { enumerable: true, get: function () { return dependency_1.DependencyType; } }); 36 | Object.defineProperty(exports, "ExistingBehavior", { enumerable: true, get: function () { return dependency_1.ExistingBehavior; } }); 37 | Object.defineProperty(exports, "InstallBehavior", { enumerable: true, get: function () { return dependency_1.InstallBehavior; } }); 38 | Object.defineProperty(exports, "addDependency", { enumerable: true, get: function () { return dependency_1.addDependency; } }); 39 | -------------------------------------------------------------------------------- /utility/json-file.d.ts: -------------------------------------------------------------------------------- 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 { JsonValue } from '@angular-devkit/core'; 9 | import { Tree } from '@angular-devkit/schematics'; 10 | export type InsertionIndex = (properties: string[]) => number; 11 | export type JSONPath = (string | number)[]; 12 | /** @private */ 13 | export declare class JSONFile { 14 | private readonly host; 15 | private readonly path; 16 | content: string; 17 | private eol; 18 | constructor(host: Tree, path: string); 19 | private _jsonAst; 20 | private get JsonAst(); 21 | get(jsonPath: JSONPath): unknown; 22 | modify(jsonPath: JSONPath, value: JsonValue | undefined, insertInOrder?: InsertionIndex | false): void; 23 | remove(jsonPath: JSONPath): void; 24 | } 25 | -------------------------------------------------------------------------------- /utility/json-file.js: -------------------------------------------------------------------------------- 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.JSONFile = void 0; 11 | const jsonc_parser_1 = require("jsonc-parser"); 12 | const eol_1 = require("./eol"); 13 | /** @private */ 14 | class JSONFile { 15 | host; 16 | path; 17 | content; 18 | eol; 19 | constructor(host, path) { 20 | this.host = host; 21 | this.path = path; 22 | this.content = this.host.readText(this.path); 23 | this.eol = (0, eol_1.getEOL)(this.content); 24 | } 25 | _jsonAst; 26 | get JsonAst() { 27 | if (this._jsonAst) { 28 | return this._jsonAst; 29 | } 30 | const errors = []; 31 | this._jsonAst = (0, jsonc_parser_1.parseTree)(this.content, errors, { allowTrailingComma: true }); 32 | if (errors.length) { 33 | const { error, offset } = errors[0]; 34 | throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${(0, jsonc_parser_1.printParseErrorCode)(error)} at location: ${offset}.`); 35 | } 36 | return this._jsonAst; 37 | } 38 | get(jsonPath) { 39 | const jsonAstNode = this.JsonAst; 40 | if (!jsonAstNode) { 41 | return undefined; 42 | } 43 | if (jsonPath.length === 0) { 44 | return (0, jsonc_parser_1.getNodeValue)(jsonAstNode); 45 | } 46 | const node = (0, jsonc_parser_1.findNodeAtLocation)(jsonAstNode, jsonPath); 47 | return node === undefined ? undefined : (0, jsonc_parser_1.getNodeValue)(node); 48 | } 49 | modify(jsonPath, value, insertInOrder) { 50 | let getInsertionIndex; 51 | if (insertInOrder === undefined) { 52 | const property = jsonPath.slice(-1)[0]; 53 | getInsertionIndex = (properties) => [...properties, property].sort().findIndex((p) => p === property); 54 | } 55 | else if (insertInOrder !== false) { 56 | getInsertionIndex = insertInOrder; 57 | } 58 | const edits = (0, jsonc_parser_1.modify)(this.content, jsonPath, value, { 59 | getInsertionIndex, 60 | formattingOptions: { 61 | eol: this.eol, 62 | insertSpaces: true, 63 | tabSize: 2, 64 | }, 65 | }); 66 | if (edits.length > 0) { 67 | const editedContent = (0, jsonc_parser_1.applyEdits)(this.content, edits); 68 | // Update the file content if it changed 69 | if (editedContent !== this.content) { 70 | this.content = editedContent; 71 | this.host.overwrite(this.path, editedContent); 72 | this._jsonAst = undefined; 73 | } 74 | } 75 | } 76 | remove(jsonPath) { 77 | if (this.get(jsonPath) !== undefined) { 78 | this.modify(jsonPath, undefined); 79 | } 80 | } 81 | } 82 | exports.JSONFile = JSONFile; 83 | -------------------------------------------------------------------------------- /utility/latest-versions.d.ts: -------------------------------------------------------------------------------- 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 | export declare const latestVersions: Record & { 9 | Angular: string; 10 | DevkitBuildAngular: string; 11 | AngularBuild: string; 12 | AngularSSR: string; 13 | NgPackagr: string; 14 | }; 15 | -------------------------------------------------------------------------------- /utility/latest-versions.js: -------------------------------------------------------------------------------- 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.latestVersions = void 0; 11 | // We could have used TypeScripts' `resolveJsonModule` to make the `latestVersion` object typesafe, 12 | // but ts_library doesn't support JSON inputs. 13 | const dependencies = require('./latest-versions/package.json')['dependencies']; 14 | exports.latestVersions = { 15 | ...dependencies, 16 | // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current 17 | Angular: '^20.1.0-next.0', 18 | NgPackagr: '^20.1.0-next.0', 19 | DevkitBuildAngular: '^20.1.0-next.1+sha-ef742db', 20 | AngularBuild: '^20.1.0-next.1+sha-ef742db', 21 | AngularSSR: '^20.1.0-next.1+sha-ef742db', 22 | }; 23 | -------------------------------------------------------------------------------- /utility/latest-versions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Package versions used by schematics in @schematics/angular.", 3 | "comment": "This file is needed so that dependencies are synced by Renovate.", 4 | "private": true, 5 | "dependencies": { 6 | "@types/express": "^5.0.1", 7 | "@types/jasmine": "~5.1.0", 8 | "@types/node": "^20.17.19", 9 | "browser-sync": "^3.0.0", 10 | "express": "^5.1.0", 11 | "jasmine-core": "~5.8.0", 12 | "jasmine-spec-reporter": "~7.0.0", 13 | "karma-chrome-launcher": "~3.2.0", 14 | "karma-coverage": "~2.2.0", 15 | "karma-jasmine-html-reporter": "~2.1.0", 16 | "karma-jasmine": "~5.1.0", 17 | "karma": "~6.4.0", 18 | "less": "^4.2.0", 19 | "postcss": "^8.5.3", 20 | "protractor": "~7.0.0", 21 | "rxjs": "~7.8.0", 22 | "tslib": "^2.3.0", 23 | "ts-node": "~10.9.0", 24 | "typescript": "~5.8.2", 25 | "zone.js": "~0.15.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /utility/ng-ast-utils.d.ts: -------------------------------------------------------------------------------- 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 { Tree } from '@angular-devkit/schematics'; 9 | import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript'; 10 | export declare function findBootstrapModuleCall(host: Tree, mainPath: string): ts.CallExpression | null; 11 | export declare function getAppModulePath(host: Tree, mainPath: string): string; 12 | export declare function isStandaloneApp(host: Tree, mainPath: string): boolean; 13 | -------------------------------------------------------------------------------- /utility/parse-name.d.ts: -------------------------------------------------------------------------------- 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 { Path } from '@angular-devkit/core'; 9 | export interface Location { 10 | name: string; 11 | path: Path; 12 | } 13 | export declare function parseName(path: string, name: string): Location; 14 | -------------------------------------------------------------------------------- /utility/parse-name.js: -------------------------------------------------------------------------------- 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.parseName = parseName; 11 | const core_1 = require("@angular-devkit/core"); 12 | function parseName(path, name) { 13 | const nameWithoutPath = (0, core_1.basename)((0, core_1.normalize)(name)); 14 | const namePath = (0, core_1.dirname)((0, core_1.join)((0, core_1.normalize)(path), name)); 15 | return { 16 | name: nameWithoutPath, 17 | path: (0, core_1.normalize)('/' + namePath), 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /utility/paths.d.ts: -------------------------------------------------------------------------------- 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 | export declare function relativePathToWorkspaceRoot(projectRoot: string | undefined): string; 9 | -------------------------------------------------------------------------------- /utility/paths.js: -------------------------------------------------------------------------------- 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.relativePathToWorkspaceRoot = relativePathToWorkspaceRoot; 11 | const posix_1 = require("node:path/posix"); 12 | function relativePathToWorkspaceRoot(projectRoot) { 13 | if (!projectRoot) { 14 | return '.'; 15 | } 16 | return (0, posix_1.relative)((0, posix_1.join)('/', projectRoot), '/') || '.'; 17 | } 18 | -------------------------------------------------------------------------------- /utility/project-targets.d.ts: -------------------------------------------------------------------------------- 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 { SchematicsException } from '@angular-devkit/schematics'; 9 | import { ProjectDefinition } from './workspace'; 10 | export declare function targetBuildNotFoundError(): SchematicsException; 11 | export declare function isUsingApplicationBuilder(project: ProjectDefinition): boolean; 12 | -------------------------------------------------------------------------------- /utility/project-targets.js: -------------------------------------------------------------------------------- 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.targetBuildNotFoundError = targetBuildNotFoundError; 11 | exports.isUsingApplicationBuilder = isUsingApplicationBuilder; 12 | const schematics_1 = require("@angular-devkit/schematics"); 13 | const workspace_models_1 = require("./workspace-models"); 14 | function targetBuildNotFoundError() { 15 | return new schematics_1.SchematicsException(`Project target "build" not found.`); 16 | } 17 | function isUsingApplicationBuilder(project) { 18 | const buildBuilder = project.targets.get('build')?.builder; 19 | const isUsingApplicationBuilder = buildBuilder === workspace_models_1.Builders.Application || buildBuilder === workspace_models_1.Builders.BuildApplication; 20 | return isUsingApplicationBuilder; 21 | } 22 | -------------------------------------------------------------------------------- /utility/standalone/app_component.d.ts: -------------------------------------------------------------------------------- 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 { Tree } from '@angular-devkit/schematics'; 9 | /** Data resolved for a bootstrapped component. */ 10 | interface BootstrappedComponentData { 11 | /** Original name of the component class. */ 12 | componentName: string; 13 | /** Path under which the component was imported in the main entrypoint. */ 14 | componentImportPathInSameFile: string; 15 | /** Original name of the NgModule being bootstrapped, null if the app isn't module-based. */ 16 | moduleName: string | null; 17 | /** 18 | * Path under which the module was imported in the main entrypoint, 19 | * null if the app isn't module-based. 20 | */ 21 | moduleImportPathInSameFile: string | null; 22 | } 23 | /** 24 | * Finds the original name and path relative to the `main.ts` of the bootrstrapped app component. 25 | * @param tree File tree in which to look for the component. 26 | * @param mainFilePath Path of the `main` file. 27 | */ 28 | export declare function resolveBootstrappedComponentData(tree: Tree, mainFilePath: string): BootstrappedComponentData | null; 29 | export {}; 30 | -------------------------------------------------------------------------------- /utility/standalone/app_config.d.ts: -------------------------------------------------------------------------------- 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 { Tree } from '@angular-devkit/schematics'; 9 | import ts from '../../third_party/github.com/Microsoft/TypeScript/lib/typescript'; 10 | /** App config that was resolved to its source node. */ 11 | export interface ResolvedAppConfig { 12 | /** Tree-relative path of the file containing the app config. */ 13 | filePath: string; 14 | /** Node defining the app config. */ 15 | node: ts.ObjectLiteralExpression; 16 | } 17 | /** 18 | * Resolves the node that defines the app config from a bootstrap call. 19 | * @param bootstrapCall Call for which to resolve the config. 20 | * @param tree File tree of the project. 21 | * @param filePath File path of the bootstrap call. 22 | */ 23 | export declare function findAppConfig(bootstrapCall: ts.CallExpression, tree: Tree, filePath: string): ResolvedAppConfig | null; 24 | -------------------------------------------------------------------------------- /utility/standalone/code_block.d.ts: -------------------------------------------------------------------------------- 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 | /** Generated code that hasn't been interpolated yet. */ 10 | export interface PendingCode { 11 | /** Code that will be inserted. */ 12 | expression: string; 13 | /** Imports that need to be added to the file in which the code is inserted. */ 14 | imports: PendingImports; 15 | } 16 | /** Map keeping track of imports and aliases under which they're referred to in an expression. */ 17 | type PendingImports = Map>; 18 | /** 19 | * Callback invoked by a Rule that produces the code 20 | * that needs to be inserted somewhere in the app. 21 | */ 22 | export type CodeBlockCallback = (block: CodeBlock) => PendingCode; 23 | /** 24 | * Utility class used to generate blocks of code that 25 | * can be inserted by the devkit into a user's app. 26 | */ 27 | export declare class CodeBlock { 28 | private _imports; 29 | /** Function used to tag a code block in order to produce a `PendingCode` object. */ 30 | code: (strings: TemplateStringsArray, ...params: unknown[]) => PendingCode; 31 | /** 32 | * Used inside of a code block to mark external symbols and which module they should be imported 33 | * from. When the code is inserted, the required import statements will be produced automatically. 34 | * @param symbolName Name of the external symbol. 35 | * @param moduleName Module from which the symbol should be imported. 36 | */ 37 | external: (symbolName: string, moduleName: string) => string; 38 | /** 39 | * Produces the necessary rules to transform a `PendingCode` object into valid code. 40 | * @param initialCode Code pending transformed. 41 | * @param filePath Path of the file in which the code will be inserted. 42 | */ 43 | static transformPendingCode(initialCode: PendingCode, filePath: string): { 44 | code: { 45 | /** Code that will be inserted. */ 46 | expression: string; 47 | /** Imports that need to be added to the file in which the code is inserted. */ 48 | imports: PendingImports; 49 | }; 50 | rules: Rule[]; 51 | }; 52 | } 53 | export {}; 54 | -------------------------------------------------------------------------------- /utility/standalone/index.d.ts: -------------------------------------------------------------------------------- 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 | export { addRootImport, addRootProvider } from './rules'; 9 | export type { PendingCode, CodeBlockCallback, CodeBlock } from './code_block'; 10 | -------------------------------------------------------------------------------- /utility/standalone/index.js: -------------------------------------------------------------------------------- 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.addRootProvider = exports.addRootImport = void 0; 11 | var rules_1 = require("./rules"); 12 | Object.defineProperty(exports, "addRootImport", { enumerable: true, get: function () { return rules_1.addRootImport; } }); 13 | Object.defineProperty(exports, "addRootProvider", { enumerable: true, get: function () { return rules_1.addRootProvider; } }); 14 | -------------------------------------------------------------------------------- /utility/standalone/rules.d.ts: -------------------------------------------------------------------------------- 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 | import { CodeBlockCallback } from './code_block'; 10 | /** 11 | * Adds an import to the root of the project. 12 | * @param project Name of the project to which to add the import. 13 | * @param callback Function that generates the code block which should be inserted. 14 | * @example 15 | * 16 | * ```ts 17 | * import { Rule } from '@angular-devkit/schematics'; 18 | * import { addRootImport } from '@schematics/angular/utility'; 19 | * 20 | * export default function(): Rule { 21 | * return addRootImport('default', ({code, external}) => { 22 | * return code`${external('MyModule', '@my/module')}.forRoot({})`; 23 | * }); 24 | * } 25 | * ``` 26 | */ 27 | export declare function addRootImport(project: string, callback: CodeBlockCallback): Rule; 28 | /** 29 | * Adds a provider to the root of the project. 30 | * @param project Name of the project to which to add the import. 31 | * @param callback Function that generates the code block which should be inserted. 32 | * @example 33 | * 34 | * ```ts 35 | * import { Rule } from '@angular-devkit/schematics'; 36 | * import { addRootProvider } from '@schematics/angular/utility'; 37 | * 38 | * export default function(): Rule { 39 | * return addRootProvider('default', ({code, external}) => { 40 | * return code`${external('provideLibrary', '@my/library')}({})`; 41 | * }); 42 | * } 43 | * ``` 44 | */ 45 | export declare function addRootProvider(project: string, callback: CodeBlockCallback): Rule; 46 | -------------------------------------------------------------------------------- /utility/standalone/util.d.ts: -------------------------------------------------------------------------------- 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 { Tree } from '@angular-devkit/schematics'; 9 | import ts from '../../third_party/github.com/Microsoft/TypeScript/lib/typescript'; 10 | import { Change } from '../change'; 11 | /** 12 | * Finds the main file of a project. 13 | * @param tree File tree for the project. 14 | * @param projectName Name of the project in which to search. 15 | */ 16 | export declare function getMainFilePath(tree: Tree, projectName: string): Promise; 17 | /** 18 | * Gets a TypeScript source file at a specific path. 19 | * @param tree File tree of a project. 20 | * @param path Path to the file. 21 | */ 22 | export declare function getSourceFile(tree: Tree, path: string): ts.SourceFile; 23 | /** Finds the call to `bootstrapApplication` within a file. */ 24 | export declare function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression; 25 | /** 26 | * Applies a set of changes to a file. 27 | * @param tree File tree of the project. 28 | * @param path Path to the file that is being changed. 29 | * @param changes Changes that should be applied to the file. 30 | */ 31 | export declare function applyChangesToFile(tree: Tree, path: string, changes: Change[]): void; 32 | /** Checks whether a node is a call to `mergeApplicationConfig`. */ 33 | export declare function isMergeAppConfigCall(node: ts.Node): node is ts.CallExpression; 34 | /** Finds the `providers` array literal within an application config. */ 35 | export declare function findProvidersLiteral(config: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null; 36 | -------------------------------------------------------------------------------- /utility/validation.d.ts: -------------------------------------------------------------------------------- 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 | export declare const htmlSelectorRe: RegExp; 9 | export declare function validateHtmlSelector(selector: string): void; 10 | export declare function validateClassName(className: string): void; 11 | -------------------------------------------------------------------------------- /utility/validation.js: -------------------------------------------------------------------------------- 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.htmlSelectorRe = void 0; 11 | exports.validateHtmlSelector = validateHtmlSelector; 12 | exports.validateClassName = validateClassName; 13 | const schematics_1 = require("@angular-devkit/schematics"); 14 | // Must start with a letter, and must contain only alphanumeric characters or dashes. 15 | // When adding a dash the segment after the dash must also start with a letter. 16 | exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/; 17 | // See: https://github.com/tc39/proposal-regexp-unicode-property-escapes/blob/fe6d07fad74cd0192d154966baa1e95e7cda78a1/README.md#other-examples 18 | const ecmaIdentifierNameRegExp = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u; 19 | function validateHtmlSelector(selector) { 20 | if (selector && !exports.htmlSelectorRe.test(selector)) { 21 | throw new schematics_1.SchematicsException(`Selector "${selector}" is invalid.`); 22 | } 23 | } 24 | function validateClassName(className) { 25 | if (!ecmaIdentifierNameRegExp.test(className)) { 26 | throw new schematics_1.SchematicsException(`Class name "${className}" is invalid.`); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /utility/workspace-models.js: -------------------------------------------------------------------------------- 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.Builders = exports.ProjectType = void 0; 11 | var ProjectType; 12 | (function (ProjectType) { 13 | ProjectType["Application"] = "application"; 14 | ProjectType["Library"] = "library"; 15 | })(ProjectType || (exports.ProjectType = ProjectType = {})); 16 | /** 17 | * An enum of the official Angular builders. 18 | * Each enum value provides the fully qualified name of the associated builder. 19 | * This enum can be used when analyzing the `builder` fields of project configurations from the 20 | * `angular.json` workspace file. 21 | */ 22 | var Builders; 23 | (function (Builders) { 24 | Builders["Application"] = "@angular-devkit/build-angular:application"; 25 | Builders["AppShell"] = "@angular-devkit/build-angular:app-shell"; 26 | Builders["Server"] = "@angular-devkit/build-angular:server"; 27 | Builders["Browser"] = "@angular-devkit/build-angular:browser"; 28 | Builders["SsrDevServer"] = "@angular-devkit/build-angular:ssr-dev-server"; 29 | Builders["Prerender"] = "@angular-devkit/build-angular:prerender"; 30 | Builders["BrowserEsbuild"] = "@angular-devkit/build-angular:browser-esbuild"; 31 | Builders["Karma"] = "@angular-devkit/build-angular:karma"; 32 | Builders["BuildKarma"] = "@angular/build:karma"; 33 | Builders["TsLint"] = "@angular-devkit/build-angular:tslint"; 34 | Builders["NgPackagr"] = "@angular-devkit/build-angular:ng-packagr"; 35 | Builders["BuildNgPackagr"] = "@angular/build:ng-packagr"; 36 | Builders["DevServer"] = "@angular-devkit/build-angular:dev-server"; 37 | Builders["BuildDevServer"] = "@angular/build:dev-server"; 38 | Builders["ExtractI18n"] = "@angular-devkit/build-angular:extract-i18n"; 39 | Builders["BuildExtractI18n"] = "@angular/build:extract-i18n"; 40 | Builders["Protractor"] = "@angular-devkit/build-angular:private-protractor"; 41 | Builders["BuildApplication"] = "@angular/build:application"; 42 | })(Builders || (exports.Builders = Builders = {})); 43 | -------------------------------------------------------------------------------- /web-worker/files/worker-tsconfig/tsconfig.worker.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | { 3 | "extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/worker", 6 | "lib": [ 7 | "es2018", 8 | "webworker" 9 | ], 10 | "types": [] 11 | }, 12 | "include": [ 13 | "src/**/*.worker.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /web-worker/files/worker/__name@dasherize__.worker.ts.template: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | addEventListener('message', ({ data }) => { 4 | const response = `worker response to ${data}`; 5 | postMessage(response); 6 | }); 7 | -------------------------------------------------------------------------------- /web-worker/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as WebWorkerOptions } from './schema'; 10 | export default function (options: WebWorkerOptions): Rule; 11 | -------------------------------------------------------------------------------- /web-worker/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new web worker in your project. Web workers allow you to run JavaScript code in 3 | * the background, improving the performance and responsiveness of your application by 4 | * offloading computationally intensive tasks. This schematic generates the necessary files 5 | * for a new web worker and provides an optional code snippet to demonstrate its usage. 6 | */ 7 | export type Schema = { 8 | /** 9 | * The name for the new web worker. This will be used to create the worker file (e.g., 10 | * `my-worker.worker.ts`). 11 | */ 12 | name: string; 13 | /** 14 | * The path where the web worker file should be created, relative to the current workspace. 15 | * If not specified, the worker will be created in the current directory. 16 | */ 17 | path?: string; 18 | /** 19 | * The name of the project where the web worker should be created. If not specified, the CLI 20 | * will determine the project from the current directory. 21 | */ 22 | project: string; 23 | /** 24 | * Generate a code snippet that demonstrates how to create and use the new web worker. 25 | */ 26 | snippet?: boolean; 27 | }; 28 | -------------------------------------------------------------------------------- /web-worker/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | -------------------------------------------------------------------------------- /web-worker/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularWebWorker", 4 | "title": "Angular Web Worker Options Schema", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "description": "Creates a new web worker in your project. Web workers allow you to run JavaScript code in the background, improving the performance and responsiveness of your application by offloading computationally intensive tasks. This schematic generates the necessary files for a new web worker and provides an optional code snippet to demonstrate its usage.", 8 | "properties": { 9 | "path": { 10 | "type": "string", 11 | "format": "path", 12 | "$default": { 13 | "$source": "workingDirectory" 14 | }, 15 | "description": "The path where the web worker file should be created, relative to the current workspace. If not specified, the worker will be created in the current directory.", 16 | "visible": false 17 | }, 18 | "project": { 19 | "type": "string", 20 | "description": "The name of the project where the web worker should be created. If not specified, the CLI will determine the project from the current directory.", 21 | "$default": { 22 | "$source": "projectName" 23 | } 24 | }, 25 | "name": { 26 | "type": "string", 27 | "description": "The name for the new web worker. This will be used to create the worker file (e.g., `my-worker.worker.ts`).", 28 | "$default": { 29 | "$source": "argv", 30 | "index": 0 31 | }, 32 | "x-prompt": "What name would you like to use for the worker?" 33 | }, 34 | "snippet": { 35 | "type": "boolean", 36 | "default": true, 37 | "description": "Generate a code snippet that demonstrates how to create and use the new web worker." 38 | } 39 | }, 40 | "required": ["name", "project"] 41 | } 42 | -------------------------------------------------------------------------------- /workspace/files/README.md.template: -------------------------------------------------------------------------------- 1 | # <%= utils.classify(name) %> 2 | 3 | This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version <%= version %>. 4 | 5 | ## Development server 6 | 7 | To start a local development server, run: 8 | 9 | ```bash 10 | ng serve 11 | ``` 12 | 13 | Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files. 14 | 15 | ## Code scaffolding 16 | 17 | Angular CLI includes powerful code scaffolding tools. To generate a new component, run: 18 | 19 | ```bash 20 | ng generate component component-name 21 | ``` 22 | 23 | For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run: 24 | 25 | ```bash 26 | ng generate --help 27 | ``` 28 | 29 | ## Building 30 | 31 | To build the project run: 32 | 33 | ```bash 34 | ng build 35 | ``` 36 | 37 | This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed. 38 | 39 | ## Running unit tests 40 | 41 | To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command: 42 | 43 | ```bash 44 | ng test 45 | ``` 46 | 47 | ## Running end-to-end tests 48 | 49 | For end-to-end (e2e) testing, run: 50 | 51 | ```bash 52 | ng e2e 53 | ``` 54 | 55 | Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs. 56 | 57 | ## Additional Resources 58 | 59 | For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. 60 | -------------------------------------------------------------------------------- /workspace/files/__dot__editorconfig.template: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | ij_typescript_use_double_quotes = false 14 | 15 | [*.md] 16 | max_line_length = off 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /workspace/files/__dot__gitignore.template: -------------------------------------------------------------------------------- 1 | # See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /workspace/files/__dot__vscode/extensions.json.template: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /workspace/files/__dot__vscode/launch.json.template: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }<% if (!minimal) { %>, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | }<% } %> 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /workspace/files/__dot__vscode/tasks.json.template: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }<% if (!minimal) { %>, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | }<% } %> 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /workspace/files/angular.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1,<% if (packageManager) { %> 4 | "cli": { 5 | "packageManager": "<%= packageManager %>" 6 | },<% } %> 7 | "newProjectRoot": "<%= newProjectRoot %>", 8 | "projects": { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /workspace/files/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= utils.dasherize(name) %>", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development"<% if (!minimal) { %>, 9 | "test": "ng test"<% } %> 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/common": "<%= latestVersions.Angular %>", 14 | "@angular/compiler": "<%= latestVersions.Angular %>", 15 | "@angular/core": "<%= latestVersions.Angular %>", 16 | "@angular/forms": "<%= latestVersions.Angular %>", 17 | "@angular/platform-browser": "<%= latestVersions.Angular %>", 18 | "@angular/router": "<%= latestVersions.Angular %>", 19 | "rxjs": "<%= latestVersions['rxjs'] %>", 20 | "tslib": "<%= latestVersions['tslib'] %>" 21 | }, 22 | "devDependencies": { 23 | "@angular/cli": "<%= '^' + version %>", 24 | "@angular/compiler-cli": "<%= latestVersions.Angular %>",<% if (!minimal) { %> 25 | "@types/jasmine": "<%= latestVersions['@types/jasmine'] %>", 26 | "jasmine-core": "<%= latestVersions['jasmine-core'] %>", 27 | "karma": "<%= latestVersions['karma'] %>", 28 | "karma-chrome-launcher": "<%= latestVersions['karma-chrome-launcher'] %>", 29 | "karma-coverage": "<%= latestVersions['karma-coverage'] %>", 30 | "karma-jasmine": "<%= latestVersions['karma-jasmine'] %>", 31 | "karma-jasmine-html-reporter": "<%= latestVersions['karma-jasmine-html-reporter'] %>",<% } %> 32 | "typescript": "<%= latestVersions['typescript'] %>" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /workspace/files/tsconfig.json.template: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "compileOnSave": false, 5 | "compilerOptions": {<% if (strict) { %> 6 | "strict": true, 7 | "noImplicitOverride": true, 8 | "noPropertyAccessFromIndexSignature": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true,<% } %> 11 | "skipLibCheck": true, 12 | "isolatedModules": true, 13 | "experimentalDecorators": true, 14 | "importHelpers": true, 15 | "target": "ES2022", 16 | "module": "preserve" 17 | }, 18 | "angularCompilerOptions": { 19 | "enableI18nLegacyMessageIdFormat": false<% if (strict) { %>, 20 | "strictInjectionParameters": true, 21 | "strictInputAccessModifiers": true, 22 | "typeCheckHostBindings": true, 23 | "strictTemplates": true<% } %> 24 | }, 25 | "files": [] 26 | } 27 | -------------------------------------------------------------------------------- /workspace/index.d.ts: -------------------------------------------------------------------------------- 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 | import { Schema as WorkspaceOptions } from './schema'; 10 | export default function (options: WorkspaceOptions): Rule; 11 | -------------------------------------------------------------------------------- /workspace/index.js: -------------------------------------------------------------------------------- 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 schematics_1 = require("@angular-devkit/schematics"); 12 | const latest_versions_1 = require("../utility/latest-versions"); 13 | function default_1(options) { 14 | return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [ 15 | options.minimal ? (0, schematics_1.filter)((path) => !path.endsWith('editorconfig.template')) : (0, schematics_1.noop)(), 16 | (0, schematics_1.applyTemplates)({ 17 | utils: schematics_1.strings, 18 | ...options, 19 | 'dot': '.', 20 | latestVersions: latest_versions_1.latestVersions, 21 | }), 22 | ])); 23 | } 24 | -------------------------------------------------------------------------------- /workspace/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new Angular workspace. A workspace provides a structured environment for 3 | * developing multiple projects, allowing you to manage dependencies, configurations, and 4 | * build processes for a collection of applications and libraries. This schematic sets up 5 | * the basic structure of the workspace and installs the necessary Angular dependencies. 6 | */ 7 | export type Schema = { 8 | /** 9 | * Create a workspace without any testing frameworks. This is intended for learning purposes 10 | * and simple experimentation, not for production applications. 11 | */ 12 | minimal?: boolean; 13 | /** 14 | * The name for the new workspace. This name will be used for the root directory and will be 15 | * referenced in various configuration files. 16 | */ 17 | name: string; 18 | /** 19 | * The path where new projects will be created within the workspace, relative to the 20 | * workspace root. By default, new projects are created in the `projects` directory. 21 | */ 22 | newProjectRoot?: string; 23 | /** 24 | * The package manager to use for installing dependencies. 25 | */ 26 | packageManager?: PackageManager; 27 | /** 28 | * Enable stricter type checking and bundle budget settings for projects created within the 29 | * workspace. This helps improve maintainability and catch bugs early on. For more 30 | * information, see https://angular.dev/tools/cli/template-typecheck#strict-mode 31 | */ 32 | strict?: boolean; 33 | /** 34 | * The version of the Angular CLI to use. 35 | */ 36 | version: string; 37 | }; 38 | /** 39 | * The package manager to use for installing dependencies. 40 | */ 41 | export declare enum PackageManager { 42 | Bun = "bun", 43 | Cnpm = "cnpm", 44 | Npm = "npm", 45 | Pnpm = "pnpm", 46 | Yarn = "yarn" 47 | } 48 | -------------------------------------------------------------------------------- /workspace/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | exports.PackageManager = void 0; 6 | /** 7 | * The package manager to use for installing dependencies. 8 | */ 9 | var PackageManager; 10 | (function (PackageManager) { 11 | PackageManager["Bun"] = "bun"; 12 | PackageManager["Cnpm"] = "cnpm"; 13 | PackageManager["Npm"] = "npm"; 14 | PackageManager["Pnpm"] = "pnpm"; 15 | PackageManager["Yarn"] = "yarn"; 16 | })(PackageManager || (exports.PackageManager = PackageManager = {})); 17 | -------------------------------------------------------------------------------- /workspace/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularWorkspace", 4 | "title": "Angular Workspace Options Schema", 5 | "description": "Creates a new Angular workspace. A workspace provides a structured environment for developing multiple projects, allowing you to manage dependencies, configurations, and build processes for a collection of applications and libraries. This schematic sets up the basic structure of the workspace and installs the necessary Angular dependencies.", 6 | "type": "object", 7 | "additionalProperties": false, 8 | "properties": { 9 | "name": { 10 | "description": "The name for the new workspace. This name will be used for the root directory and will be referenced in various configuration files.", 11 | "type": "string", 12 | "$default": { 13 | "$source": "argv", 14 | "index": 0 15 | } 16 | }, 17 | "newProjectRoot": { 18 | "description": "The path where new projects will be created within the workspace, relative to the workspace root. By default, new projects are created in the `projects` directory.", 19 | "type": "string", 20 | "visible": "false" 21 | }, 22 | "version": { 23 | "type": "string", 24 | "description": "The version of the Angular CLI to use.", 25 | "visible": false, 26 | "$default": { 27 | "$source": "ng-cli-version" 28 | } 29 | }, 30 | "minimal": { 31 | "description": "Create a workspace without any testing frameworks. This is intended for learning purposes and simple experimentation, not for production applications.", 32 | "type": "boolean", 33 | "default": false 34 | }, 35 | "strict": { 36 | "description": "Enable stricter type checking and bundle budget settings for projects created within the workspace. This helps improve maintainability and catch bugs early on. For more information, see https://angular.dev/tools/cli/template-typecheck#strict-mode", 37 | "type": "boolean", 38 | "default": true 39 | }, 40 | "packageManager": { 41 | "description": "The package manager to use for installing dependencies.", 42 | "type": "string", 43 | "enum": ["npm", "yarn", "pnpm", "cnpm", "bun"] 44 | } 45 | }, 46 | "required": ["name", "version"] 47 | } 48 | --------------------------------------------------------------------------------