UNPKG

2.54 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. 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.io/license
7 */
8import { logging } from '@angular-devkit/core';
9import { workflow } from '@angular-devkit/schematics';
10import { FileSystemCollection, FileSystemEngine, FileSystemSchematic, NodeWorkflow } from '@angular-devkit/schematics/tools';
11import { BaseCommandOptions, Command } from './command';
12import { Arguments, CommandContext, CommandDescription, Option } from './interface';
13export interface BaseSchematicSchema {
14 debug?: boolean;
15 dryRun?: boolean;
16 force?: boolean;
17 interactive?: boolean;
18 defaults?: boolean;
19 packageRegistry?: string;
20}
21export interface RunSchematicOptions extends BaseSchematicSchema {
22 collectionName: string;
23 schematicName: string;
24 additionalOptions?: {
25 [key: string]: {};
26 };
27 schematicOptions?: string[];
28 showNothingDone?: boolean;
29}
30export declare class UnknownCollectionError extends Error {
31 constructor(collectionName: string);
32}
33export declare abstract class SchematicCommand<T extends BaseSchematicSchema & BaseCommandOptions> extends Command<T> {
34 readonly allowPrivateSchematics: boolean;
35 private _host;
36 private _workspace;
37 protected _workflow: NodeWorkflow;
38 protected defaultCollectionName: string;
39 protected collectionName: string;
40 protected schematicName?: string;
41 constructor(context: CommandContext, description: CommandDescription, logger: logging.Logger);
42 initialize(options: T & Arguments): Promise<void>;
43 printHelp(options: T & Arguments): Promise<number>;
44 printHelpUsage(): Promise<void>;
45 protected getEngine(): FileSystemEngine;
46 protected getCollection(collectionName: string): FileSystemCollection;
47 protected getSchematic(collection: FileSystemCollection, schematicName: string, allowPrivate?: boolean): FileSystemSchematic;
48 protected setPathOptions(options: Option[], workingDir: string): {
49 [name: string]: string;
50 };
51 protected createWorkflow(options: BaseSchematicSchema): Promise<workflow.BaseWorkflow>;
52 protected getDefaultSchematicCollection(): Promise<string>;
53 protected runSchematic(options: RunSchematicOptions): Promise<number | void>;
54 protected parseFreeFormArguments(schematicOptions: string[]): Promise<Arguments>;
55 protected parseArguments(schematicOptions: string[], options: Option[] | null): Promise<Arguments>;
56 private _loadWorkspace;
57}