CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-schematics--angular

Angular schematics collection providing code generators for Angular applications, components, services, and other constructs.

Pending
Overview
Eval results
Files

schematics.mddocs/

Schematics

Angular schematics are code generators that create and modify files in an Angular project. @schematics/angular provides 24 schematics that can be invoked through the Angular CLI or programmatically.

Capabilities

Application Schematic

Creates a new Angular application with routing, styling, and initial project structure.

/**
 * Creates a new Angular application
 * @param options - Application configuration options
 * @returns Rule for creating the application
 */
declare function application(options: ApplicationSchema): Rule;

interface ApplicationSchema {
  name: string;
  version?: string;
  routing?: boolean;
  inlineStyle?: boolean;
  inlineTemplate?: boolean;
  style?: Style;
  skipTests?: boolean;
  skipPackageJson?: boolean;
  skipInstall?: boolean;
  strict?: boolean;
  standalone?: boolean;
  ssr?: boolean;
  viewEncapsulation?: ViewEncapsulation;
  prefix?: string;
  displayBlock?: boolean;
}

enum Style {
  Css = 'css',
  Scss = 'scss', 
  Sass = 'sass',
  Less = 'less',
  Styl = 'styl'
}

Usage Example:

import { application } from '@schematics/angular';

const appRule = application({
  name: 'my-app',
  routing: true,
  style: Style.Scss,
  standalone: true
});

Component Schematic

Creates Angular components with template, styles, and test files.

/**
 * Creates an Angular component
 * @param options - Component configuration options  
 * @returns Rule for creating the component
 */
declare function component(options: ComponentSchema): Rule;

interface ComponentSchema {
  name: string;
  path?: string;
  project?: string;
  inlineTemplate?: boolean;
  inlineStyle?: boolean;
  displayBlock?: boolean;
  changeDetection?: ChangeDetectionStrategy;
  style?: Style;
  type?: string;
  skipTests?: boolean;
  flat?: boolean;
  skipImport?: boolean;
  selector?: string;
  module?: string;
  export?: boolean;
  prefix?: string;
  standalone?: boolean;
}

enum ChangeDetectionStrategy {
  Default = 'Default',
  OnPush = 'OnPush'
}

enum ViewEncapsulation {
  Emulated = 'Emulated',
  None = 'None',
  ShadowDom = 'ShadowDom'
}

Service Schematic

Creates Angular services with dependency injection setup.

/**
 * Creates an Angular service
 * @param options - Service configuration options
 * @returns Rule for creating the service  
 */
declare function service(options: ServiceSchema): Rule;

interface ServiceSchema {
  name: string;
  path?: string;
  project?: string;
  flat?: boolean;
  skipTests?: boolean;
}

Module Schematic

Creates Angular modules with routing and component organization.

/**
 * Creates an Angular module
 * @param options - Module configuration options
 * @returns Rule for creating the module
 */
declare function module(options: ModuleSchema): Rule;

interface ModuleSchema {
  name: string;
  path?: string;
  project?: string;
  routing?: boolean;
  routingScope?: RoutingScope;
  flat?: boolean;
  commonModule?: boolean;
  module?: string;
}

enum RoutingScope {
  Child = 'Child',
  Root = 'Root'
}

Directive Schematic

Creates Angular directives for DOM manipulation and behavior.

/**
 * Creates an Angular directive
 * @param options - Directive configuration options
 * @returns Rule for creating the directive
 */
declare function directive(options: DirectiveSchema): Rule;

interface DirectiveSchema {
  name: string;
  path?: string;
  project?: string;
  skipTests?: boolean;
  skipImport?: boolean;
  selector?: string;
  flat?: boolean;
  module?: string;
  export?: boolean;
  prefix?: string;
  standalone?: boolean;
}

Pipe Schematic

Creates Angular pipes for data transformation in templates.

/**
 * Creates an Angular pipe
 * @param options - Pipe configuration options
 * @returns Rule for creating the pipe
 */
declare function pipe(options: PipeSchema): Rule;

interface PipeSchema {
  name: string;
  path?: string;
  project?: string;
  skipTests?: boolean;
  skipImport?: boolean;
  flat?: boolean;
  module?: string;
  export?: boolean;
  standalone?: boolean;
}

Guard Schematic

Creates route guards for navigation control and security.

/**
 * Creates a route guard
 * @param options - Guard configuration options
 * @returns Rule for creating the guard
 */
declare function guard(options: GuardSchema): Rule;

interface GuardSchema {
  name: string;
  path?: string;
  project?: string;
  skipTests?: boolean;
  flat?: boolean;
  implements?: GuardType[];
}

enum GuardType {
  CanActivate = 'CanActivate',
  CanActivateChild = 'CanActivateChild', 
  CanDeactivate = 'CanDeactivate',
  CanLoad = 'CanLoad',
  CanMatch = 'CanMatch'
}

Interceptor Schematic

Creates HTTP interceptors for request/response processing.

