@platforma-sdk/tengo-builder 1.14.13 → 1.15.0

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,41 +1,41 @@
1
- var Ee = Object.defineProperty;
2
- var Ne = (t, e, r) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var l = (t, e, r) => Ne(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { spawnSync as Se, spawn as ke } from "node:child_process";
5
- import { Flags as F, Command as $ } from "@oclif/core";
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";
6
6
  import * as f from "node:path";
7
- import * as u from "node:fs";
8
- import { readFileSync as Te } from "node:fs";
9
- import { gunzipSync as xe, gzipSync as Ae } from "node:zlib";
10
- import De from "canonicalize";
11
- import j from "winston";
12
- import * as D from "node:fs/promises";
13
- import { TengoTesterBinaryPath as fe } from "@milaboratories/tengo-tester";
14
- import { stdout as R } from "node:process";
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
15
  function O(t) {
16
16
  throw new Error("Unexpected object: " + t);
17
17
  }
18
- function Fe() {
18
+ function Le() {
19
19
  let t = process.cwd();
20
20
  for (; t; ) {
21
21
  const e = f.join(t, "node_modules");
22
- if (u.existsSync(e)) return e;
22
+ if (p.existsSync(e)) return e;
23
23
  const r = f.resolve(t, "..");
24
24
  if (r === t) break;
25
25
  t = r;
26
26
  }
27
27
  throw new Error("Unable to find node_modules directory.");
28
28
  }
29
- function v(t) {
29
+ function $(t) {
30
30
  try {
31
- const e = u.statSync(t);
31
+ const e = p.statSync(t);
32
32
  return e.isDirectory() ? "dir" : e.isFile() ? "file" : e.isSymbolicLink() ? "link" : "unknown";
33
33
  } catch (e) {
34
34
  if (e.code == "ENOENT") return "absent";
35
35
  throw e;
36
36
  }
37
37
  }
38
- function re(t) {
38
+ function ae(t) {
39
39
  return `${t.type}||${t.pkg}||${t.id}`;
40
40
  }
41
41
  function m(t) {
@@ -44,58 +44,58 @@ function m(t) {
44
44
  function g(t) {
45
45
  return `${t.type}:${t.pkg}:${t.id}`;
46
46
  }
47
- function oe(t, e) {
47
+ function le(t, e) {
48
48
  return t.type == e.type && t.pkg == e.pkg && t.id == e.id;
49
49
  }
50
- function y(t) {
50
+ function h(t) {
51
51
  return `${t.pkg}:${t.id}`;
52
52
  }
53
- function L(t) {
54
- return { name: y(t), version: t.version };
53
+ function I(t) {
54
+ return { name: h(t), version: t.version };
55
55
  }
56
- function Oe(t) {
56
+ function Ie(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 se(t) {
62
+ function ce(t) {
63
63
  return `${t.pkg}:${t.id}:${t.version}`;
64
64
  }
65
- const Re = new TextDecoder(), Me = new TextEncoder();
66
- class de {
67
- constructor(e, r, s) {
65
+ const Ce = new TextDecoder(), Ge = new TextEncoder();
66
+ class he {
67
+ constructor(e, r, o) {
68
68
  l(this, "data");
69
69
  l(this, "content");
70
70
  this.compileMode = e, this.fullName = r;
71
- let { data: n, content: o } = s;
72
- if (n === void 0 && o === void 0)
71
+ let { data: n, content: s } = o;
72
+ if (n === void 0 && s === void 0)
73
73
  throw new Error("Neither data nor content is provided for template constructor");
74
- if (n !== void 0 && o !== void 0)
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(Re.decode(xe(o))), n.type !== "pl.tengo-template.v2"))
76
+ if (n === void 0 && (n = JSON.parse(Ce.decode(Oe(s))), n.type !== "pl.tengo-template.v2"))
77
77
  throw new Error("malformed template");
78
- o === void 0 && (o = Ae(Me.encode(De(n))));
79
- const i = Oe(n);
78
+ s === void 0 && (s = Re(Ge.encode(je(n))));
79
+ const i = Ie(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: ${se(i)} != ${se(r)}`);
82
- this.data = n, this.content = o;
81
+ throw new Error(`Compiled template name don't match it's package and file names: ${ce(i)} != ${ce(r)}`);
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 C {
88
+ class z {
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 s = re(this.nameExtractor(e)), n = this.map.get(s);
95
- return n && !r || this.map.set(s, e), n;
94
+ const o = ae(this.nameExtractor(e)), n = this.map.get(o);
95
+ return n && !r || this.map.set(o, e), n;
96
96
  }
97
97
  get(e) {
98
- return this.map.get(re(e));
98
+ return this.map.get(ae(e));
99
99
  }
100
100
  get array() {
101
101
  const e = [];
@@ -105,19 +105,19 @@ class C {
105
105
  this.map.forEach((r) => e(r, this.nameExtractor(r)));
106
106
  }
107
107
  }
108
- function je() {
109
- return new C((t) => t);
108
+ function Je() {
109
+ return new z((t) => t);
110
110
  }
111
- class I {
111
+ class C {
112
112
  constructor(e) {
113
113
  l(this, "dev");
114
114
  l(this, "dist");
115
- this.nameExtractor = e, this.dev = new C(e), this.dist = new C(e);
115
+ this.nameExtractor = e, this.dev = new z(e), this.dist = new z(e);
116
116
  }
117
- add(e, r, s = !0) {
117
+ add(e, r, o = !0) {
118
118
  switch (e) {
119
119
  case "dist":
120
- return this.dist.add(r, s);
120
+ return this.dist.add(r, o);
121
121
  default:
122
122
  O(e);
123
123
  }
@@ -132,52 +132,60 @@ class I {
132
132
  }
133
133
  array(e) {
134
134
  const r = [];
135
- return this.forEach(e, (s) => r.push(s)), r;
135
+ return this.forEach(e, (o) => r.push(o)), r;
136
136
  }
137
137
  forEach(e, r) {
138
- this.dist.forEach((s, n) => r(this.get(e, n) ?? s, n));
138
+ this.dist.forEach((o, n) => r(this.get(e, n) ?? o, n));
139
139
  }
140
140
  }
141
- class Le {
141
+ class ze {
142
142
  constructor(e) {
143
- l(this, "libs", new I((e) => e.fullName));
144
- l(this, "software", new I((e) => e.fullName));
145
- l(this, "templates", new I((e) => e.fullName));
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));
146
147
  this.compileMode = e;
147
148
  }
148
- populateTemplateDataFromDependencies(e, r, s, n) {
149
- for (const o of s)
150
- switch (o.type) {
149
+ populateTemplateDataFromDependencies(e, r, o, n) {
150
+ for (const s of o)
151
+ switch (s.type) {
151
152
  case "library":
152
- const i = this.getLibOrError(o), a = n.indexOf(y(o));
153
+ const i = this.getLibOrError(s), a = n.indexOf(h(s));
153
154
  if (a >= 0) {
154
- let p = `library import recursion detected: ${n.slice(a).join(" -> ")} -> ${y(o)}`;
155
- throw new Error(p);
155
+ let y = `library import recursion detected: ${n.slice(a).join(" -> ")} -> ${h(s)}`;
156
+ throw new Error(y);
156
157
  }
157
- r.libs[y(o)] = {
158
- ...L(i.fullName),
158
+ r.libs[h(s)] = {
159
+ ...I(i.fullName),
159
160
  src: i.src
160
- }, this.populateTemplateDataFromDependencies(e, r, i.dependencies, [...n, y(o)]);
161
+ }, this.populateTemplateDataFromDependencies(e, r, i.dependencies, [...n, h(s)]);
161
162
  break;
162
163
  case "software":
163
- const c = this.getSoftwareOrError(o);
164
- r.software[y(o)] = {
165
- ...L(c.fullName),
164
+ const c = this.getSoftwareOrError(s);
165
+ r.software[h(s)] = {
166
+ ...I(c.fullName),
166
167
  src: c.src
167
168
  };
168
169
  break;
170
+ case "asset":
171
+ const d = this.getAssetOrError(s);
172
+ r.software[h(s)] = {
173
+ ...I(d.fullName),
174
+ src: d.src
175
+ };
176
+ break;
169
177
  case "template":
170
- if (oe(e, o))
178
+ if (le(e, s))
171
179
  continue;
172
- const d = this.getTemplateOrError(o);
173
- r.templates[y(o)] = d.data;
180
+ const u = this.getTemplateOrError(s);
181
+ r.templates[h(s)] = u.data;
174
182
  break;
175
183
  case "test":
176
184
  throw new Error(
177
- `dependencies tree error: tests should never be part of template: ${g(o)} is dependency of ${y(e)}`
185
+ `dependencies tree error: tests should never be part of template: ${g(s)} is dependency of ${h(e)}`
178
186
  );
179
187
  default:
180
- O(o.type);
188
+ O(s.type);
181
189
  }
182
190
  }
183
191
  /** This method assumes that all dependencies are already added to the compiler's context */
@@ -186,15 +194,16 @@ class Le {
186
194
  throw new Error("unexpected source type");
187
195
  const r = {
188
196
  type: "pl.tengo-template.v2",
189
- ...L(e.fullName),
197
+ ...I(e.fullName),
190
198
  templates: {},
191
199
  libs: {},
192
200
  software: {},
201
+ assets: {},
193
202
  src: e.src
194
203
  };
195
204
  this.populateTemplateDataFromDependencies(e.fullName, r, e.dependencies, []);
196
- const s = new de(e.compileMode, e.fullName, { data: r });
197
- return this.addTemplate(s), s;
205
+ const o = new he(e.compileMode, e.fullName, { data: r });
206
+ return this.addTemplate(o), o;
198
207
  }
199
208
  addLib(e) {
200
209
  const r = this.libs.add(e.compileMode, e, !1);
@@ -214,7 +223,7 @@ class Le {
214
223
  getLibOrError(e) {
215
224
  const r = this.getLib(e);
216
225
  if (!r)
217
- throw new Error(`library not found: ${y(e)}`);
226
+ throw new Error(`library not found: ${h(e)}`);
218
227
  return r;
219
228
  }
220
229
  addSoftware(e) {
@@ -235,7 +244,28 @@ class Le {
235
244
  getSoftwareOrError(e) {
236
245
  const r = this.getSoftware(e);
237
246
  if (!r)
238
- throw new Error(`software info not found: ${y(e)}`);
247
+ throw new Error(`software info not found: ${h(e)}`);
248
+ return r;
249
+ }
250
+ addAsset(e) {
251
+ const r = this.assets.add(e.compileMode, e, !1);
252
+ if (r)
253
+ throw new Error(
254
+ `compiler already contain info for asset: adding = ${m(e.fullName)}, contains = ${m(r.fullName)}`
255
+ );
256
+ }
257
+ allAssets() {
258
+ return this.assets.array(this.compileMode);
259
+ }
260
+ getAsset(e) {
261
+ if (e.type !== "asset")
262
+ throw new Error(`illegal artifact type: got ${e.type} instead of 'asset`);
263
+ return this.assets.get(this.compileMode, e);
264
+ }
265
+ getAssetOrError(e) {
266
+ const r = this.getAsset(e);
267
+ if (!r)
268
+ throw new Error(`asset info not found: ${h(e)}`);
239
269
  return r;
240
270
  }
241
271
  addTemplate(e) {
@@ -256,7 +286,7 @@ class Le {
256
286
  getTemplateOrError(e) {
257
287
  const r = this.getTemplate(e);
258
288
  if (!r)
259
- throw new Error(`template not found: ${y(e)}`);
289
+ throw new Error(`template not found: ${h(e)}`);
260
290
  return r;
261
291
  }
262
292
  getArtefact(e) {
@@ -267,6 +297,8 @@ class Le {
267
297
  return this.getLib(e);
268
298
  case "software":
269
299
  return this.getSoftware(e);
300
+ case "asset":
301
+ return this.getAsset(e);
270
302
  case "test":
271
303
  return;
272
304
  default:
@@ -284,79 +316,82 @@ class Le {
284
316
  });
285
317
  }
286
318
  compileAndAdd(e) {
287
- const r = { templates: [], libs: [], software: [] };
288
- let s = [];
319
+ const r = { templates: [], libs: [], software: [], assets: [] };
320
+ let o = [];
289
321
  for (const n of e)
290
- n.fullName.type === "library" ? (this.addLib(n), r.libs.push(n)) : n.fullName.type === "software" ? (this.addSoftware(n), r.software.push(n)) : s.push(n);
291
- for (; s.length > 0; ) {
322
+ n.fullName.type === "library" ? (this.addLib(n), r.libs.push(n)) : n.fullName.type === "software" ? (this.addSoftware(n), r.software.push(n)) : n.fullName.type === "asset" ? (this.addAsset(n), r.assets.push(n)) : o.push(n);
323
+ for (; o.length > 0; ) {
292
324
  const n = [];
293
- for (const o of s) {
294
- const i = o.dependencies.filter(
325
+ for (const s of o) {
326
+ const i = s.dependencies.filter(
295
327
  (a) => !this.getArtefact(a) && // allow self reference for templates
296
- !(o.fullName.type === "template" && oe(o.fullName, a))
328
+ !(s.fullName.type === "template" && le(s.fullName, a))
297
329
  );
298
330
  if (i.length > 0) {
299
- let a = `Unsatisfied dependencies in ${m(o.fullName)}:
331
+ let a = `Unsatisfied dependencies in ${m(s.fullName)}:
300
332
  `;
301
333
  for (const c of i)
302
334
  a += ` - ${g(c)}
303
335
  `;
304
- n.push({ src: o, err: Error(a) });
336
+ n.push({ src: s, err: Error(a) });
305
337
  continue;
306
338
  }
307
- switch (o.fullName.type) {
339
+ switch (s.fullName.type) {
308
340
  case "library":
309
- this.addLib(o), r.libs.push(o);
341
+ this.addLib(s), r.libs.push(s);
310
342
  break;
311
343
  case "software":
312
- this.addSoftware(o), r.software.push(o);
344
+ this.addSoftware(s), r.software.push(s);
345
+ break;
346
+ case "asset":
347
+ this.addAsset(s), r.assets.push(s);
313
348
  break;
314
349
  case "template":
315
350
  try {
316
- const a = this.compileAndAddTemplate(o);
351
+ const a = this.compileAndAddTemplate(s);
317
352
  r.templates.push(a);
318
353
  } catch (a) {
319
- let c = `Unsatisfied dependencies in ${m(o.fullName)}:
354
+ let c = `Unsatisfied dependencies in ${m(s.fullName)}:
320
355
  `;
321
356
  c += ` - ${a.message}
322
- `, n.push({ src: o, err: Error(c) });
357
+ `, n.push({ src: s, err: Error(c) });
323
358
  }
324
359
  break;
325
360
  case "test":
326
361
  break;
327
362
  default:
328
- O(o.fullName.type);
363
+ O(s.fullName.type);
329
364
  }
330
365
  }
331
- if (s.length === n.length) {
332
- let o = "";
366
+ if (o.length === n.length) {
367
+ let s = "";
333
368
  for (const i of n)
334
- o += `
369
+ s += `
335
370
  ${i.err.message}`;
336
- throw new Error(o);
371
+ throw new Error(s);
337
372
  }
338
- s = n.map(({ src: o }) => o);
373
+ o = n.map(({ src: s }) => s);
339
374
  }
340
375
  return r;
341
376
  }
342
377
  }
343
- const ne = "[_a-zA-Z][_a-zA-Z0-9]*", M = (t, e) => new RegExp(
378
+ const fe = "[_a-zA-Z][_a-zA-Z0-9]*", R = (t, e) => new RegExp(
344
379
  `\\b${t}\\.(?<fnCall>(?<fnName>` + e + ')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'
345
- ), Ie = (t) => M(t, "getTemplateId"), Ce = (t) => M(t, "getSoftwareInfo"), ie = (t) => M(t, "importTemplate"), ae = (t) => M(t, "importSoftware"), Ge = /^\s*(\/\/)|(\/\*.*\*\/)/, Je = /^\s*\/\*/, ze = /\*\//, pe = /\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/, Pe = new RegExp(
346
- `\\b(?<importName>${ne}(\\.${ne})*)${pe.source}`
347
- ), We = /(?<pkgName>[^"]+)?:(?<depID>[^"]+)/;
348
- class ue {
349
- constructor(e, r, s, n, o) {
350
- this.compileMode = e, this.fullName = r, this.src = s, this.srcName = n, this.dependencies = o;
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 {
384
+ constructor(e, r, o, n, s) {
385
+ this.compileMode = e, this.fullName = r, this.src = o, this.srcName = n, this.dependencies = s;
351
386
  }
352
387
  }
353
- function me(t, e, r, s) {
354
- const n = Te(e).toString(), { deps: o, normalized: i } = Ue(n, r, s);
355
- return new ue(t, r, i, e, o.array);
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);
356
391
  }
357
- function Ue(t, e, r) {
358
- const s = je(), n = t.split(`
359
- `), o = [];
392
+ function Xe(t, e, r) {
393
+ const o = Je(), n = t.split(`
394
+ `), s = [];
360
395
  let i = {
361
396
  isInCommentBlock: !1,
362
397
  tplDepREs: /* @__PURE__ */ new Map()
@@ -364,332 +399,358 @@ function Ue(t, e, r) {
364
399
  for (const c of n) {
365
400
  a++;
366
401
  try {
367
- const d = qe(
402
+ const d = He(
368
403
  c,
369
404
  i,
370
405
  e.pkg,
371
406
  r
372
407
  );
373
- o.push(d.line), i = d.context, d.artifact && s.add(d.artifact);
408
+ s.push(d.line), i = d.context, d.artifact && o.add(d.artifact);
374
409
  } catch (d) {
375
410
  throw new Error(`[line ${a}]: ${d.message}
376
411
  ${c}`);
377
412
  }
378
413
  }
379
414
  return {
380
- normalized: o.join(`
415
+ normalized: s.join(`
381
416
  `),
382
- deps: s
417
+ deps: o
383
418
  };
384
419
  }
385
- function qe(t, e, r, s) {
420
+ function He(t, e, r, o) {
386
421
  if (e.isInCommentBlock)
387
- return ze.exec(t) && (e.isInCommentBlock = !1), { line: t, context: e, artifact: void 0 };
388
- if (Ge.exec(t))
422
+ return Ve.exec(t) && (e.isInCommentBlock = !1), { line: t, context: e, artifact: void 0 };
423
+ if (qe.exec(t))
389
424
  return { line: t, context: e, artifact: void 0 };
390
- if (Je.exec(t))
425
+ if (Be.exec(t))
391
426
  return e.isInCommentBlock = !0, { line: t, context: e, artifact: void 0 };
392
- const n = pe.exec(t);
427
+ const n = we.exec(t);
393
428
  if (n) {
394
- const o = Be(t);
395
- if (o.module === "plapi")
396
- return e.tplDepREs.has(o.module) || e.tplDepREs.set(o.module, [
397
- ["template", Ie(o.alias)],
398
- ["software", Ce(o.alias)]
429
+ const s = Qe(t);
430
+ if (s.module === "plapi")
431
+ return e.tplDepREs.has(s.module) || e.tplDepREs.set(s.module, [
432
+ ["template", We(s.alias)],
433
+ ["software", Pe(s.alias)]
399
434
  ]), { line: t, context: e, artifact: void 0 };
400
- (o.module === "@milaboratory/tengo-sdk:ll" || o.module === "@platforma-sdk/workflow-tengo:ll" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && o.module === ":ll") && (e.tplDepREs.has(o.module) || e.tplDepREs.set(o.module, [
401
- ["template", ie(o.alias)],
402
- ["software", ae(o.alias)]
403
- ])), (o.module === "@milaboratory/tengo-sdk:assets" || o.module === "@platforma-sdk/workflow-tengo:assets" || (r === "@milaboratory/tengo-sdk" || r === "@platforma-sdk/workflow-tengo") && o.module === ":assets") && (e.tplDepREs.has(o.module) || e.tplDepREs.set(o.module, [
404
- ["template", ie(o.alias)],
405
- ["software", ae(o.alias)]
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)]
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)]
406
442
  ]));
407
- const i = le(o.module, "library", r);
443
+ const i = ue(s.module, "library", r);
408
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 };
409
445
  }
410
446
  if (e.tplDepREs.size > 0)
411
- for (const [o, i] of e.tplDepREs)
447
+ for (const [s, i] of e.tplDepREs)
412
448
  for (const [a, c] of i) {
413
449
  const d = c.exec(t);
414
450
  if (!d || !d.groups)
415
451
  continue;
416
- const { fnCall: p, templateName: b, fnName: h } = d.groups;
417
- if (!p || !b || !h)
452
+ const { fnCall: u, templateName: y, fnName: b } = d.groups;
453
+ if (!u || !y || !b)
418
454
  throw Error("failed to parse template import statement");
419
- const w = le(b, a, r);
455
+ const w = ue(y, a, r);
420
456
  if (!w)
421
- throw Error(`failed to parse artifact name in ${h} import statement`);
422
- return t = t.replace(p, `${h}("${w.pkg}:${w.id}")`), { line: t, context: e, artifact: w };
457
+ throw Error(`failed to parse artifact name in ${b} import statement`);
458
+ return t = t.replace(u, `${b}("${w.pkg}:${w.id}")`), { line: t, context: e, artifact: w };
423
459
  }
424
460
  return { line: t, context: e, artifact: void 0 };
425
461
  }
426
- function Be(t) {
427
- const e = Pe.exec(t);
462
+ function Qe(t) {
463
+ const e = Ze.exec(t);
428
464
  if (!e || !e.groups)
429
465
  throw Error("failed to parse 'import' statement");
430
- const { importName: r, moduleName: s } = e.groups;
431
- if (!r || !s)
466
+ const { importName: r, moduleName: o } = e.groups;
467
+ if (!r || !o)
432
468
  throw Error("failed to parse 'import' statement");
433
469
  return {
434
- module: s,
470
+ module: o,
435
471
  alias: r
436
472
  };
437
473
  }
438
- function le(t, e, r) {
439
- const s = We.exec(t);
440
- if (!s)
474
+ function ue(t, e, r) {
475
+ const o = Ke.exec(t);
476
+ if (!o)
441
477
  return;
442
- if (!s.groups)
478
+ if (!o.groups)
443
479
  throw Error(
444
480
  "failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'"
445
481
  );
446
- const { pkgName: n, depID: o } = s.groups;
447
- if (!o)
482
+ const { pkgName: n, depID: s } = o.groups;
483
+ if (!s)
448
484
  throw Error(
449
485
  "failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'"
450
486
  );
451
- return { type: e, pkg: n ?? r, id: o };
487
+ return { type: e, pkg: n ?? r, id: s };
452
488
  }
453
- const G = ".plj.gz", J = ".lib.tengo", z = ".sw.json", ce = ".test.tengo", P = ".tpl.tengo", W = ".lib.tengo", U = ".sw.json", Ve = [W, P, U];
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];
454
490
  function E(t = "debug") {
455
- return j.createLogger({
491
+ return J.createLogger({
456
492
  level: t,
457
- format: j.format.printf(({ level: e, message: r }) => `${e.padStart(6, " ")}: ${r}`),
493
+ format: J.format.printf(({ level: e, message: r }) => `${e.padStart(6, " ")}: ${r}`),
458
494
  transports: [
459
- new j.transports.Console({
495
+ new J.transports.Console({
460
496
  stderrLevels: ["error", "warn", "info", "debug"],
461
497
  handleExceptions: !0
462
498
  })
463
499
  ]
464
500
  });
465
501
  }
466
- function k() {
467
- return JSON.parse(u.readFileSync("package.json").toString());
502
+ function j() {
503
+ return JSON.parse(p.readFileSync("package.json").toString());
468
504
  }
469
- function ge(t, e) {
505
+ function be(t, e) {
470
506
  return f.resolve(e, t, "tengo", "lib");
471
507
  }
472
- function he(t, e) {
508
+ function $e(t, e) {
473
509
  return f.resolve(e, t, "tengo", "tpl");
474
510
  }
475
- function we(t, e) {
511
+ function ve(t, e) {
476
512
  return f.resolve(e, t, "tengo", "software");
477
513
  }
478
- function ye(t, e, r, s, n = !1) {
479
- const o = f.resolve(s, "package.json");
480
- if (v(o) !== "file") {
481
- for (const w of u.readdirSync(s)) {
482
- const $e = v(f.join(s, w)) === "link", te = f.resolve(s, w);
483
- v(te) === "dir" && ye(t, e, r, te, $e);
514
+ function Ee(t, e) {
515
+ return f.resolve(e, t, "tengo", "asset");
516
+ }
517
+ function Ne(t, e, r, o, n = !1) {
518
+ const s = f.resolve(o, "package.json");
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);
484
523
  }
485
524
  return;
486
525
  }
487
- const i = ge("dist", s), a = he("dist", s), c = we("dist", s), d = v(i) === "dir", p = v(a) === "dir", b = v(c) === "dir";
488
- if (!d && !p && !b)
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";
527
+ if (!u && !y && !b && !w)
489
528
  return;
490
- const h = JSON.parse(u.readFileSync(o).toString());
491
- if (h.name !== r.name) {
492
- if (v(f.resolve(s, "node_modules")) === "dir" && n)
529
+ const D = JSON.parse(p.readFileSync(s).toString());
530
+ if (D.name !== r.name) {
531
+ if ($(f.resolve(o, "node_modules")) === "dir" && n)
493
532
  throw new Error(
494
- `nested node_modules is a sign of library dependencies version incompatibility in ${s}`
533
+ `nested node_modules is a sign of library dependencies version incompatibility in ${o}`
495
534
  );
496
- d && Ze(t, h, "dist", i, e), p && Ke(t, h, "dist", a, e), b && Xe(t, h, "dist", c, e);
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);
497
536
  }
498
537
  }
499
- function Ze(t, e, r, s, n) {
500
- for (const o of u.readdirSync(s)) {
501
- const i = f.resolve(s, o);
502
- if (!o.endsWith(J)) throw new Error(`unexpected file in 'lib' folder: ${i}`);
538
+ function _e(t, e, r, o, n) {
539
+ for (const s of p.readdirSync(o)) {
540
+ const i = f.resolve(o, s);
541
+ if (!s.endsWith(P)) throw new Error(`unexpected file in 'lib' folder: ${i}`);
503
542
  const a = {
504
543
  type: "library",
505
544
  pkg: e.name,
506
- id: o.slice(0, o.length - J.length),
545
+ id: s.slice(0, s.length - P.length),
507
546
  version: e.version
508
- }, c = me(r, i, a, !0);
547
+ }, c = ye(r, i, a, !0);
509
548
  if (n.addLib(c), t.debug(`Adding dependency ${m(a)} from ${i}`), c.dependencies.length > 0) {
510
549
  t.debug("Dependencies:");
511
550
  for (const d of c.dependencies) t.debug(` - ${g(d)}`);
512
551
  }
513
552
  }
514
553
  }
515
- function Ke(t, e, r, s, n) {
516
- for (const o of u.readdirSync(s)) {
517
- const i = f.resolve(s, o);
518
- if (!o.endsWith(G)) throw new Error(`unexpected file in 'tpl' folder: ${i}`);
554
+ function et(t, e, r, o, n) {
555
+ for (const s of p.readdirSync(o)) {
556
+ const i = f.resolve(o, s);
557
+ if (!s.endsWith(W)) throw new Error(`unexpected file in 'tpl' folder: ${i}`);
519
558
  const a = {
520
559
  type: "template",
521
560
  pkg: e.name,
522
- id: o.slice(0, o.length - G.length),
561
+ id: s.slice(0, s.length - W.length),
523
562
  version: e.version
524
- }, c = new de(r, a, { content: u.readFileSync(i) });
563
+ }, c = new he(r, a, { content: p.readFileSync(i) });
525
564
  n.addTemplate(c), t.debug(`Adding dependency ${m(a)} from ${i}`);
526
565
  }
527
566
  }
528
- function Xe(t, e, r, s, n) {
529
- for (const o of u.readdirSync(s)) {
530
- const i = f.resolve(s, o);
531
- if (!o.endsWith(z))
567
+ function tt(t, e, r, o, n) {
568
+ for (const s of p.readdirSync(o)) {
569
+ const i = f.resolve(o, s);
570
+ if (!s.endsWith(T))
532
571
  throw new Error(`unexpected file in 'software' folder: ${i}`);
533
572
  const a = {
534
573
  type: "software",
535
574
  pkg: e.name,
536
- id: o.slice(0, o.length - z.length),
575
+ id: s.slice(0, s.length - T.length),
537
576
  version: e.version
538
- }, c = new ue(r, a, u.readFileSync(i).toString(), i, []);
539
- n.addSoftware(c), t.debug(`Adding dependency ${m(a)} from ${i}`);
577
+ }, c = new te(r, a, p.readFileSync(i).toString(), i, []);
578
+ t.debug(`Adding dependency ${m(a)} from ${i}`), n.addSoftware(c);
540
579
  }
541
580
  }
542
- function T(t, e, r, s, n) {
543
- const o = [];
544
- for (const i of u.readdirSync(f.join(s, n))) {
545
- const a = f.join(n, i), c = f.join(s, a);
546
- if (v(c) === "dir") {
547
- const w = T(t, e, r, s, a);
548
- o.push(...w);
581
+ function st(t, e, r, o, n) {
582
+ for (const s of p.readdirSync(o)) {
583
+ const i = f.resolve(o, s);
584
+ if (!s.endsWith(T))
585
+ throw new Error(`unexpected file in 'asset' folder: ${i}`);
586
+ const a = {
587
+ type: "asset",
588
+ pkg: e.name,
589
+ id: s.slice(0, s.length - T.length),
590
+ version: e.version
591
+ }, c = new te(r, a, p.readFileSync(i).toString(), i, []);
592
+ t.debug(`Adding dependency ${m(a)} from ${i}`), n.addAsset(c);
593
+ }
594
+ }
595
+ function L(t, e, r, o, n) {
596
+ const s = [];
597
+ for (const i of p.readdirSync(f.join(o, n))) {
598
+ const a = f.join(n, i), c = f.join(o, a);
599
+ if ($(c) === "dir") {
600
+ const w = L(t, e, r, o, a);
601
+ s.push(...w);
549
602
  continue;
550
603
  }
551
- const d = i === "index.lib.tengo" ? `${f.basename(n)}.lib.tengo` : a, p = He(e, d.replaceAll(f.sep, "."));
552
- if (!p)
604
+ const d = i === "index.lib.tengo" ? `${f.basename(n)}.lib.tengo` : a, u = rt(e, d.replaceAll(f.sep, "."));
605
+ if (!u)
553
606
  continue;
554
- const b = f.resolve(s, a);
555
- t.debug(`Parsing ${m(p)} from ${b}`);
556
- const h = me(r, b, p, !0);
557
- if (h.dependencies.length > 0) {
607
+ const y = f.resolve(o, a);
608
+ t.debug(`Parsing ${m(u)} from ${y}`);
609
+ const b = ye(r, y, u, !0);
610
+ if (b.dependencies.length > 0) {
558
611
  t.debug("Detected dependencies:");
559
- for (const w of h.dependencies) t.debug(` - ${g(w)}`);
612
+ for (const w of b.dependencies) t.debug(` - ${g(w)}`);
560
613
  }
561
- o.push(h);
614
+ s.push(b);
562
615
  }
563
- return o;
616
+ return s;
564
617
  }
565
- function Y(t, e, r) {
566
- const s = new Le(r);
567
- return ye(t, s, e, Fe()), s;
618
+ function se(t, e, r) {
619
+ const o = new ze(r);
620
+ return Ne(t, o, e, Le()), o;
568
621
  }
569
- function He(t, e) {
622
+ function rt(t, e) {
570
623
  const r = { pkg: t.name, version: t.version };
571
- return e.endsWith(W) ? {
624
+ return e.endsWith(q) ? {
572
625
  ...r,
573
- id: e.substring(0, e.length - W.length),
626
+ id: e.substring(0, e.length - q.length),
574
627
  type: "library"
575
- } : e.endsWith(P) ? {
576
- ...r,
577
- id: e.substring(0, e.length - P.length),
578
- type: "template"
579
628
  } : e.endsWith(U) ? {
580
629
  ...r,
581
630
  id: e.substring(0, e.length - U.length),
631
+ type: "template"
632
+ } : e.endsWith(B) ? {
633
+ ...r,
634
+ id: e.substring(0, e.length - B.length),
582
635
  type: "software"
583
- } : e.endsWith(ce) ? {
636
+ } : e.endsWith(me) ? {
584
637
  ...r,
585
- id: e.substring(0, e.length - ce.length),
638
+ id: e.substring(0, e.length - me.length),
586
639
  type: "test"
587
640
  } : null;
588
641
  }
589
- function Qe(t, e) {
590
- const r = k(), s = Y(t, r, e), n = T(t, r, e, "src", "");
642
+ function ot(t, e) {
643
+ const r = j(), o = se(t, r, e), n = L(t, r, e, "src", "");
591
644
  if (n.length === 0) {
592
645
  const i = [];
593
- for (const a of Ve)
646
+ for (const a of Ye)
594
647
  i.push(`*${a}`);
595
648
  t.error(`Nothing to compile. Looked for ${i.join(", ")}`), process.exit(1);
596
649
  }
597
650
  t.info(`Compiling '${e}'...`);
598
- const o = s.compileAndAdd(n);
599
- return t.debug("Done."), o;
651
+ const s = o.compileAndAdd(n);
652
+ return t.debug("Done."), s;
600
653
  }
601
- function Ye(t, e, r) {
654
+ function nt(t, e, r) {
602
655
  if (e.libs.length > 0) {
603
- const s = ge(r, ".");
604
- u.mkdirSync(s, { recursive: !0 });
656
+ const o = be(r, ".");
657
+ p.mkdirSync(o, { recursive: !0 });
605
658
  for (const n of e.libs) {
606
- const o = f.resolve(s, n.fullName.id + J);
607
- t.info(` - writing ${o}`), u.writeFileSync(o, n.src);
659
+ const s = f.resolve(o, n.fullName.id + P);
660
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
608
661
  }
609
662
  }
610
663
  if (e.templates.length > 0) {
611
- const s = he(r, ".");
612
- u.mkdirSync(s, { recursive: !0 });
664
+ const o = $e(r, ".");
665
+ p.mkdirSync(o, { recursive: !0 });
613
666
  for (const n of e.templates) {
614
- const o = f.resolve(s, n.fullName.id + G);
615
- t.info(` - writing ${o}`), u.writeFileSync(o, n.content);
667
+ const s = f.resolve(o, n.fullName.id + W);
668
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.content);
616
669
  }
617
670
  }
618
671
  if (e.software.length > 0) {
619
- const s = we(r, ".");
620
- u.mkdirSync(s, { recursive: !0 });
672
+ const o = ve(r, ".");
673
+ p.mkdirSync(o, { recursive: !0 });
674
+ for (const n of e.software) {
675
+ const s = f.resolve(o, n.fullName.id + T);
676
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
677
+ }
678
+ }
679
+ if (e.assets.length > 0) {
680
+ const o = Ee(r, ".");
681
+ p.mkdirSync(o, { recursive: !0 });
621
682
  for (const n of e.software) {
622
- const o = f.resolve(s, n.fullName.id + z);
623
- t.info(` - writing ${o}`), u.writeFileSync(o, n.src);
683
+ const s = f.resolve(o, n.fullName.id + T);
684
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
624
685
  }
625
686
  }
626
687
  }
627
- const _ = {
628
- "log-level": F.string({
688
+ const re = {
689
+ "log-level": M.string({
629
690
  description: "logging level",
630
691
  default: "info",
631
692
  options: ["error", "warn", "info", "debug"]
632
693
  })
633
- }, _e = {
634
- "generate-tags": F.boolean({
694
+ }, it = {
695
+ "generate-tags": M.boolean({
635
696
  description: "generate tags, default false",
636
697
  default: !1
637
698
  }),
638
- "tags-file": F.file({
699
+ "tags-file": M.file({
639
700
  description: 'where to put ".tags" file, it should be a root of VS Code project',
640
701
  default: "../../.tags"
641
702
  // usually a user opens a directory with all blocks
642
703
  }),
643
- "tags-additional-args": F.string({
704
+ "tags-additional-args": M.string({
644
705
  description: "additional flags for universal-ctags command: e.g. -e for emacs",
645
706
  default: [],
646
707
  multiple: !0,
647
708
  delimiter: ","
648
709
  })
649
- }, x = class x extends $ {
710
+ }, k = class k extends v {
650
711
  async run() {
651
- const { flags: e } = await this.parse(x), r = E(e["log-level"]), s = k(), n = Qe(r, "dist");
652
- Ye(r, n, "dist"), r.info("");
653
- let o = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
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("");
714
+ let s = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
654
715
  `;
655
- o += `declare type TplName = ${n.templates.map((p) => '"' + p.fullName.id + '"').join(" | ")};
656
- `, o += `declare const Templates: Record<TplName, TemplateFromFile>;
657
- `, o += `export { Templates };
716
+ s += `declare type TplName = ${n.templates.map((u) => '"' + u.fullName.id + '"').join(" | ")};
717
+ `, s += `declare const Templates: Record<TplName, TemplateFromFile>;
718
+ `, s += `export { Templates };
658
719
  `;
659
720
  let i = `module.exports = { Templates: {
660
721
  `, a = `import { resolve } from 'node:path';
661
722
  export const Templates = {
662
723
  `;
663
724
  const c = n.templates.map(
664
- (p) => ` '${p.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${p.fullName.id}.plj.gz') }`
725
+ (u) => ` '${u.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${u.fullName.id}.plj.gz') }`
665
726
  ).join(`,
666
727
  `), d = n.templates.map(
667
- (p) => ` '${p.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${p.fullName.id}.plj.gz') }`
728
+ (u) => ` '${u.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${u.fullName.id}.plj.gz') }`
668
729
  ).join(`,
669
730
  `);
670
731
  i += c, a += d, i += `
671
732
  }};
672
733
  `, a += `
673
734
  };
674
- `, await D.writeFile("dist/index.d.ts", o), s.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)), et(e), e["generate-tags"] && tt(r, e), r.info("Template Pack build done.");
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.");
675
736
  }
676
737
  };
677
- l(x, "description", "build tengo sources into single distributable pack file"), l(x, "examples", ["<%= config.bin %> <%= command.id %>"]), l(x, "flags", {
678
- ..._,
679
- ..._e
738
+ 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
680
741
  });
681
- let q = x;
682
- function et(t) {
742
+ let V = k;
743
+ function at(t) {
683
744
  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(","));
684
745
  }
685
- function tt(t, e) {
746
+ function lt(t, e) {
686
747
  var a;
687
- const r = f.resolve(e["tags-file"]), s = f.dirname(r), n = e["tags-additional-args"], o = rt(s);
748
+ const r = f.resolve(e["tags-file"]), o = f.dirname(r), n = e["tags-additional-args"], s = ct(o);
688
749
  t.info(
689
- `Generating tags for tengo autocompletion from "${s}" in "${r}", additional arguments: "${n}".
690
- Found ${o.length} tengo files...`
750
+ `Generating tags for tengo autocompletion from "${o}" in "${r}", additional arguments: "${n}".
751
+ Found ${s.length} tengo files...`
691
752
  );
692
- const i = Se(
753
+ const i = De(
693
754
  "ctags",
694
755
  [
695
756
  "-f",
@@ -702,12 +763,12 @@ Found ${o.length} tengo files...`
702
763
  "--kinddef-tengo=c,constant,constant",
703
764
  '--regex-tengo=/^\\s*(.*) := ("|\\{).*/\\1/c/',
704
765
  "-R",
705
- ...o
766
+ ...s
706
767
  ],
707
768
  {
708
769
  env: process.env,
709
770
  stdio: "inherit",
710
- cwd: s
771
+ cwd: o
711
772
  }
712
773
  );
713
774
  if ((a = i.error) != null && a.message.includes("ENOENT")) {
@@ -721,112 +782,122 @@ For vscode, you should also install ctags extension:
721
782
  https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
722
783
  return;
723
784
  }
724
- ot(i, "failed to generate ctags"), t.info("Generation of tags is done.");
785
+ ft(i, "failed to generate ctags"), t.info("Generation of tags is done.");
725
786
  }
726
- function rt(t) {
727
- const e = u.readdirSync(t, { withFileTypes: !0, recursive: !0 }), r = [];
728
- return e.forEach((s) => {
729
- if (!s.isDirectory() && s.name.endsWith(".tengo")) {
730
- const n = f.join(s.parentPath, s.name).replace(t, ".");
787
+ function ct(t) {
788
+ const e = p.readdirSync(t, { withFileTypes: !0, recursive: !0 }), r = [];
789
+ return e.forEach((o) => {
790
+ if (!o.isDirectory() && o.name.endsWith(".tengo")) {
791
+ const n = f.join(o.parentPath, o.name).replace(t, ".");
731
792
  r.push(n);
732
793
  }
733
794
  }), r;
734
795
  }
735
- function ot(t, e) {
796
+ function ft(t, e) {
736
797
  t.error && console.log(t.error);
737
798
  const r = e;
738
799
  t.status !== 0 && console.log(`WARN: ${r} the build will continue as-is`);
739
800
  }
740
- function ee(t, e) {
741
- const r = k(), s = T(t, r, "dist", "src", ""), n = Y(t, r, "dist");
742
- for (const o of n.allLibs())
801
+ function oe(t, e) {
802
+ const r = j(), o = L(t, r, "dist", "src", ""), n = se(t, r, "dist");
803
+ for (const s of n.allLibs())
804
+ t.debug(
805
+ `Dumping to pl-tester: ${g(s.fullName)}`
806
+ ), e.write(JSON.stringify(s) + `
807
+ `);
808
+ for (const s of o)
809
+ s.fullName.type === "library" && (t.debug(
810
+ `Dumping to pl-tester: ${g(s.fullName)}`
811
+ ), e.write(JSON.stringify(s) + `
812
+ `));
813
+ for (const s of n.allTemplates())
743
814
  t.debug(
744
- `Dumping to pl-tester: ${g(o.fullName)}`
745
- ), e.write(JSON.stringify(o) + `
815
+ `Dumping to pl-tester: ${g(s.fullName)}`
816
+ ), e.write(JSON.stringify(s) + `
746
817
  `);
747
- for (const o of s)
748
- o.fullName.type === "library" && (t.debug(
749
- `Dumping to pl-tester: ${g(o.fullName)}`
750
- ), e.write(JSON.stringify(o) + `
818
+ for (const s of o)
819
+ s.fullName.type === "template" && (t.debug(
820
+ `Dumping to pl-tester: ${g(s.fullName)} ${s.srcName}`
821
+ ), e.write(JSON.stringify(s) + `
751
822
  `));
752
- for (const o of n.allTemplates())
823
+ for (const s of n.allSoftware())
753
824
  t.debug(
754
- `Dumping to pl-tester: ${g(o.fullName)}`
755
- ), e.write(JSON.stringify(o) + `
825
+ `Dumping to pl-tester: ${g(s.fullName)}`
826
+ ), e.write(JSON.stringify(s) + `
756
827
  `);
757
- for (const o of s)
758
- o.fullName.type === "template" && (t.debug(
759
- `Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`
760
- ), e.write(JSON.stringify(o) + `
828
+ for (const s of o)
829
+ s.fullName.type === "software" && (t.debug(
830
+ `Dumping to pl-tester: ${g(s.fullName)}`
831
+ ), e.write(JSON.stringify(s) + `
761
832
  `));
762
- for (const o of n.allSoftware())
833
+ for (const s of n.allAssets())
763
834
  t.debug(
764
- `Dumping to pl-tester: ${g(o.fullName)}`
765
- ), e.write(JSON.stringify(o) + `
835
+ `Dumping to pl-tester: ${g(s.fullName)}`
836
+ ), e.write(JSON.stringify(s) + `
766
837
  `);
767
- for (const o of s)
768
- o.fullName.type === "software" && (t.debug(
769
- `Dumping to pl-tester: ${g(o.fullName)}`
770
- ), e.write(JSON.stringify(o) + `
838
+ for (const s of o)
839
+ s.fullName.type === "asset" && (t.debug(
840
+ `Dumping to pl-tester: ${g(s.fullName)}`
841
+ ), e.write(JSON.stringify(s) + `
771
842
  `));
772
- for (const o of s)
773
- o.fullName.type === "test" && (t.debug(
774
- `Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`
775
- ), e.write(JSON.stringify(o) + `
843
+ for (const s of o)
844
+ s.fullName.type === "test" && (t.debug(
845
+ `Dumping to pl-tester: ${g(s.fullName)} ${s.srcName}`
846
+ ), e.write(JSON.stringify(s) + `
776
847
  `));
777
848
  }
778
- function st(t, e, r) {
779
- const s = k(), n = T(t, s, "dist", "src", "");
849
+ function dt(t, e, r) {
850
+ const o = j(), n = L(t, o, "dist", "src", "");
780
851
  if (!e) {
781
852
  for (const i of n)
782
853
  i.fullName.type === "library" && r.write(JSON.stringify(i) + `
783
854
  `);
784
855
  return;
785
856
  }
786
- const o = Y(t, s, "dist");
857
+ const s = se(t, o, "dist");
787
858
  for (const i of n)
788
- i.fullName.type === "library" && o.addLib(i);
789
- for (const i of o.allLibs())
859
+ i.fullName.type === "library" && s.addLib(i);
860
+ for (const i of s.allLibs())
790
861
  r.write(JSON.stringify(i) + `
791
862
  `);
792
863
  }
793
- function nt(t, e) {
794
- const r = k(), s = T(t, r, "dist", "src", "");
795
- for (const n of s)
796
- n.fullName.type === "template" && e.write(JSON.stringify(n) + `
864
+ function G(t, e, r) {
865
+ const o = j(), n = L(t, o, "dist", "src", "");
866
+ for (const s of n)
867
+ s.fullName.type === r && e.write(JSON.stringify(s) + `
797
868
  `);
798
869
  }
799
- function it(t, e) {
800
- const r = k(), s = T(t, r, "dist", "src", "");
801
- for (const n of s)
802
- n.fullName.type === "software" && e.write(JSON.stringify(n) + `
803
- `);
870
+ function pt(t, e) {
871
+ G(t, e, "template");
804
872
  }
805
- function at(t, e) {
806
- const r = k(), s = T(t, r, "dist", "src", "");
807
- for (const n of s)
808
- n.fullName.type === "test" && e.write(JSON.stringify(n) + `
809
- `);
873
+ function ut(t, e) {
874
+ G(t, e, "software");
875
+ }
876
+ function mt(t, e) {
877
+ G(t, e, "asset");
810
878
  }
811
- function be(t, ...e) {
812
- const r = ke(t, e, { stdio: ["pipe", "inherit", "inherit"] });
813
- return r.stdin.on("error", (s) => {
814
- s.code;
879
+ function gt(t, e) {
880
+ G(t, e, "test");
881
+ }
882
+ function Se(t, ...e) {
883
+ const r = Fe(t, e, { stdio: ["pipe", "inherit", "inherit"] });
884
+ return r.stdin.on("error", (o) => {
885
+ o.code;
815
886
  }), r;
816
887
  }
817
- function ve(t) {
888
+ function ke(t) {
818
889
  return new Promise((e, r) => {
819
- t.on("close", (s) => {
820
- e(s);
821
- }), t.on("error", (s) => {
822
- r(s);
890
+ t.on("close", (o) => {
891
+ e(o);
892
+ }), t.on("error", (o) => {
893
+ r(o);
823
894
  });
824
895
  });
825
896
  }
826
- const N = class N extends $ {
897
+ const N = class N extends v {
827
898
  async run() {
828
- const { flags: e, argv: r } = await this.parse(N), s = E(e["log-level"]), n = r.length == 0 ? ["./src"] : r, o = be(
829
- fe,
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,
830
901
  "check",
831
902
  "--log-level",
832
903
  e["log-level"],
@@ -835,12 +906,12 @@ const N = class N extends $ {
835
906
  ...n
836
907
  );
837
908
  try {
838
- ee(s, o.stdin);
909
+ oe(o, s.stdin);
839
910
  } catch (i) {
840
- s.error(i);
911
+ o.error(i);
841
912
  } finally {
842
- o.stdin.end();
843
- const i = await ve(o);
913
+ s.stdin.end();
914
+ const i = await ke(s);
844
915
  process.exit(i);
845
916
  }
846
917
  }
@@ -848,91 +919,101 @@ const N = class N extends $ {
848
919
  l(N, "description", "check tengo sources for language processor an"), // static override args = {
849
920
  // "log-level": Args.string({description: 'logging level'}),
850
921
  // }
851
- l(N, "strict", !1), l(N, "flags", { ..._ }), l(N, "examples", ["<%= config.bin %> <%= command.id %>"]);
852
- let B = N;
853
- const S = class S extends $ {
922
+ l(N, "strict", !1), l(N, "flags", { ...re }), l(N, "examples", ["<%= config.bin %> <%= command.id %>"]);
923
+ let Z = N;
924
+ const S = class S extends v {
854
925
  async run() {
855
- const { flags: e } = await this.parse(S), r = E(e["log-level"]), s = this.argv.length == 0 ? ["./src"] : this.argv, n = be(
856
- fe,
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,
857
928
  "run",
858
929
  "--log-level",
859
930
  e["log-level"],
860
931
  "--artifacts",
861
932
  "-",
862
- ...s
933
+ ...o
863
934
  );
864
935
  try {
865
- ee(r, n.stdin);
866
- } catch (o) {
867
- r.error(o);
936
+ oe(r, n.stdin);
937
+ } catch (s) {
938
+ r.error(s);
868
939
  } finally {
869
940
  n.stdin.end();
870
- const o = await ve(n);
871
- process.exit(o);
941
+ const s = await ke(n);
942
+ process.exit(s);
872
943
  }
873
944
  }
874
945
  };
875
- l(S, "description", "run tengo unit tests (.test.tengo)"), l(S, "strict", !1), l(S, "flags", { ..._ }), l(S, "examples", ["<%= config.bin %> <%= command.id %>"]);
876
- let V = S;
877
- class Z extends $ {
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 {
949
+ async run() {
950
+ const e = E();
951
+ oe(e, x);
952
+ }
953
+ }
954
+ l(X, "description", "parse sources in current package and dump all found artifacts to stdout"), l(X, "examples", [
955
+ "<%= config.bin %> <%= command.id %>"
956
+ ]);
957
+ class H extends v {
878
958
  async run() {
879
959
  const e = E();
880
- ee(e, R);
960
+ mt(e, x);
881
961
  }
882
962
  }
883
- l(Z, "description", "parse sources in current package and dump all found artifacts to stdout"), l(Z, "examples", [
963
+ l(H, "description", "parse sources in current package and dump all found tests to stdout"), l(H, "examples", [
884
964
  "<%= config.bin %> <%= command.id %>"
885
965
  ]);
886
- const A = class A extends $ {
966
+ const A = class A extends v {
887
967
  async run() {
888
968
  const { flags: e } = await this.parse(A), r = E();
889
- st(r, e.deps, R);
969
+ dt(r, e.deps, x);
890
970
  }
891
971
  };
892
972
  l(A, "description", "parse sources in current package and dump all found templates to stdout"), l(A, "examples", [
893
973
  "<%= config.bin %> <%= command.id %>"
894
974
  ]), l(A, "flags", {
895
- deps: F.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
975
+ deps: M.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
896
976
  });
897
- let K = A;
898
- class X extends $ {
977
+ let Q = A;
978
+ class Y extends v {
899
979
  async run() {
900
980
  const e = E();
901
- it(e, R);
981
+ ut(e, x);
902
982
  }
903
983
  }
904
- l(X, "description", "parse sources in current package and dump all found tests to stdout"), l(X, "examples", [
984
+ l(Y, "description", "parse sources in current package and dump all found tests to stdout"), l(Y, "examples", [
905
985
  "<%= config.bin %> <%= command.id %>"
906
986
  ]);
907
- class H extends $ {
987
+ class _ extends v {
908
988
  async run() {
909
989
  const e = E();
910
- nt(e, R);
990
+ pt(e, x);
911
991
  }
912
992
  }
913
- l(H, "description", "parse sources in current package and dump all found templates to stdout"), l(H, "examples", [
993
+ l(_, "description", "parse sources in current package and dump all found templates to stdout"), l(_, "examples", [
914
994
  "<%= config.bin %> <%= command.id %>"
915
995
  ]);
916
- class Q extends $ {
996
+ class ee extends v {
917
997
  async run() {
918
998
  const e = E();
919
- at(e, R);
999
+ gt(e, x);
920
1000
  }
921
1001
  }
922
- l(Q, "description", "parse sources in current package and dump all found tests to stdout"), l(Q, "examples", [
1002
+ l(ee, "description", "parse sources in current package and dump all found tests to stdout"), l(ee, "examples", [
923
1003
  "<%= config.bin %> <%= command.id %>"
924
1004
  ]);
925
- const yt = {
926
- build: q,
927
- check: B,
928
- test: V,
929
- "dump:all": Z,
930
- "dump:libs": K,
931
- "dump:software": X,
932
- "dump:templates": H,
933
- "dump:tests": Q
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
934
1015
  };
935
1016
  export {
936
- yt as COMMANDS
1017
+ At as COMMANDS
937
1018
  };
938
1019
  //# sourceMappingURL=index.mjs.map