@platforma-sdk/tengo-builder 1.17.5 → 1.17.6
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 +4 -4
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/dump/all.d.ts.map +1 -1
- package/dist/commands/dump/assets.d.ts.map +1 -1
- package/dist/commands/dump/libs.d.ts.map +1 -1
- package/dist/commands/dump/software.d.ts.map +1 -1
- package/dist/commands/dump/templates.d.ts.map +1 -1
- package/dist/commands/dump/tests.d.ts.map +1 -1
- package/dist/commands/test.d.ts +1 -1
- package/dist/compiler/artifactset.d.ts.map +1 -1
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compileroptions.d.ts.map +1 -1
- package/dist/compiler/main.d.ts.map +1 -1
- package/dist/compiler/source.d.ts.map +1 -1
- package/dist/compiler/test.artifacts.d.ts.map +1 -1
- package/dist/compiler/util.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -47
- package/dist/index.mjs.map +1 -1
- package/dist/shared/basecmd.d.ts +4 -4
- package/dist/shared/basecmd.d.ts.map +1 -1
- package/dist/shared/dump.d.ts.map +1 -1
- package/dist/shared/proc.d.ts +2 -2
- package/dist/shared/proc.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/commands/build.ts +12 -11
- package/src/commands/check.ts +2 -2
- package/src/commands/dump/all.ts +8 -8
- package/src/commands/dump/assets.ts +8 -8
- package/src/commands/dump/libs.ts +11 -12
- package/src/commands/dump/software.ts +8 -8
- package/src/commands/dump/templates.ts +8 -9
- package/src/commands/dump/tests.ts +8 -8
- package/src/commands/test.ts +1 -1
- package/src/compiler/artifactset.ts +14 -13
- package/src/compiler/compiler.ts +62 -56
- package/src/compiler/compileroptions.ts +12 -12
- package/src/compiler/main.ts +29 -27
- package/src/compiler/package.ts +1 -1
- package/src/compiler/source.ts +53 -51
- package/src/compiler/test.artifacts.ts +24 -24
- package/src/compiler/util.ts +7 -5
- package/src/shared/basecmd.ts +16 -16
- package/src/shared/dump.ts +22 -21
- package/src/shared/proc.ts +6 -4
package/dist/index.mjs
CHANGED
|
@@ -42,8 +42,9 @@ function E(s) {
|
|
|
42
42
|
const e = p.statSync(s);
|
|
43
43
|
return e.isDirectory() ? "dir" : e.isFile() ? "file" : e.isSymbolicLink() ? "link" : "unknown";
|
|
44
44
|
} catch (e) {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const t = e;
|
|
46
|
+
if (t.code == "ENOENT") return "absent";
|
|
47
|
+
throw t;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
function Ce(s) {
|
|
@@ -192,38 +193,41 @@ class ze {
|
|
|
192
193
|
for (const o of r)
|
|
193
194
|
switch (o.type) {
|
|
194
195
|
case "library": {
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
throw new Error(
|
|
196
|
+
const i = this.getLibOrError(o), a = n.indexOf(h(o));
|
|
197
|
+
if (a >= 0) {
|
|
198
|
+
const u = `library import recursion detected: ${n.slice(a).join(" -> ")} -> ${h(o)}`;
|
|
199
|
+
throw new Error(u);
|
|
199
200
|
}
|
|
200
|
-
const
|
|
201
|
-
...j(
|
|
202
|
-
src:
|
|
201
|
+
const c = {
|
|
202
|
+
...j(i.fullName),
|
|
203
|
+
src: i.src
|
|
203
204
|
};
|
|
204
|
-
Pe(
|
|
205
|
+
Pe(i.compilerOptions), t.libs[h(o)] = c, this.populateTemplateDataFromDependencies(e, t, i.dependencies, [...n, h(o)]);
|
|
205
206
|
break;
|
|
206
207
|
}
|
|
207
|
-
case "software":
|
|
208
|
+
case "software": {
|
|
208
209
|
const i = this.getSoftwareOrError(o);
|
|
209
210
|
t.software[h(o)] = {
|
|
210
211
|
...j(i.fullName),
|
|
211
212
|
src: i.src
|
|
212
213
|
};
|
|
213
214
|
break;
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
}
|
|
216
|
+
case "asset": {
|
|
217
|
+
const i = this.getAssetOrError(o);
|
|
216
218
|
t.software[h(o)] = {
|
|
217
|
-
...j(
|
|
218
|
-
src:
|
|
219
|
+
...j(i.fullName),
|
|
220
|
+
src: i.src
|
|
219
221
|
};
|
|
220
222
|
break;
|
|
221
|
-
|
|
223
|
+
}
|
|
224
|
+
case "template": {
|
|
222
225
|
if (de(e, o))
|
|
223
226
|
continue;
|
|
224
|
-
const
|
|
225
|
-
t.templates[h(o)] =
|
|
227
|
+
const i = this.getTemplateOrError(o);
|
|
228
|
+
t.templates[h(o)] = i.data;
|
|
226
229
|
break;
|
|
230
|
+
}
|
|
227
231
|
case "test":
|
|
228
232
|
throw new Error(
|
|
229
233
|
`dependencies tree error: tests should never be part of template: ${g(o)} is dependency of ${h(e)}`
|
|
@@ -368,8 +372,7 @@ class ze {
|
|
|
368
372
|
const n = [];
|
|
369
373
|
for (const o of r) {
|
|
370
374
|
const i = o.dependencies.filter(
|
|
371
|
-
(a) => !this.getArtefact(a) &&
|
|
372
|
-
!(o.fullName.type === "template" && de(o.fullName, a))
|
|
375
|
+
(a) => !this.getArtefact(a) && !(o.fullName.type === "template" && de(o.fullName, a))
|
|
373
376
|
);
|
|
374
377
|
if (i.length > 0) {
|
|
375
378
|
let a = `Unsatisfied dependencies in ${m(o.fullName)}:
|
|
@@ -395,10 +398,11 @@ class ze {
|
|
|
395
398
|
const a = this.compileAndAddTemplate(o);
|
|
396
399
|
t.templates.push(a);
|
|
397
400
|
} catch (a) {
|
|
398
|
-
|
|
401
|
+
const c = a;
|
|
402
|
+
let u = `Unsatisfied dependencies in ${m(o.fullName)}:
|
|
399
403
|
`;
|
|
400
|
-
|
|
401
|
-
`, n.push({ src: o, err: Error(
|
|
404
|
+
u += ` - ${c.message}
|
|
405
|
+
`, n.push({ src: o, err: Error(u) });
|
|
402
406
|
}
|
|
403
407
|
break;
|
|
404
408
|
case "test":
|
|
@@ -464,7 +468,8 @@ function st(s, e, t, r) {
|
|
|
464
468
|
);
|
|
465
469
|
a.push(d.line), c = d.context, d.artifact && n.add(d.artifact), d.option && o.push(d.option);
|
|
466
470
|
} catch (d) {
|
|
467
|
-
|
|
471
|
+
const w = d;
|
|
472
|
+
throw new Error(`[line ${c.lineNo}]: ${w.message}
|
|
468
473
|
${u}`);
|
|
469
474
|
}
|
|
470
475
|
}
|
|
@@ -521,13 +526,13 @@ function ot(s, e, t, r, n) {
|
|
|
521
526
|
const d = u.exec(e);
|
|
522
527
|
if (!d || !d.groups)
|
|
523
528
|
continue;
|
|
524
|
-
const { fnCall:
|
|
525
|
-
if (!
|
|
529
|
+
const { fnCall: w, templateName: v, fnName: y } = d.groups;
|
|
530
|
+
if (!w || !v || !y)
|
|
526
531
|
throw Error("failed to parse template import statement");
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
529
|
-
throw Error(`failed to parse artifact name in ${
|
|
530
|
-
return e = e.replace(
|
|
532
|
+
const b = ge(v, c, r);
|
|
533
|
+
if (!b)
|
|
534
|
+
throw Error(`failed to parse artifact name in ${y} import statement`);
|
|
535
|
+
return e = e.replace(w, `${y}("${b.pkg}:${b.id}")`), { line: e, context: t, artifact: b, option: void 0 };
|
|
531
536
|
}
|
|
532
537
|
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
533
538
|
}
|
|
@@ -583,16 +588,16 @@ function ke(s, e, t, r, n = !1) {
|
|
|
583
588
|
}
|
|
584
589
|
return;
|
|
585
590
|
}
|
|
586
|
-
const i = Ee("dist", r), a = $e("dist", r), c = Ne("dist", r), u = Se("dist", r), d = E(i) === "dir",
|
|
587
|
-
if (!d && !
|
|
591
|
+
const i = Ee("dist", r), a = $e("dist", r), c = Ne("dist", r), u = Se("dist", r), d = E(i) === "dir", w = E(a) === "dir", v = E(c) === "dir", y = E(u) === "dir";
|
|
592
|
+
if (!d && !w && !v && !y)
|
|
588
593
|
return;
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
594
|
+
const b = JSON.parse(p.readFileSync(o).toString());
|
|
595
|
+
if (b.name !== t.name) {
|
|
591
596
|
if (E(f.resolve(r, "node_modules")) === "dir" && n)
|
|
592
597
|
throw new Error(
|
|
593
598
|
`nested node_modules is a sign of library dependencies version incompatibility in ${r}`
|
|
594
599
|
);
|
|
595
|
-
d && it(s,
|
|
600
|
+
d && it(s, b, "dist", i, e), w && at(s, b, "dist", a, e), v && lt(s, b, "dist", c, e), y && ct(s, b, "dist", u, e);
|
|
596
601
|
}
|
|
597
602
|
}
|
|
598
603
|
function it(s, e, t, r, n) {
|
|
@@ -657,21 +662,21 @@ function L(s, e, t, r, n) {
|
|
|
657
662
|
for (const i of p.readdirSync(f.join(r, n))) {
|
|
658
663
|
const a = f.join(n, i), c = f.join(r, a);
|
|
659
664
|
if (E(c) === "dir") {
|
|
660
|
-
const
|
|
661
|
-
o.push(...
|
|
665
|
+
const y = L(s, e, t, r, a);
|
|
666
|
+
o.push(...y);
|
|
662
667
|
continue;
|
|
663
668
|
}
|
|
664
669
|
const u = i === "index.lib.tengo" ? `${f.dirname(a)}.lib.tengo` : a, d = dt(e, u.replaceAll(f.sep, "."));
|
|
665
670
|
if (!d)
|
|
666
671
|
continue;
|
|
667
|
-
const
|
|
668
|
-
s.debug(`Parsing ${m(d)} from ${
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
672
|
+
const w = f.resolve(r, a);
|
|
673
|
+
s.debug(`Parsing ${m(d)} from ${w}`);
|
|
674
|
+
const v = ve(s, t, w, d, !0);
|
|
675
|
+
if (v.dependencies.length > 0) {
|
|
671
676
|
s.debug("Detected dependencies:");
|
|
672
|
-
for (const
|
|
677
|
+
for (const y of v.dependencies) s.debug(` - ${g(y)}`);
|
|
673
678
|
}
|
|
674
|
-
o.push(
|
|
679
|
+
o.push(v);
|
|
675
680
|
}
|
|
676
681
|
return o;
|
|
677
682
|
}
|
|
@@ -811,7 +816,7 @@ function gt(s, e) {
|
|
|
811
816
|
var a;
|
|
812
817
|
const t = f.resolve(e["tags-file"]), r = f.dirname(t), n = e["tags-additional-args"], o = ht(r);
|
|
813
818
|
s.info(
|
|
814
|
-
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${n}".
|
|
819
|
+
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${n.join('" "')}".
|
|
815
820
|
Found ${o.length} tengo files...`
|
|
816
821
|
);
|
|
817
822
|
const i = Oe(
|
|
@@ -1024,7 +1029,7 @@ class H extends $ {
|
|
|
1024
1029
|
Et(e, D);
|
|
1025
1030
|
}
|
|
1026
1031
|
}
|
|
1027
|
-
l(H, "description", "parse sources in current package and dump all found
|
|
1032
|
+
l(H, "description", "parse sources in current package and dump all found assets to stdout"), l(H, "examples", [
|
|
1028
1033
|
"<%= config.bin %> <%= command.id %>"
|
|
1029
1034
|
]);
|
|
1030
1035
|
const T = class T extends $ {
|
|
@@ -1033,7 +1038,7 @@ const T = class T extends $ {
|
|
|
1033
1038
|
yt(t, e.deps, D);
|
|
1034
1039
|
}
|
|
1035
1040
|
};
|
|
1036
|
-
l(T, "description", "parse sources in current package and dump all found
|
|
1041
|
+
l(T, "description", "parse sources in current package and dump all found libs to stdout"), l(T, "examples", [
|
|
1037
1042
|
"<%= config.bin %> <%= command.id %>"
|
|
1038
1043
|
]), l(T, "flags", {
|
|
1039
1044
|
deps: F.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
|
|
@@ -1045,7 +1050,7 @@ class ee extends $ {
|
|
|
1045
1050
|
vt(e, D);
|
|
1046
1051
|
}
|
|
1047
1052
|
}
|
|
1048
|
-
l(ee, "description", "parse sources in current package and dump all found
|
|
1053
|
+
l(ee, "description", "parse sources in current package and dump all found software to stdout"), l(ee, "examples", [
|
|
1049
1054
|
"<%= config.bin %> <%= command.id %>"
|
|
1050
1055
|
]);
|
|
1051
1056
|
class te extends $ {
|