/**
 * Creates an HTTP interceptor
 * @param options - Interceptor configuration options
 * @returns Rule for creating the interceptor
 */
declare function interceptor(options: InterceptorSchema): Rule;

interface InterceptorSchema {
  name: string;
  path?: string;
  project?: string;
  skipTests?: boolean;
  flat?: boolean;
  functional?: boolean;
}

Resolver Schematic

Creates route resolvers for pre-loading data before navigation.

/**
 * Creates a route resolver
 * @param options - Resolver configuration options
 * @returns Rule for creating the resolver
 */
declare function resolver(options: ResolverSchema): Rule;

interface ResolverSchema {
  name: string;
  path?: string;
  project?: string;
  skipTests?: boolean;
  flat?: boolean;
}

Library Schematic

Creates Angular libraries for code sharing and distribution.

/**
 * Creates an Angular library
 * @param options - Library configuration options
 * @returns Rule for creating the library
 */
declare function library(options: LibrarySchema): Rule;

interface LibrarySchema {
  name: string;
  prefix?: string;
  skipPackageJson?: boolean;
  skipInstall?: boolean;
  skipTsConfig?: boolean;
  standalone?: boolean;
}

Additional Schematics

Class Schematic

declare function class(options: ClassSchema): Rule;

interface ClassSchema {
  name: string;
  path?: string;
  project?: string;
  skipTests?: boolean;
  type?: string;
}

Interface Schematic

declare function interface(options: InterfaceSchema): Rule;

interface InterfaceSchema {
  name: string;
  path?: string;
  project?: string;
  prefix?: string;
  type?: string;
}

Enum Schematic

declare function enum(options: EnumSchema): Rule;

interface EnumSchema {
  name: string;
  path?: string;
  project?: string;
  type?: string;
}

Service Worker Schematic

declare function serviceWorker(options: ServiceWorkerSchema): Rule;

interface ServiceWorkerSchema {
  project: string;
  target?: string;
  configuration?: string;
}

Web Worker Schematic

declare function webWorker(options: WebWorkerSchema): Rule;

interface WebWorkerSchema {
  name: string;
  path?: string;
  project?: string;
  target?: string;
  snippet?: boolean;
}

App Shell Schematic

declare function appShell(options: AppShellSchema): Rule;

interface AppShellSchema {
  project: string;
  route?: string;
  name?: string;
}

Environments Schematic

declare function environments(options: EnvironmentsSchema): Rule;

interface EnvironmentsSchema {
  project: string;
}

Config Schematic

declare function config(options: ConfigSchema): Rule;

interface ConfigSchema {
  project: string;
  type: ConfigType;
}

enum ConfigType {
  Karma = 'karma',
  Browserslist = 'browserslist'
}

AI Config Schematic

declare function aiConfig(options: AiConfigSchema): Rule;

interface AiConfigSchema {
  project: string;
}

Web Worker Schematic

declare function webWorker(options: WebWorkerSchema): Rule;

interface WebWorkerSchema {
  name: string;
  path?: string;
  project?: string;
  target?: string;
  snippet?: boolean;
}

App Shell Schematic

declare function appShell(options: AppShellSchema): Rule;

interface AppShellSchema {
  project: string;
  route?: string;
  name?: string;
}

Environments Schematic

declare function environments(options: EnvironmentsSchema): Rule;

interface EnvironmentsSchema {
  project: string;
}

Config Schematic

declare function config(options: ConfigSchema): Rule;

interface ConfigSchema {
  project: string;
  type: ConfigType;
}

enum ConfigType {
  Karma = 'karma',
  Browserslist = 'browserslist'
}

Hidden/Internal Schematics

These schematics are marked as hidden and are primarily used internally by Angular CLI:

  • ng-new: Creates initial workspace structure
  • workspace: Sets up Angular workspace configuration
  • private-e2e: Internal E2E testing setup (private API)
  • server: Server-side rendering application setup
  • ssr: Server-side rendering configuration

Migration Schematics

@schematics/angular includes a migration collection for automatic project updates between Angular versions. These migrations handle breaking changes and deprecated APIs:

// Migration collection available at @schematics/angular/migrations.json
interface MigrationSchema {
  version: string;
  description: string;
  factory: string;
}

Available Migrations (v20.2.2)

  • replace-provide-server-rendering-import (v20.0.0): Updates server rendering imports
  • replace-provide-server-routing (v20.0.0): Updates server routing configuration
  • update-module-resolution (v20.0.0): Updates module resolution settings
  • previous-style-guide (v20.0.0): Applies previous style guide changes
  • use-application-builder (v20.0.0): Migrates to application builder
  • remove-default-karma-config (v20.2.0): Removes default Karma configuration

Usage:

ng update @angular/cli --migrate-only --from=19 --to=20

Install with Tessl CLI

npx tessl i tessl/npm-schematics--angular

docs

ast-utilities.md

dependency-management.md

index.md

schematics.md

standalone-utilities.md

workspace-utilities.md

tile.json