nestia 2.0.7-dev.20220414-5 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +2 -1
- package/bin/executable/internal/NestiaSdkCli.d.ts +4 -0
- package/bin/executable/internal/NestiaSdkCli.d.ts.map +1 -0
- package/bin/executable/internal/NestiaSdkCli.js +233 -0
- package/bin/executable/nestia.js +2 -4
- package/package.json +2 -2
- package/bin/executable/sdk.d.ts +0 -2
- package/bin/executable/sdk.d.ts.map +0 -1
- package/bin/executable/sdk.js +0 -206
|
@@ -6,11 +6,12 @@ jobs:
|
|
|
6
6
|
runs-on: ${{ matrix.os }}
|
|
7
7
|
strategy:
|
|
8
8
|
matrix:
|
|
9
|
-
os: [
|
|
9
|
+
os: [windows-latest, macos-latest, ubuntu-latest]
|
|
10
10
|
steps:
|
|
11
11
|
- uses: actions/checkout@v1
|
|
12
12
|
- uses: actions/setup-node@v1
|
|
13
13
|
with:
|
|
14
14
|
node-version: 12.x
|
|
15
15
|
- run: npm install
|
|
16
|
+
- run: npm run build
|
|
16
17
|
- run: npm run test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NestiaSdkCli.d.ts","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkCli.ts"],"names":[],"mappings":"AAiBA,yBAAiB,YAAY,CAC7B;IACI,SAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBlF;CAwDJ"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (_) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
73
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
74
|
+
if (!m) return o;
|
|
75
|
+
var i = m.call(o), r, ar = [], e;
|
|
76
|
+
try {
|
|
77
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
78
|
+
}
|
|
79
|
+
catch (error) { e = { error: error }; }
|
|
80
|
+
finally {
|
|
81
|
+
try {
|
|
82
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
83
|
+
}
|
|
84
|
+
finally { if (e) throw e.error; }
|
|
85
|
+
}
|
|
86
|
+
return ar;
|
|
87
|
+
};
|
|
88
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
89
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
90
|
+
if (ar || !(i in from)) {
|
|
91
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
92
|
+
ar[i] = from[i];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
96
|
+
};
|
|
97
|
+
var __values = (this && this.__values) || function(o) {
|
|
98
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
99
|
+
if (m) return m.call(o);
|
|
100
|
+
if (o && typeof o.length === "number") return {
|
|
101
|
+
next: function () {
|
|
102
|
+
if (o && i >= o.length) o = void 0;
|
|
103
|
+
return { value: o && o[i++], done: !o };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
107
|
+
};
|
|
108
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
109
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
110
|
+
};
|
|
111
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
112
|
+
exports.NestiaSdkCli = void 0;
|
|
113
|
+
var cli = __importStar(require("cli"));
|
|
114
|
+
var fs = __importStar(require("fs"));
|
|
115
|
+
var path = __importStar(require("path"));
|
|
116
|
+
var jsonc_simple_parser_1 = __importDefault(require("jsonc-simple-parser"));
|
|
117
|
+
var WorkerConnector_1 = require("tgrid/protocols/workers/WorkerConnector");
|
|
118
|
+
var NestiaApplication_1 = require("../../NestiaApplication");
|
|
119
|
+
var NestiaSdkCli;
|
|
120
|
+
(function (NestiaSdkCli) {
|
|
121
|
+
function main(elements, pure) {
|
|
122
|
+
if (pure === void 0) { pure = true; }
|
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
+
var command, inputs, elements_1, elements_1_1, arg;
|
|
125
|
+
var e_1, _a;
|
|
126
|
+
return __generator(this, function (_b) {
|
|
127
|
+
switch (_b.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
if (pure === false)
|
|
130
|
+
cli.setArgv(__spreadArray([
|
|
131
|
+
process.argv[0],
|
|
132
|
+
process.argv[1],
|
|
133
|
+
"nestia"
|
|
134
|
+
], __read(elements), false));
|
|
135
|
+
command = cli.parse({
|
|
136
|
+
exclude: ["e", "Something to exclude", "string", null],
|
|
137
|
+
out: ["o", "Output path of the SDK files", "string", null],
|
|
138
|
+
});
|
|
139
|
+
inputs = [];
|
|
140
|
+
try {
|
|
141
|
+
for (elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
142
|
+
arg = elements_1_1.value;
|
|
143
|
+
if (arg[0] === "-")
|
|
144
|
+
break;
|
|
145
|
+
inputs.push(arg);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
149
|
+
finally {
|
|
150
|
+
try {
|
|
151
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
152
|
+
}
|
|
153
|
+
finally { if (e_1) throw e_1.error; }
|
|
154
|
+
}
|
|
155
|
+
return [4 /*yield*/, generate(inputs, command)];
|
|
156
|
+
case 1:
|
|
157
|
+
_b.sent();
|
|
158
|
+
return [2 /*return*/];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
NestiaSdkCli.main = main;
|
|
164
|
+
function generate(include, command) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
var config, parentPath, parentStats, content, options, app;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
switch (_a.label) {
|
|
169
|
+
case 0: return [4 /*yield*/, get_nestia_config()];
|
|
170
|
+
case 1:
|
|
171
|
+
config = _a.sent();
|
|
172
|
+
if (config === null) {
|
|
173
|
+
if (command.out === null)
|
|
174
|
+
throw new Error("Output directory is not specified. Add the \"--out <output_directory>\" option.");
|
|
175
|
+
config = {
|
|
176
|
+
input: {
|
|
177
|
+
include: include,
|
|
178
|
+
exclude: command.exclude
|
|
179
|
+
? [command.exclude]
|
|
180
|
+
: undefined
|
|
181
|
+
},
|
|
182
|
+
output: command.out
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
parentPath = path.resolve(config.output + "/..");
|
|
186
|
+
return [4 /*yield*/, fs.promises.stat(parentPath)];
|
|
187
|
+
case 2:
|
|
188
|
+
parentStats = _a.sent();
|
|
189
|
+
if (parentStats.isDirectory() === false)
|
|
190
|
+
throw new Error("Unable to find parent directory of the output path: \"".concat(parentPath, "\"."));
|
|
191
|
+
if (!(fs.existsSync("tsconfig.json") === true)) return [3 /*break*/, 4];
|
|
192
|
+
return [4 /*yield*/, fs.promises.readFile("tsconfig.json", "utf8")];
|
|
193
|
+
case 3:
|
|
194
|
+
content = _a.sent();
|
|
195
|
+
options = jsonc_simple_parser_1.default.parse(content).compilerOptions;
|
|
196
|
+
config.compilerOptions = __assign(__assign({}, options), (config.compilerOptions || {}));
|
|
197
|
+
_a.label = 4;
|
|
198
|
+
case 4:
|
|
199
|
+
app = new NestiaApplication_1.NestiaApplication(config);
|
|
200
|
+
return [4 /*yield*/, app.generate()];
|
|
201
|
+
case 5:
|
|
202
|
+
_a.sent();
|
|
203
|
+
return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function get_nestia_config() {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
210
|
+
var connector, driver, config;
|
|
211
|
+
return __generator(this, function (_a) {
|
|
212
|
+
switch (_a.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
connector = new WorkerConnector_1.WorkerConnector(null, null, "process");
|
|
215
|
+
return [4 /*yield*/, connector.connect("".concat(__dirname, "/nestia.config.getter.js"))];
|
|
216
|
+
case 1:
|
|
217
|
+
_a.sent();
|
|
218
|
+
return [4 /*yield*/, connector.getDriver()];
|
|
219
|
+
case 2:
|
|
220
|
+
driver = _a.sent();
|
|
221
|
+
return [4 /*yield*/, driver.get()];
|
|
222
|
+
case 3:
|
|
223
|
+
config = _a.sent();
|
|
224
|
+
return [4 /*yield*/, connector.close()];
|
|
225
|
+
case 4:
|
|
226
|
+
_a.sent();
|
|
227
|
+
return [2 /*return*/, config];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
})(NestiaSdkCli = exports.NestiaSdkCli || (exports.NestiaSdkCli = {}));
|
|
233
|
+
//# sourceMappingURL=NestiaSdkCli.js.map
|
package/bin/executable/nestia.js
CHANGED
|
@@ -73,6 +73,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
74
|
var cp = __importStar(require("child_process"));
|
|
75
75
|
var process = __importStar(require("process"));
|
|
76
|
+
var NestiaSdkCli_1 = require("./internal/NestiaSdkCli");
|
|
76
77
|
function install() {
|
|
77
78
|
var e_1, _a;
|
|
78
79
|
try {
|
|
@@ -95,11 +96,8 @@ function sdk() {
|
|
|
95
96
|
return __awaiter(this, void 0, void 0, function () {
|
|
96
97
|
return __generator(this, function (_a) {
|
|
97
98
|
switch (_a.label) {
|
|
98
|
-
case 0:
|
|
99
|
-
// EXECUTE THE COMMAND, BUT IGNORE WARNINGS
|
|
100
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("".concat(__dirname, "/sdk.js"))); })];
|
|
99
|
+
case 0: return [4 /*yield*/, NestiaSdkCli_1.NestiaSdkCli.main(process.argv.slice(3))];
|
|
101
100
|
case 1:
|
|
102
|
-
// EXECUTE THE COMMAND, BUT IGNORE WARNINGS
|
|
103
101
|
_a.sent();
|
|
104
102
|
return [2 /*return*/];
|
|
105
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestia",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Automatic SDK and Document generator for the NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "rimraf bin && ttsc",
|
|
12
12
|
"dev": "npm run build -- --watch",
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "node bin/test"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
package/bin/executable/sdk.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/executable/sdk.ts"],"names":[],"mappings":""}
|
package/bin/executable/sdk.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (_) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __values = (this && this.__values) || function(o) {
|
|
73
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
74
|
-
if (m) return m.call(o);
|
|
75
|
-
if (o && typeof o.length === "number") return {
|
|
76
|
-
next: function () {
|
|
77
|
-
if (o && i >= o.length) o = void 0;
|
|
78
|
-
return { value: o && o[i++], done: !o };
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
82
|
-
};
|
|
83
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
84
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
85
|
-
};
|
|
86
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
|
-
var cli = __importStar(require("cli"));
|
|
88
|
-
var fs = __importStar(require("fs"));
|
|
89
|
-
var path = __importStar(require("path"));
|
|
90
|
-
var jsonc_simple_parser_1 = __importDefault(require("jsonc-simple-parser"));
|
|
91
|
-
var WorkerConnector_1 = require("tgrid/protocols/workers/WorkerConnector");
|
|
92
|
-
var NestiaApplication_1 = require("../NestiaApplication");
|
|
93
|
-
function get_nestia_config() {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
var connector, driver, config;
|
|
96
|
-
return __generator(this, function (_a) {
|
|
97
|
-
switch (_a.label) {
|
|
98
|
-
case 0:
|
|
99
|
-
connector = new WorkerConnector_1.WorkerConnector(null, null, "process");
|
|
100
|
-
return [4 /*yield*/, connector.connect(__dirname + "/internal/nestia.config.getter.js")];
|
|
101
|
-
case 1:
|
|
102
|
-
_a.sent();
|
|
103
|
-
return [4 /*yield*/, connector.getDriver()];
|
|
104
|
-
case 2:
|
|
105
|
-
driver = _a.sent();
|
|
106
|
-
return [4 /*yield*/, driver.get()];
|
|
107
|
-
case 3:
|
|
108
|
-
config = _a.sent();
|
|
109
|
-
return [4 /*yield*/, connector.close()];
|
|
110
|
-
case 4:
|
|
111
|
-
_a.sent();
|
|
112
|
-
return [2 /*return*/, config];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function generate(include, command) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
-
var config, parentPath, parentStats, content, options, app;
|
|
120
|
-
return __generator(this, function (_a) {
|
|
121
|
-
switch (_a.label) {
|
|
122
|
-
case 0: return [4 /*yield*/, get_nestia_config()];
|
|
123
|
-
case 1:
|
|
124
|
-
config = _a.sent();
|
|
125
|
-
if (config === null) {
|
|
126
|
-
if (command.out === null)
|
|
127
|
-
throw new Error("Output directory is not specified. Add the \"--out <output_directory>\" option.");
|
|
128
|
-
config = {
|
|
129
|
-
input: {
|
|
130
|
-
include: include,
|
|
131
|
-
exclude: command.exclude
|
|
132
|
-
? [command.exclude]
|
|
133
|
-
: undefined
|
|
134
|
-
},
|
|
135
|
-
output: command.out
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
parentPath = path.resolve(config.output + "/..");
|
|
139
|
-
return [4 /*yield*/, fs.promises.stat(parentPath)];
|
|
140
|
-
case 2:
|
|
141
|
-
parentStats = _a.sent();
|
|
142
|
-
if (parentStats.isDirectory() === false)
|
|
143
|
-
throw new Error("Unable to find parent directory of the output path: \"".concat(parentPath, "\"."));
|
|
144
|
-
if (!(fs.existsSync("tsconfig.json") === true)) return [3 /*break*/, 4];
|
|
145
|
-
return [4 /*yield*/, fs.promises.readFile("tsconfig.json", "utf8")];
|
|
146
|
-
case 3:
|
|
147
|
-
content = _a.sent();
|
|
148
|
-
options = jsonc_simple_parser_1.default.parse(content).compilerOptions;
|
|
149
|
-
config.compilerOptions = __assign(__assign({}, options), (config.compilerOptions || {}));
|
|
150
|
-
_a.label = 4;
|
|
151
|
-
case 4:
|
|
152
|
-
app = new NestiaApplication_1.NestiaApplication(config);
|
|
153
|
-
return [4 /*yield*/, app.generate()];
|
|
154
|
-
case 5:
|
|
155
|
-
_a.sent();
|
|
156
|
-
return [2 /*return*/];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function main() {
|
|
162
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var command, inputs, _a, _b, arg, exp_1;
|
|
164
|
-
var e_1, _c;
|
|
165
|
-
return __generator(this, function (_d) {
|
|
166
|
-
switch (_d.label) {
|
|
167
|
-
case 0:
|
|
168
|
-
command = cli.parse({
|
|
169
|
-
exclude: ["e", "Something to exclude", "string", null],
|
|
170
|
-
out: ["o", "Output path of the SDK files", "string", null],
|
|
171
|
-
});
|
|
172
|
-
_d.label = 1;
|
|
173
|
-
case 1:
|
|
174
|
-
_d.trys.push([1, 3, , 4]);
|
|
175
|
-
inputs = [];
|
|
176
|
-
try {
|
|
177
|
-
for (_a = __values(process.argv.slice(2)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
178
|
-
arg = _b.value;
|
|
179
|
-
if (arg[0] === "-")
|
|
180
|
-
break;
|
|
181
|
-
inputs.push(arg);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
185
|
-
finally {
|
|
186
|
-
try {
|
|
187
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
188
|
-
}
|
|
189
|
-
finally { if (e_1) throw e_1.error; }
|
|
190
|
-
}
|
|
191
|
-
return [4 /*yield*/, generate(inputs, command)];
|
|
192
|
-
case 2:
|
|
193
|
-
_d.sent();
|
|
194
|
-
return [3 /*break*/, 4];
|
|
195
|
-
case 3:
|
|
196
|
-
exp_1 = _d.sent();
|
|
197
|
-
console.log(exp_1);
|
|
198
|
-
process.exit(-1);
|
|
199
|
-
return [3 /*break*/, 4];
|
|
200
|
-
case 4: return [2 /*return*/];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
main();
|
|
206
|
-
//# sourceMappingURL=sdk.js.map
|