@platforma-sdk/tengo-builder 1.17.3 → 1.17.5
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/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compileroptions.d.ts +1 -1
- package/dist/compiler/compileroptions.d.ts.map +1 -1
- package/dist/compiler/template.d.ts +1 -47
- package/dist/compiler/template.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -108
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -6
- package/src/compiler/compiler.ts +2 -1
- package/src/compiler/compileroptions.ts +1 -1
- package/src/compiler/template.ts +23 -75
- package/src/index.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
var xe = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var l = (s, e, t) =>
|
|
4
|
-
import { spawnSync as
|
|
5
|
-
import { Flags as
|
|
2
|
+
var Fe = (s, e, t) => e in s ? xe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var l = (s, e, t) => Fe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { spawnSync as Oe, spawn as Re } from "node:child_process";
|
|
5
|
+
import { Flags as F, Command as $ } from "@oclif/core";
|
|
6
6
|
import * as f from "node:path";
|
|
7
7
|
import * as p from "node:fs";
|
|
8
8
|
import { readFileSync as Me } from "node:fs";
|
|
9
9
|
import * as G from "winston";
|
|
10
|
-
import {
|
|
11
|
-
import Ie from "canonicalize";
|
|
10
|
+
import { parseTemplate as Le, serializeTemplate as je } from "@milaboratories/pl-model-backend";
|
|
12
11
|
import * as x from "node:fs/promises";
|
|
13
12
|
import { TengoTesterBinaryPath as we } from "@milaboratories/tengo-tester";
|
|
14
13
|
import { stdout as D } from "node:process";
|
|
15
|
-
function
|
|
14
|
+
function O(s) {
|
|
16
15
|
throw new Error("Unexpected object: " + s);
|
|
17
16
|
}
|
|
18
17
|
function N(s = "debug") {
|
|
@@ -27,7 +26,7 @@ function N(s = "debug") {
|
|
|
27
26
|
]
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
function
|
|
29
|
+
function Ie() {
|
|
31
30
|
let s = process.cwd();
|
|
32
31
|
for (; s; ) {
|
|
33
32
|
const e = f.join(s, "node_modules");
|
|
@@ -47,7 +46,7 @@ function E(s) {
|
|
|
47
46
|
throw e;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
function
|
|
49
|
+
function Ce(s) {
|
|
51
50
|
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());
|
|
52
51
|
}
|
|
53
52
|
function ce(s) {
|
|
@@ -68,7 +67,7 @@ function h(s) {
|
|
|
68
67
|
function j(s) {
|
|
69
68
|
return { name: h(s), version: s.version };
|
|
70
69
|
}
|
|
71
|
-
function
|
|
70
|
+
function Ge(s) {
|
|
72
71
|
const e = s.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);
|
|
73
72
|
if (!e) throw new Error(`malformed artifact name: ${s.name}`);
|
|
74
73
|
return { pkg: e.groups.pkg, id: e.groups.id, version: s.version };
|
|
@@ -76,7 +75,6 @@ function Je(s) {
|
|
|
76
75
|
function fe(s) {
|
|
77
76
|
return `${s.pkg}:${s.id}:${s.version}`;
|
|
78
77
|
}
|
|
79
|
-
const Ue = new TextDecoder(), ze = new TextEncoder();
|
|
80
78
|
class ye {
|
|
81
79
|
constructor(e, t, r) {
|
|
82
80
|
l(this, "data");
|
|
@@ -87,19 +85,19 @@ class ye {
|
|
|
87
85
|
throw new Error("Neither data nor content is provided for template constructor");
|
|
88
86
|
if (n !== void 0 && o !== void 0)
|
|
89
87
|
throw new Error("Both data and content are provided for template constructor");
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
o === void 0 && (o = je(ze.encode(Ie(n))));
|
|
93
|
-
const i = Je(n);
|
|
88
|
+
n === void 0 && (n = Le(o)), o === void 0 && (o = je(n));
|
|
89
|
+
const i = Ge(n);
|
|
94
90
|
if (i.pkg !== t.pkg || i.id !== t.id || i.version !== t.version)
|
|
95
|
-
throw new Error(
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Compiled template name don't match it's package and file names: ${fe(i)} != ${fe(t)}`
|
|
93
|
+
);
|
|
96
94
|
this.data = n, this.content = o;
|
|
97
95
|
}
|
|
98
96
|
toJSON() {
|
|
99
97
|
return { compileMode: this.compileMode, fullName: this.fullName, data: this.data };
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
|
-
class
|
|
100
|
+
class U {
|
|
103
101
|
constructor(e) {
|
|
104
102
|
l(this, "map", /* @__PURE__ */ new Map());
|
|
105
103
|
this.nameExtractor = e;
|
|
@@ -119,21 +117,21 @@ class J {
|
|
|
119
117
|
this.map.forEach((t) => e(t, this.nameExtractor(t)));
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
|
-
function
|
|
123
|
-
return new
|
|
120
|
+
function Ue() {
|
|
121
|
+
return new U((s) => s);
|
|
124
122
|
}
|
|
125
123
|
class I {
|
|
126
124
|
constructor(e) {
|
|
127
125
|
l(this, "dev");
|
|
128
126
|
l(this, "dist");
|
|
129
|
-
this.nameExtractor = e, this.dev = new
|
|
127
|
+
this.nameExtractor = e, this.dev = new U(e), this.dist = new U(e);
|
|
130
128
|
}
|
|
131
129
|
add(e, t, r = !0) {
|
|
132
130
|
switch (e) {
|
|
133
131
|
case "dist":
|
|
134
132
|
return this.dist.add(t, r);
|
|
135
133
|
default:
|
|
136
|
-
|
|
134
|
+
O(e);
|
|
137
135
|
}
|
|
138
136
|
}
|
|
139
137
|
get(e, t) {
|
|
@@ -141,7 +139,7 @@ class I {
|
|
|
141
139
|
case "dist":
|
|
142
140
|
return this.dist.get(t);
|
|
143
141
|
default:
|
|
144
|
-
|
|
142
|
+
O(e);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
array(e) {
|
|
@@ -152,16 +150,16 @@ class I {
|
|
|
152
150
|
this.dist.forEach((r, n) => t(this.get(e, n) ?? r, n));
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
|
-
function
|
|
153
|
+
function Je(s, e) {
|
|
156
154
|
for (const t of s)
|
|
157
155
|
switch (t.name) {
|
|
158
156
|
case "hash_override": {
|
|
159
|
-
e.hashOverride =
|
|
157
|
+
e.hashOverride = We(t.args);
|
|
160
158
|
break;
|
|
161
159
|
}
|
|
162
160
|
}
|
|
163
161
|
}
|
|
164
|
-
function
|
|
162
|
+
function Pe(s, e) {
|
|
165
163
|
for (const t of s)
|
|
166
164
|
switch (t.name) {
|
|
167
165
|
case "hash_override":
|
|
@@ -170,19 +168,19 @@ function _e(s, e) {
|
|
|
170
168
|
);
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
|
-
function
|
|
171
|
+
function We(s) {
|
|
174
172
|
if (s.length != 1)
|
|
175
173
|
throw new Error(
|
|
176
174
|
"hash_override compiler option expects exactly one argument: hash_override <some string>. Note, you can use only UUID as a value."
|
|
177
175
|
);
|
|
178
176
|
const e = s[0].toLowerCase();
|
|
179
|
-
if (!
|
|
177
|
+
if (!Ce(e))
|
|
180
178
|
throw new Error(
|
|
181
179
|
`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`
|
|
182
180
|
);
|
|
183
181
|
return e;
|
|
184
182
|
}
|
|
185
|
-
class
|
|
183
|
+
class ze {
|
|
186
184
|
constructor(e) {
|
|
187
185
|
l(this, "libs", new I((e) => e.fullName));
|
|
188
186
|
l(this, "software", new I((e) => e.fullName));
|
|
@@ -203,7 +201,7 @@ class Be {
|
|
|
203
201
|
...j(u.fullName),
|
|
204
202
|
src: u.src
|
|
205
203
|
};
|
|
206
|
-
|
|
204
|
+
Pe(u.compilerOptions), t.libs[h(o)] = y, this.populateTemplateDataFromDependencies(e, t, u.dependencies, [...n, h(o)]);
|
|
207
205
|
break;
|
|
208
206
|
}
|
|
209
207
|
case "software":
|
|
@@ -231,7 +229,7 @@ class Be {
|
|
|
231
229
|
`dependencies tree error: tests should never be part of template: ${g(o)} is dependency of ${h(e)}`
|
|
232
230
|
);
|
|
233
231
|
default:
|
|
234
|
-
|
|
232
|
+
O(o.type);
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
/** This method assumes that all dependencies are already added to the compiler's context */
|
|
@@ -247,7 +245,7 @@ class Be {
|
|
|
247
245
|
assets: {},
|
|
248
246
|
src: e.src
|
|
249
247
|
};
|
|
250
|
-
|
|
248
|
+
Je(e.compilerOptions, t), this.populateTemplateDataFromDependencies(e.fullName, t, e.dependencies, []);
|
|
251
249
|
const r = new ye(e.compileMode, e.fullName, { data: t });
|
|
252
250
|
return this.addTemplate(r), r;
|
|
253
251
|
}
|
|
@@ -348,7 +346,7 @@ class Be {
|
|
|
348
346
|
case "test":
|
|
349
347
|
return;
|
|
350
348
|
default:
|
|
351
|
-
|
|
349
|
+
O(e.type);
|
|
352
350
|
}
|
|
353
351
|
}
|
|
354
352
|
checkLibs() {
|
|
@@ -406,7 +404,7 @@ class Be {
|
|
|
406
404
|
case "test":
|
|
407
405
|
break;
|
|
408
406
|
default:
|
|
409
|
-
|
|
407
|
+
O(o.fullName.type);
|
|
410
408
|
}
|
|
411
409
|
}
|
|
412
410
|
if (r.length === n.length) {
|
|
@@ -423,9 +421,9 @@ ${i.err.message}`;
|
|
|
423
421
|
}
|
|
424
422
|
const pe = "[_a-zA-Z][_a-zA-Z0-9]*", R = (s, e) => new RegExp(
|
|
425
423
|
`\\b${s}\\.(?<fnCall>(?<fnName>` + e + ')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'
|
|
426
|
-
),
|
|
424
|
+
), _e = (s) => R(s, "getTemplateId"), qe = (s) => R(s, "getSoftwareInfo"), ue = (s) => R(s, "importTemplate"), me = (s) => R(s, "importSoftware"), Be = (s) => R(s, "importAsset"), Ve = /^\s*$/, Ze = /^\/\/tengo:[\w]/, Ke = /^\s*\/\/\s*tengo:\s*./, Xe = /^\s*(\/\/)|(\/\*.*\*\/)/, Ye = /^\s*\/\*/, He = /\*\//, be = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/, Qe = new RegExp(
|
|
427
425
|
`\\b(?<importName>${pe}(\\.${pe})*)${be.source}`
|
|
428
|
-
),
|
|
426
|
+
), et = /(?<pkgName>[^"]+)?:(?<depID>[^"]+)/, tt = (s) => {
|
|
429
427
|
const e = s.split(" "), t = e[0].split(":");
|
|
430
428
|
if (t.length != 2)
|
|
431
429
|
throw new Error(
|
|
@@ -442,11 +440,11 @@ class oe {
|
|
|
442
440
|
}
|
|
443
441
|
}
|
|
444
442
|
function ve(s, e, t, r, n) {
|
|
445
|
-
const o = Me(t).toString(), { deps: i, normalized: a, opts: c } =
|
|
443
|
+
const o = Me(t).toString(), { deps: i, normalized: a, opts: c } = st(s, o, r, n);
|
|
446
444
|
return new oe(e, r, a, t, i.array, c);
|
|
447
445
|
}
|
|
448
|
-
function
|
|
449
|
-
const n =
|
|
446
|
+
function st(s, e, t, r) {
|
|
447
|
+
const n = Ue(), o = [], i = e.split(`
|
|
450
448
|
`), a = [];
|
|
451
449
|
let c = {
|
|
452
450
|
isInCommentBlock: !1,
|
|
@@ -457,7 +455,7 @@ function nt(s, e, t, r) {
|
|
|
457
455
|
for (const u of i) {
|
|
458
456
|
c.lineNo++;
|
|
459
457
|
try {
|
|
460
|
-
const d =
|
|
458
|
+
const d = ot(
|
|
461
459
|
s,
|
|
462
460
|
u,
|
|
463
461
|
c,
|
|
@@ -477,34 +475,34 @@ function nt(s, e, t, r) {
|
|
|
477
475
|
opts: o
|
|
478
476
|
};
|
|
479
477
|
}
|
|
480
|
-
function
|
|
478
|
+
function ot(s, e, t, r, n) {
|
|
481
479
|
if (t.isInCommentBlock)
|
|
482
|
-
return
|
|
483
|
-
if (
|
|
480
|
+
return He.exec(e) && (t.isInCommentBlock = !1), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
481
|
+
if (Ze.exec(e)) {
|
|
484
482
|
if (!t.canDetectOptions)
|
|
485
483
|
throw s.error(
|
|
486
484
|
`[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'`
|
|
487
485
|
), new Error("tengo compiler options ('//tengo:' comments) can be set only in file header");
|
|
488
|
-
return { line: e, context: t, artifact: void 0, option:
|
|
486
|
+
return { line: e, context: t, artifact: void 0, option: tt(e) };
|
|
489
487
|
}
|
|
490
|
-
if (
|
|
488
|
+
if (Ke.exec(e) && t.canDetectOptions)
|
|
491
489
|
return s.warn(
|
|
492
490
|
`[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)`
|
|
493
491
|
), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
494
|
-
if (
|
|
492
|
+
if (Xe.exec(e))
|
|
495
493
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
496
|
-
if (
|
|
494
|
+
if (Ye.exec(e))
|
|
497
495
|
return t.isInCommentBlock = !0, { line: e, context: t, artifact: void 0, option: void 0 };
|
|
498
|
-
if (
|
|
496
|
+
if (Ve.exec(e))
|
|
499
497
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
500
498
|
t.canDetectOptions = !1;
|
|
501
499
|
const o = be.exec(e);
|
|
502
500
|
if (o) {
|
|
503
|
-
const i =
|
|
501
|
+
const i = rt(e);
|
|
504
502
|
if (i.module === "plapi")
|
|
505
503
|
return t.tplDepREs.has(i.module) || t.tplDepREs.set(i.module, [
|
|
506
|
-
["template",
|
|
507
|
-
["software",
|
|
504
|
+
["template", _e(i.alias)],
|
|
505
|
+
["software", qe(i.alias)]
|
|
508
506
|
]), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
509
507
|
(i.module === "@milaboratory/tengo-sdk:ll" || i.module === "@platforma-sdk/workflow-tengo:ll" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && i.module === ":ll") && (t.tplDepREs.has(i.module) || t.tplDepREs.set(i.module, [
|
|
510
508
|
["template", ue(i.alias)],
|
|
@@ -512,7 +510,7 @@ function it(s, e, t, r, n) {
|
|
|
512
510
|
])), (i.module === "@milaboratory/tengo-sdk:assets" || i.module === "@platforma-sdk/workflow-tengo:assets" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && i.module === ":assets") && (t.tplDepREs.has(i.module) || t.tplDepREs.set(i.module, [
|
|
513
511
|
["template", ue(i.alias)],
|
|
514
512
|
["software", me(i.alias)],
|
|
515
|
-
["asset",
|
|
513
|
+
["asset", Be(i.alias)]
|
|
516
514
|
]));
|
|
517
515
|
const a = ge(i.module, "library", r);
|
|
518
516
|
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 };
|
|
@@ -533,8 +531,8 @@ function it(s, e, t, r, n) {
|
|
|
533
531
|
}
|
|
534
532
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
535
533
|
}
|
|
536
|
-
function
|
|
537
|
-
const e =
|
|
534
|
+
function rt(s) {
|
|
535
|
+
const e = Qe.exec(s);
|
|
538
536
|
if (!e || !e.groups)
|
|
539
537
|
throw Error("failed to parse 'import' statement");
|
|
540
538
|
const { importName: t, moduleName: r } = e.groups;
|
|
@@ -546,7 +544,7 @@ function at(s) {
|
|
|
546
544
|
};
|
|
547
545
|
}
|
|
548
546
|
function ge(s, e, t) {
|
|
549
|
-
const r =
|
|
547
|
+
const r = et.exec(s);
|
|
550
548
|
if (!r)
|
|
551
549
|
return;
|
|
552
550
|
if (!r.groups)
|
|
@@ -560,7 +558,7 @@ function ge(s, e, t) {
|
|
|
560
558
|
);
|
|
561
559
|
return { type: e, pkg: n ?? t, id: o };
|
|
562
560
|
}
|
|
563
|
-
const
|
|
561
|
+
const J = ".plj.gz", P = ".lib.tengo", W = ".sw.json", z = ".as.json", he = ".test.tengo", _ = ".tpl.tengo", q = ".lib.tengo", B = ".sw.json", V = ".as.json", nt = [q, _, B, V];
|
|
564
562
|
function M() {
|
|
565
563
|
return JSON.parse(p.readFileSync("package.json").toString());
|
|
566
564
|
}
|
|
@@ -594,17 +592,17 @@ function ke(s, e, t, r, n = !1) {
|
|
|
594
592
|
throw new Error(
|
|
595
593
|
`nested node_modules is a sign of library dependencies version incompatibility in ${r}`
|
|
596
594
|
);
|
|
597
|
-
d &&
|
|
595
|
+
d && it(s, v, "dist", i, e), y && at(s, v, "dist", a, e), w && lt(s, v, "dist", c, e), b && ct(s, v, "dist", u, e);
|
|
598
596
|
}
|
|
599
597
|
}
|
|
600
|
-
function
|
|
598
|
+
function it(s, e, t, r, n) {
|
|
601
599
|
for (const o of p.readdirSync(r)) {
|
|
602
600
|
const i = f.resolve(r, o);
|
|
603
|
-
if (!o.endsWith(
|
|
601
|
+
if (!o.endsWith(P)) throw new Error(`unexpected file in 'lib' folder: ${i}`);
|
|
604
602
|
const a = {
|
|
605
603
|
type: "library",
|
|
606
604
|
pkg: e.name,
|
|
607
|
-
id: o.slice(0, o.length -
|
|
605
|
+
id: o.slice(0, o.length - P.length),
|
|
608
606
|
version: e.version
|
|
609
607
|
}, c = ve(s, t, i, a, !0);
|
|
610
608
|
if (n.addLib(c), s.debug(`Adding dependency ${m(a)} from ${i}`), c.dependencies.length > 0) {
|
|
@@ -613,42 +611,42 @@ function ct(s, e, t, r, n) {
|
|
|
613
611
|
}
|
|
614
612
|
}
|
|
615
613
|
}
|
|
616
|
-
function
|
|
614
|
+
function at(s, e, t, r, n) {
|
|
617
615
|
for (const o of p.readdirSync(r)) {
|
|
618
616
|
const i = f.resolve(r, o);
|
|
619
|
-
if (!o.endsWith(
|
|
617
|
+
if (!o.endsWith(J)) throw new Error(`unexpected file in 'tpl' folder: ${i}`);
|
|
620
618
|
const a = {
|
|
621
619
|
type: "template",
|
|
622
620
|
pkg: e.name,
|
|
623
|
-
id: o.slice(0, o.length -
|
|
621
|
+
id: o.slice(0, o.length - J.length),
|
|
624
622
|
version: e.version
|
|
625
623
|
}, c = new ye(t, a, { content: p.readFileSync(i) });
|
|
626
624
|
n.addTemplate(c), s.debug(`Adding dependency ${m(a)} from ${i}`);
|
|
627
625
|
}
|
|
628
626
|
}
|
|
629
|
-
function
|
|
627
|
+
function lt(s, e, t, r, n) {
|
|
630
628
|
for (const o of p.readdirSync(r)) {
|
|
631
629
|
const i = f.resolve(r, o);
|
|
632
|
-
if (!o.endsWith(
|
|
630
|
+
if (!o.endsWith(W))
|
|
633
631
|
throw new Error(`unexpected file in 'software' folder: ${i}`);
|
|
634
632
|
const a = {
|
|
635
633
|
type: "software",
|
|
636
634
|
pkg: e.name,
|
|
637
|
-
id: o.slice(0, o.length -
|
|
635
|
+
id: o.slice(0, o.length - W.length),
|
|
638
636
|
version: e.version
|
|
639
637
|
}, c = new oe(t, a, p.readFileSync(i).toString(), i, [], []);
|
|
640
638
|
s.debug(`Adding dependency ${m(a)} from ${i}`), n.addSoftware(c);
|
|
641
639
|
}
|
|
642
640
|
}
|
|
643
|
-
function
|
|
641
|
+
function ct(s, e, t, r, n) {
|
|
644
642
|
for (const o of p.readdirSync(r)) {
|
|
645
643
|
const i = f.resolve(r, o);
|
|
646
|
-
if (!o.endsWith(
|
|
644
|
+
if (!o.endsWith(z))
|
|
647
645
|
throw new Error(`unexpected file in 'asset' folder: ${i}`);
|
|
648
646
|
const a = {
|
|
649
647
|
type: "asset",
|
|
650
648
|
pkg: e.name,
|
|
651
|
-
id: o.slice(0, o.length -
|
|
649
|
+
id: o.slice(0, o.length - z.length),
|
|
652
650
|
version: e.version
|
|
653
651
|
}, c = new oe(t, a, p.readFileSync(i).toString(), i, [], []);
|
|
654
652
|
s.debug(`Adding dependency ${m(a)} from ${i}`), n.addAsset(c);
|
|
@@ -663,7 +661,7 @@ function L(s, e, t, r, n) {
|
|
|
663
661
|
o.push(...b);
|
|
664
662
|
continue;
|
|
665
663
|
}
|
|
666
|
-
const u = i === "index.lib.tengo" ? `${f.dirname(a)}.lib.tengo` : a, d =
|
|
664
|
+
const u = i === "index.lib.tengo" ? `${f.dirname(a)}.lib.tengo` : a, d = dt(e, u.replaceAll(f.sep, "."));
|
|
667
665
|
if (!d)
|
|
668
666
|
continue;
|
|
669
667
|
const y = f.resolve(r, a);
|
|
@@ -678,10 +676,10 @@ function L(s, e, t, r, n) {
|
|
|
678
676
|
return o;
|
|
679
677
|
}
|
|
680
678
|
function re(s, e, t) {
|
|
681
|
-
const r = new
|
|
682
|
-
return ke(s, r, e,
|
|
679
|
+
const r = new ze(t);
|
|
680
|
+
return ke(s, r, e, Ie()), r;
|
|
683
681
|
}
|
|
684
|
-
function
|
|
682
|
+
function dt(s, e) {
|
|
685
683
|
const t = { pkg: s.name, version: s.version };
|
|
686
684
|
return e.endsWith(q) ? {
|
|
687
685
|
...t,
|
|
@@ -705,11 +703,11 @@ function ut(s, e) {
|
|
|
705
703
|
type: "test"
|
|
706
704
|
} : null;
|
|
707
705
|
}
|
|
708
|
-
function
|
|
706
|
+
function ft(s, e) {
|
|
709
707
|
const t = M(), r = re(s, t, e), n = L(s, t, e, "src", "");
|
|
710
708
|
if (n.length === 0) {
|
|
711
709
|
const i = [];
|
|
712
|
-
for (const a of
|
|
710
|
+
for (const a of nt)
|
|
713
711
|
i.push(`*${a}`);
|
|
714
712
|
s.error(`Nothing to compile. Looked for ${i.join(", ")}`), process.exit(1);
|
|
715
713
|
}
|
|
@@ -717,12 +715,12 @@ function mt(s, e) {
|
|
|
717
715
|
const o = r.compileAndAdd(n);
|
|
718
716
|
return s.debug("Done."), o;
|
|
719
717
|
}
|
|
720
|
-
function
|
|
718
|
+
function pt(s, e, t) {
|
|
721
719
|
if (e.libs.length > 0) {
|
|
722
720
|
const r = Ee(t, ".");
|
|
723
721
|
p.mkdirSync(r, { recursive: !0 });
|
|
724
722
|
for (const n of e.libs) {
|
|
725
|
-
const o = f.resolve(r, n.fullName.id +
|
|
723
|
+
const o = f.resolve(r, n.fullName.id + P);
|
|
726
724
|
s.info(` - writing ${o}`), p.writeFileSync(o, n.src);
|
|
727
725
|
}
|
|
728
726
|
}
|
|
@@ -730,7 +728,7 @@ function gt(s, e, t) {
|
|
|
730
728
|
const r = $e(t, ".");
|
|
731
729
|
p.mkdirSync(r, { recursive: !0 });
|
|
732
730
|
for (const n of e.templates) {
|
|
733
|
-
const o = f.resolve(r, n.fullName.id +
|
|
731
|
+
const o = f.resolve(r, n.fullName.id + J);
|
|
734
732
|
s.info(` - writing ${o}`), p.writeFileSync(o, n.content);
|
|
735
733
|
}
|
|
736
734
|
}
|
|
@@ -738,7 +736,7 @@ function gt(s, e, t) {
|
|
|
738
736
|
const r = Ne(t, ".");
|
|
739
737
|
p.mkdirSync(r, { recursive: !0 });
|
|
740
738
|
for (const n of e.software) {
|
|
741
|
-
const o = f.resolve(r, n.fullName.id +
|
|
739
|
+
const o = f.resolve(r, n.fullName.id + W);
|
|
742
740
|
s.info(` - writing ${o}`), p.writeFileSync(o, n.src);
|
|
743
741
|
}
|
|
744
742
|
}
|
|
@@ -746,28 +744,28 @@ function gt(s, e, t) {
|
|
|
746
744
|
const r = Se(t, ".");
|
|
747
745
|
p.mkdirSync(r, { recursive: !0 });
|
|
748
746
|
for (const n of e.software) {
|
|
749
|
-
const o = f.resolve(r, n.fullName.id +
|
|
747
|
+
const o = f.resolve(r, n.fullName.id + z);
|
|
750
748
|
s.info(` - writing ${o}`), p.writeFileSync(o, n.src);
|
|
751
749
|
}
|
|
752
750
|
}
|
|
753
751
|
}
|
|
754
752
|
const ne = {
|
|
755
|
-
"log-level":
|
|
753
|
+
"log-level": F.string({
|
|
756
754
|
description: "logging level",
|
|
757
755
|
default: "info",
|
|
758
756
|
options: ["error", "warn", "info", "debug"]
|
|
759
757
|
})
|
|
760
|
-
},
|
|
761
|
-
"generate-tags":
|
|
758
|
+
}, ut = {
|
|
759
|
+
"generate-tags": F.boolean({
|
|
762
760
|
description: "generate tags, default false",
|
|
763
761
|
default: !1
|
|
764
762
|
}),
|
|
765
|
-
"tags-file":
|
|
763
|
+
"tags-file": F.file({
|
|
766
764
|
description: 'where to put ".tags" file, it should be a root of VS Code project',
|
|
767
765
|
default: "../../.tags"
|
|
768
766
|
// usually a user opens a directory with all blocks
|
|
769
767
|
}),
|
|
770
|
-
"tags-additional-args":
|
|
768
|
+
"tags-additional-args": F.string({
|
|
771
769
|
description: "additional flags for universal-ctags command: e.g. -e for emacs",
|
|
772
770
|
default: [],
|
|
773
771
|
multiple: !0,
|
|
@@ -775,8 +773,8 @@ const ne = {
|
|
|
775
773
|
})
|
|
776
774
|
}, A = class A extends $ {
|
|
777
775
|
async run() {
|
|
778
|
-
const { flags: e } = await this.parse(A), t = N(e["log-level"]), r = M(), n =
|
|
779
|
-
|
|
776
|
+
const { flags: e } = await this.parse(A), t = N(e["log-level"]), r = M(), n = ft(t, "dist");
|
|
777
|
+
pt(t, n, "dist"), t.info("");
|
|
780
778
|
let o = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
|
|
781
779
|
`;
|
|
782
780
|
o += `declare type TplName = ${n.templates.map((d) => '"' + d.fullName.id + '"').join(" | ")};
|
|
@@ -798,25 +796,25 @@ export const Templates = {
|
|
|
798
796
|
}};
|
|
799
797
|
`, a += `
|
|
800
798
|
};
|
|
801
|
-
`, 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)),
|
|
799
|
+
`, 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)), mt(e), e["generate-tags"] && gt(t, e), t.info("Template Pack build done.");
|
|
802
800
|
}
|
|
803
801
|
};
|
|
804
802
|
l(A, "description", "build tengo sources into single distributable pack file"), l(A, "examples", ["<%= config.bin %> <%= command.id %>"]), l(A, "flags", {
|
|
805
803
|
...ne,
|
|
806
|
-
...
|
|
804
|
+
...ut
|
|
807
805
|
});
|
|
808
806
|
let Z = A;
|
|
809
|
-
function
|
|
807
|
+
function mt(s) {
|
|
810
808
|
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(","));
|
|
811
809
|
}
|
|
812
|
-
function
|
|
810
|
+
function gt(s, e) {
|
|
813
811
|
var a;
|
|
814
|
-
const t = f.resolve(e["tags-file"]), r = f.dirname(t), n = e["tags-additional-args"], o =
|
|
812
|
+
const t = f.resolve(e["tags-file"]), r = f.dirname(t), n = e["tags-additional-args"], o = ht(r);
|
|
815
813
|
s.info(
|
|
816
814
|
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${n}".
|
|
817
815
|
Found ${o.length} tengo files...`
|
|
818
816
|
);
|
|
819
|
-
const i =
|
|
817
|
+
const i = Oe(
|
|
820
818
|
"ctags",
|
|
821
819
|
[
|
|
822
820
|
"-f",
|
|
@@ -848,9 +846,9 @@ For vscode, you should also install ctags extension:
|
|
|
848
846
|
https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
|
|
849
847
|
return;
|
|
850
848
|
}
|
|
851
|
-
|
|
849
|
+
wt(i, "failed to generate ctags"), s.info("Generation of tags is done.");
|
|
852
850
|
}
|
|
853
|
-
function
|
|
851
|
+
function ht(s) {
|
|
854
852
|
const e = p.readdirSync(s, { withFileTypes: !0, recursive: !0 }), t = [];
|
|
855
853
|
return e.forEach((r) => {
|
|
856
854
|
if (!r.isDirectory() && r.name.endsWith(".tengo")) {
|
|
@@ -859,7 +857,7 @@ function bt(s) {
|
|
|
859
857
|
}
|
|
860
858
|
}), t;
|
|
861
859
|
}
|
|
862
|
-
function
|
|
860
|
+
function wt(s, e) {
|
|
863
861
|
s.error && console.log(s.error);
|
|
864
862
|
const t = e;
|
|
865
863
|
s.status !== 0 && console.log(`WARN: ${t} the build will continue as-is`);
|
|
@@ -912,7 +910,7 @@ function ie(s, e) {
|
|
|
912
910
|
), e.write(JSON.stringify(o) + `
|
|
913
911
|
`));
|
|
914
912
|
}
|
|
915
|
-
function
|
|
913
|
+
function yt(s, e, t) {
|
|
916
914
|
const r = M(), n = L(s, r, "dist", "src", "");
|
|
917
915
|
if (!e) {
|
|
918
916
|
for (const i of n)
|
|
@@ -933,16 +931,16 @@ function C(s, e, t) {
|
|
|
933
931
|
o.fullName.type === t && e.write(JSON.stringify(o) + `
|
|
934
932
|
`);
|
|
935
933
|
}
|
|
936
|
-
function
|
|
934
|
+
function bt(s, e) {
|
|
937
935
|
C(s, e, "template");
|
|
938
936
|
}
|
|
939
|
-
function
|
|
937
|
+
function vt(s, e) {
|
|
940
938
|
C(s, e, "software");
|
|
941
939
|
}
|
|
942
|
-
function
|
|
940
|
+
function Et(s, e) {
|
|
943
941
|
C(s, e, "asset");
|
|
944
942
|
}
|
|
945
|
-
function
|
|
943
|
+
function $t(s, e) {
|
|
946
944
|
C(s, e, "test");
|
|
947
945
|
}
|
|
948
946
|
function Ae(s, ...e) {
|
|
@@ -1023,7 +1021,7 @@ l(Y, "description", "parse sources in current package and dump all found artifac
|
|
|
1023
1021
|
class H extends $ {
|
|
1024
1022
|
async run() {
|
|
1025
1023
|
const e = N();
|
|
1026
|
-
|
|
1024
|
+
Et(e, D);
|
|
1027
1025
|
}
|
|
1028
1026
|
}
|
|
1029
1027
|
l(H, "description", "parse sources in current package and dump all found tests to stdout"), l(H, "examples", [
|
|
@@ -1032,19 +1030,19 @@ l(H, "description", "parse sources in current package and dump all found tests t
|
|
|
1032
1030
|
const T = class T extends $ {
|
|
1033
1031
|
async run() {
|
|
1034
1032
|
const { flags: e } = await this.parse(T), t = N();
|
|
1035
|
-
|
|
1033
|
+
yt(t, e.deps, D);
|
|
1036
1034
|
}
|
|
1037
1035
|
};
|
|
1038
1036
|
l(T, "description", "parse sources in current package and dump all found templates to stdout"), l(T, "examples", [
|
|
1039
1037
|
"<%= config.bin %> <%= command.id %>"
|
|
1040
1038
|
]), l(T, "flags", {
|
|
1041
|
-
deps:
|
|
1039
|
+
deps: F.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
|
|
1042
1040
|
});
|
|
1043
1041
|
let Q = T;
|
|
1044
1042
|
class ee extends $ {
|
|
1045
1043
|
async run() {
|
|
1046
1044
|
const e = N();
|
|
1047
|
-
|
|
1045
|
+
vt(e, D);
|
|
1048
1046
|
}
|
|
1049
1047
|
}
|
|
1050
1048
|
l(ee, "description", "parse sources in current package and dump all found tests to stdout"), l(ee, "examples", [
|
|
@@ -1053,7 +1051,7 @@ l(ee, "description", "parse sources in current package and dump all found tests
|
|
|
1053
1051
|
class te extends $ {
|
|
1054
1052
|
async run() {
|
|
1055
1053
|
const e = N();
|
|
1056
|
-
|
|
1054
|
+
bt(e, D);
|
|
1057
1055
|
}
|
|
1058
1056
|
}
|
|
1059
1057
|
l(te, "description", "parse sources in current package and dump all found templates to stdout"), l(te, "examples", [
|
|
@@ -1062,13 +1060,13 @@ l(te, "description", "parse sources in current package and dump all found templa
|
|
|
1062
1060
|
class se extends $ {
|
|
1063
1061
|
async run() {
|
|
1064
1062
|
const e = N();
|
|
1065
|
-
|
|
1063
|
+
$t(e, D);
|
|
1066
1064
|
}
|
|
1067
1065
|
}
|
|
1068
1066
|
l(se, "description", "parse sources in current package and dump all found tests to stdout"), l(se, "examples", [
|
|
1069
1067
|
"<%= config.bin %> <%= command.id %>"
|
|
1070
1068
|
]);
|
|
1071
|
-
const
|
|
1069
|
+
const Ot = {
|
|
1072
1070
|
build: Z,
|
|
1073
1071
|
check: K,
|
|
1074
1072
|
test: X,
|
|
@@ -1080,6 +1078,6 @@ const jt = {
|
|
|
1080
1078
|
"dump:tests": se
|
|
1081
1079
|
};
|
|
1082
1080
|
export {
|
|
1083
|
-
|
|
1081
|
+
Ot as COMMANDS
|
|
1084
1082
|
};
|
|
1085
1083
|
//# sourceMappingURL=index.mjs.map
|