-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathnode-workflow.ts
67 lines (62 loc) · 1.89 KB
/
node-workflow.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Path, getSystemPath, schema, virtualFs } from '@angular-devkit/core';
import {
workflow,
} from '@angular-devkit/schematics'; // tslint:disable-line:no-implicit-dependencies
import { BuiltinTaskExecutor } from '../../tasks/node';
import { FileSystemEngine } from '../description';
import { NodeModulesEngineHost } from '../node-module-engine-host';
/**
* A workflow specifically for Node tools.
*/
export class NodeWorkflow extends workflow.BaseWorkflow {
constructor(
host: virtualFs.Host,
options: {
force?: boolean;
dryRun?: boolean;
root?: Path;
packageManager?: string;
registry?: schema.CoreSchemaRegistry;
resolvePaths?: string[],
},
) {
const engineHost = new NodeModulesEngineHost(options.resolvePaths);
super({
host,
engineHost,
force: options.force,
dryRun: options.dryRun,
registry: options.registry,
});
engineHost.registerTaskExecutor(
BuiltinTaskExecutor.NodePackage,
{
allowPackageManagerOverride: true,
packageManager: options.packageManager,
rootDirectory: options.root && getSystemPath(options.root),
},
);
engineHost.registerTaskExecutor(
BuiltinTaskExecutor.RepositoryInitializer,
{
rootDirectory: options.root && getSystemPath(options.root),
},
);
engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);
this._context = [];
}
get engine(): FileSystemEngine {
return this._engine as {} as FileSystemEngine;
}
get engineHost(): NodeModulesEngineHost {
return this._engineHost as NodeModulesEngineHost;
}
}