CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-angular-devkit--schematics

Angular Schematics library for scaffolding and code generation with virtual file trees and rule-based transformations.

Pending
Overview
Eval results
Files

workflow.mddocs/

Workflow System

The workflow system provides high-level orchestration for schematic execution with lifecycle management, error handling, and context propagation. It serves as the primary interface for coordinating complex schematic operations with multiple collections and schematics.

Capabilities

Workflow Interface

Core workflow interface for executing schematics with full lifecycle management.

/**
 * Main workflow interface for orchestrating schematic execution
 */
interface Workflow {
  readonly context: Readonly<WorkflowExecutionContext>;
  
  /** Execute a schematic with the given context */
  execute(
    options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext
  ): Observable<void>;
}

/**
 * Required execution context for workflow operations
 */
interface RequiredWorkflowExecutionContext {
  collection: string;
  schematic: string;
  options: object;
}

/**
 * Complete execution context with optional fields
 */
interface WorkflowExecutionContext extends RequiredWorkflowExecutionContext {
  debug: boolean;
  logger: logging.Logger;
  parentContext?: Readonly<WorkflowExecutionContext>;
  allowPrivate?: boolean;
}

Base Workflow Implementation

Abstract base class for implementing custom workflows.

/**
 * Configuration options for base workflow
 */
interface BaseWorkflowOptions {
  host: virtualFs.Host;
  engineHost: EngineHost<{}, {}>;
  registry?: schema.CoreSchemaRegistry;
  force?: boolean;
  dryRun?: boolean;
}

/**
 * Abstract base workflow with common functionality
 */
abstract class BaseWorkflow implements Workflow {
  constructor(options: BaseWorkflowOptions);
  
  readonly context: Readonly<WorkflowExecutionContext>;
  readonly engine: Engine<{}, {}>;
  readonly engineHost: EngineHost<{}, {}>;
  readonly registry: schema.SchemaRegistry;
  readonly reporter: Observable<DryRunEvent>;
  readonly lifeCycle: Observable<LifeCycleEvent>;
  
  execute(
    options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext
  ): Observable<void>;
}

Lifecycle Events

Events emitted during workflow execution for monitoring and debugging.

/**
 * Lifecycle events emitted during workflow execution
 */
interface LifeCycleEvent {
  kind: 'start' | 'end' | 'workflow-start' | 'workflow-end' | 'post-tasks-start' | 'post-tasks-end';
}

Usage Examples:

import { BaseWorkflow, BaseWorkflowOptions } from "@angular-devkit/schematics";
import { virtualFs, logging } from "@angular-devkit/core";

// Create a custom workflow
class CustomWorkflow extends BaseWorkflow {
  constructor(options: BaseWorkflowOptions) {
    super(options);
    
    // Subscribe to lifecycle events
    this.lifeCycle.subscribe(event => {
      console.log(`Workflow event: ${event.kind}`);
    });
  }
}

// Execute a schematic through workflow
const workflow = new CustomWorkflow({
  host: new virtualFs.SimpleMemoryHost(),
  engineHost: new FileSystemEngineHost()
});

workflow.execute({
  collection: '@schematics/angular',
  schematic: 'component',
  options: { name: 'my-component' },
  debug: false,
  logger: new logging.NullLogger()
}).subscribe({
  next: () => console.log('Schematic executed successfully'),
  error: (err) => console.error('Execution failed:', err)
});

Workflow Exceptions

/**
 * Exception thrown when workflow execution fails
 */
class UnsuccessfulWorkflowExecution extends BaseException {
  constructor(message?: string);
}

Types

Context Types

type ExecutionOptions = {
  scope?: string;
  interactive?: boolean;
};

Install with Tessl CLI

npx tessl i tessl/npm-angular-devkit--schematics

docs

file-system-actions.md

index.md

node-tools.md

output-sinks.md

rule-system.md

schematic-engine.md

template-engine.md

tree-operations.md

workflow.md

tile.json