@platforma-sdk/tengo-builder 1.17.5 → 1.17.7

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.
Files changed (47) hide show
  1. package/dist/commands/build.d.ts +4 -4
  2. package/dist/commands/build.d.ts.map +1 -1
  3. package/dist/commands/check.d.ts +1 -1
  4. package/dist/commands/dump/all.d.ts.map +1 -1
  5. package/dist/commands/dump/assets.d.ts.map +1 -1
  6. package/dist/commands/dump/libs.d.ts.map +1 -1
  7. package/dist/commands/dump/software.d.ts.map +1 -1
  8. package/dist/commands/dump/templates.d.ts.map +1 -1
  9. package/dist/commands/dump/tests.d.ts.map +1 -1
  10. package/dist/commands/test.d.ts +1 -1
  11. package/dist/compiler/artifactset.d.ts.map +1 -1
  12. package/dist/compiler/compiler.d.ts.map +1 -1
  13. package/dist/compiler/compileroptions.d.ts.map +1 -1
  14. package/dist/compiler/main.d.ts.map +1 -1
  15. package/dist/compiler/source.d.ts.map +1 -1
  16. package/dist/compiler/test.artifacts.d.ts.map +1 -1
  17. package/dist/compiler/util.d.ts.map +1 -1
  18. package/dist/index.js +8 -8
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +52 -47
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/shared/basecmd.d.ts +4 -4
  23. package/dist/shared/basecmd.d.ts.map +1 -1
  24. package/dist/shared/dump.d.ts.map +1 -1
  25. package/dist/shared/proc.d.ts +2 -2
  26. package/dist/shared/proc.d.ts.map +1 -1
  27. package/package.json +4 -4
  28. package/src/commands/build.ts +12 -11
  29. package/src/commands/check.ts +2 -2
  30. package/src/commands/dump/all.ts +8 -8
  31. package/src/commands/dump/assets.ts +8 -8
  32. package/src/commands/dump/libs.ts +11 -12
  33. package/src/commands/dump/software.ts +8 -8
  34. package/src/commands/dump/templates.ts +8 -9
  35. package/src/commands/dump/tests.ts +8 -8
  36. package/src/commands/test.ts +1 -1
  37. package/src/compiler/artifactset.ts +14 -13
  38. package/src/compiler/compiler.ts +62 -56
  39. package/src/compiler/compileroptions.ts +12 -12
  40. package/src/compiler/main.ts +29 -27
  41. package/src/compiler/package.ts +1 -1
  42. package/src/compiler/source.ts +53 -51
  43. package/src/compiler/test.artifacts.ts +24 -24
  44. package/src/compiler/util.ts +7 -5
  45. package/src/shared/basecmd.ts +16 -16
  46. package/src/shared/dump.ts +22 -21
  47. 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
- if (e.code == "ENOENT") return "absent";
46
- throw e;
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 u = this.getLibOrError(o), d = n.indexOf(h(o));
196
- if (d >= 0) {
197
- let w = `library import recursion detected: ${n.slice(d).join(" -> ")} -> ${h(o)}`;
198
- throw new Error(w);
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 y = {
201
- ...j(u.fullName),
202
- src: u.src
201
+ const c = {
202
+ ...j(i.fullName),
203
+ src: i.src
203
204
  };
204
- Pe(u.compilerOptions), t.libs[h(o)] = y, this.populateTemplateDataFromDependencies(e, t, u.dependencies, [...n, h(o)]);
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
- case "asset":
215
- const a = this.getAssetOrError(o);
215
+ }
216
+ case "asset": {
217
+ const i = this.getAssetOrError(o);
216
218
  t.software[h(o)] = {
217
- ...j(a.fullName),
218
- src: a.src
219
+ ...j(i.fullName),
220
+ src: i.src
219
221
  };
220
222
  break;
221
- case "template":
223
+ }
224
+ case "template": {
222
225
  if (de(e, o))
223
226
  continue;
224
- const c = this.getTemplateOrError(o);
225
- t.templates[h(o)] = c.data;
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) && // allow self reference for templates
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
- let c = `Unsatisfied dependencies in ${m(o.fullName)}:
401
+ const c = a;
402
+ let u = `Unsatisfied dependencies in ${m(o.fullName)}:
399
403
  `;
400
- c += ` - ${a.message}
401
- `, n.push({ src: o, err: Error(c) });
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
- throw new Error(`[line ${c.lineNo}]: ${d.message}
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: y, templateName: w, fnName: b } = d.groups;
525
- if (!y || !w || !b)
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 v = ge(w, c, r);
528
- if (!v)
529
- throw Error(`failed to parse artifact name in ${b} import statement`);
530
- return e = e.replace(y, `${b}("${v.pkg}:${v.id}")`), { line: e, context: t, artifact: v, option: void 0 };
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", y = E(a) === "dir", w = E(c) === "dir", b = E(u) === "dir";
587
- if (!d && !y && !w && !b)
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 v = JSON.parse(p.readFileSync(o).toString());
590
- if (v.name !== t.name) {
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, 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);
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 b = L(s, e, t, r, a);
661
- o.push(...b);
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 y = f.resolve(r, a);
668
- s.debug(`Parsing ${m(d)} from ${y}`);
669
- const w = ve(s, t, y, d, !0);
670
- if (w.dependencies.length > 0) {
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 b of w.dependencies) s.debug(` - ${g(b)}`);
677
+ for (const y of v.dependencies) s.debug(` - ${g(y)}`);
673
678
  }
674
- o.push(w);
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 tests to stdout"), l(H, "examples", [
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 templates to stdout"), l(T, "examples", [
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 tests to stdout"), l(ee, "examples", [
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 $ {