@platforma-sdk/tengo-builder 2.1.3 → 2.1.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/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/commands/build.ts +24 -8
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (s, e, t) =>
|
|
4
|
-
import { spawnSync as
|
|
1
|
+
var xe = Object.defineProperty;
|
|
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 c = (s, e, t) => Fe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { spawnSync as Re, spawn as je } 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
7
|
import * as p from "node:fs";
|
|
8
|
-
import { readFileSync as
|
|
8
|
+
import { readFileSync as Le } from "node:fs";
|
|
9
9
|
import * as O from "winston";
|
|
10
|
-
import { parseTemplate as
|
|
11
|
-
import { createHash as
|
|
12
|
-
import { tryResolve as
|
|
10
|
+
import { parseTemplate as Me, serializeTemplate as Ce } from "@milaboratories/pl-model-backend";
|
|
11
|
+
import { createHash as Ie } from "node:crypto";
|
|
12
|
+
import { tryResolve as Je, tryResolveOrError as Pe } from "@milaboratories/resolve-helper";
|
|
13
13
|
import * as x from "node:fs/promises";
|
|
14
14
|
import { TengoTesterBinaryPath as we } from "@milaboratories/tengo-tester";
|
|
15
15
|
import { stdout as D } from "node:process";
|
|
@@ -45,7 +45,7 @@ function S(s) {
|
|
|
45
45
|
throw t;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function Ge(s) {
|
|
49
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());
|
|
50
50
|
}
|
|
51
51
|
function le(s) {
|
|
@@ -69,7 +69,7 @@ function w(s) {
|
|
|
69
69
|
function I(s) {
|
|
70
70
|
return { name: w(s), version: s.version };
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function He(s) {
|
|
73
73
|
const e = s.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);
|
|
74
74
|
if (!e) throw new Error(`malformed artifact name: ${s.name}`);
|
|
75
75
|
return { pkg: e.groups.pkg, id: e.groups.id, version: s.version };
|
|
@@ -77,7 +77,7 @@ function Ge(s) {
|
|
|
77
77
|
function fe(s) {
|
|
78
78
|
return `${s.pkg}:${s.id}:${s.version}`;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function We(s, e, t, r) {
|
|
81
81
|
return ye(e, t), {
|
|
82
82
|
compileMode: s,
|
|
83
83
|
fullName: e,
|
|
@@ -85,8 +85,8 @@ function He(s, e, t, r) {
|
|
|
85
85
|
source: r
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const r =
|
|
88
|
+
function Ue(s, e, t) {
|
|
89
|
+
const r = Me(t);
|
|
90
90
|
if (r.type !== "pl.tengo-template.v3")
|
|
91
91
|
throw new Error("malformed v3 template");
|
|
92
92
|
return ye(e, r), {
|
|
@@ -96,7 +96,7 @@ function We(s, e, t) {
|
|
|
96
96
|
content: t
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function ze(s) {
|
|
100
100
|
return {
|
|
101
101
|
compileMode: s.compileMode,
|
|
102
102
|
fullName: s.fullName,
|
|
@@ -105,7 +105,7 @@ function Ue(s) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
function ye(s, e) {
|
|
108
|
-
const t =
|
|
108
|
+
const t = He(e.template);
|
|
109
109
|
if (t.pkg !== s.pkg || t.id !== s.id || t.version !== s.version)
|
|
110
110
|
throw new Error(
|
|
111
111
|
`Compiled template name don't match it's package and file names: ${fe(t)} != ${fe(s)}`
|
|
@@ -131,7 +131,7 @@ class be {
|
|
|
131
131
|
this.map.forEach((t) => e(t, this.nameExtractor(t)));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function _e() {
|
|
135
135
|
return new be((s) => s);
|
|
136
136
|
}
|
|
137
137
|
class J {
|
|
@@ -164,16 +164,16 @@ class J {
|
|
|
164
164
|
this.dist.forEach((r, i) => t(this.get(e, i) ?? r, i));
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function qe(s, e) {
|
|
168
168
|
for (const t of s)
|
|
169
169
|
switch (t.name) {
|
|
170
170
|
case "hash_override": {
|
|
171
|
-
e.hashOverride =
|
|
171
|
+
e.hashOverride = Ke(t.args);
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Be(s, e) {
|
|
177
177
|
for (const t of s)
|
|
178
178
|
switch (t.name) {
|
|
179
179
|
case "hash_override":
|
|
@@ -182,19 +182,19 @@ function qe(s, e) {
|
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Ke(s) {
|
|
186
186
|
if (s.length != 1)
|
|
187
187
|
throw new Error(
|
|
188
188
|
"hash_override compiler option expects exactly one argument: hash_override <some string>. Note, you can use only UUID as a value."
|
|
189
189
|
);
|
|
190
190
|
const e = s[0].toLowerCase();
|
|
191
|
-
if (!
|
|
191
|
+
if (!Ge(e))
|
|
192
192
|
throw new Error(
|
|
193
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`
|
|
194
194
|
);
|
|
195
195
|
return e;
|
|
196
196
|
}
|
|
197
|
-
class
|
|
197
|
+
class Ve {
|
|
198
198
|
constructor(e) {
|
|
199
199
|
c(this, "libs", new J((e) => e.fullName));
|
|
200
200
|
c(this, "software", new J((e) => e.fullName));
|
|
@@ -216,7 +216,7 @@ class Ke {
|
|
|
216
216
|
...I(n.fullName),
|
|
217
217
|
sourceHash: n.sourceHash
|
|
218
218
|
};
|
|
219
|
-
|
|
219
|
+
Be(n.compilerOptions), t.template.libs[w(o)] = l, t.hashToSource[l.sourceHash] = n.src, this.populateTemplateDataFromDependencies(e, t, n.dependencies, [...i, w(o)]);
|
|
220
220
|
break;
|
|
221
221
|
}
|
|
222
222
|
case "software": {
|
|
@@ -270,7 +270,7 @@ class Ke {
|
|
|
270
270
|
sourceHash: e.sourceHash
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
-
return
|
|
273
|
+
return qe(e.compilerOptions, t.template), this.populateTemplateDataFromDependencies(e.fullName, t, e.dependencies, []), t;
|
|
274
274
|
}
|
|
275
275
|
addLib(e) {
|
|
276
276
|
const t = this.libs.add(e.compileMode, e, !1);
|
|
@@ -419,7 +419,7 @@ class Ke {
|
|
|
419
419
|
break;
|
|
420
420
|
case "template":
|
|
421
421
|
try {
|
|
422
|
-
const a = this.compileAndAddTemplate(o), l =
|
|
422
|
+
const a = this.compileAndAddTemplate(o), l = We(o.compileMode, o.fullName, a, o.src);
|
|
423
423
|
this.addTemplate(l), t.templates.push(l);
|
|
424
424
|
} catch (a) {
|
|
425
425
|
const l = a;
|
|
@@ -449,9 +449,9 @@ ${n.err.message}`;
|
|
|
449
449
|
}
|
|
450
450
|
const de = "[_a-zA-Z][_a-zA-Z0-9]*", j = (s, e) => new RegExp(
|
|
451
451
|
`\\b${s}\\.(?<fnCall>(?<fnName>` + e + ')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'
|
|
452
|
-
),
|
|
452
|
+
), Xe = (s) => j(s, "getTemplateId"), Ze = (s) => j(s, "getSoftwareInfo"), pe = (s) => j(s, "importTemplate"), ue = (s) => j(s, "importSoftware"), Ye = (s) => j(s, "importAsset"), Qe = /^\s*$/, et = /^\/\/tengo:[\w]/, tt = /^\s*\/\/\s*tengo:\s*./, st = /\/\*.*?\*\//g, ot = /^\s*(\/\/)/, rt = /^\s*\/\*/, nt = /\*\//, ve = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/, it = new RegExp(
|
|
453
453
|
`\\b(?<importName>${de}(\\.${de})*)${ve.source}`
|
|
454
|
-
),
|
|
454
|
+
), at = /(?<pkgName>[^"]+)?:(?<depID>[^"]+)/, lt = (s) => {
|
|
455
455
|
const e = s.split(" "), t = e[0].split(":");
|
|
456
456
|
if (t.length != 2)
|
|
457
457
|
throw new Error(
|
|
@@ -468,7 +468,7 @@ class oe {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
function Ee(s, e, t, r, i) {
|
|
471
|
-
const o =
|
|
471
|
+
const o = Le(t).toString(), { deps: n, normalized: a, opts: l } = ct(s, o, r, i);
|
|
472
472
|
return new oe(
|
|
473
473
|
e,
|
|
474
474
|
r,
|
|
@@ -479,8 +479,8 @@ function Ee(s, e, t, r, i) {
|
|
|
479
479
|
l
|
|
480
480
|
);
|
|
481
481
|
}
|
|
482
|
-
function
|
|
483
|
-
const i =
|
|
482
|
+
function ct(s, e, t, r) {
|
|
483
|
+
const i = _e(), o = [], n = e.split(`
|
|
484
484
|
`), a = [];
|
|
485
485
|
let l = {
|
|
486
486
|
isInCommentBlock: !1,
|
|
@@ -491,7 +491,7 @@ function lt(s, e, t, r) {
|
|
|
491
491
|
for (const d of n) {
|
|
492
492
|
l.lineNo++;
|
|
493
493
|
try {
|
|
494
|
-
const { line: g, context: m, artifact: y, option: b } =
|
|
494
|
+
const { line: g, context: m, artifact: y, option: b } = ft(
|
|
495
495
|
s,
|
|
496
496
|
d,
|
|
497
497
|
l,
|
|
@@ -512,36 +512,36 @@ function lt(s, e, t, r) {
|
|
|
512
512
|
opts: o
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
|
-
function
|
|
516
|
-
if (e = e.replaceAll(
|
|
517
|
-
return
|
|
518
|
-
if (
|
|
515
|
+
function ft(s, e, t, r, i) {
|
|
516
|
+
if (e = e.replaceAll(st, ""), t.isInCommentBlock)
|
|
517
|
+
return nt.exec(e) && (t.isInCommentBlock = !1), { line: "", context: t, artifact: void 0, option: void 0 };
|
|
518
|
+
if (et.exec(e)) {
|
|
519
519
|
if (!t.canDetectOptions)
|
|
520
520
|
throw s.error(
|
|
521
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'`
|
|
522
522
|
), new Error("tengo compiler options ('//tengo:' comments) can be set only in file header");
|
|
523
|
-
return { line: e, context: t, artifact: void 0, option:
|
|
523
|
+
return { line: e, context: t, artifact: void 0, option: lt(e) };
|
|
524
524
|
}
|
|
525
|
-
if (
|
|
525
|
+
if (tt.exec(e) && t.canDetectOptions)
|
|
526
526
|
return s.warn(
|
|
527
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)`
|
|
528
528
|
), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
529
|
-
if (
|
|
529
|
+
if (ot.test(e))
|
|
530
530
|
return { line: "", context: t, artifact: void 0, option: void 0 };
|
|
531
|
-
if (
|
|
531
|
+
if (rt.exec(e))
|
|
532
532
|
return t.isInCommentBlock = !0, { line: "", context: t, artifact: void 0, option: void 0 };
|
|
533
533
|
if (e.includes("/*"))
|
|
534
534
|
throw new Error("malformed multiline comment");
|
|
535
|
-
if (
|
|
535
|
+
if (Qe.exec(e))
|
|
536
536
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
537
537
|
t.canDetectOptions = !1;
|
|
538
538
|
const o = ve.exec(e);
|
|
539
539
|
if (o) {
|
|
540
|
-
const n =
|
|
540
|
+
const n = dt(e);
|
|
541
541
|
if (n.module === "plapi")
|
|
542
542
|
return t.tplDepREs.has(n.module) || t.tplDepREs.set(n.module, [
|
|
543
|
-
["template",
|
|
544
|
-
["software",
|
|
543
|
+
["template", Xe(n.alias)],
|
|
544
|
+
["software", Ze(n.alias)]
|
|
545
545
|
]), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
546
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
547
|
["template", pe(n.alias)],
|
|
@@ -549,7 +549,7 @@ function ct(s, e, t, r, i) {
|
|
|
549
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
550
|
["template", pe(n.alias)],
|
|
551
551
|
["software", ue(n.alias)],
|
|
552
|
-
["asset",
|
|
552
|
+
["asset", Ye(n.alias)]
|
|
553
553
|
]));
|
|
554
554
|
const a = me(n.module, "library", r);
|
|
555
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 };
|
|
@@ -570,8 +570,8 @@ function ct(s, e, t, r, i) {
|
|
|
570
570
|
}
|
|
571
571
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
const e =
|
|
573
|
+
function dt(s) {
|
|
574
|
+
const e = it.exec(s);
|
|
575
575
|
if (!e || !e.groups)
|
|
576
576
|
throw Error("failed to parse 'import' statement");
|
|
577
577
|
const { importName: t, moduleName: r } = e.groups;
|
|
@@ -585,7 +585,7 @@ function ft(s) {
|
|
|
585
585
|
};
|
|
586
586
|
}
|
|
587
587
|
function me(s, e, t) {
|
|
588
|
-
const r =
|
|
588
|
+
const r = at.exec(s);
|
|
589
589
|
if (!r)
|
|
590
590
|
return;
|
|
591
591
|
if (!r.groups)
|
|
@@ -600,13 +600,13 @@ function me(s, e, t) {
|
|
|
600
600
|
return { type: e, pkg: i ?? t, id: o };
|
|
601
601
|
}
|
|
602
602
|
function re(s) {
|
|
603
|
-
return
|
|
603
|
+
return Ie("sha256").update(s).digest("hex");
|
|
604
604
|
}
|
|
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",
|
|
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", pt = [_, z, q, B];
|
|
606
606
|
function ge(s, e) {
|
|
607
607
|
if (!f.isAbsolute(s))
|
|
608
608
|
throw new Error(`Root path must be absolute: ${s}`);
|
|
609
|
-
let t =
|
|
609
|
+
let t = Je(s, e);
|
|
610
610
|
if (t) {
|
|
611
611
|
let i = 0;
|
|
612
612
|
do {
|
|
@@ -616,7 +616,7 @@ function ge(s, e) {
|
|
|
616
616
|
i++, t = f.dirname(t);
|
|
617
617
|
} while (i < 7 && f.basename(t) !== "node_modules");
|
|
618
618
|
}
|
|
619
|
-
const r =
|
|
619
|
+
const r = Pe(s, `${e}/package.json`);
|
|
620
620
|
if (r.result === void 0) {
|
|
621
621
|
if (r.err === "ERR_PACKAGE_PATH_NOT_EXPORTED")
|
|
622
622
|
return;
|
|
@@ -624,7 +624,7 @@ function ge(s, e) {
|
|
|
624
624
|
}
|
|
625
625
|
return r.result;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function ut(s) {
|
|
628
628
|
if (!f.isAbsolute(s))
|
|
629
629
|
throw new Error(`Root path must be absolute: ${s}`);
|
|
630
630
|
const e = f.join(s, "package.json");
|
|
@@ -633,7 +633,7 @@ function pt(s) {
|
|
|
633
633
|
throw new Error(`Can't resolve package.json in ${s}`);
|
|
634
634
|
}
|
|
635
635
|
function A(s, e, t = "root") {
|
|
636
|
-
const r =
|
|
636
|
+
const r = ut(s), i = JSON.parse(p.readFileSync(r).toString()), o = [];
|
|
637
637
|
if (i.dependencies && t !== "devDependency")
|
|
638
638
|
for (const n of Object.keys(i.dependencies)) {
|
|
639
639
|
const a = ge(s, n);
|
|
@@ -682,9 +682,9 @@ function Te(s, e, t) {
|
|
|
682
682
|
if (!a && !l && !d && !g)
|
|
683
683
|
return;
|
|
684
684
|
const m = { name: t.name, version: t.version };
|
|
685
|
-
a &&
|
|
685
|
+
a && mt(s, m, "dist", r, e), l && ht(s, m, "dist", i, e), d && gt(s, m, "dist", o, e), g && wt(s, m, "dist", n, e);
|
|
686
686
|
}
|
|
687
|
-
function
|
|
687
|
+
function mt(s, e, t, r, i) {
|
|
688
688
|
for (const o of p.readdirSync(r)) {
|
|
689
689
|
const n = f.resolve(r, o);
|
|
690
690
|
if (!o.endsWith(H)) throw new Error(`unexpected file in 'lib' folder: ${n}`);
|
|
@@ -700,7 +700,7 @@ function ut(s, e, t, r, i) {
|
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function ht(s, e, t, r, i) {
|
|
704
704
|
for (const o of p.readdirSync(r)) {
|
|
705
705
|
const n = f.resolve(r, o);
|
|
706
706
|
if (!o.endsWith(G)) throw new Error(`unexpected file in 'tpl' folder: ${n}`);
|
|
@@ -709,11 +709,11 @@ function mt(s, e, t, r, i) {
|
|
|
709
709
|
pkg: e.name,
|
|
710
710
|
id: o.slice(0, o.length - G.length),
|
|
711
711
|
version: e.version
|
|
712
|
-
}, l =
|
|
713
|
-
i.addTemplate(
|
|
712
|
+
}, l = Ue(t, a, p.readFileSync(n));
|
|
713
|
+
i.addTemplate(ze(l)), s.debug(`Adding dependency ${u(a)} from ${n}`);
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function gt(s, e, t, r, i) {
|
|
717
717
|
for (const o of p.readdirSync(r)) {
|
|
718
718
|
const n = f.resolve(r, o);
|
|
719
719
|
if (!o.endsWith(W))
|
|
@@ -735,7 +735,7 @@ function ht(s, e, t, r, i) {
|
|
|
735
735
|
s.debug(`Adding dependency ${u(a)} from ${n}`), i.addSoftware(d);
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
|
-
function
|
|
738
|
+
function wt(s, e, t, r, i) {
|
|
739
739
|
for (const o of p.readdirSync(r)) {
|
|
740
740
|
const n = f.resolve(r, o);
|
|
741
741
|
if (!o.endsWith(U))
|
|
@@ -766,7 +766,7 @@ function L(s, e, t, r, i) {
|
|
|
766
766
|
o.push(...b);
|
|
767
767
|
continue;
|
|
768
768
|
}
|
|
769
|
-
const d = n === "index.lib.tengo" ? `${f.dirname(a)}.lib.tengo` : a, g =
|
|
769
|
+
const d = n === "index.lib.tengo" ? `${f.dirname(a)}.lib.tengo` : a, g = yt(e, d.replaceAll(f.sep, "."));
|
|
770
770
|
if (!g) {
|
|
771
771
|
s.info(`Skipping unknown file type: ${d}`);
|
|
772
772
|
continue;
|
|
@@ -783,10 +783,10 @@ function L(s, e, t, r, i) {
|
|
|
783
783
|
return o;
|
|
784
784
|
}
|
|
785
785
|
function ne(s, e, t) {
|
|
786
|
-
const r = new
|
|
786
|
+
const r = new Ve(t);
|
|
787
787
|
return Te(s, r, e), r;
|
|
788
788
|
}
|
|
789
|
-
function
|
|
789
|
+
function yt(s, e) {
|
|
790
790
|
const t = { pkg: s.name, version: s.version };
|
|
791
791
|
return e.endsWith(_) ? {
|
|
792
792
|
...t,
|
|
@@ -810,11 +810,11 @@ function wt(s, e) {
|
|
|
810
810
|
type: "test"
|
|
811
811
|
} : null;
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function bt(s, e, t) {
|
|
814
814
|
const r = ne(s, e, t), i = L(s, e, t, "src", "");
|
|
815
815
|
if (i.length === 0) {
|
|
816
816
|
const n = [];
|
|
817
|
-
for (const a of
|
|
817
|
+
for (const a of pt)
|
|
818
818
|
n.push(`*${a}`);
|
|
819
819
|
s.error(`Nothing to compile. Looked for ${n.join(", ")}`), process.exit(1);
|
|
820
820
|
}
|
|
@@ -822,7 +822,7 @@ function yt(s, e, t) {
|
|
|
822
822
|
const o = r.compileAndAdd(i);
|
|
823
823
|
return s.debug("Done."), o;
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function vt(s, e, t) {
|
|
826
826
|
if (e.libs.length > 0) {
|
|
827
827
|
const r = $e(t, ".");
|
|
828
828
|
p.mkdirSync(r, { recursive: !0 });
|
|
@@ -836,7 +836,7 @@ function bt(s, e, t) {
|
|
|
836
836
|
p.mkdirSync(r, { recursive: !0 });
|
|
837
837
|
for (const i of e.templates) {
|
|
838
838
|
const o = f.resolve(r, i.fullName.id + G);
|
|
839
|
-
s.info(` - writing ${o}`), p.writeFileSync(o,
|
|
839
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, Ce(i.data));
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
842
|
if (e.software.length > 0) {
|
|
@@ -862,7 +862,7 @@ const ie = {
|
|
|
862
862
|
default: "info",
|
|
863
863
|
options: ["error", "warn", "info", "debug"]
|
|
864
864
|
})
|
|
865
|
-
},
|
|
865
|
+
}, Et = {
|
|
866
866
|
"generate-tags": F.boolean({
|
|
867
867
|
description: "generate tags, default false",
|
|
868
868
|
default: !1
|
|
@@ -880,18 +880,18 @@ const ie = {
|
|
|
880
880
|
})
|
|
881
881
|
}, k = class k extends v {
|
|
882
882
|
async run() {
|
|
883
|
-
const { flags: e } = await this.parse(k), t = E(e["log-level"]), r = A(process.cwd(), t), i =
|
|
884
|
-
|
|
885
|
-
const { dts: o, cjs: n, mjs: a } =
|
|
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)),
|
|
883
|
+
const { flags: e } = await this.parse(k), t = E(e["log-level"]), r = A(process.cwd(), t), i = bt(t, r, "dist");
|
|
884
|
+
vt(t, i, "dist"), t.info("Template Pack build done.");
|
|
885
|
+
const { dts: o, cjs: n, mjs: a } = $t(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)), Nt(e), e["generate-tags"] && St(t, e), t.info("Template Pack build done.");
|
|
887
887
|
}
|
|
888
888
|
};
|
|
889
889
|
c(k, "description", "build tengo sources into single distributable pack file"), c(k, "examples", ["<%= config.bin %> <%= command.id %>"]), c(k, "flags", {
|
|
890
890
|
...ie,
|
|
891
|
-
...
|
|
891
|
+
...Et
|
|
892
892
|
});
|
|
893
893
|
let K = k;
|
|
894
|
-
function
|
|
894
|
+
function $t(s) {
|
|
895
895
|
let e = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
|
|
896
896
|
`;
|
|
897
897
|
e += `declare type TplName = ${s.templates.map((n) => '"' + n.fullName.id + '"').join(" | ")};
|
|
@@ -915,17 +915,17 @@ export const Templates = {
|
|
|
915
915
|
};
|
|
916
916
|
`, { dts: e, cjs: t, mjs: r };
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function Nt(s) {
|
|
919
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(","));
|
|
920
920
|
}
|
|
921
|
-
function
|
|
921
|
+
function St(s, e) {
|
|
922
922
|
var a;
|
|
923
|
-
const t = f.resolve(e["tags-file"]), r = f.dirname(t), i = e["tags-additional-args"], o =
|
|
923
|
+
const t = f.resolve(e["tags-file"]), r = f.dirname(t), i = e["tags-additional-args"], o = kt(r, Ae(r, 9));
|
|
924
924
|
s.info(
|
|
925
925
|
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${i.join('" "')}".
|
|
926
926
|
Found ${o.length} tengo files...`
|
|
927
927
|
);
|
|
928
|
-
const n =
|
|
928
|
+
const n = Re(
|
|
929
929
|
"ctags",
|
|
930
930
|
[
|
|
931
931
|
"-f",
|
|
@@ -957,18 +957,22 @@ For vscode, you should also install ctags extension:
|
|
|
957
957
|
https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
|
|
958
958
|
return;
|
|
959
959
|
}
|
|
960
|
-
|
|
961
|
-
}
|
|
962
|
-
function
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
960
|
+
Tt(n, "failed to generate ctags"), s.info("Generation of tags is done.");
|
|
961
|
+
}
|
|
962
|
+
function Ae(s, e) {
|
|
963
|
+
if (e === 0)
|
|
964
|
+
return [];
|
|
965
|
+
const t = p.readdirSync(s, { withFileTypes: !0 });
|
|
966
|
+
let r = [];
|
|
967
|
+
return t.forEach((i) => {
|
|
968
|
+
const o = f.join(s, i.name);
|
|
969
|
+
i.isDirectory() && (r = r.concat(Ae(o, e - 1))), !i.isDirectory() && i.name.endsWith(".tengo") && r.push(o);
|
|
970
|
+
}), r;
|
|
970
971
|
}
|
|
971
972
|
function kt(s, e) {
|
|
973
|
+
return e.map((t) => t.replace(s, "."));
|
|
974
|
+
}
|
|
975
|
+
function Tt(s, e) {
|
|
972
976
|
s.error && console.log(s.error);
|
|
973
977
|
const t = e;
|
|
974
978
|
s.status !== 0 && console.log(`WARN: ${t} the build will continue as-is`);
|
|
@@ -1021,7 +1025,7 @@ function ae(s, e) {
|
|
|
1021
1025
|
), e.write(JSON.stringify(o) + `
|
|
1022
1026
|
`));
|
|
1023
1027
|
}
|
|
1024
|
-
function
|
|
1028
|
+
function At(s, e, t) {
|
|
1025
1029
|
const r = A(process.cwd(), s), i = L(s, r, "dist", "src", "");
|
|
1026
1030
|
if (!e) {
|
|
1027
1031
|
for (const n of i)
|
|
@@ -1042,25 +1046,25 @@ function P(s, e, t) {
|
|
|
1042
1046
|
o.fullName.type === t && e.write(JSON.stringify(o) + `
|
|
1043
1047
|
`);
|
|
1044
1048
|
}
|
|
1045
|
-
function
|
|
1049
|
+
function Dt(s, e) {
|
|
1046
1050
|
P(s, e, "template");
|
|
1047
1051
|
}
|
|
1048
|
-
function
|
|
1052
|
+
function Ot(s, e) {
|
|
1049
1053
|
P(s, e, "software");
|
|
1050
1054
|
}
|
|
1051
|
-
function
|
|
1055
|
+
function xt(s, e) {
|
|
1052
1056
|
P(s, e, "asset");
|
|
1053
1057
|
}
|
|
1054
|
-
function
|
|
1058
|
+
function Ft(s, e) {
|
|
1055
1059
|
P(s, e, "test");
|
|
1056
1060
|
}
|
|
1057
|
-
function
|
|
1058
|
-
const t =
|
|
1061
|
+
function De(s, ...e) {
|
|
1062
|
+
const t = je(s, e, { stdio: ["pipe", "inherit", "inherit"] });
|
|
1059
1063
|
return t.stdin.on("error", (r) => {
|
|
1060
1064
|
r.code;
|
|
1061
1065
|
}), t;
|
|
1062
1066
|
}
|
|
1063
|
-
function
|
|
1067
|
+
function Oe(s) {
|
|
1064
1068
|
return new Promise((e, t) => {
|
|
1065
1069
|
s.on("close", (r) => {
|
|
1066
1070
|
e(r);
|
|
@@ -1071,7 +1075,7 @@ function De(s) {
|
|
|
1071
1075
|
}
|
|
1072
1076
|
const $ = class $ extends v {
|
|
1073
1077
|
async run() {
|
|
1074
|
-
const { flags: e, argv: t } = await this.parse($), r = E(e["log-level"]), i = t.length == 0 ? ["./src"] : t, o =
|
|
1078
|
+
const { flags: e, argv: t } = await this.parse($), r = E(e["log-level"]), i = t.length == 0 ? ["./src"] : t, o = De(
|
|
1075
1079
|
we,
|
|
1076
1080
|
"check",
|
|
1077
1081
|
"--log-level",
|
|
@@ -1086,7 +1090,7 @@ const $ = class $ extends v {
|
|
|
1086
1090
|
r.error(n);
|
|
1087
1091
|
} finally {
|
|
1088
1092
|
o.stdin.end();
|
|
1089
|
-
const n = await
|
|
1093
|
+
const n = await Oe(o);
|
|
1090
1094
|
process.exit(n);
|
|
1091
1095
|
}
|
|
1092
1096
|
}
|
|
@@ -1098,7 +1102,7 @@ c($, "strict", !1), c($, "flags", { ...ie }), c($, "examples", ["<%= config.bin
|
|
|
1098
1102
|
let V = $;
|
|
1099
1103
|
const N = class N extends v {
|
|
1100
1104
|
async run() {
|
|
1101
|
-
const { flags: e } = await this.parse(N), t = E(e["log-level"]), r = this.argv.length == 0 ? ["./src"] : this.argv, i =
|
|
1105
|
+
const { flags: e } = await this.parse(N), t = E(e["log-level"]), r = this.argv.length == 0 ? ["./src"] : this.argv, i = De(
|
|
1102
1106
|
we,
|
|
1103
1107
|
"run",
|
|
1104
1108
|
"--log-level",
|
|
@@ -1113,7 +1117,7 @@ const N = class N extends v {
|
|
|
1113
1117
|
t.error(o);
|
|
1114
1118
|
} finally {
|
|
1115
1119
|
i.stdin.end();
|
|
1116
|
-
const o = await
|
|
1120
|
+
const o = await Oe(i);
|
|
1117
1121
|
process.exit(o);
|
|
1118
1122
|
}
|
|
1119
1123
|
}
|
|
@@ -1132,7 +1136,7 @@ c(Z, "description", "parse sources in current package and dump all found artifac
|
|
|
1132
1136
|
class Y extends v {
|
|
1133
1137
|
async run() {
|
|
1134
1138
|
const e = E();
|
|
1135
|
-
|
|
1139
|
+
xt(e, D);
|
|
1136
1140
|
}
|
|
1137
1141
|
}
|
|
1138
1142
|
c(Y, "description", "parse sources in current package and dump all found assets to stdout"), c(Y, "examples", [
|
|
@@ -1141,7 +1145,7 @@ c(Y, "description", "parse sources in current package and dump all found assets
|
|
|
1141
1145
|
const T = class T extends v {
|
|
1142
1146
|
async run() {
|
|
1143
1147
|
const { flags: e } = await this.parse(T), t = E();
|
|
1144
|
-
|
|
1148
|
+
At(t, e.deps, D);
|
|
1145
1149
|
}
|
|
1146
1150
|
};
|
|
1147
1151
|
c(T, "description", "parse sources in current package and dump all found libs to stdout"), c(T, "examples", [
|
|
@@ -1153,7 +1157,7 @@ let Q = T;
|
|
|
1153
1157
|
class ee extends v {
|
|
1154
1158
|
async run() {
|
|
1155
1159
|
const e = E();
|
|
1156
|
-
|
|
1160
|
+
Ot(e, D);
|
|
1157
1161
|
}
|
|
1158
1162
|
}
|
|
1159
1163
|
c(ee, "description", "parse sources in current package and dump all found software to stdout"), c(ee, "examples", [
|
|
@@ -1162,7 +1166,7 @@ c(ee, "description", "parse sources in current package and dump all found softwa
|
|
|
1162
1166
|
class te extends v {
|
|
1163
1167
|
async run() {
|
|
1164
1168
|
const e = E();
|
|
1165
|
-
|
|
1169
|
+
Dt(e, D);
|
|
1166
1170
|
}
|
|
1167
1171
|
}
|
|
1168
1172
|
c(te, "description", "parse sources in current package and dump all found templates to stdout"), c(te, "examples", [
|
|
@@ -1171,13 +1175,13 @@ c(te, "description", "parse sources in current package and dump all found templa
|
|
|
1171
1175
|
class se extends v {
|
|
1172
1176
|
async run() {
|
|
1173
1177
|
const e = E();
|
|
1174
|
-
|
|
1178
|
+
Ft(e, D);
|
|
1175
1179
|
}
|
|
1176
1180
|
}
|
|
1177
1181
|
c(se, "description", "parse sources in current package and dump all found tests to stdout"), c(se, "examples", [
|
|
1178
1182
|
"<%= config.bin %> <%= command.id %>"
|
|
1179
1183
|
]);
|
|
1180
|
-
const
|
|
1184
|
+
const Ht = {
|
|
1181
1185
|
build: K,
|
|
1182
1186
|
check: V,
|
|
1183
1187
|
test: X,
|
|
@@ -1189,6 +1193,6 @@ const Gt = {
|
|
|
1189
1193
|
"dump:tests": se
|
|
1190
1194
|
};
|
|
1191
1195
|
export {
|
|
1192
|
-
|
|
1196
|
+
Ht as COMMANDS
|
|
1193
1197
|
};
|
|
1194
1198
|
//# sourceMappingURL=index.mjs.map
|