@platforma-sdk/tengo-builder 1.15.0 → 1.15.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/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
- var Te = Object.defineProperty;
2
- var xe = (t, e, r) => e in t ? Te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var l = (t, e, r) => xe(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { spawnSync as De, spawn as Fe } from "node:child_process";
5
- import { Flags as M, Command as v } from "@oclif/core";
1
+ var De = Object.defineProperty;
2
+ var Fe = (t, e, r) => e in t ? De(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var l = (t, e, r) => Fe(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { spawnSync as Me, spawn as Oe } from "node:child_process";
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 Me } from "node:fs";
9
- import { gunzipSync as Oe, gzipSync as Re } from "node:zlib";
10
- import je from "canonicalize";
11
- import J from "winston";
12
- import * as F from "node:fs/promises";
13
- import { TengoTesterBinaryPath as ge } from "@milaboratories/tengo-tester";
14
- import { stdout as x } from "node:process";
15
- function O(t) {
8
+ import { readFileSync as Re } from "node:fs";
9
+ import { gunzipSync as je, gzipSync as Le } from "node:zlib";
10
+ import Ie from "canonicalize";
11
+ import G from "winston";
12
+ import * as D from "node:fs/promises";
13
+ import { TengoTesterBinaryPath as we } from "@milaboratories/tengo-tester";
14
+ import { stdout as T } from "node:process";
15
+ function M(t) {
16
16
  throw new Error("Unexpected object: " + t);
17
17
  }
18
- function Le() {
18
+ function Ce() {
19
19
  let t = process.cwd();
20
20
  for (; t; ) {
21
21
  const e = f.join(t, "node_modules");
@@ -35,7 +35,7 @@ function $(t) {
35
35
  throw e;
36
36
  }
37
37
  }
38
- function ae(t) {
38
+ function ce(t) {
39
39
  return `${t.type}||${t.pkg}||${t.id}`;
40
40
  }
41
41
  function m(t) {
@@ -44,26 +44,26 @@ function m(t) {
44
44
  function g(t) {
45
45
  return `${t.type}:${t.pkg}:${t.id}`;
46
46
  }
47
- function le(t, e) {
47
+ function fe(t, e) {
48
48
  return t.type == e.type && t.pkg == e.pkg && t.id == e.id;
49
49
  }
50
50
  function h(t) {
51
51
  return `${t.pkg}:${t.id}`;
52
52
  }
53
- function I(t) {
53
+ function L(t) {
54
54
  return { name: h(t), version: t.version };
55
55
  }
56
- function Ie(t) {
56
+ function Ge(t) {
57
57
  const e = t.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);
58
58
  if (!e)
59
59
  throw new Error(`malformed artifact name: ${t.name}`);
60
60
  return { pkg: e.groups.pkg, id: e.groups.id, version: t.version };
61
61
  }
62
- function ce(t) {
62
+ function de(t) {
63
63
  return `${t.pkg}:${t.id}:${t.version}`;
64
64
  }
65
- const Ce = new TextDecoder(), Ge = new TextEncoder();
66
- class he {
65
+ const Je = new TextDecoder(), ze = new TextEncoder();
66
+ class ye {
67
67
  constructor(e, r, o) {
68
68
  l(this, "data");
69
69
  l(this, "content");
@@ -73,29 +73,29 @@ class he {
73
73
  throw new Error("Neither data nor content is provided for template constructor");
74
74
  if (n !== void 0 && s !== void 0)
75
75
  throw new Error("Both data and content are provided for template constructor");
76
- if (n === void 0 && (n = JSON.parse(Ce.decode(Oe(s))), n.type !== "pl.tengo-template.v2"))
76
+ if (n === void 0 && (n = JSON.parse(Je.decode(je(s))), n.type !== "pl.tengo-template.v2"))
77
77
  throw new Error("malformed template");
78
- s === void 0 && (s = Re(Ge.encode(je(n))));
79
- const i = Ie(n);
78
+ s === void 0 && (s = Le(ze.encode(Ie(n))));
79
+ const i = Ge(n);
80
80
  if (i.pkg !== r.pkg || i.id !== r.id || i.version !== r.version)
81
- throw new Error(`Compiled template name don't match it's package and file names: ${ce(i)} != ${ce(r)}`);
81
+ throw new Error(`Compiled template name don't match it's package and file names: ${de(i)} != ${de(r)}`);
82
82
  this.data = n, this.content = s;
83
83
  }
84
84
  toJSON() {
85
85
  return { compileMode: this.compileMode, fullName: this.fullName, data: this.data };
86
86
  }
87
87
  }
88
- class z {
88
+ class J {
89
89
  constructor(e) {
90
90
  l(this, "map", /* @__PURE__ */ new Map());
91
91
  this.nameExtractor = e;
92
92
  }
93
93
  add(e, r = !0) {
94
- const o = ae(this.nameExtractor(e)), n = this.map.get(o);
94
+ const o = ce(this.nameExtractor(e)), n = this.map.get(o);
95
95
  return n && !r || this.map.set(o, e), n;
96
96
  }
97
97
  get(e) {
98
- return this.map.get(ae(e));
98
+ return this.map.get(ce(e));
99
99
  }
100
100
  get array() {
101
101
  const e = [];
@@ -105,21 +105,21 @@ class z {
105
105
  this.map.forEach((r) => e(r, this.nameExtractor(r)));
106
106
  }
107
107
  }
108
- function Je() {
109
- return new z((t) => t);
108
+ function We() {
109
+ return new J((t) => t);
110
110
  }
111
- class C {
111
+ class I {
112
112
  constructor(e) {
113
113
  l(this, "dev");
114
114
  l(this, "dist");
115
- this.nameExtractor = e, this.dev = new z(e), this.dist = new z(e);
115
+ this.nameExtractor = e, this.dev = new J(e), this.dist = new J(e);
116
116
  }
117
117
  add(e, r, o = !0) {
118
118
  switch (e) {
119
119
  case "dist":
120
120
  return this.dist.add(r, o);
121
121
  default:
122
- O(e);
122
+ M(e);
123
123
  }
124
124
  }
125
125
  get(e, r) {
@@ -127,7 +127,7 @@ class C {
127
127
  case "dist":
128
128
  return this.dist.get(r);
129
129
  default:
130
- O(e);
130
+ M(e);
131
131
  }
132
132
  }
133
133
  array(e) {
@@ -138,12 +138,12 @@ class C {
138
138
  this.dist.forEach((o, n) => r(this.get(e, n) ?? o, n));
139
139
  }
140
140
  }
141
- class ze {
141
+ class Pe {
142
142
  constructor(e) {
143
- l(this, "libs", new C((e) => e.fullName));
144
- l(this, "software", new C((e) => e.fullName));
145
- l(this, "assets", new C((e) => e.fullName));
146
- l(this, "templates", new C((e) => e.fullName));
143
+ l(this, "libs", new I((e) => e.fullName));
144
+ l(this, "software", new I((e) => e.fullName));
145
+ l(this, "assets", new I((e) => e.fullName));
146
+ l(this, "templates", new I((e) => e.fullName));
147
147
  this.compileMode = e;
148
148
  }
149
149
  populateTemplateDataFromDependencies(e, r, o, n) {
@@ -156,26 +156,26 @@ class ze {
156
156
  throw new Error(y);
157
157
  }
158
158
  r.libs[h(s)] = {
159
- ...I(i.fullName),
159
+ ...L(i.fullName),
160
160
  src: i.src
161
161
  }, this.populateTemplateDataFromDependencies(e, r, i.dependencies, [...n, h(s)]);
162
162
  break;
163
163
  case "software":
164
164
  const c = this.getSoftwareOrError(s);
165
165
  r.software[h(s)] = {
166
- ...I(c.fullName),
166
+ ...L(c.fullName),
167
167
  src: c.src
168
168
  };
169
169
  break;
170
170
  case "asset":
171
171
  const d = this.getAssetOrError(s);
172
172
  r.software[h(s)] = {
173
- ...I(d.fullName),
173
+ ...L(d.fullName),
174
174
  src: d.src
175
175
  };
176
176
  break;
177
177
  case "template":
178
- if (le(e, s))
178
+ if (fe(e, s))
179
179
  continue;
180
180
  const u = this.getTemplateOrError(s);
181
181
  r.templates[h(s)] = u.data;
@@ -185,7 +185,7 @@ class ze {
185
185
  `dependencies tree error: tests should never be part of template: ${g(s)} is dependency of ${h(e)}`
186
186
  );
187
187
  default:
188
- O(s.type);
188
+ M(s.type);
189
189
  }
190
190
  }
191
191
  /** This method assumes that all dependencies are already added to the compiler's context */
@@ -194,7 +194,7 @@ class ze {
194
194
  throw new Error("unexpected source type");
195
195
  const r = {
196
196
  type: "pl.tengo-template.v2",
197
- ...I(e.fullName),
197
+ ...L(e.fullName),
198
198
  templates: {},
199
199
  libs: {},
200
200
  software: {},
@@ -202,7 +202,7 @@ class ze {
202
202
  src: e.src
203
203
  };
204
204
  this.populateTemplateDataFromDependencies(e.fullName, r, e.dependencies, []);
205
- const o = new he(e.compileMode, e.fullName, { data: r });
205
+ const o = new ye(e.compileMode, e.fullName, { data: r });
206
206
  return this.addTemplate(o), o;
207
207
  }
208
208
  addLib(e) {
@@ -302,7 +302,7 @@ class ze {
302
302
  case "test":
303
303
  return;
304
304
  default:
305
- O(e.type);
305
+ M(e.type);
306
306
  }
307
307
  }
308
308
  checkLibs() {
@@ -325,7 +325,7 @@ class ze {
325
325
  for (const s of o) {
326
326
  const i = s.dependencies.filter(
327
327
  (a) => !this.getArtefact(a) && // allow self reference for templates
328
- !(s.fullName.type === "template" && le(s.fullName, a))
328
+ !(s.fullName.type === "template" && fe(s.fullName, a))
329
329
  );
330
330
  if (i.length > 0) {
331
331
  let a = `Unsatisfied dependencies in ${m(s.fullName)}:
@@ -360,7 +360,7 @@ class ze {
360
360
  case "test":
361
361
  break;
362
362
  default:
363
- O(s.fullName.type);
363
+ M(s.fullName.type);
364
364
  }
365
365
  }
366
366
  if (o.length === n.length) {
@@ -375,22 +375,22 @@ ${i.err.message}`;
375
375
  return r;
376
376
  }
377
377
  }
378
- const fe = "[_a-zA-Z][_a-zA-Z0-9]*", R = (t, e) => new RegExp(
378
+ const pe = "[_a-zA-Z][_a-zA-Z0-9]*", O = (t, e) => new RegExp(
379
379
  `\\b${t}\\.(?<fnCall>(?<fnName>` + e + ')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'
380
- ), We = (t) => R(t, "getTemplateId"), Pe = (t) => R(t, "getSoftwareInfo"), de = (t) => R(t, "importTemplate"), pe = (t) => R(t, "importSoftware"), Ue = (t) => R(t, "importAsset"), qe = /^\s*(\/\/)|(\/\*.*\*\/)/, Be = /^\s*\/\*/, Ve = /\*\//, we = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/, Ze = new RegExp(
381
- `\\b(?<importName>${fe}(\\.${fe})*)${we.source}`
382
- ), Ke = /(?<pkgName>[^"]+)?:(?<depID>[^"]+)/;
383
- class te {
380
+ ), Ue = (t) => O(t, "getTemplateId"), qe = (t) => O(t, "getSoftwareInfo"), ue = (t) => O(t, "importTemplate"), me = (t) => O(t, "importSoftware"), Be = (t) => O(t, "importAsset"), Ve = /^\s*(\/\/)|(\/\*.*\*\/)/, Ze = /^\s*\/\*/, Ke = /\*\//, be = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/, Xe = new RegExp(
381
+ `\\b(?<importName>${pe}(\\.${pe})*)${be.source}`
382
+ ), He = /(?<pkgName>[^"]+)?:(?<depID>[^"]+)/;
383
+ class re {
384
384
  constructor(e, r, o, n, s) {
385
385
  this.compileMode = e, this.fullName = r, this.src = o, this.srcName = n, this.dependencies = s;
386
386
  }
387
387
  }
388
- function ye(t, e, r, o) {
389
- const n = Me(e).toString(), { deps: s, normalized: i } = Xe(n, r, o);
390
- return new te(t, r, i, e, s.array);
388
+ function $e(t, e, r, o) {
389
+ const n = Re(e).toString(), { deps: s, normalized: i } = Qe(n, r, o);
390
+ return new re(t, r, i, e, s.array);
391
391
  }
392
- function Xe(t, e, r) {
393
- const o = Je(), n = t.split(`
392
+ function Qe(t, e, r) {
393
+ const o = We(), n = t.split(`
394
394
  `), s = [];
395
395
  let i = {
396
396
  isInCommentBlock: !1,
@@ -399,7 +399,7 @@ function Xe(t, e, r) {
399
399
  for (const c of n) {
400
400
  a++;
401
401
  try {
402
- const d = He(
402
+ const d = Ye(
403
403
  c,
404
404
  i,
405
405
  e.pkg,
@@ -417,30 +417,30 @@ function Xe(t, e, r) {
417
417
  deps: o
418
418
  };
419
419
  }
420
- function He(t, e, r, o) {
420
+ function Ye(t, e, r, o) {
421
421
  if (e.isInCommentBlock)
422
- return Ve.exec(t) && (e.isInCommentBlock = !1), { line: t, context: e, artifact: void 0 };
423
- if (qe.exec(t))
422
+ return Ke.exec(t) && (e.isInCommentBlock = !1), { line: t, context: e, artifact: void 0 };
423
+ if (Ve.exec(t))
424
424
  return { line: t, context: e, artifact: void 0 };
425
- if (Be.exec(t))
425
+ if (Ze.exec(t))
426
426
  return e.isInCommentBlock = !0, { line: t, context: e, artifact: void 0 };
427
- const n = we.exec(t);
427
+ const n = be.exec(t);
428
428
  if (n) {
429
- const s = Qe(t);
429
+ const s = _e(t);
430
430
  if (s.module === "plapi")
431
431
  return e.tplDepREs.has(s.module) || e.tplDepREs.set(s.module, [
432
- ["template", We(s.alias)],
433
- ["software", Pe(s.alias)]
432
+ ["template", Ue(s.alias)],
433
+ ["software", qe(s.alias)]
434
434
  ]), { line: t, context: e, artifact: void 0 };
435
435
  (s.module === "@milaboratory/tengo-sdk:ll" || s.module === "@platforma-sdk/workflow-tengo:ll" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && s.module === ":ll") && (e.tplDepREs.has(s.module) || e.tplDepREs.set(s.module, [
436
- ["template", de(s.alias)],
437
- ["software", pe(s.alias)]
436
+ ["template", ue(s.alias)],
437
+ ["software", me(s.alias)]
438
438
  ])), (s.module === "@milaboratory/tengo-sdk:assets" || s.module === "@platforma-sdk/workflow-tengo:assets" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && s.module === ":assets") && (e.tplDepREs.has(s.module) || e.tplDepREs.set(s.module, [
439
- ["template", de(s.alias)],
440
- ["software", pe(s.alias)],
441
- ["asset", Ue(s.alias)]
439
+ ["template", ue(s.alias)],
440
+ ["software", me(s.alias)],
441
+ ["asset", Be(s.alias)]
442
442
  ]));
443
- const i = ue(s.module, "library", r);
443
+ const i = ge(s.module, "library", r);
444
444
  return i ? (t = t.replace(n[0], ` := import("${i.pkg}:${i.id}")`), { line: t, context: e, artifact: i }) : { line: t, context: e, artifact: void 0 };
445
445
  }
446
446
  if (e.tplDepREs.size > 0)
@@ -452,15 +452,15 @@ function He(t, e, r, o) {
452
452
  const { fnCall: u, templateName: y, fnName: b } = d.groups;
453
453
  if (!u || !y || !b)
454
454
  throw Error("failed to parse template import statement");
455
- const w = ue(y, a, r);
455
+ const w = ge(y, a, r);
456
456
  if (!w)
457
457
  throw Error(`failed to parse artifact name in ${b} import statement`);
458
458
  return t = t.replace(u, `${b}("${w.pkg}:${w.id}")`), { line: t, context: e, artifact: w };
459
459
  }
460
460
  return { line: t, context: e, artifact: void 0 };
461
461
  }
462
- function Qe(t) {
463
- const e = Ze.exec(t);
462
+ function _e(t) {
463
+ const e = Xe.exec(t);
464
464
  if (!e || !e.groups)
465
465
  throw Error("failed to parse 'import' statement");
466
466
  const { importName: r, moduleName: o } = e.groups;
@@ -471,8 +471,8 @@ function Qe(t) {
471
471
  alias: r
472
472
  };
473
473
  }
474
- function ue(t, e, r) {
475
- const o = Ke.exec(t);
474
+ function ge(t, e, r) {
475
+ const o = He.exec(t);
476
476
  if (!o)
477
477
  return;
478
478
  if (!o.groups)
@@ -486,127 +486,127 @@ function ue(t, e, r) {
486
486
  );
487
487
  return { type: e, pkg: n ?? r, id: s };
488
488
  }
489
- const W = ".plj.gz", P = ".lib.tengo", T = ".sw.json", me = ".test.tengo", U = ".tpl.tengo", q = ".lib.tengo", B = ".sw.json", Ye = [q, U, B];
489
+ const z = ".plj.gz", W = ".lib.tengo", P = ".sw.json", U = ".as.json", he = ".test.tengo", q = ".tpl.tengo", B = ".lib.tengo", V = ".sw.json", Z = ".as.json", et = [B, q, V, Z];
490
490
  function E(t = "debug") {
491
- return J.createLogger({
491
+ return G.createLogger({
492
492
  level: t,
493
- format: J.format.printf(({ level: e, message: r }) => `${e.padStart(6, " ")}: ${r}`),
493
+ format: G.format.printf(({ level: e, message: r }) => `${e.padStart(6, " ")}: ${r}`),
494
494
  transports: [
495
- new J.transports.Console({
495
+ new G.transports.Console({
496
496
  stderrLevels: ["error", "warn", "info", "debug"],
497
497
  handleExceptions: !0
498
498
  })
499
499
  ]
500
500
  });
501
501
  }
502
- function j() {
502
+ function R() {
503
503
  return JSON.parse(p.readFileSync("package.json").toString());
504
504
  }
505
- function be(t, e) {
505
+ function ve(t, e) {
506
506
  return f.resolve(e, t, "tengo", "lib");
507
507
  }
508
- function $e(t, e) {
508
+ function Ee(t, e) {
509
509
  return f.resolve(e, t, "tengo", "tpl");
510
510
  }
511
- function ve(t, e) {
511
+ function Ne(t, e) {
512
512
  return f.resolve(e, t, "tengo", "software");
513
513
  }
514
- function Ee(t, e) {
514
+ function Se(t, e) {
515
515
  return f.resolve(e, t, "tengo", "asset");
516
516
  }
517
- function Ne(t, e, r, o, n = !1) {
517
+ function ke(t, e, r, o, n = !1) {
518
518
  const s = f.resolve(o, "package.json");
519
519
  if ($(s) !== "file") {
520
- for (const ne of p.readdirSync(o)) {
521
- const Ae = $(f.join(o, ne)) === "link", ie = f.resolve(o, ne);
522
- $(ie) === "dir" && Ne(t, e, r, ie, Ae);
520
+ for (const ae of p.readdirSync(o)) {
521
+ const xe = $(f.join(o, ae)) === "link", le = f.resolve(o, ae);
522
+ $(le) === "dir" && ke(t, e, r, le, xe);
523
523
  }
524
524
  return;
525
525
  }
526
- const i = be("dist", o), a = $e("dist", o), c = ve("dist", o), d = Ee("dist", o), u = $(i) === "dir", y = $(a) === "dir", b = $(c) === "dir", w = $(d) === "dir";
526
+ const i = ve("dist", o), a = Ee("dist", o), c = Ne("dist", o), d = Se("dist", o), u = $(i) === "dir", y = $(a) === "dir", b = $(c) === "dir", w = $(d) === "dir";
527
527
  if (!u && !y && !b && !w)
528
528
  return;
529
- const D = JSON.parse(p.readFileSync(s).toString());
530
- if (D.name !== r.name) {
529
+ const x = JSON.parse(p.readFileSync(s).toString());
530
+ if (x.name !== r.name) {
531
531
  if ($(f.resolve(o, "node_modules")) === "dir" && n)
532
532
  throw new Error(
533
533
  `nested node_modules is a sign of library dependencies version incompatibility in ${o}`
534
534
  );
535
- u && _e(t, D, "dist", i, e), y && et(t, D, "dist", a, e), b && tt(t, D, "dist", c, e), w && st(t, D, "dist", d, e);
535
+ u && tt(t, x, "dist", i, e), y && st(t, x, "dist", a, e), b && rt(t, x, "dist", c, e), w && ot(t, x, "dist", d, e);
536
536
  }
537
537
  }
538
- function _e(t, e, r, o, n) {
538
+ function tt(t, e, r, o, n) {
539
539
  for (const s of p.readdirSync(o)) {
540
540
  const i = f.resolve(o, s);
541
- if (!s.endsWith(P)) throw new Error(`unexpected file in 'lib' folder: ${i}`);
541
+ if (!s.endsWith(W)) throw new Error(`unexpected file in 'lib' folder: ${i}`);
542
542
  const a = {
543
543
  type: "library",
544
544
  pkg: e.name,
545
- id: s.slice(0, s.length - P.length),
545
+ id: s.slice(0, s.length - W.length),
546
546
  version: e.version
547
- }, c = ye(r, i, a, !0);
547
+ }, c = $e(r, i, a, !0);
548
548
  if (n.addLib(c), t.debug(`Adding dependency ${m(a)} from ${i}`), c.dependencies.length > 0) {
549
549
  t.debug("Dependencies:");
550
550
  for (const d of c.dependencies) t.debug(` - ${g(d)}`);
551
551
  }
552
552
  }
553
553
  }
554
- function et(t, e, r, o, n) {
554
+ function st(t, e, r, o, n) {
555
555
  for (const s of p.readdirSync(o)) {
556
556
  const i = f.resolve(o, s);
557
- if (!s.endsWith(W)) throw new Error(`unexpected file in 'tpl' folder: ${i}`);
557
+ if (!s.endsWith(z)) throw new Error(`unexpected file in 'tpl' folder: ${i}`);
558
558
  const a = {
559
559
  type: "template",
560
560
  pkg: e.name,
561
- id: s.slice(0, s.length - W.length),
561
+ id: s.slice(0, s.length - z.length),
562
562
  version: e.version
563
- }, c = new he(r, a, { content: p.readFileSync(i) });
563
+ }, c = new ye(r, a, { content: p.readFileSync(i) });
564
564
  n.addTemplate(c), t.debug(`Adding dependency ${m(a)} from ${i}`);
565
565
  }
566
566
  }
567
- function tt(t, e, r, o, n) {
567
+ function rt(t, e, r, o, n) {
568
568
  for (const s of p.readdirSync(o)) {
569
569
  const i = f.resolve(o, s);
570
- if (!s.endsWith(T))
570
+ if (!s.endsWith(P))
571
571
  throw new Error(`unexpected file in 'software' folder: ${i}`);
572
572
  const a = {
573
573
  type: "software",
574
574
  pkg: e.name,
575
- id: s.slice(0, s.length - T.length),
575
+ id: s.slice(0, s.length - P.length),
576
576
  version: e.version
577
- }, c = new te(r, a, p.readFileSync(i).toString(), i, []);
577
+ }, c = new re(r, a, p.readFileSync(i).toString(), i, []);
578
578
  t.debug(`Adding dependency ${m(a)} from ${i}`), n.addSoftware(c);
579
579
  }
580
580
  }
581
- function st(t, e, r, o, n) {
581
+ function ot(t, e, r, o, n) {
582
582
  for (const s of p.readdirSync(o)) {
583
583
  const i = f.resolve(o, s);
584
- if (!s.endsWith(T))
584
+ if (!s.endsWith(U))
585
585
  throw new Error(`unexpected file in 'asset' folder: ${i}`);
586
586
  const a = {
587
587
  type: "asset",
588
588
  pkg: e.name,
589
- id: s.slice(0, s.length - T.length),
589
+ id: s.slice(0, s.length - U.length),
590
590
  version: e.version
591
- }, c = new te(r, a, p.readFileSync(i).toString(), i, []);
591
+ }, c = new re(r, a, p.readFileSync(i).toString(), i, []);
592
592
  t.debug(`Adding dependency ${m(a)} from ${i}`), n.addAsset(c);
593
593
  }
594
594
  }
595
- function L(t, e, r, o, n) {
595
+ function j(t, e, r, o, n) {
596
596
  const s = [];
597
597
  for (const i of p.readdirSync(f.join(o, n))) {
598
598
  const a = f.join(n, i), c = f.join(o, a);
599
599
  if ($(c) === "dir") {
600
- const w = L(t, e, r, o, a);
600
+ const w = j(t, e, r, o, a);
601
601
  s.push(...w);
602
602
  continue;
603
603
  }
604
- const d = i === "index.lib.tengo" ? `${f.basename(n)}.lib.tengo` : a, u = rt(e, d.replaceAll(f.sep, "."));
604
+ const d = i === "index.lib.tengo" ? `${f.basename(n)}.lib.tengo` : a, u = nt(e, d.replaceAll(f.sep, "."));
605
605
  if (!u)
606
606
  continue;
607
607
  const y = f.resolve(o, a);
608
608
  t.debug(`Parsing ${m(u)} from ${y}`);
609
- const b = ye(r, y, u, !0);
609
+ const b = $e(r, y, u, !0);
610
610
  if (b.dependencies.length > 0) {
611
611
  t.debug("Detected dependencies:");
612
612
  for (const w of b.dependencies) t.debug(` - ${g(w)}`);
@@ -615,35 +615,39 @@ function L(t, e, r, o, n) {
615
615
  }
616
616
  return s;
617
617
  }
618
- function se(t, e, r) {
619
- const o = new ze(r);
620
- return Ne(t, o, e, Le()), o;
618
+ function oe(t, e, r) {
619
+ const o = new Pe(r);
620
+ return ke(t, o, e, Ce()), o;
621
621
  }
622
- function rt(t, e) {
622
+ function nt(t, e) {
623
623
  const r = { pkg: t.name, version: t.version };
624
- return e.endsWith(q) ? {
624
+ return e.endsWith(B) ? {
625
625
  ...r,
626
- id: e.substring(0, e.length - q.length),
626
+ id: e.substring(0, e.length - B.length),
627
627
  type: "library"
628
- } : e.endsWith(U) ? {
628
+ } : e.endsWith(q) ? {
629
629
  ...r,
630
- id: e.substring(0, e.length - U.length),
630
+ id: e.substring(0, e.length - q.length),
631
631
  type: "template"
632
- } : e.endsWith(B) ? {
632
+ } : e.endsWith(V) ? {
633
633
  ...r,
634
- id: e.substring(0, e.length - B.length),
634
+ id: e.substring(0, e.length - V.length),
635
635
  type: "software"
636
- } : e.endsWith(me) ? {
636
+ } : e.endsWith(Z) ? {
637
637
  ...r,
638
- id: e.substring(0, e.length - me.length),
638
+ id: e.substring(0, e.length - Z.length),
639
+ type: "asset"
640
+ } : e.endsWith(he) ? {
641
+ ...r,
642
+ id: e.substring(0, e.length - he.length),
639
643
  type: "test"
640
644
  } : null;
641
645
  }
642
- function ot(t, e) {
643
- const r = j(), o = se(t, r, e), n = L(t, r, e, "src", "");
646
+ function it(t, e) {
647
+ const r = R(), o = oe(t, r, e), n = j(t, r, e, "src", "");
644
648
  if (n.length === 0) {
645
649
  const i = [];
646
- for (const a of Ye)
650
+ for (const a of et)
647
651
  i.push(`*${a}`);
648
652
  t.error(`Nothing to compile. Looked for ${i.join(", ")}`), process.exit(1);
649
653
  }
@@ -651,57 +655,57 @@ function ot(t, e) {
651
655
  const s = o.compileAndAdd(n);
652
656
  return t.debug("Done."), s;
653
657
  }
654
- function nt(t, e, r) {
658
+ function at(t, e, r) {
655
659
  if (e.libs.length > 0) {
656
- const o = be(r, ".");
660
+ const o = ve(r, ".");
657
661
  p.mkdirSync(o, { recursive: !0 });
658
662
  for (const n of e.libs) {
659
- const s = f.resolve(o, n.fullName.id + P);
663
+ const s = f.resolve(o, n.fullName.id + W);
660
664
  t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
661
665
  }
662
666
  }
663
667
  if (e.templates.length > 0) {
664
- const o = $e(r, ".");
668
+ const o = Ee(r, ".");
665
669
  p.mkdirSync(o, { recursive: !0 });
666
670
  for (const n of e.templates) {
667
- const s = f.resolve(o, n.fullName.id + W);
671
+ const s = f.resolve(o, n.fullName.id + z);
668
672
  t.info(` - writing ${s}`), p.writeFileSync(s, n.content);
669
673
  }
670
674
  }
671
675
  if (e.software.length > 0) {
672
- const o = ve(r, ".");
676
+ const o = Ne(r, ".");
673
677
  p.mkdirSync(o, { recursive: !0 });
674
678
  for (const n of e.software) {
675
- const s = f.resolve(o, n.fullName.id + T);
679
+ const s = f.resolve(o, n.fullName.id + P);
676
680
  t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
677
681
  }
678
682
  }
679
683
  if (e.assets.length > 0) {
680
- const o = Ee(r, ".");
684
+ const o = Se(r, ".");
681
685
  p.mkdirSync(o, { recursive: !0 });
682
686
  for (const n of e.software) {
683
- const s = f.resolve(o, n.fullName.id + T);
687
+ const s = f.resolve(o, n.fullName.id + U);
684
688
  t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
685
689
  }
686
690
  }
687
691
  }
688
- const re = {
689
- "log-level": M.string({
692
+ const ne = {
693
+ "log-level": F.string({
690
694
  description: "logging level",
691
695
  default: "info",
692
696
  options: ["error", "warn", "info", "debug"]
693
697
  })
694
- }, it = {
695
- "generate-tags": M.boolean({
698
+ }, lt = {
699
+ "generate-tags": F.boolean({
696
700
  description: "generate tags, default false",
697
701
  default: !1
698
702
  }),
699
- "tags-file": M.file({
703
+ "tags-file": F.file({
700
704
  description: 'where to put ".tags" file, it should be a root of VS Code project',
701
705
  default: "../../.tags"
702
706
  // usually a user opens a directory with all blocks
703
707
  }),
704
- "tags-additional-args": M.string({
708
+ "tags-additional-args": F.string({
705
709
  description: "additional flags for universal-ctags command: e.g. -e for emacs",
706
710
  default: [],
707
711
  multiple: !0,
@@ -709,8 +713,8 @@ const re = {
709
713
  })
710
714
  }, k = class k extends v {
711
715
  async run() {
712
- const { flags: e } = await this.parse(k), r = E(e["log-level"]), o = j(), n = ot(r, "dist");
713
- nt(r, n, "dist"), r.info("");
716
+ const { flags: e } = await this.parse(k), r = E(e["log-level"]), o = R(), n = it(r, "dist");
717
+ at(r, n, "dist"), r.info("");
714
718
  let s = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
715
719
  `;
716
720
  s += `declare type TplName = ${n.templates.map((u) => '"' + u.fullName.id + '"').join(" | ")};
@@ -732,25 +736,25 @@ export const Templates = {
732
736
  }};
733
737
  `, a += `
734
738
  };
735
- `, await F.writeFile("dist/index.d.ts", s), o.type === "module" ? (await F.writeFile("dist/index.cjs", i), await F.writeFile("dist/index.js", a)) : (await F.writeFile("dist/index.js", i), await F.writeFile("dist/index.mjs", a)), at(e), e["generate-tags"] && lt(r, e), r.info("Template Pack build done.");
739
+ `, await D.writeFile("dist/index.d.ts", s), o.type === "module" ? (await D.writeFile("dist/index.cjs", i), await D.writeFile("dist/index.js", a)) : (await D.writeFile("dist/index.js", i), await D.writeFile("dist/index.mjs", a)), ct(e), e["generate-tags"] && ft(r, e), r.info("Template Pack build done.");
736
740
  }
737
741
  };
738
742
  l(k, "description", "build tengo sources into single distributable pack file"), l(k, "examples", ["<%= config.bin %> <%= command.id %>"]), l(k, "flags", {
739
- ...re,
740
- ...it
743
+ ...ne,
744
+ ...lt
741
745
  });
742
- let V = k;
743
- function at(t) {
746
+ let K = k;
747
+ function ct(t) {
744
748
  process.env.GENERATE_TAGS != null && (t["generate-tags"] = process.env.GENERATE_TAGS == "true"), process.env.TAGS_FILE != null && (t["tags-file"] = process.env.TAGS_FILE), process.env.TAGS_ADDITIONAL_ARGS != null && (t["tags-additional-args"] = process.env.TAGS_ADDITIONAL_ARGS.split(","));
745
749
  }
746
- function lt(t, e) {
750
+ function ft(t, e) {
747
751
  var a;
748
- const r = f.resolve(e["tags-file"]), o = f.dirname(r), n = e["tags-additional-args"], s = ct(o);
752
+ const r = f.resolve(e["tags-file"]), o = f.dirname(r), n = e["tags-additional-args"], s = dt(o);
749
753
  t.info(
750
754
  `Generating tags for tengo autocompletion from "${o}" in "${r}", additional arguments: "${n}".
751
755
  Found ${s.length} tengo files...`
752
756
  );
753
- const i = De(
757
+ const i = Me(
754
758
  "ctags",
755
759
  [
756
760
  "-f",
@@ -782,9 +786,9 @@ For vscode, you should also install ctags extension:
782
786
  https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
783
787
  return;
784
788
  }
785
- ft(i, "failed to generate ctags"), t.info("Generation of tags is done.");
789
+ pt(i, "failed to generate ctags"), t.info("Generation of tags is done.");
786
790
  }
787
- function ct(t) {
791
+ function dt(t) {
788
792
  const e = p.readdirSync(t, { withFileTypes: !0, recursive: !0 }), r = [];
789
793
  return e.forEach((o) => {
790
794
  if (!o.isDirectory() && o.name.endsWith(".tengo")) {
@@ -793,13 +797,13 @@ function ct(t) {
793
797
  }
794
798
  }), r;
795
799
  }
796
- function ft(t, e) {
800
+ function pt(t, e) {
797
801
  t.error && console.log(t.error);
798
802
  const r = e;
799
803
  t.status !== 0 && console.log(`WARN: ${r} the build will continue as-is`);
800
804
  }
801
- function oe(t, e) {
802
- const r = j(), o = L(t, r, "dist", "src", ""), n = se(t, r, "dist");
805
+ function ie(t, e) {
806
+ const r = R(), o = j(t, r, "dist", "src", ""), n = oe(t, r, "dist");
803
807
  for (const s of n.allLibs())
804
808
  t.debug(
805
809
  `Dumping to pl-tester: ${g(s.fullName)}`
@@ -846,46 +850,46 @@ function oe(t, e) {
846
850
  ), e.write(JSON.stringify(s) + `
847
851
  `));
848
852
  }
849
- function dt(t, e, r) {
850
- const o = j(), n = L(t, o, "dist", "src", "");
853
+ function ut(t, e, r) {
854
+ const o = R(), n = j(t, o, "dist", "src", "");
851
855
  if (!e) {
852
856
  for (const i of n)
853
857
  i.fullName.type === "library" && r.write(JSON.stringify(i) + `
854
858
  `);
855
859
  return;
856
860
  }
857
- const s = se(t, o, "dist");
861
+ const s = oe(t, o, "dist");
858
862
  for (const i of n)
859
863
  i.fullName.type === "library" && s.addLib(i);
860
864
  for (const i of s.allLibs())
861
865
  r.write(JSON.stringify(i) + `
862
866
  `);
863
867
  }
864
- function G(t, e, r) {
865
- const o = j(), n = L(t, o, "dist", "src", "");
868
+ function C(t, e, r) {
869
+ const o = R(), n = j(t, o, "dist", "src", "");
866
870
  for (const s of n)
867
871
  s.fullName.type === r && e.write(JSON.stringify(s) + `
868
872
  `);
869
873
  }
870
- function pt(t, e) {
871
- G(t, e, "template");
872
- }
873
- function ut(t, e) {
874
- G(t, e, "software");
875
- }
876
874
  function mt(t, e) {
877
- G(t, e, "asset");
875
+ C(t, e, "template");
878
876
  }
879
877
  function gt(t, e) {
880
- G(t, e, "test");
878
+ C(t, e, "software");
879
+ }
880
+ function ht(t, e) {
881
+ C(t, e, "asset");
882
+ }
883
+ function wt(t, e) {
884
+ C(t, e, "test");
881
885
  }
882
- function Se(t, ...e) {
883
- const r = Fe(t, e, { stdio: ["pipe", "inherit", "inherit"] });
886
+ function Ae(t, ...e) {
887
+ const r = Oe(t, e, { stdio: ["pipe", "inherit", "inherit"] });
884
888
  return r.stdin.on("error", (o) => {
885
889
  o.code;
886
890
  }), r;
887
891
  }
888
- function ke(t) {
892
+ function Te(t) {
889
893
  return new Promise((e, r) => {
890
894
  t.on("close", (o) => {
891
895
  e(o);
@@ -896,8 +900,8 @@ function ke(t) {
896
900
  }
897
901
  const N = class N extends v {
898
902
  async run() {
899
- const { flags: e, argv: r } = await this.parse(N), o = E(e["log-level"]), n = r.length == 0 ? ["./src"] : r, s = Se(
900
- ge,
903
+ const { flags: e, argv: r } = await this.parse(N), o = E(e["log-level"]), n = r.length == 0 ? ["./src"] : r, s = Ae(
904
+ we,
901
905
  "check",
902
906
  "--log-level",
903
907
  e["log-level"],
@@ -906,12 +910,12 @@ const N = class N extends v {
906
910
  ...n
907
911
  );
908
912
  try {
909
- oe(o, s.stdin);
913
+ ie(o, s.stdin);
910
914
  } catch (i) {
911
915
  o.error(i);
912
916
  } finally {
913
917
  s.stdin.end();
914
- const i = await ke(s);
918
+ const i = await Te(s);
915
919
  process.exit(i);
916
920
  }
917
921
  }
@@ -919,12 +923,12 @@ const N = class N extends v {
919
923
  l(N, "description", "check tengo sources for language processor an"), // static override args = {
920
924
  // "log-level": Args.string({description: 'logging level'}),
921
925
  // }
922
- l(N, "strict", !1), l(N, "flags", { ...re }), l(N, "examples", ["<%= config.bin %> <%= command.id %>"]);
923
- let Z = N;
926
+ l(N, "strict", !1), l(N, "flags", { ...ne }), l(N, "examples", ["<%= config.bin %> <%= command.id %>"]);
927
+ let X = N;
924
928
  const S = class S extends v {
925
929
  async run() {
926
- const { flags: e } = await this.parse(S), r = E(e["log-level"]), o = this.argv.length == 0 ? ["./src"] : this.argv, n = Se(
927
- ge,
930
+ const { flags: e } = await this.parse(S), r = E(e["log-level"]), o = this.argv.length == 0 ? ["./src"] : this.argv, n = Ae(
931
+ we,
928
932
  "run",
929
933
  "--log-level",
930
934
  e["log-level"],
@@ -933,87 +937,87 @@ const S = class S extends v {
933
937
  ...o
934
938
  );
935
939
  try {
936
- oe(r, n.stdin);
940
+ ie(r, n.stdin);
937
941
  } catch (s) {
938
942
  r.error(s);
939
943
  } finally {
940
944
  n.stdin.end();
941
- const s = await ke(n);
945
+ const s = await Te(n);
942
946
  process.exit(s);
943
947
  }
944
948
  }
945
949
  };
946
- l(S, "description", "run tengo unit tests (.test.tengo)"), l(S, "strict", !1), l(S, "flags", { ...re }), l(S, "examples", ["<%= config.bin %> <%= command.id %>"]);
947
- let K = S;
948
- class X extends v {
950
+ l(S, "description", "run tengo unit tests (.test.tengo)"), l(S, "strict", !1), l(S, "flags", { ...ne }), l(S, "examples", ["<%= config.bin %> <%= command.id %>"]);
951
+ let H = S;
952
+ class Q extends v {
949
953
  async run() {
950
954
  const e = E();
951
- oe(e, x);
955
+ ie(e, T);
952
956
  }
953
957
  }
954
- l(X, "description", "parse sources in current package and dump all found artifacts to stdout"), l(X, "examples", [
958
+ l(Q, "description", "parse sources in current package and dump all found artifacts to stdout"), l(Q, "examples", [
955
959
  "<%= config.bin %> <%= command.id %>"
956
960
  ]);
957
- class H extends v {
961
+ class Y extends v {
958
962
  async run() {
959
963
  const e = E();
960
- mt(e, x);
964
+ ht(e, T);
961
965
  }
962
966
  }
963
- l(H, "description", "parse sources in current package and dump all found tests to stdout"), l(H, "examples", [
967
+ l(Y, "description", "parse sources in current package and dump all found tests to stdout"), l(Y, "examples", [
964
968
  "<%= config.bin %> <%= command.id %>"
965
969
  ]);
966
970
  const A = class A extends v {
967
971
  async run() {
968
972
  const { flags: e } = await this.parse(A), r = E();
969
- dt(r, e.deps, x);
973
+ ut(r, e.deps, T);
970
974
  }
971
975
  };
972
976
  l(A, "description", "parse sources in current package and dump all found templates to stdout"), l(A, "examples", [
973
977
  "<%= config.bin %> <%= command.id %>"
974
978
  ]), l(A, "flags", {
975
- deps: M.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
979
+ deps: F.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
976
980
  });
977
- let Q = A;
978
- class Y extends v {
981
+ let _ = A;
982
+ class ee extends v {
979
983
  async run() {
980
984
  const e = E();
981
- ut(e, x);
985
+ gt(e, T);
982
986
  }
983
987
  }
984
- l(Y, "description", "parse sources in current package and dump all found tests to stdout"), l(Y, "examples", [
988
+ l(ee, "description", "parse sources in current package and dump all found tests to stdout"), l(ee, "examples", [
985
989
  "<%= config.bin %> <%= command.id %>"
986
990
  ]);
987
- class _ extends v {
991
+ class te extends v {
988
992
  async run() {
989
993
  const e = E();
990
- pt(e, x);
994
+ mt(e, T);
991
995
  }
992
996
  }
993
- l(_, "description", "parse sources in current package and dump all found templates to stdout"), l(_, "examples", [
997
+ l(te, "description", "parse sources in current package and dump all found templates to stdout"), l(te, "examples", [
994
998
  "<%= config.bin %> <%= command.id %>"
995
999
  ]);
996
- class ee extends v {
1000
+ class se extends v {
997
1001
  async run() {
998
1002
  const e = E();
999
- gt(e, x);
1003
+ wt(e, T);
1000
1004
  }
1001
1005
  }
1002
- l(ee, "description", "parse sources in current package and dump all found tests to stdout"), l(ee, "examples", [
1006
+ l(se, "description", "parse sources in current package and dump all found tests to stdout"), l(se, "examples", [
1003
1007
  "<%= config.bin %> <%= command.id %>"
1004
1008
  ]);
1005
- const At = {
1006
- build: V,
1007
- check: Z,
1008
- test: K,
1009
- "dump:all": X,
1010
- "dump:assets": H,
1011
- "dump:libs": Q,
1012
- "dump:software": Y,
1013
- "dump:templates": _,
1014
- "dump:tests": ee
1009
+ const xt = {
1010
+ build: K,
1011
+ check: X,
1012
+ test: H,
1013
+ "dump:all": Q,
1014
+ "dump:assets": Y,
1015
+ "dump:libs": _,
1016
+ "dump:software": ee,
1017
+ "dump:templates": te,
1018
+ "dump:tests": se
1015
1019
  };
1016
1020
  export {
1017
- At as COMMANDS
1021
+ xt as COMMANDS
1018
1022
  };
1019
1023
  //# sourceMappingURL=index.mjs.map