mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 20:02:40 +08:00
refactor(@angular-devkit/schematics): use interface for NodeWorkflow options
This change removes the previously repeated type definitions for the options of the NodeWorkflow class.
This commit is contained in:
parent
433a4152ef
commit
34f769fcde
@ -126,15 +126,20 @@ export declare class NodePackageDoesNotSupportSchematics extends BaseException {
|
|||||||
export declare class NodeWorkflow extends workflow.BaseWorkflow {
|
export declare class NodeWorkflow extends workflow.BaseWorkflow {
|
||||||
get engine(): FileSystemEngine;
|
get engine(): FileSystemEngine;
|
||||||
get engineHost(): NodeModulesEngineHost;
|
get engineHost(): NodeModulesEngineHost;
|
||||||
constructor(host: virtualFs.Host, options: {
|
constructor(host: virtualFs.Host, options: NodeWorkflowOptions & {
|
||||||
force?: boolean;
|
|
||||||
dryRun?: boolean;
|
|
||||||
root?: Path;
|
root?: Path;
|
||||||
packageManager?: string;
|
|
||||||
packageRegistry?: string;
|
|
||||||
registry?: schema.CoreSchemaRegistry;
|
|
||||||
resolvePaths?: string[];
|
|
||||||
});
|
});
|
||||||
|
constructor(root: string, options: NodeWorkflowOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NodeWorkflowOptions {
|
||||||
|
dryRun?: boolean;
|
||||||
|
force?: boolean;
|
||||||
|
packageManager?: string;
|
||||||
|
packageRegistry?: string;
|
||||||
|
registry?: schema.CoreSchemaRegistry;
|
||||||
|
resolvePaths?: string[];
|
||||||
|
schemaValidation?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare type OptionTransform<T extends object, R extends object> = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<R> | PromiseLike<R> | R;
|
export declare type OptionTransform<T extends object, R extends object> = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<R> | PromiseLike<R> | R;
|
||||||
|
@ -15,47 +15,25 @@ import { FileSystemEngine } from '../description';
|
|||||||
import { NodeModulesEngineHost } from '../node-module-engine-host';
|
import { NodeModulesEngineHost } from '../node-module-engine-host';
|
||||||
import { validateOptionsWithSchema } from '../schema-option-transform';
|
import { validateOptionsWithSchema } from '../schema-option-transform';
|
||||||
|
|
||||||
|
export interface NodeWorkflowOptions {
|
||||||
|
force?: boolean;
|
||||||
|
dryRun?: boolean;
|
||||||
|
packageManager?: string;
|
||||||
|
packageRegistry?: string;
|
||||||
|
registry?: schema.CoreSchemaRegistry;
|
||||||
|
resolvePaths?: string[];
|
||||||
|
schemaValidation?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A workflow specifically for Node tools.
|
* A workflow specifically for Node tools.
|
||||||
*/
|
*/
|
||||||
export class NodeWorkflow extends workflow.BaseWorkflow {
|
export class NodeWorkflow extends workflow.BaseWorkflow {
|
||||||
constructor(root: string, options: {
|
constructor(root: string, options: NodeWorkflowOptions);
|
||||||
force?: boolean;
|
|
||||||
dryRun?: boolean;
|
|
||||||
packageManager?: string;
|
|
||||||
packageRegistry?: string;
|
|
||||||
registry?: schema.CoreSchemaRegistry;
|
|
||||||
resolvePaths?: string[],
|
|
||||||
schemaValidation?: boolean;
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(
|
constructor(host: virtualFs.Host, options: NodeWorkflowOptions & { root?: Path });
|
||||||
host: virtualFs.Host,
|
|
||||||
options: {
|
|
||||||
force?: boolean;
|
|
||||||
dryRun?: boolean;
|
|
||||||
root?: Path;
|
|
||||||
packageManager?: string;
|
|
||||||
packageRegistry?: string;
|
|
||||||
registry?: schema.CoreSchemaRegistry;
|
|
||||||
resolvePaths?: string[],
|
|
||||||
schemaValidation?: boolean;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(
|
constructor(hostOrRoot: virtualFs.Host | string, options: NodeWorkflowOptions & { root?: Path }) {
|
||||||
hostOrRoot: virtualFs.Host | string,
|
|
||||||
options: {
|
|
||||||
force?: boolean;
|
|
||||||
dryRun?: boolean;
|
|
||||||
root?: Path;
|
|
||||||
packageManager?: string;
|
|
||||||
packageRegistry?: string;
|
|
||||||
registry?: schema.CoreSchemaRegistry;
|
|
||||||
resolvePaths?: string[],
|
|
||||||
schemaValidation?: boolean;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
let host;
|
let host;
|
||||||
let root;
|
let root;
|
||||||
if (typeof hostOrRoot === 'string') {
|
if (typeof hostOrRoot === 'string') {
|
||||||
@ -76,21 +54,15 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
|
|||||||
registry: options.registry,
|
registry: options.registry,
|
||||||
});
|
});
|
||||||
|
|
||||||
engineHost.registerTaskExecutor(
|
engineHost.registerTaskExecutor(BuiltinTaskExecutor.NodePackage, {
|
||||||
BuiltinTaskExecutor.NodePackage,
|
allowPackageManagerOverride: true,
|
||||||
{
|
packageManager: options.packageManager,
|
||||||
allowPackageManagerOverride: true,
|
rootDirectory: root && getSystemPath(root),
|
||||||
packageManager: options.packageManager,
|
registry: options.packageRegistry,
|
||||||
rootDirectory: root && getSystemPath(root),
|
});
|
||||||
registry: options.packageRegistry,
|
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RepositoryInitializer, {
|
||||||
},
|
rootDirectory: root && getSystemPath(root),
|
||||||
);
|
});
|
||||||
engineHost.registerTaskExecutor(
|
|
||||||
BuiltinTaskExecutor.RepositoryInitializer,
|
|
||||||
{
|
|
||||||
rootDirectory: root && getSystemPath(root),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
|
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
|
||||||
engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);
|
engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user