1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
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 | * A workflow specifically for Node tools.
|
---|
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 = 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 && core_1.getSystemPath(root),
|
---|
46 | registry: options.packageRegistry,
|
---|
47 | });
|
---|
48 | engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.RepositoryInitializer, {
|
---|
49 | rootDirectory: root && core_1.getSystemPath(root),
|
---|
50 | });
|
---|
51 | engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.RunSchematic);
|
---|
52 | engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.TslintFix);
|
---|
53 | if (options.optionTransforms) {
|
---|
54 | for (const transform of options.optionTransforms) {
|
---|
55 | engineHost.registerOptionsTransform(transform);
|
---|
56 | }
|
---|
57 | }
|
---|
58 | if (options.schemaValidation) {
|
---|
59 | engineHost.registerOptionsTransform(schema_option_transform_1.validateOptionsWithSchema(this.registry));
|
---|
60 | }
|
---|
61 | this._context = [];
|
---|
62 | }
|
---|
63 | get engine() {
|
---|
64 | return this._engine;
|
---|
65 | }
|
---|
66 | get engineHost() {
|
---|
67 | return this._engineHost;
|
---|
68 | }
|
---|
69 | }
|
---|
70 | exports.NodeWorkflow = NodeWorkflow;
|
---|