@platforma-sdk/tengo-builder 2.0.3 → 2.1.1
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/dist/commands/build.d.ts.map +1 -1
- package/dist/compiler/artifactset.d.ts +4 -0
- package/dist/compiler/artifactset.d.ts.map +1 -1
- package/dist/compiler/compiler.d.ts +11 -9
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compileroptions.d.ts +3 -3
- package/dist/compiler/compileroptions.d.ts.map +1 -1
- package/dist/compiler/main.d.ts +4 -5
- package/dist/compiler/main.d.ts.map +1 -1
- package/dist/compiler/source.d.ts +24 -4
- package/dist/compiler/source.d.ts.map +1 -1
- package/dist/compiler/template.d.ts +17 -13
- package/dist/compiler/template.d.ts.map +1 -1
- package/dist/compiler/test.artifacts.d.ts +2 -0
- package/dist/compiler/test.artifacts.d.ts.map +1 -1
- package/dist/index.js +29 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +473 -410
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/src/commands/build.ts +31 -27
- package/src/compiler/artifactset.ts +4 -0
- package/src/compiler/compiler.test.ts +276 -17
- package/src/compiler/compiler.ts +87 -60
- package/src/compiler/compileroptions.ts +3 -3
- package/src/compiler/main.test.ts +45 -0
- package/src/compiler/main.ts +76 -36
- package/src/compiler/source.test.ts +324 -1
- package/src/compiler/source.ts +47 -42
- package/src/compiler/template.test.ts +22 -14
- package/src/compiler/template.ts +85 -38
- package/src/compiler/test.artifacts.ts +10 -0
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (s, e, t) =>
|
|
4
|
-
import { spawnSync as
|
|
1
|
+
var Oe = Object.defineProperty;
|
|
2
|
+
var xe = (s, e, t) => e in s ? Oe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var c = (s, e, t) => xe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { spawnSync as Fe, spawn as Re } from "node:child_process";
|
|
5
5
|
import { Flags as F, Command as v } from "@oclif/core";
|
|
6
6
|
import * as f from "node:path";
|
|
7
|
-
import * as
|
|
8
|
-
import { readFileSync as
|
|
7
|
+
import * as p from "node:fs";
|
|
8
|
+
import { readFileSync as je } from "node:fs";
|
|
9
9
|
import * as O from "winston";
|
|
10
|
-
import { parseTemplate as
|
|
11
|
-
import {
|
|
10
|
+
import { parseTemplate as Le, serializeTemplate as Me } from "@milaboratories/pl-model-backend";
|
|
11
|
+
import { createHash as Ce } from "node:crypto";
|
|
12
|
+
import { tryResolve as Ie, tryResolveOrError as Je } from "@milaboratories/resolve-helper";
|
|
12
13
|
import * as x from "node:fs/promises";
|
|
13
|
-
import { TengoTesterBinaryPath as
|
|
14
|
+
import { TengoTesterBinaryPath as we } from "@milaboratories/tengo-tester";
|
|
14
15
|
import { stdout as D } from "node:process";
|
|
15
16
|
function R(s) {
|
|
16
17
|
throw new Error("Unexpected object: " + s);
|
|
@@ -21,9 +22,9 @@ function E(s = "debug") {
|
|
|
21
22
|
format: O.format.combine(
|
|
22
23
|
O.format.errors({ stack: !0 }),
|
|
23
24
|
O.format.printf(({ level: e, message: t, stack: r }) => {
|
|
24
|
-
const
|
|
25
|
-
return r ? `${
|
|
26
|
-
${r}` :
|
|
25
|
+
const i = `${e.padStart(6, " ")}: ${t}`;
|
|
26
|
+
return r ? `${i}
|
|
27
|
+
${r}` : i;
|
|
27
28
|
})
|
|
28
29
|
),
|
|
29
30
|
transports: [
|
|
@@ -34,9 +35,9 @@ ${r}` : n;
|
|
|
34
35
|
]
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function S(s) {
|
|
38
39
|
try {
|
|
39
|
-
const e =
|
|
40
|
+
const e = p.statSync(s);
|
|
40
41
|
return e.isDirectory() ? "dir" : e.isFile() ? "file" : e.isSymbolicLink() ? "link" : "unknown";
|
|
41
42
|
} catch (e) {
|
|
42
43
|
const t = e;
|
|
@@ -44,13 +45,13 @@ function k(s) {
|
|
|
44
45
|
throw t;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function Pe(s) {
|
|
48
49
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s.toLowerCase());
|
|
49
50
|
}
|
|
50
51
|
function le(s) {
|
|
51
52
|
return `${s.type}||${s.pkg}||${s.id}`;
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function u(s) {
|
|
54
55
|
return `${s.type}:${s.pkg}:${s.id}:${s.version}`;
|
|
55
56
|
}
|
|
56
57
|
function h(s) {
|
|
@@ -62,50 +63,62 @@ function ce(s, e) {
|
|
|
62
63
|
function C(s, e) {
|
|
63
64
|
return s.type == e.type && s.pkg == e.pkg && s.id == e.id && s.version == e.version;
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function w(s) {
|
|
66
67
|
return `${s.pkg}:${s.id}`;
|
|
67
68
|
}
|
|
68
69
|
function I(s) {
|
|
69
|
-
return { name:
|
|
70
|
+
return { name: w(s), version: s.version };
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
+
function Ge(s) {
|
|
72
73
|
const e = s.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);
|
|
73
74
|
if (!e) throw new Error(`malformed artifact name: ${s.name}`);
|
|
74
75
|
return { pkg: e.groups.pkg, id: e.groups.id, version: s.version };
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function fe(s) {
|
|
77
78
|
return `${s.pkg}:${s.id}:${s.version}`;
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
function He(s, e, t, r) {
|
|
81
|
+
return ye(e, t), {
|
|
82
|
+
compileMode: s,
|
|
83
|
+
fullName: e,
|
|
84
|
+
data: t,
|
|
85
|
+
source: r
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function We(s, e, t) {
|
|
89
|
+
const r = Le(t);
|
|
90
|
+
if (r.type !== "pl.tengo-template.v3")
|
|
91
|
+
throw new Error("malformed v3 template");
|
|
92
|
+
return ye(e, r), {
|
|
93
|
+
compileMode: s,
|
|
94
|
+
fullName: e,
|
|
95
|
+
data: r,
|
|
96
|
+
content: t
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function Ue(s) {
|
|
100
|
+
return {
|
|
101
|
+
compileMode: s.compileMode,
|
|
102
|
+
fullName: s.fullName,
|
|
103
|
+
data: s.data,
|
|
104
|
+
source: s.data.hashToSource[s.data.template.sourceHash]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function ye(s, e) {
|
|
108
|
+
const t = Ge(e.template);
|
|
109
|
+
if (t.pkg !== s.pkg || t.id !== s.id || t.version !== s.version)
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Compiled template name don't match it's package and file names: ${fe(t)} != ${fe(s)}`
|
|
112
|
+
);
|
|
100
113
|
}
|
|
101
|
-
class
|
|
114
|
+
class be {
|
|
102
115
|
constructor(e) {
|
|
103
116
|
c(this, "map", /* @__PURE__ */ new Map());
|
|
104
117
|
this.nameExtractor = e;
|
|
105
118
|
}
|
|
106
119
|
add(e, t = !0) {
|
|
107
|
-
const r = le(this.nameExtractor(e)),
|
|
108
|
-
return
|
|
120
|
+
const r = le(this.nameExtractor(e)), i = this.map.get(r);
|
|
121
|
+
return i && !t || this.map.set(r, e), i;
|
|
109
122
|
}
|
|
110
123
|
get(e) {
|
|
111
124
|
return this.map.get(le(e));
|
|
@@ -118,14 +131,14 @@ class ye {
|
|
|
118
131
|
this.map.forEach((t) => e(t, this.nameExtractor(t)));
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
|
-
function
|
|
122
|
-
return new
|
|
134
|
+
function ze() {
|
|
135
|
+
return new be((s) => s);
|
|
123
136
|
}
|
|
124
137
|
class J {
|
|
125
138
|
constructor(e) {
|
|
126
139
|
// private readonly dev: ArtifactMap<T>;
|
|
127
140
|
c(this, "dist");
|
|
128
|
-
this.dist = new
|
|
141
|
+
this.dist = new be(e);
|
|
129
142
|
}
|
|
130
143
|
add(e, t, r = !0) {
|
|
131
144
|
switch (e) {
|
|
@@ -148,19 +161,19 @@ class J {
|
|
|
148
161
|
return this.forEach(e, (r) => t.push(r)), t;
|
|
149
162
|
}
|
|
150
163
|
forEach(e, t) {
|
|
151
|
-
this.dist.forEach((r,
|
|
164
|
+
this.dist.forEach((r, i) => t(this.get(e, i) ?? r, i));
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
|
-
function
|
|
167
|
+
function _e(s, e) {
|
|
155
168
|
for (const t of s)
|
|
156
169
|
switch (t.name) {
|
|
157
170
|
case "hash_override": {
|
|
158
|
-
e.hashOverride =
|
|
171
|
+
e.hashOverride = Be(t.args);
|
|
159
172
|
break;
|
|
160
173
|
}
|
|
161
174
|
}
|
|
162
175
|
}
|
|
163
|
-
function
|
|
176
|
+
function qe(s, e) {
|
|
164
177
|
for (const t of s)
|
|
165
178
|
switch (t.name) {
|
|
166
179
|
case "hash_override":
|
|
@@ -169,19 +182,19 @@ function Ue(s, e) {
|
|
|
169
182
|
);
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
|
-
function
|
|
185
|
+
function Be(s) {
|
|
173
186
|
if (s.length != 1)
|
|
174
187
|
throw new Error(
|
|
175
188
|
"hash_override compiler option expects exactly one argument: hash_override <some string>. Note, you can use only UUID as a value."
|
|
176
189
|
);
|
|
177
190
|
const e = s[0].toLowerCase();
|
|
178
|
-
if (!
|
|
191
|
+
if (!Pe(e))
|
|
179
192
|
throw new Error(
|
|
180
193
|
`hash_override must contain valid UUID as an override. As hash_override affects deduplication, it becomes completely not possible to distinguish several different templates from each other on backend's side. This means, if you set hash_override to a simple value (say, letter "a") on two completely different templates, they will be marked as interchangeable on backend's side with unpredictable consequences. UUID looks like a safe enough tradeoff between the feature usage simplicity and duplication safety`
|
|
181
194
|
);
|
|
182
195
|
return e;
|
|
183
196
|
}
|
|
184
|
-
class
|
|
197
|
+
class Ke {
|
|
185
198
|
constructor(e) {
|
|
186
199
|
c(this, "libs", new J((e) => e.fullName));
|
|
187
200
|
c(this, "software", new J((e) => e.fullName));
|
|
@@ -189,48 +202,51 @@ class ze {
|
|
|
189
202
|
c(this, "templates", new J((e) => e.fullName));
|
|
190
203
|
this.compileMode = e;
|
|
191
204
|
}
|
|
192
|
-
|
|
205
|
+
/** Recursively add dependencies to the template. */
|
|
206
|
+
populateTemplateDataFromDependencies(e, t, r, i) {
|
|
193
207
|
for (const o of r)
|
|
194
208
|
switch (o.type) {
|
|
195
209
|
case "library": {
|
|
196
|
-
const
|
|
210
|
+
const n = this.getLibOrError(o), a = i.indexOf(w(o));
|
|
197
211
|
if (a >= 0) {
|
|
198
|
-
const
|
|
199
|
-
throw new Error(
|
|
212
|
+
const d = `library import recursion detected: ${i.slice(a).join(" -> ")} -> ${w(o)}`;
|
|
213
|
+
throw new Error(d);
|
|
200
214
|
}
|
|
201
215
|
const l = {
|
|
202
|
-
...I(
|
|
203
|
-
|
|
216
|
+
...I(n.fullName),
|
|
217
|
+
sourceHash: n.sourceHash
|
|
204
218
|
};
|
|
205
|
-
|
|
219
|
+
qe(n.compilerOptions), t.template.libs[w(o)] = l, t.hashToSource[l.sourceHash] = n.src, this.populateTemplateDataFromDependencies(e, t, n.dependencies, [...i, w(o)]);
|
|
206
220
|
break;
|
|
207
221
|
}
|
|
208
222
|
case "software": {
|
|
209
|
-
const
|
|
210
|
-
t.software[
|
|
211
|
-
...I(
|
|
212
|
-
|
|
213
|
-
};
|
|
223
|
+
const n = this.getSoftwareOrError(o);
|
|
224
|
+
t.template.software[w(o)] = {
|
|
225
|
+
...I(n.fullName),
|
|
226
|
+
sourceHash: n.sourceHash
|
|
227
|
+
}, t.hashToSource[n.sourceHash] = n.src;
|
|
214
228
|
break;
|
|
215
229
|
}
|
|
216
230
|
case "asset": {
|
|
217
|
-
const
|
|
218
|
-
t.software[
|
|
219
|
-
...I(
|
|
220
|
-
|
|
221
|
-
};
|
|
231
|
+
const n = this.getAssetOrError(o);
|
|
232
|
+
t.template.software[w(o)] = {
|
|
233
|
+
...I(n.fullName),
|
|
234
|
+
sourceHash: n.sourceHash
|
|
235
|
+
}, t.hashToSource[n.sourceHash] = n.src;
|
|
222
236
|
break;
|
|
223
237
|
}
|
|
224
238
|
case "template": {
|
|
225
239
|
if (ce(e, o))
|
|
226
240
|
continue;
|
|
227
|
-
const
|
|
228
|
-
t.templates[
|
|
241
|
+
const n = this.getTemplateOrError(o);
|
|
242
|
+
t.template.templates[w(o)] = n.data.template, t.hashToSource[n.data.template.sourceHash] = n.source;
|
|
243
|
+
for (const [a, l] of Object.entries(n.data.hashToSource))
|
|
244
|
+
t.hashToSource[a] = l;
|
|
229
245
|
break;
|
|
230
246
|
}
|
|
231
247
|
case "test":
|
|
232
248
|
throw new Error(
|
|
233
|
-
`dependencies tree error: tests should never be part of template: ${h(o)} is dependency of ${
|
|
249
|
+
`dependencies tree error: tests should never be part of template: ${h(o)} is dependency of ${w(e)}`
|
|
234
250
|
);
|
|
235
251
|
default:
|
|
236
252
|
R(o.type);
|
|
@@ -241,23 +257,26 @@ class ze {
|
|
|
241
257
|
if (e.fullName.type !== "template")
|
|
242
258
|
throw new Error("unexpected source type");
|
|
243
259
|
const t = {
|
|
244
|
-
type: "pl.tengo-template.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
260
|
+
type: "pl.tengo-template.v3",
|
|
261
|
+
hashToSource: {
|
|
262
|
+
[e.sourceHash]: e.src
|
|
263
|
+
},
|
|
264
|
+
template: {
|
|
265
|
+
...I(e.fullName),
|
|
266
|
+
templates: {},
|
|
267
|
+
libs: {},
|
|
268
|
+
software: {},
|
|
269
|
+
assets: {},
|
|
270
|
+
sourceHash: e.sourceHash
|
|
271
|
+
}
|
|
251
272
|
};
|
|
252
|
-
|
|
253
|
-
const r = new we(e.compileMode, e.fullName, { data: t });
|
|
254
|
-
return this.addTemplate(r), r;
|
|
273
|
+
return _e(e.compilerOptions, t.template), this.populateTemplateDataFromDependencies(e.fullName, t, e.dependencies, []), t;
|
|
255
274
|
}
|
|
256
275
|
addLib(e) {
|
|
257
276
|
const t = this.libs.add(e.compileMode, e, !1);
|
|
258
277
|
if (t && !C(e.fullName, t.fullName))
|
|
259
278
|
throw new Error(
|
|
260
|
-
`compiler already contain such library: adding = ${
|
|
279
|
+
`compiler already contain such library: adding = ${u(e.fullName)}, contains = ${u(t.fullName)}`
|
|
261
280
|
);
|
|
262
281
|
}
|
|
263
282
|
allLibs() {
|
|
@@ -271,14 +290,24 @@ class ze {
|
|
|
271
290
|
getLibOrError(e) {
|
|
272
291
|
const t = this.getLib(e);
|
|
273
292
|
if (!t)
|
|
274
|
-
throw new Error(`library not found: ${
|
|
293
|
+
throw new Error(`library not found: ${w(e)}`);
|
|
275
294
|
return t;
|
|
276
295
|
}
|
|
296
|
+
checkLibs() {
|
|
297
|
+
this.libs.forEach(this.compileMode, (e) => {
|
|
298
|
+
for (const t of e.dependencies) {
|
|
299
|
+
if (t.type === "test")
|
|
300
|
+
throw new Error(`test should never be dependency of production code: ${h(t)} test is dependency of ${u(e.fullName)}`);
|
|
301
|
+
if (!this.getArtefact(t))
|
|
302
|
+
throw new Error(`unresolved dependency ${h(t)} for ${u(e.fullName)}`);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
277
306
|
addSoftware(e) {
|
|
278
307
|
const t = this.software.add(e.compileMode, e, !1);
|
|
279
308
|
if (t && !C(e.fullName, t.fullName))
|
|
280
309
|
throw new Error(
|
|
281
|
-
`compiler already contain info for software: adding = ${
|
|
310
|
+
`compiler already contain info for software: adding = ${u(e.fullName)}, contains = ${u(t.fullName)}`
|
|
282
311
|
);
|
|
283
312
|
}
|
|
284
313
|
allSoftware() {
|
|
@@ -292,14 +321,14 @@ class ze {
|
|
|
292
321
|
getSoftwareOrError(e) {
|
|
293
322
|
const t = this.getSoftware(e);
|
|
294
323
|
if (!t)
|
|
295
|
-
throw new Error(`software info not found: ${
|
|
324
|
+
throw new Error(`software info not found: ${w(e)}`);
|
|
296
325
|
return t;
|
|
297
326
|
}
|
|
298
327
|
addAsset(e) {
|
|
299
328
|
const t = this.assets.add(e.compileMode, e, !1);
|
|
300
329
|
if (t && !C(e.fullName, t.fullName))
|
|
301
330
|
throw new Error(
|
|
302
|
-
`compiler already contain info for asset: adding = ${
|
|
331
|
+
`compiler already contain info for asset: adding = ${u(e.fullName)}, contains = ${u(t.fullName)}`
|
|
303
332
|
);
|
|
304
333
|
}
|
|
305
334
|
allAssets() {
|
|
@@ -313,14 +342,14 @@ class ze {
|
|
|
313
342
|
getAssetOrError(e) {
|
|
314
343
|
const t = this.getAsset(e);
|
|
315
344
|
if (!t)
|
|
316
|
-
throw new Error(`asset info not found: ${
|
|
345
|
+
throw new Error(`asset info not found: ${w(e)}`);
|
|
317
346
|
return t;
|
|
318
347
|
}
|
|
319
348
|
addTemplate(e) {
|
|
320
349
|
const t = this.templates.add(e.compileMode, e, !1);
|
|
321
350
|
if (t && !C(e.fullName, t.fullName))
|
|
322
351
|
throw new Error(
|
|
323
|
-
`compiler already contain such template: adding = ${
|
|
352
|
+
`compiler already contain such template: adding = ${u(e.fullName)}, contains = ${u(t.fullName)}`
|
|
324
353
|
);
|
|
325
354
|
}
|
|
326
355
|
allTemplates() {
|
|
@@ -334,7 +363,7 @@ class ze {
|
|
|
334
363
|
getTemplateOrError(e) {
|
|
335
364
|
const t = this.getTemplate(e);
|
|
336
365
|
if (!t)
|
|
337
|
-
throw new Error(`template not found: ${
|
|
366
|
+
throw new Error(`template not found: ${w(e)}`);
|
|
338
367
|
return t;
|
|
339
368
|
}
|
|
340
369
|
getArtefact(e) {
|
|
@@ -353,34 +382,29 @@ class ze {
|
|
|
353
382
|
R(e.type);
|
|
354
383
|
}
|
|
355
384
|
}
|
|
356
|
-
checkLibs() {
|
|
357
|
-
this.libs.forEach(this.compileMode, (e) => {
|
|
358
|
-
for (const t of e.dependencies) {
|
|
359
|
-
if (t.type === "test")
|
|
360
|
-
throw new Error(`test should never be dependency of production code: ${h(t)} test is dependency of ${g(e.fullName)}`);
|
|
361
|
-
if (!this.getArtefact(t))
|
|
362
|
-
throw new Error(`unresolved dependency ${h(t)} for ${g(e.fullName)}`);
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
385
|
compileAndAdd(e) {
|
|
367
|
-
const t = {
|
|
386
|
+
const t = {
|
|
387
|
+
templates: [],
|
|
388
|
+
libs: [],
|
|
389
|
+
software: [],
|
|
390
|
+
assets: []
|
|
391
|
+
};
|
|
368
392
|
let r = [];
|
|
369
|
-
for (const
|
|
370
|
-
|
|
393
|
+
for (const i of e)
|
|
394
|
+
i.fullName.type === "library" ? (this.addLib(i), t.libs.push(i)) : i.fullName.type === "software" ? (this.addSoftware(i), t.software.push(i)) : i.fullName.type === "asset" ? (this.addAsset(i), t.assets.push(i)) : r.push(i);
|
|
371
395
|
for (; r.length > 0; ) {
|
|
372
|
-
const
|
|
396
|
+
const i = [];
|
|
373
397
|
for (const o of r) {
|
|
374
|
-
const
|
|
398
|
+
const n = o.dependencies.filter(
|
|
375
399
|
(a) => !this.getArtefact(a) && !(o.fullName.type === "template" && ce(o.fullName, a))
|
|
376
400
|
);
|
|
377
|
-
if (
|
|
378
|
-
let a = `Unsatisfied dependencies in ${
|
|
401
|
+
if (n.length > 0) {
|
|
402
|
+
let a = `Unsatisfied dependencies in ${u(o.fullName)}:
|
|
379
403
|
`;
|
|
380
|
-
for (const l of
|
|
404
|
+
for (const l of n)
|
|
381
405
|
a += ` - ${h(l)}
|
|
382
406
|
`;
|
|
383
|
-
|
|
407
|
+
i.push({ src: o, err: new Error(a) });
|
|
384
408
|
continue;
|
|
385
409
|
}
|
|
386
410
|
switch (o.fullName.type) {
|
|
@@ -395,14 +419,14 @@ class ze {
|
|
|
395
419
|
break;
|
|
396
420
|
case "template":
|
|
397
421
|
try {
|
|
398
|
-
const a = this.compileAndAddTemplate(o);
|
|
399
|
-
t.templates.push(
|
|
422
|
+
const a = this.compileAndAddTemplate(o), l = He(o.compileMode, o.fullName, a, o.src);
|
|
423
|
+
this.addTemplate(l), t.templates.push(l);
|
|
400
424
|
} catch (a) {
|
|
401
425
|
const l = a;
|
|
402
|
-
let
|
|
426
|
+
let d = `Unsatisfied dependencies in ${u(o.fullName)}:
|
|
403
427
|
`;
|
|
404
|
-
|
|
405
|
-
`,
|
|
428
|
+
d += ` - ${l.message}
|
|
429
|
+
`, i.push({ src: o, err: Error(d) });
|
|
406
430
|
}
|
|
407
431
|
break;
|
|
408
432
|
case "test":
|
|
@@ -411,23 +435,23 @@ class ze {
|
|
|
411
435
|
R(o.fullName.type);
|
|
412
436
|
}
|
|
413
437
|
}
|
|
414
|
-
if (r.length ===
|
|
438
|
+
if (r.length === i.length) {
|
|
415
439
|
let o = "";
|
|
416
|
-
for (const
|
|
440
|
+
for (const n of i)
|
|
417
441
|
o += `
|
|
418
|
-
${
|
|
442
|
+
${n.err.message}`;
|
|
419
443
|
throw new Error(o);
|
|
420
444
|
}
|
|
421
|
-
r =
|
|
445
|
+
r = i.map(({ src: o }) => o);
|
|
422
446
|
}
|
|
423
447
|
return t;
|
|
424
448
|
}
|
|
425
449
|
}
|
|
426
|
-
const
|
|
450
|
+
const de = "[_a-zA-Z][_a-zA-Z0-9]*", j = (s, e) => new RegExp(
|
|
427
451
|
`\\b${s}\\.(?<fnCall>(?<fnName>` + e + ')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'
|
|
428
|
-
),
|
|
429
|
-
`\\b(?<importName>${
|
|
430
|
-
),
|
|
452
|
+
), Ve = (s) => j(s, "getTemplateId"), Xe = (s) => j(s, "getSoftwareInfo"), pe = (s) => j(s, "importTemplate"), ue = (s) => j(s, "importSoftware"), Ze = (s) => j(s, "importAsset"), Ye = /^\s*$/, Qe = /^\/\/tengo:[\w]/, et = /^\s*\/\/\s*tengo:\s*./, tt = /\/\*.*?\*\//g, st = /^\s*(\/\/)/, ot = /^\s*\/\*/, rt = /\*\//, ve = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/, nt = new RegExp(
|
|
453
|
+
`\\b(?<importName>${de}(\\.${de})*)${ve.source}`
|
|
454
|
+
), it = /(?<pkgName>[^"]+)?:(?<depID>[^"]+)/, at = (s) => {
|
|
431
455
|
const e = s.split(" "), t = e[0].split(":");
|
|
432
456
|
if (t.length != 2)
|
|
433
457
|
throw new Error(
|
|
@@ -438,17 +462,25 @@ const fe = "[_a-zA-Z][_a-zA-Z0-9]*", j = (s, e) => new RegExp(
|
|
|
438
462
|
args: e.slice(1)
|
|
439
463
|
};
|
|
440
464
|
};
|
|
441
|
-
class
|
|
442
|
-
constructor(e, t, r,
|
|
443
|
-
this.compileMode = e, this.fullName = t, this.
|
|
465
|
+
class oe {
|
|
466
|
+
constructor(e, t, r, i, o, n, a) {
|
|
467
|
+
this.compileMode = e, this.fullName = t, this.sourceHash = r, this.src = i, this.srcName = o, this.dependencies = n, this.compilerOptions = a;
|
|
444
468
|
}
|
|
445
469
|
}
|
|
446
|
-
function
|
|
447
|
-
const o =
|
|
448
|
-
return new
|
|
470
|
+
function Ee(s, e, t, r, i) {
|
|
471
|
+
const o = je(t).toString(), { deps: n, normalized: a, opts: l } = lt(s, o, r, i);
|
|
472
|
+
return new oe(
|
|
473
|
+
e,
|
|
474
|
+
r,
|
|
475
|
+
re(a),
|
|
476
|
+
a,
|
|
477
|
+
t,
|
|
478
|
+
n.array,
|
|
479
|
+
l
|
|
480
|
+
);
|
|
449
481
|
}
|
|
450
|
-
function
|
|
451
|
-
const
|
|
482
|
+
function lt(s, e, t, r) {
|
|
483
|
+
const i = ze(), o = [], n = e.split(`
|
|
452
484
|
`), a = [];
|
|
453
485
|
let l = {
|
|
454
486
|
isInCommentBlock: !1,
|
|
@@ -456,90 +488,90 @@ function ot(s, e, t, r) {
|
|
|
456
488
|
tplDepREs: /* @__PURE__ */ new Map(),
|
|
457
489
|
lineNo: 0
|
|
458
490
|
};
|
|
459
|
-
for (const
|
|
491
|
+
for (const d of n) {
|
|
460
492
|
l.lineNo++;
|
|
461
493
|
try {
|
|
462
|
-
const
|
|
494
|
+
const { line: g, context: m, artifact: y, option: b } = ct(
|
|
463
495
|
s,
|
|
464
|
-
|
|
496
|
+
d,
|
|
465
497
|
l,
|
|
466
498
|
t.pkg,
|
|
467
499
|
r
|
|
468
500
|
);
|
|
469
|
-
a.push(
|
|
470
|
-
} catch (
|
|
471
|
-
const
|
|
472
|
-
throw new Error(`[line ${l.lineNo} in ${
|
|
473
|
-
${
|
|
501
|
+
a.push(g), l = m, y && i.add(y), b && o.push(b);
|
|
502
|
+
} catch (g) {
|
|
503
|
+
const m = g;
|
|
504
|
+
throw new Error(`[line ${l.lineNo} in ${u(t)}]: ${m.message}
|
|
505
|
+
${d}`, { cause: m });
|
|
474
506
|
}
|
|
475
507
|
}
|
|
476
508
|
return {
|
|
477
509
|
normalized: a.join(`
|
|
478
510
|
`),
|
|
479
|
-
deps:
|
|
511
|
+
deps: i,
|
|
480
512
|
opts: o
|
|
481
513
|
};
|
|
482
514
|
}
|
|
483
|
-
function
|
|
484
|
-
if (e = e.replaceAll(
|
|
485
|
-
return
|
|
486
|
-
if (
|
|
515
|
+
function ct(s, e, t, r, i) {
|
|
516
|
+
if (e = e.replaceAll(tt, ""), t.isInCommentBlock)
|
|
517
|
+
return rt.exec(e) && (t.isInCommentBlock = !1), { line: "", context: t, artifact: void 0, option: void 0 };
|
|
518
|
+
if (Qe.exec(e)) {
|
|
487
519
|
if (!t.canDetectOptions)
|
|
488
520
|
throw s.error(
|
|
489
521
|
`[line ${t.lineNo}]: compiler option '//tengo:' was detected, but it cannot be applied as compiler options can be set only at the file header, before any code line'`
|
|
490
522
|
), new Error("tengo compiler options ('//tengo:' comments) can be set only in file header");
|
|
491
|
-
return { line: e, context: t, artifact: void 0, option:
|
|
523
|
+
return { line: e, context: t, artifact: void 0, option: at(e) };
|
|
492
524
|
}
|
|
493
|
-
if (
|
|
525
|
+
if (et.exec(e) && t.canDetectOptions)
|
|
494
526
|
return s.warn(
|
|
495
527
|
`[line ${t.lineNo}]: text simillar to compiler option ('//tengo:...') was detected, but it has wrong format. Leave it as is, if you did not mean to use a line as compiler option. Or format it to '//tengo:<option>' otherwise (no spaces between '//' and 'tengo', no spaces between ':' and option name)`
|
|
496
528
|
), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
497
|
-
if (
|
|
529
|
+
if (st.test(e))
|
|
498
530
|
return { line: "", context: t, artifact: void 0, option: void 0 };
|
|
499
|
-
if (
|
|
531
|
+
if (ot.exec(e))
|
|
500
532
|
return t.isInCommentBlock = !0, { line: "", context: t, artifact: void 0, option: void 0 };
|
|
501
533
|
if (e.includes("/*"))
|
|
502
534
|
throw new Error("malformed multiline comment");
|
|
503
|
-
if (
|
|
535
|
+
if (Ye.exec(e))
|
|
504
536
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
505
537
|
t.canDetectOptions = !1;
|
|
506
|
-
const o =
|
|
538
|
+
const o = ve.exec(e);
|
|
507
539
|
if (o) {
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
510
|
-
return t.tplDepREs.has(
|
|
511
|
-
["template",
|
|
512
|
-
["software",
|
|
540
|
+
const n = ft(e);
|
|
541
|
+
if (n.module === "plapi")
|
|
542
|
+
return t.tplDepREs.has(n.module) || t.tplDepREs.set(n.module, [
|
|
543
|
+
["template", Ve(n.alias)],
|
|
544
|
+
["software", Xe(n.alias)]
|
|
513
545
|
]), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
514
|
-
(
|
|
515
|
-
["template", pe(
|
|
516
|
-
["software", ue(
|
|
517
|
-
])), (
|
|
518
|
-
["template", pe(
|
|
519
|
-
["software", ue(
|
|
520
|
-
["asset",
|
|
546
|
+
(n.module === "@milaboratory/tengo-sdk:ll" || n.module === "@platforma-sdk/workflow-tengo:ll" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && n.module === ":ll") && (t.tplDepREs.has(n.module) || t.tplDepREs.set(n.module, [
|
|
547
|
+
["template", pe(n.alias)],
|
|
548
|
+
["software", ue(n.alias)]
|
|
549
|
+
])), (n.module === "@milaboratory/tengo-sdk:assets" || n.module === "@platforma-sdk/workflow-tengo:assets" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && n.module === ":assets") && (t.tplDepREs.has(n.module) || t.tplDepREs.set(n.module, [
|
|
550
|
+
["template", pe(n.alias)],
|
|
551
|
+
["software", ue(n.alias)],
|
|
552
|
+
["asset", Ze(n.alias)]
|
|
521
553
|
]));
|
|
522
|
-
const a = me(
|
|
554
|
+
const a = me(n.module, "library", r);
|
|
523
555
|
return a ? (e = e.replace(o[0], ` := import("${a.pkg}:${a.id}")`), { line: e, context: t, artifact: a, option: void 0 }) : { line: e, context: t, artifact: void 0, option: void 0 };
|
|
524
556
|
}
|
|
525
557
|
if (t.tplDepREs.size > 0)
|
|
526
|
-
for (const [
|
|
527
|
-
for (const [l,
|
|
528
|
-
const
|
|
529
|
-
if (!
|
|
558
|
+
for (const [n, a] of t.tplDepREs)
|
|
559
|
+
for (const [l, d] of a) {
|
|
560
|
+
const g = d.exec(e);
|
|
561
|
+
if (!g || !g.groups)
|
|
530
562
|
continue;
|
|
531
|
-
const { fnCall:
|
|
532
|
-
if (!
|
|
563
|
+
const { fnCall: m, templateName: y, fnName: b } = g.groups;
|
|
564
|
+
if (!m || !y || !b)
|
|
533
565
|
throw Error("failed to parse template import statement");
|
|
534
|
-
const
|
|
535
|
-
if (!
|
|
566
|
+
const M = me(y, l, r);
|
|
567
|
+
if (!M)
|
|
536
568
|
throw Error(`failed to parse artifact name in ${b} import statement`);
|
|
537
|
-
return e = e.replace(
|
|
569
|
+
return e = e.replace(m, `${b}("${M.pkg}:${M.id}")`), { line: e, context: t, artifact: M, option: void 0 };
|
|
538
570
|
}
|
|
539
571
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
540
572
|
}
|
|
541
|
-
function
|
|
542
|
-
const e =
|
|
573
|
+
function ft(s) {
|
|
574
|
+
const e = nt.exec(s);
|
|
543
575
|
if (!e || !e.groups)
|
|
544
576
|
throw Error("failed to parse 'import' statement");
|
|
545
577
|
const { importName: t, moduleName: r } = e.groups;
|
|
@@ -547,45 +579,44 @@ function nt(s) {
|
|
|
547
579
|
throw Error("failed to parse 'import' statement");
|
|
548
580
|
return {
|
|
549
581
|
module: r,
|
|
582
|
+
// the module name without wrapping quotes: import("<module>")
|
|
550
583
|
alias: t
|
|
584
|
+
// the name of variable that keeps imported module: <alias> := import("<module>")
|
|
551
585
|
};
|
|
552
586
|
}
|
|
553
587
|
function me(s, e, t) {
|
|
554
|
-
const r =
|
|
588
|
+
const r = it.exec(s);
|
|
555
589
|
if (!r)
|
|
556
590
|
return;
|
|
557
591
|
if (!r.groups)
|
|
558
592
|
throw Error(
|
|
559
593
|
"failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'"
|
|
560
594
|
);
|
|
561
|
-
const { pkgName:
|
|
595
|
+
const { pkgName: i, depID: o } = r.groups;
|
|
562
596
|
if (!o)
|
|
563
597
|
throw Error(
|
|
564
598
|
"failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'"
|
|
565
599
|
);
|
|
566
|
-
return { type: e, pkg:
|
|
600
|
+
return { type: e, pkg: i ?? t, id: o };
|
|
601
|
+
}
|
|
602
|
+
function re(s) {
|
|
603
|
+
return Ce("sha256").update(s).digest("hex");
|
|
567
604
|
}
|
|
568
|
-
const
|
|
569
|
-
function
|
|
605
|
+
const G = ".plj.gz", H = ".lib.tengo", W = ".sw.json", U = ".as.json", he = ".test.tengo", z = ".tpl.tengo", _ = ".lib.tengo", q = ".sw.json", B = ".as.json", dt = [_, z, q, B];
|
|
606
|
+
function ge(s, e) {
|
|
570
607
|
if (!f.isAbsolute(s))
|
|
571
608
|
throw new Error(`Root path must be absolute: ${s}`);
|
|
572
|
-
|
|
573
|
-
const n = f.join(s, "package.json");
|
|
574
|
-
if (k(n) === "file")
|
|
575
|
-
return n;
|
|
576
|
-
throw new Error(`Can't resolve package.json in ${s}`);
|
|
577
|
-
}
|
|
578
|
-
let t = Le(s, e);
|
|
609
|
+
let t = Ie(s, e);
|
|
579
610
|
if (t) {
|
|
580
|
-
let
|
|
611
|
+
let i = 0;
|
|
581
612
|
do {
|
|
582
613
|
const o = f.join(t, "package.json");
|
|
583
|
-
if (
|
|
614
|
+
if (S(o) === "file")
|
|
584
615
|
return o;
|
|
585
|
-
|
|
586
|
-
} while (
|
|
616
|
+
i++, t = f.dirname(t);
|
|
617
|
+
} while (i < 7 && f.basename(t) !== "node_modules");
|
|
587
618
|
}
|
|
588
|
-
const r =
|
|
619
|
+
const r = Je(s, `${e}/package.json`);
|
|
589
620
|
if (r.result === void 0) {
|
|
590
621
|
if (r.err === "ERR_PACKAGE_PATH_NOT_EXPORTED")
|
|
591
622
|
return;
|
|
@@ -593,207 +624,235 @@ function G(s, e) {
|
|
|
593
624
|
}
|
|
594
625
|
return r.result;
|
|
595
626
|
}
|
|
596
|
-
function
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
627
|
+
function pt(s) {
|
|
628
|
+
if (!f.isAbsolute(s))
|
|
629
|
+
throw new Error(`Root path must be absolute: ${s}`);
|
|
630
|
+
const e = f.join(s, "package.json");
|
|
631
|
+
if (S(e) === "file")
|
|
632
|
+
return e;
|
|
633
|
+
throw new Error(`Can't resolve package.json in ${s}`);
|
|
634
|
+
}
|
|
635
|
+
function A(s, e, t = "root") {
|
|
636
|
+
const r = pt(s), i = JSON.parse(p.readFileSync(r).toString()), o = [];
|
|
637
|
+
if (i.dependencies && t !== "devDependency")
|
|
638
|
+
for (const n of Object.keys(i.dependencies)) {
|
|
639
|
+
const a = ge(s, n);
|
|
640
|
+
if (a === void 0)
|
|
641
|
+
throw new Error(`Can't resolve package.json for dependency ${n} of ${s}`);
|
|
642
|
+
const l = f.dirname(a);
|
|
643
|
+
o.push(A(l, e, "dependency"));
|
|
608
644
|
}
|
|
609
|
-
if (
|
|
610
|
-
for (const
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
613
|
-
e.warn(`Can't resolve package.json for dev dependency ${
|
|
645
|
+
if (i.devDependencies && t === "root")
|
|
646
|
+
for (const n of Object.keys(i.devDependencies)) {
|
|
647
|
+
const a = ge(s, n);
|
|
648
|
+
if (a === void 0) {
|
|
649
|
+
e.warn(`Can't resolve package.json for dev dependency ${n} of ${s}`);
|
|
614
650
|
continue;
|
|
615
651
|
}
|
|
616
|
-
const
|
|
617
|
-
|
|
652
|
+
const l = f.dirname(a);
|
|
653
|
+
o.push(A(l, e, "devDependency"));
|
|
618
654
|
}
|
|
619
|
-
return {
|
|
655
|
+
return {
|
|
656
|
+
name: i.name,
|
|
657
|
+
version: i.version,
|
|
658
|
+
type: i.type,
|
|
659
|
+
dependencies: o,
|
|
660
|
+
root: s,
|
|
661
|
+
context: t
|
|
662
|
+
};
|
|
620
663
|
}
|
|
621
|
-
function
|
|
664
|
+
function $e(s, e) {
|
|
622
665
|
return f.resolve(e, s, "tengo", "lib");
|
|
623
666
|
}
|
|
624
|
-
function
|
|
667
|
+
function Ne(s, e) {
|
|
625
668
|
return f.resolve(e, s, "tengo", "tpl");
|
|
626
669
|
}
|
|
627
|
-
function
|
|
670
|
+
function Se(s, e) {
|
|
628
671
|
return f.resolve(e, s, "tengo", "software");
|
|
629
672
|
}
|
|
630
673
|
function ke(s, e) {
|
|
631
674
|
return f.resolve(e, s, "tengo", "asset");
|
|
632
675
|
}
|
|
633
|
-
function
|
|
634
|
-
for (const
|
|
635
|
-
|
|
676
|
+
function Te(s, e, t) {
|
|
677
|
+
for (const y of t.dependencies)
|
|
678
|
+
Te(s, e, y);
|
|
636
679
|
if (t.context === "root")
|
|
637
680
|
return;
|
|
638
|
-
const r =
|
|
639
|
-
if (!a && !l && !
|
|
681
|
+
const r = $e("dist", t.root), i = Ne("dist", t.root), o = Se("dist", t.root), n = ke("dist", t.root), a = S(r) === "dir", l = S(i) === "dir", d = S(o) === "dir", g = S(n) === "dir";
|
|
682
|
+
if (!a && !l && !d && !g)
|
|
640
683
|
return;
|
|
641
|
-
const
|
|
642
|
-
a &&
|
|
684
|
+
const m = { name: t.name, version: t.version };
|
|
685
|
+
a && ut(s, m, "dist", r, e), l && mt(s, m, "dist", i, e), d && ht(s, m, "dist", o, e), g && gt(s, m, "dist", n, e);
|
|
643
686
|
}
|
|
644
|
-
function
|
|
645
|
-
for (const o of
|
|
646
|
-
const
|
|
647
|
-
if (!o.endsWith(
|
|
687
|
+
function ut(s, e, t, r, i) {
|
|
688
|
+
for (const o of p.readdirSync(r)) {
|
|
689
|
+
const n = f.resolve(r, o);
|
|
690
|
+
if (!o.endsWith(H)) throw new Error(`unexpected file in 'lib' folder: ${n}`);
|
|
648
691
|
const a = {
|
|
649
692
|
type: "library",
|
|
650
693
|
pkg: e.name,
|
|
651
|
-
id: o.slice(0, o.length -
|
|
694
|
+
id: o.slice(0, o.length - H.length),
|
|
652
695
|
version: e.version
|
|
653
|
-
}, l =
|
|
654
|
-
if (
|
|
696
|
+
}, l = Ee(s, t, n, a, !0);
|
|
697
|
+
if (i.addLib(l), s.debug(`Adding dependency ${u(a)} from ${n}`), l.dependencies.length > 0) {
|
|
655
698
|
s.debug("Dependencies:");
|
|
656
|
-
for (const
|
|
699
|
+
for (const d of l.dependencies) s.debug(` - ${h(d)}`);
|
|
657
700
|
}
|
|
658
701
|
}
|
|
659
702
|
}
|
|
660
|
-
function
|
|
661
|
-
for (const o of
|
|
662
|
-
const
|
|
663
|
-
if (!o.endsWith(
|
|
703
|
+
function mt(s, e, t, r, i) {
|
|
704
|
+
for (const o of p.readdirSync(r)) {
|
|
705
|
+
const n = f.resolve(r, o);
|
|
706
|
+
if (!o.endsWith(G)) throw new Error(`unexpected file in 'tpl' folder: ${n}`);
|
|
664
707
|
const a = {
|
|
665
708
|
type: "template",
|
|
666
709
|
pkg: e.name,
|
|
667
|
-
id: o.slice(0, o.length -
|
|
710
|
+
id: o.slice(0, o.length - G.length),
|
|
668
711
|
version: e.version
|
|
669
|
-
}, l =
|
|
670
|
-
|
|
712
|
+
}, l = We(t, a, p.readFileSync(n));
|
|
713
|
+
i.addTemplate(Ue(l)), s.debug(`Adding dependency ${u(a)} from ${n}`);
|
|
671
714
|
}
|
|
672
715
|
}
|
|
673
|
-
function
|
|
674
|
-
for (const o of
|
|
675
|
-
const
|
|
676
|
-
if (!o.endsWith(
|
|
677
|
-
throw new Error(`unexpected file in 'software' folder: ${
|
|
716
|
+
function ht(s, e, t, r, i) {
|
|
717
|
+
for (const o of p.readdirSync(r)) {
|
|
718
|
+
const n = f.resolve(r, o);
|
|
719
|
+
if (!o.endsWith(W))
|
|
720
|
+
throw new Error(`unexpected file in 'software' folder: ${n}`);
|
|
678
721
|
const a = {
|
|
679
722
|
type: "software",
|
|
680
723
|
pkg: e.name,
|
|
681
|
-
id: o.slice(0, o.length -
|
|
724
|
+
id: o.slice(0, o.length - W.length),
|
|
682
725
|
version: e.version
|
|
683
|
-
}, l =
|
|
684
|
-
|
|
726
|
+
}, l = p.readFileSync(n).toString(), d = new oe(
|
|
727
|
+
t,
|
|
728
|
+
a,
|
|
729
|
+
re(l),
|
|
730
|
+
l,
|
|
731
|
+
n,
|
|
732
|
+
[],
|
|
733
|
+
[]
|
|
734
|
+
);
|
|
735
|
+
s.debug(`Adding dependency ${u(a)} from ${n}`), i.addSoftware(d);
|
|
685
736
|
}
|
|
686
737
|
}
|
|
687
|
-
function
|
|
688
|
-
for (const o of
|
|
689
|
-
const
|
|
690
|
-
if (!o.endsWith(
|
|
691
|
-
throw new Error(`unexpected file in 'asset' folder: ${
|
|
738
|
+
function gt(s, e, t, r, i) {
|
|
739
|
+
for (const o of p.readdirSync(r)) {
|
|
740
|
+
const n = f.resolve(r, o);
|
|
741
|
+
if (!o.endsWith(U))
|
|
742
|
+
throw new Error(`unexpected file in 'asset' folder: ${n}`);
|
|
692
743
|
const a = {
|
|
693
744
|
type: "asset",
|
|
694
745
|
pkg: e.name,
|
|
695
|
-
id: o.slice(0, o.length -
|
|
746
|
+
id: o.slice(0, o.length - U.length),
|
|
696
747
|
version: e.version
|
|
697
|
-
}, l =
|
|
698
|
-
|
|
748
|
+
}, l = p.readFileSync(n).toString(), d = new oe(
|
|
749
|
+
t,
|
|
750
|
+
a,
|
|
751
|
+
re(l),
|
|
752
|
+
l,
|
|
753
|
+
n,
|
|
754
|
+
[],
|
|
755
|
+
[]
|
|
756
|
+
);
|
|
757
|
+
s.debug(`Adding dependency ${u(a)} from ${n}`), i.addAsset(d);
|
|
699
758
|
}
|
|
700
759
|
}
|
|
701
|
-
function
|
|
760
|
+
function L(s, e, t, r, i) {
|
|
702
761
|
const o = [];
|
|
703
|
-
for (const
|
|
704
|
-
const a = f.join(
|
|
705
|
-
if (
|
|
706
|
-
const b =
|
|
762
|
+
for (const n of p.readdirSync(f.join(r, i))) {
|
|
763
|
+
const a = f.join(i, n), l = f.join(r, a);
|
|
764
|
+
if (S(l) === "dir") {
|
|
765
|
+
const b = L(s, e, t, r, a);
|
|
707
766
|
o.push(...b);
|
|
708
767
|
continue;
|
|
709
768
|
}
|
|
710
|
-
const
|
|
711
|
-
if (!
|
|
712
|
-
s.info(`Skipping unknown file type: ${
|
|
769
|
+
const d = n === "index.lib.tengo" ? `${f.dirname(a)}.lib.tengo` : a, g = wt(e, d.replaceAll(f.sep, "."));
|
|
770
|
+
if (!g) {
|
|
771
|
+
s.info(`Skipping unknown file type: ${d}`);
|
|
713
772
|
continue;
|
|
714
773
|
}
|
|
715
|
-
const
|
|
716
|
-
s.debug(`Parsing ${g
|
|
717
|
-
const
|
|
718
|
-
if (
|
|
774
|
+
const m = f.resolve(r, a);
|
|
775
|
+
s.debug(`Parsing ${u(g)} from ${m}`);
|
|
776
|
+
const y = Ee(s, t, m, g, !0);
|
|
777
|
+
if (y.dependencies.length > 0) {
|
|
719
778
|
s.debug("Detected dependencies:");
|
|
720
|
-
for (const b of
|
|
779
|
+
for (const b of y.dependencies) s.debug(` - ${h(b)}`);
|
|
721
780
|
}
|
|
722
|
-
o.push(
|
|
781
|
+
o.push(y);
|
|
723
782
|
}
|
|
724
783
|
return o;
|
|
725
784
|
}
|
|
726
785
|
function ne(s, e, t) {
|
|
727
|
-
const r = new
|
|
728
|
-
return
|
|
786
|
+
const r = new Ke(t);
|
|
787
|
+
return Te(s, r, e), r;
|
|
729
788
|
}
|
|
730
|
-
function
|
|
789
|
+
function wt(s, e) {
|
|
731
790
|
const t = { pkg: s.name, version: s.version };
|
|
732
|
-
return e.endsWith(
|
|
791
|
+
return e.endsWith(_) ? {
|
|
733
792
|
...t,
|
|
734
|
-
id: e.substring(0, e.length -
|
|
793
|
+
id: e.substring(0, e.length - _.length),
|
|
735
794
|
type: "library"
|
|
736
|
-
} : e.endsWith(
|
|
795
|
+
} : e.endsWith(z) ? {
|
|
737
796
|
...t,
|
|
738
|
-
id: e.substring(0, e.length -
|
|
797
|
+
id: e.substring(0, e.length - z.length),
|
|
739
798
|
type: "template"
|
|
740
|
-
} : e.endsWith(
|
|
799
|
+
} : e.endsWith(q) ? {
|
|
741
800
|
...t,
|
|
742
|
-
id: e.substring(0, e.length -
|
|
801
|
+
id: e.substring(0, e.length - q.length),
|
|
743
802
|
type: "software"
|
|
744
|
-
} : e.endsWith(
|
|
803
|
+
} : e.endsWith(B) ? {
|
|
745
804
|
...t,
|
|
746
|
-
id: e.substring(0, e.length -
|
|
805
|
+
id: e.substring(0, e.length - B.length),
|
|
747
806
|
type: "asset"
|
|
748
|
-
} : e.endsWith(
|
|
807
|
+
} : e.endsWith(he) ? {
|
|
749
808
|
...t,
|
|
750
|
-
id: e.substring(0, e.length -
|
|
809
|
+
id: e.substring(0, e.length - he.length),
|
|
751
810
|
type: "test"
|
|
752
811
|
} : null;
|
|
753
812
|
}
|
|
754
|
-
function
|
|
755
|
-
const
|
|
756
|
-
if (
|
|
757
|
-
const
|
|
758
|
-
for (const a of
|
|
759
|
-
|
|
760
|
-
s.error(`Nothing to compile. Looked for ${
|
|
813
|
+
function yt(s, e, t) {
|
|
814
|
+
const r = ne(s, e, t), i = L(s, e, t, "src", "");
|
|
815
|
+
if (i.length === 0) {
|
|
816
|
+
const n = [];
|
|
817
|
+
for (const a of dt)
|
|
818
|
+
n.push(`*${a}`);
|
|
819
|
+
s.error(`Nothing to compile. Looked for ${n.join(", ")}`), process.exit(1);
|
|
761
820
|
}
|
|
762
|
-
s.info(`Compiling '${
|
|
763
|
-
const o = r.compileAndAdd(
|
|
821
|
+
s.info(`Compiling '${t}'...`);
|
|
822
|
+
const o = r.compileAndAdd(i);
|
|
764
823
|
return s.debug("Done."), o;
|
|
765
824
|
}
|
|
766
|
-
function
|
|
825
|
+
function bt(s, e, t) {
|
|
767
826
|
if (e.libs.length > 0) {
|
|
768
|
-
const r =
|
|
769
|
-
|
|
770
|
-
for (const
|
|
771
|
-
const o = f.resolve(r,
|
|
772
|
-
s.info(` - writing ${o}`),
|
|
827
|
+
const r = $e(t, ".");
|
|
828
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
829
|
+
for (const i of e.libs) {
|
|
830
|
+
const o = f.resolve(r, i.fullName.id + H);
|
|
831
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, i.src);
|
|
773
832
|
}
|
|
774
833
|
}
|
|
775
834
|
if (e.templates.length > 0) {
|
|
776
|
-
const r =
|
|
777
|
-
|
|
778
|
-
for (const
|
|
779
|
-
const o = f.resolve(r,
|
|
780
|
-
s.info(` - writing ${o}`),
|
|
835
|
+
const r = Ne(t, ".");
|
|
836
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
837
|
+
for (const i of e.templates) {
|
|
838
|
+
const o = f.resolve(r, i.fullName.id + G);
|
|
839
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, Me(i.data));
|
|
781
840
|
}
|
|
782
841
|
}
|
|
783
842
|
if (e.software.length > 0) {
|
|
784
|
-
const r =
|
|
785
|
-
|
|
786
|
-
for (const
|
|
787
|
-
const o = f.resolve(r,
|
|
788
|
-
s.info(` - writing ${o}`),
|
|
843
|
+
const r = Se(t, ".");
|
|
844
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
845
|
+
for (const i of e.software) {
|
|
846
|
+
const o = f.resolve(r, i.fullName.id + W);
|
|
847
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, i.src);
|
|
789
848
|
}
|
|
790
849
|
}
|
|
791
850
|
if (e.assets.length > 0) {
|
|
792
851
|
const r = ke(t, ".");
|
|
793
|
-
|
|
794
|
-
for (const
|
|
795
|
-
const o = f.resolve(r,
|
|
796
|
-
s.info(` - writing ${o}`),
|
|
852
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
853
|
+
for (const i of e.software) {
|
|
854
|
+
const o = f.resolve(r, i.fullName.id + U);
|
|
855
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, i.src);
|
|
797
856
|
}
|
|
798
857
|
}
|
|
799
858
|
}
|
|
@@ -803,7 +862,7 @@ const ie = {
|
|
|
803
862
|
default: "info",
|
|
804
863
|
options: ["error", "warn", "info", "debug"]
|
|
805
864
|
})
|
|
806
|
-
},
|
|
865
|
+
}, vt = {
|
|
807
866
|
"generate-tags": F.boolean({
|
|
808
867
|
description: "generate tags, default false",
|
|
809
868
|
default: !1
|
|
@@ -819,55 +878,59 @@ const ie = {
|
|
|
819
878
|
multiple: !0,
|
|
820
879
|
delimiter: ","
|
|
821
880
|
})
|
|
822
|
-
},
|
|
881
|
+
}, k = class k extends v {
|
|
823
882
|
async run() {
|
|
824
|
-
const { flags: e } = await this.parse(
|
|
825
|
-
|
|
826
|
-
|
|
883
|
+
const { flags: e } = await this.parse(k), t = E(e["log-level"]), r = A(process.cwd(), t), i = yt(t, r, "dist");
|
|
884
|
+
bt(t, i, "dist"), t.info("Template Pack build done.");
|
|
885
|
+
const { dts: o, cjs: n, mjs: a } = Et(i);
|
|
886
|
+
await x.writeFile("dist/index.d.ts", o), r.type === "module" ? (await x.writeFile("dist/index.cjs", n), await x.writeFile("dist/index.js", a)) : (await x.writeFile("dist/index.js", n), await x.writeFile("dist/index.mjs", a)), $t(e), e["generate-tags"] && Nt(t, e), t.info("Template Pack build done.");
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
c(k, "description", "build tengo sources into single distributable pack file"), c(k, "examples", ["<%= config.bin %> <%= command.id %>"]), c(k, "flags", {
|
|
890
|
+
...ie,
|
|
891
|
+
...vt
|
|
892
|
+
});
|
|
893
|
+
let K = k;
|
|
894
|
+
function Et(s) {
|
|
895
|
+
let e = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
|
|
827
896
|
`;
|
|
828
|
-
|
|
829
|
-
`,
|
|
830
|
-
`,
|
|
897
|
+
e += `declare type TplName = ${s.templates.map((n) => '"' + n.fullName.id + '"').join(" | ")};
|
|
898
|
+
`, e += `declare const Templates: Record<TplName, TemplateFromFile>;
|
|
899
|
+
`, e += `export { Templates };
|
|
831
900
|
`;
|
|
832
|
-
|
|
833
|
-
`,
|
|
901
|
+
let t = `module.exports = { Templates: {
|
|
902
|
+
`, r = `import { resolve } from 'node:path';
|
|
834
903
|
export const Templates = {
|
|
835
904
|
`;
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
`),
|
|
840
|
-
|
|
841
|
-
|
|
905
|
+
const i = s.templates.map(
|
|
906
|
+
(n) => ` '${n.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${n.fullName.id}.plj.gz') }`
|
|
907
|
+
).join(`,
|
|
908
|
+
`), o = s.templates.map(
|
|
909
|
+
(n) => ` '${n.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${n.fullName.id}.plj.gz') }`
|
|
910
|
+
).join(`,
|
|
842
911
|
`);
|
|
843
|
-
|
|
912
|
+
return t += i, r += o, t += `
|
|
844
913
|
}};
|
|
845
|
-
`,
|
|
846
|
-
};
|
|
847
|
-
`, await x.writeFile("dist/index.d.ts", o), r.type === "module" ? (await x.writeFile("dist/index.cjs", i), await x.writeFile("dist/index.js", a)) : (await x.writeFile("dist/index.js", i), await x.writeFile("dist/index.mjs", a)), gt(e), e["generate-tags"] && ht(t, e), t.info("Template Pack build done.");
|
|
848
|
-
}
|
|
914
|
+
`, r += `
|
|
849
915
|
};
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
});
|
|
854
|
-
let X = A;
|
|
855
|
-
function gt(s) {
|
|
916
|
+
`, { dts: e, cjs: t, mjs: r };
|
|
917
|
+
}
|
|
918
|
+
function $t(s) {
|
|
856
919
|
process.env.GENERATE_TAGS != null && (s["generate-tags"] = process.env.GENERATE_TAGS == "true"), process.env.TAGS_FILE != null && (s["tags-file"] = process.env.TAGS_FILE), process.env.TAGS_ADDITIONAL_ARGS != null && (s["tags-additional-args"] = process.env.TAGS_ADDITIONAL_ARGS.split(","));
|
|
857
920
|
}
|
|
858
|
-
function
|
|
921
|
+
function Nt(s, e) {
|
|
859
922
|
var a;
|
|
860
|
-
const t = f.resolve(e["tags-file"]), r = f.dirname(t),
|
|
923
|
+
const t = f.resolve(e["tags-file"]), r = f.dirname(t), i = e["tags-additional-args"], o = St(r);
|
|
861
924
|
s.info(
|
|
862
|
-
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${
|
|
925
|
+
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${i.join('" "')}".
|
|
863
926
|
Found ${o.length} tengo files...`
|
|
864
927
|
);
|
|
865
|
-
const
|
|
928
|
+
const n = Fe(
|
|
866
929
|
"ctags",
|
|
867
930
|
[
|
|
868
931
|
"-f",
|
|
869
932
|
t,
|
|
870
|
-
...
|
|
933
|
+
...i,
|
|
871
934
|
"--langdef=tengo",
|
|
872
935
|
"--map-tengo=+.tengo",
|
|
873
936
|
"--kinddef-tengo=f,function,function",
|
|
@@ -883,7 +946,7 @@ Found ${o.length} tengo files...`
|
|
|
883
946
|
cwd: r
|
|
884
947
|
}
|
|
885
948
|
);
|
|
886
|
-
if ((a =
|
|
949
|
+
if ((a = n.error) != null && a.message.includes("ENOENT")) {
|
|
887
950
|
console.log(`
|
|
888
951
|
pl-tengo can create tags for tengo autocompletion,
|
|
889
952
|
but the program should be installed
|
|
@@ -894,25 +957,25 @@ For vscode, you should also install ctags extension:
|
|
|
894
957
|
https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
|
|
895
958
|
return;
|
|
896
959
|
}
|
|
897
|
-
|
|
960
|
+
kt(n, "failed to generate ctags"), s.info("Generation of tags is done.");
|
|
898
961
|
}
|
|
899
|
-
function
|
|
900
|
-
const e =
|
|
962
|
+
function St(s) {
|
|
963
|
+
const e = p.readdirSync(s, { withFileTypes: !0, recursive: !0 }), t = [];
|
|
901
964
|
return e.forEach((r) => {
|
|
902
965
|
if (!r.isDirectory() && r.name.endsWith(".tengo")) {
|
|
903
|
-
const
|
|
904
|
-
t.push(
|
|
966
|
+
const i = f.join(r.parentPath, r.name).replace(s, ".");
|
|
967
|
+
t.push(i);
|
|
905
968
|
}
|
|
906
969
|
}), t;
|
|
907
970
|
}
|
|
908
|
-
function
|
|
971
|
+
function kt(s, e) {
|
|
909
972
|
s.error && console.log(s.error);
|
|
910
973
|
const t = e;
|
|
911
974
|
s.status !== 0 && console.log(`WARN: ${t} the build will continue as-is`);
|
|
912
975
|
}
|
|
913
976
|
function ae(s, e) {
|
|
914
|
-
const t =
|
|
915
|
-
for (const o of
|
|
977
|
+
const t = A(process.cwd(), s), r = L(s, t, "dist", "src", ""), i = ne(s, t, "dist");
|
|
978
|
+
for (const o of i.allLibs())
|
|
916
979
|
s.debug(
|
|
917
980
|
`Dumping to pl-tester: ${h(o.fullName)}`
|
|
918
981
|
), e.write(JSON.stringify(o) + `
|
|
@@ -922,7 +985,7 @@ function ae(s, e) {
|
|
|
922
985
|
`Dumping to pl-tester: ${h(o.fullName)}`
|
|
923
986
|
), e.write(JSON.stringify(o) + `
|
|
924
987
|
`));
|
|
925
|
-
for (const o of
|
|
988
|
+
for (const o of i.allTemplates())
|
|
926
989
|
s.debug(
|
|
927
990
|
`Dumping to pl-tester: ${h(o.fullName)}`
|
|
928
991
|
), e.write(JSON.stringify(o) + `
|
|
@@ -932,7 +995,7 @@ function ae(s, e) {
|
|
|
932
995
|
`Dumping to pl-tester: ${h(o.fullName)} ${o.srcName}`
|
|
933
996
|
), e.write(JSON.stringify(o) + `
|
|
934
997
|
`));
|
|
935
|
-
for (const o of
|
|
998
|
+
for (const o of i.allSoftware())
|
|
936
999
|
s.debug(
|
|
937
1000
|
`Dumping to pl-tester: ${h(o.fullName)}`
|
|
938
1001
|
), e.write(JSON.stringify(o) + `
|
|
@@ -942,7 +1005,7 @@ function ae(s, e) {
|
|
|
942
1005
|
`Dumping to pl-tester: ${h(o.fullName)}`
|
|
943
1006
|
), e.write(JSON.stringify(o) + `
|
|
944
1007
|
`));
|
|
945
|
-
for (const o of
|
|
1008
|
+
for (const o of i.allAssets())
|
|
946
1009
|
s.debug(
|
|
947
1010
|
`Dumping to pl-tester: ${h(o.fullName)}`
|
|
948
1011
|
), e.write(JSON.stringify(o) + `
|
|
@@ -958,46 +1021,46 @@ function ae(s, e) {
|
|
|
958
1021
|
), e.write(JSON.stringify(o) + `
|
|
959
1022
|
`));
|
|
960
1023
|
}
|
|
961
|
-
function
|
|
962
|
-
const r =
|
|
1024
|
+
function Tt(s, e, t) {
|
|
1025
|
+
const r = A(process.cwd(), s), i = L(s, r, "dist", "src", "");
|
|
963
1026
|
if (!e) {
|
|
964
|
-
for (const
|
|
965
|
-
|
|
1027
|
+
for (const n of i)
|
|
1028
|
+
n.fullName.type === "library" && t.write(JSON.stringify(n) + `
|
|
966
1029
|
`);
|
|
967
1030
|
return;
|
|
968
1031
|
}
|
|
969
1032
|
const o = ne(s, r, "dist");
|
|
970
|
-
for (const
|
|
971
|
-
|
|
972
|
-
for (const
|
|
973
|
-
t.write(JSON.stringify(
|
|
1033
|
+
for (const n of i)
|
|
1034
|
+
n.fullName.type === "library" && o.addLib(n);
|
|
1035
|
+
for (const n of o.allLibs())
|
|
1036
|
+
t.write(JSON.stringify(n) + `
|
|
974
1037
|
`);
|
|
975
1038
|
}
|
|
976
1039
|
function P(s, e, t) {
|
|
977
|
-
const r =
|
|
978
|
-
for (const o of
|
|
1040
|
+
const r = A(process.cwd(), s), i = L(s, r, "dist", "src", "");
|
|
1041
|
+
for (const o of i)
|
|
979
1042
|
o.fullName.type === t && e.write(JSON.stringify(o) + `
|
|
980
1043
|
`);
|
|
981
1044
|
}
|
|
982
|
-
function
|
|
1045
|
+
function At(s, e) {
|
|
983
1046
|
P(s, e, "template");
|
|
984
1047
|
}
|
|
985
|
-
function
|
|
1048
|
+
function Dt(s, e) {
|
|
986
1049
|
P(s, e, "software");
|
|
987
1050
|
}
|
|
988
|
-
function
|
|
1051
|
+
function Ot(s, e) {
|
|
989
1052
|
P(s, e, "asset");
|
|
990
1053
|
}
|
|
991
|
-
function
|
|
1054
|
+
function xt(s, e) {
|
|
992
1055
|
P(s, e, "test");
|
|
993
1056
|
}
|
|
994
1057
|
function Ae(s, ...e) {
|
|
995
|
-
const t =
|
|
1058
|
+
const t = Re(s, e, { stdio: ["pipe", "inherit", "inherit"] });
|
|
996
1059
|
return t.stdin.on("error", (r) => {
|
|
997
1060
|
r.code;
|
|
998
1061
|
}), t;
|
|
999
1062
|
}
|
|
1000
|
-
function
|
|
1063
|
+
function De(s) {
|
|
1001
1064
|
return new Promise((e, t) => {
|
|
1002
1065
|
s.on("close", (r) => {
|
|
1003
1066
|
e(r);
|
|
@@ -1008,23 +1071,23 @@ function Te(s) {
|
|
|
1008
1071
|
}
|
|
1009
1072
|
const $ = class $ extends v {
|
|
1010
1073
|
async run() {
|
|
1011
|
-
const { flags: e, argv: t } = await this.parse($), r = E(e["log-level"]),
|
|
1012
|
-
|
|
1074
|
+
const { flags: e, argv: t } = await this.parse($), r = E(e["log-level"]), i = t.length == 0 ? ["./src"] : t, o = Ae(
|
|
1075
|
+
we,
|
|
1013
1076
|
"check",
|
|
1014
1077
|
"--log-level",
|
|
1015
1078
|
e["log-level"],
|
|
1016
1079
|
"--artifacts",
|
|
1017
1080
|
"-",
|
|
1018
|
-
...
|
|
1081
|
+
...i
|
|
1019
1082
|
);
|
|
1020
1083
|
try {
|
|
1021
1084
|
ae(r, o.stdin);
|
|
1022
|
-
} catch (
|
|
1023
|
-
r.error(
|
|
1085
|
+
} catch (n) {
|
|
1086
|
+
r.error(n);
|
|
1024
1087
|
} finally {
|
|
1025
1088
|
o.stdin.end();
|
|
1026
|
-
const
|
|
1027
|
-
process.exit(
|
|
1089
|
+
const n = await De(o);
|
|
1090
|
+
process.exit(n);
|
|
1028
1091
|
}
|
|
1029
1092
|
}
|
|
1030
1093
|
};
|
|
@@ -1032,11 +1095,11 @@ c($, "description", "check tengo sources for language processor an"), // static
|
|
|
1032
1095
|
// "log-level": Args.string({description: 'logging level'}),
|
|
1033
1096
|
// }
|
|
1034
1097
|
c($, "strict", !1), c($, "flags", { ...ie }), c($, "examples", ["<%= config.bin %> <%= command.id %>"]);
|
|
1035
|
-
let
|
|
1098
|
+
let V = $;
|
|
1036
1099
|
const N = class N extends v {
|
|
1037
1100
|
async run() {
|
|
1038
|
-
const { flags: e } = await this.parse(N), t = E(e["log-level"]), r = this.argv.length == 0 ? ["./src"] : this.argv,
|
|
1039
|
-
|
|
1101
|
+
const { flags: e } = await this.parse(N), t = E(e["log-level"]), r = this.argv.length == 0 ? ["./src"] : this.argv, i = Ae(
|
|
1102
|
+
we,
|
|
1040
1103
|
"run",
|
|
1041
1104
|
"--log-level",
|
|
1042
1105
|
e["log-level"],
|
|
@@ -1045,40 +1108,40 @@ const N = class N extends v {
|
|
|
1045
1108
|
...r
|
|
1046
1109
|
);
|
|
1047
1110
|
try {
|
|
1048
|
-
ae(t,
|
|
1111
|
+
ae(t, i.stdin);
|
|
1049
1112
|
} catch (o) {
|
|
1050
1113
|
t.error(o);
|
|
1051
1114
|
} finally {
|
|
1052
|
-
|
|
1053
|
-
const o = await
|
|
1115
|
+
i.stdin.end();
|
|
1116
|
+
const o = await De(i);
|
|
1054
1117
|
process.exit(o);
|
|
1055
1118
|
}
|
|
1056
1119
|
}
|
|
1057
1120
|
};
|
|
1058
1121
|
c(N, "description", "run tengo unit tests (.test.tengo)"), c(N, "strict", !1), c(N, "flags", { ...ie }), c(N, "examples", ["<%= config.bin %> <%= command.id %>"]);
|
|
1059
|
-
let
|
|
1060
|
-
class
|
|
1122
|
+
let X = N;
|
|
1123
|
+
class Z extends v {
|
|
1061
1124
|
async run() {
|
|
1062
1125
|
const e = E();
|
|
1063
1126
|
ae(e, D);
|
|
1064
1127
|
}
|
|
1065
1128
|
}
|
|
1066
|
-
c(
|
|
1129
|
+
c(Z, "description", "parse sources in current package and dump all found artifacts to stdout"), c(Z, "examples", [
|
|
1067
1130
|
"<%= config.bin %> <%= command.id %>"
|
|
1068
1131
|
]);
|
|
1069
|
-
class
|
|
1132
|
+
class Y extends v {
|
|
1070
1133
|
async run() {
|
|
1071
1134
|
const e = E();
|
|
1072
|
-
|
|
1135
|
+
Ot(e, D);
|
|
1073
1136
|
}
|
|
1074
1137
|
}
|
|
1075
|
-
c(
|
|
1138
|
+
c(Y, "description", "parse sources in current package and dump all found assets to stdout"), c(Y, "examples", [
|
|
1076
1139
|
"<%= config.bin %> <%= command.id %>"
|
|
1077
1140
|
]);
|
|
1078
1141
|
const T = class T extends v {
|
|
1079
1142
|
async run() {
|
|
1080
1143
|
const { flags: e } = await this.parse(T), t = E();
|
|
1081
|
-
|
|
1144
|
+
Tt(t, e.deps, D);
|
|
1082
1145
|
}
|
|
1083
1146
|
};
|
|
1084
1147
|
c(T, "description", "parse sources in current package and dump all found libs to stdout"), c(T, "examples", [
|
|
@@ -1086,46 +1149,46 @@ c(T, "description", "parse sources in current package and dump all found libs to
|
|
|
1086
1149
|
]), c(T, "flags", {
|
|
1087
1150
|
deps: F.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
|
|
1088
1151
|
});
|
|
1089
|
-
let
|
|
1090
|
-
class
|
|
1152
|
+
let Q = T;
|
|
1153
|
+
class ee extends v {
|
|
1091
1154
|
async run() {
|
|
1092
1155
|
const e = E();
|
|
1093
|
-
|
|
1156
|
+
Dt(e, D);
|
|
1094
1157
|
}
|
|
1095
1158
|
}
|
|
1096
|
-
c(
|
|
1159
|
+
c(ee, "description", "parse sources in current package and dump all found software to stdout"), c(ee, "examples", [
|
|
1097
1160
|
"<%= config.bin %> <%= command.id %>"
|
|
1098
1161
|
]);
|
|
1099
|
-
class
|
|
1162
|
+
class te extends v {
|
|
1100
1163
|
async run() {
|
|
1101
1164
|
const e = E();
|
|
1102
|
-
|
|
1165
|
+
At(e, D);
|
|
1103
1166
|
}
|
|
1104
1167
|
}
|
|
1105
|
-
c(
|
|
1168
|
+
c(te, "description", "parse sources in current package and dump all found templates to stdout"), c(te, "examples", [
|
|
1106
1169
|
"<%= config.bin %> <%= command.id %>"
|
|
1107
1170
|
]);
|
|
1108
|
-
class
|
|
1171
|
+
class se extends v {
|
|
1109
1172
|
async run() {
|
|
1110
1173
|
const e = E();
|
|
1111
|
-
|
|
1174
|
+
xt(e, D);
|
|
1112
1175
|
}
|
|
1113
1176
|
}
|
|
1114
|
-
c(
|
|
1177
|
+
c(se, "description", "parse sources in current package and dump all found tests to stdout"), c(se, "examples", [
|
|
1115
1178
|
"<%= config.bin %> <%= command.id %>"
|
|
1116
1179
|
]);
|
|
1117
|
-
const
|
|
1118
|
-
build:
|
|
1119
|
-
check:
|
|
1120
|
-
test:
|
|
1121
|
-
"dump:all":
|
|
1122
|
-
"dump:assets":
|
|
1123
|
-
"dump:libs":
|
|
1124
|
-
"dump:software":
|
|
1125
|
-
"dump:templates":
|
|
1126
|
-
"dump:tests":
|
|
1180
|
+
const Gt = {
|
|
1181
|
+
build: K,
|
|
1182
|
+
check: V,
|
|
1183
|
+
test: X,
|
|
1184
|
+
"dump:all": Z,
|
|
1185
|
+
"dump:assets": Y,
|
|
1186
|
+
"dump:libs": Q,
|
|
1187
|
+
"dump:software": ee,
|
|
1188
|
+
"dump:templates": te,
|
|
1189
|
+
"dump:tests": se
|
|
1127
1190
|
};
|
|
1128
1191
|
export {
|
|
1129
|
-
|
|
1192
|
+
Gt as COMMANDS
|
|
1130
1193
|
};
|
|
1131
1194
|
//# sourceMappingURL=index.mjs.map
|