1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.NodeWorkflow = void 0;
|
11 | const core_1 = require("@angular-devkit/core");
|
12 | const node_1 = require("@angular-devkit/core/node");
|
13 | const schematics_1 = require("@angular-devkit/schematics");
|
14 | const node_2 = require("../../tasks/node");
|
15 | const node_module_engine_host_1 = require("../node-module-engine-host");
|
16 | const schema_option_transform_1 = require("../schema-option-transform");
|
17 |
|
18 |
|
19 |
|
20 | class NodeWorkflow extends schematics_1.workflow.BaseWorkflow {
|
21 | constructor(hostOrRoot, options) {
|
22 | var _a;
|
23 | let host;
|
24 | let root;
|
25 | if (typeof hostOrRoot === 'string') {
|
26 | root = (0, core_1.normalize)(hostOrRoot);
|
27 | host = new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), root);
|
28 | }
|
29 | else {
|
30 | host = hostOrRoot;
|
31 | root = options.root;
|
32 | }
|
33 | const engineHost = ((_a = options.engineHostCreator) === null || _a === void 0 ? void 0 : _a.call(options, options)) || new node_module_engine_host_1.NodeModulesEngineHost(options.resolvePaths);
|
34 | super({
|
35 | host,
|
36 | engineHost,
|
37 | force: options.force,
|
38 | dryRun: options.dryRun,
|
39 | registry: options.registry,
|
40 | });
|
41 | engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.NodePackage, {
|
42 | allowPackageManagerOverride: true,
|
43 | packageManager: options.packageManager,
|
44 | force: options.packageManagerForce,
|
45 | rootDirectory: root && (0, core_1.getSystemPath)(root),
|
46 | registry: options.packageRegistry,
|
47 | });
|
48 | engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.RepositoryInitializer, {
|
49 | rootDirectory: root && (0, core_1.getSystemPath)(root),
|
50 | });
|
51 | engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.RunSchematic);
|
52 | if (options.optionTransforms) {
|
53 | for (const transform of options.optionTransforms) {
|
54 | engineHost.registerOptionsTransform(transform);
|
55 | }
|
56 | }
|
57 | if (options.schemaValidation) {
|
58 | engineHost.registerOptionsTransform((0, schema_option_transform_1.validateOptionsWithSchema)(this.registry));
|
59 | }
|
60 | this._context = [];
|
61 | }
|
62 | get engine() {
|
63 | return this._engine;
|
64 | }
|
65 | get engineHost() {
|
66 | return this._engineHost;
|
67 | }
|
68 | }
|
69 | exports.NodeWorkflow = NodeWorkflow;
|