1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
10 | if (k2 === undefined) k2 = k;
|
11 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
12 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
13 | desc = { enumerable: true, get: function() { return m[k]; } };
|
14 | }
|
15 | Object.defineProperty(o, k2, desc);
|
16 | }) : (function(o, m, k, k2) {
|
17 | if (k2 === undefined) k2 = k;
|
18 | o[k2] = m[k];
|
19 | }));
|
20 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
21 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
22 | }) : function(o, v) {
|
23 | o["default"] = v;
|
24 | });
|
25 | var __importStar = (this && this.__importStar) || function (mod) {
|
26 | if (mod && mod.__esModule) return mod;
|
27 | var result = {};
|
28 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
29 | __setModuleDefault(result, mod);
|
30 | return result;
|
31 | };
|
32 | Object.defineProperty(exports, "__esModule", { value: true });
|
33 | exports.FileSystemEngineHost = void 0;
|
34 | const fs_1 = require("fs");
|
35 | const path_1 = require("path");
|
36 | const rxjs_1 = require("rxjs");
|
37 | const operators_1 = require("rxjs/operators");
|
38 | const src_1 = require("../src");
|
39 | const export_ref_1 = require("./export-ref");
|
40 | const file_system_engine_host_base_1 = require("./file-system-engine-host-base");
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | class FileSystemEngineHost extends file_system_engine_host_base_1.FileSystemEngineHostBase {
|
46 | constructor(_root) {
|
47 | super();
|
48 | this._root = _root;
|
49 | }
|
50 | _resolveCollectionPath(name) {
|
51 | try {
|
52 |
|
53 | const maybePath = require.resolve((0, path_1.join)(this._root, name + '.json'));
|
54 | if ((0, fs_1.existsSync)(maybePath)) {
|
55 | return maybePath;
|
56 | }
|
57 | }
|
58 | catch (error) { }
|
59 | try {
|
60 |
|
61 | const maybePath = require.resolve((0, path_1.join)(this._root, name, 'collection.json'));
|
62 | if ((0, fs_1.existsSync)(maybePath)) {
|
63 | return maybePath;
|
64 | }
|
65 | }
|
66 | catch (error) { }
|
67 | throw new file_system_engine_host_base_1.CollectionCannotBeResolvedException(name);
|
68 | }
|
69 | _resolveReferenceString(refString, parentPath) {
|
70 |
|
71 | const ref = new export_ref_1.ExportStringRef(refString, parentPath);
|
72 | if (!ref.ref) {
|
73 | return null;
|
74 | }
|
75 | return { ref: ref.ref, path: ref.module };
|
76 | }
|
77 | _transformCollectionDescription(name, desc) {
|
78 | if (!desc.schematics || typeof desc.schematics != 'object') {
|
79 | throw new file_system_engine_host_base_1.CollectionMissingSchematicsMapException(name);
|
80 | }
|
81 | return {
|
82 | ...desc,
|
83 | name,
|
84 | };
|
85 | }
|
86 | _transformSchematicDescription(name, _collection, desc) {
|
87 | if (!desc.factoryFn || !desc.path || !desc.description) {
|
88 | throw new file_system_engine_host_base_1.SchematicMissingFieldsException(name);
|
89 | }
|
90 | return desc;
|
91 | }
|
92 | hasTaskExecutor(name) {
|
93 | if (super.hasTaskExecutor(name)) {
|
94 | return true;
|
95 | }
|
96 | try {
|
97 | const maybePath = require.resolve((0, path_1.join)(this._root, name));
|
98 | if ((0, fs_1.existsSync)(maybePath)) {
|
99 | return true;
|
100 | }
|
101 | }
|
102 | catch { }
|
103 | return false;
|
104 | }
|
105 | createTaskExecutor(name) {
|
106 | if (!super.hasTaskExecutor(name)) {
|
107 | try {
|
108 | const path = require.resolve((0, path_1.join)(this._root, name));
|
109 |
|
110 | return (0, rxjs_1.from)(Promise.resolve().then(() => __importStar(require(path))).then((mod) => { var _a; return (((_a = mod.default) === null || _a === void 0 ? void 0 : _a.default) || mod.default)(); })).pipe((0, operators_1.catchError)(() => (0, rxjs_1.throwError)(new src_1.UnregisteredTaskException(name))));
|
111 | }
|
112 | catch { }
|
113 | }
|
114 | return super.createTaskExecutor(name);
|
115 | }
|
116 | }
|
117 | exports.FileSystemEngineHost = FileSystemEngineHost;
|