@platforma-sdk/tengo-builder 1.14.13 → 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,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 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
- 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";
7
+ import * as p from "node:fs";
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
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";
15
- function O(t) {
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 Fe() {
18
+ function Ce() {
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 ce(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 fe(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
53
  function L(t) {
54
- return { name: y(t), version: t.version };
54
+ return { name: h(t), version: t.version };
55
55
  }
56
- function Oe(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 se(t) {
62
+ function de(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 Je = new TextDecoder(), ze = new TextEncoder();
66
+ class ye {
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(Je.decode(je(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 = 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: ${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: ${de(i)} != ${de(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 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 s = re(this.nameExtractor(e)), n = this.map.get(s);
95
- return n && !r || this.map.set(s, e), n;
94
+ const o = ce(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(ce(e));
99
99
  }
100
100
  get array() {
101
101
  const e = [];
@@ -105,21 +105,21 @@ 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 We() {
109
+ return new J((t) => t);
110
110
  }
111
111
  class I {
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 J(e), this.dist = new J(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
- O(e);
122
+ M(e);
123
123
  }
124
124
  }
125
125
  get(e, r) {
@@ -127,57 +127,65 @@ class I {
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) {
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 Pe {
142
142
  constructor(e) {
143
143
  l(this, "libs", new I((e) => e.fullName));
144
144
  l(this, "software", new I((e) => e.fullName));
145
+ l(this, "assets", new I((e) => e.fullName));
145
146
  l(this, "templates", new I((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
+ r.libs[h(s)] = {
158
159
  ...L(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)] = {
164
+ const c = this.getSoftwareOrError(s);
165
+ r.software[h(s)] = {
165
166
  ...L(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
+ ...L(d.fullName),
174
+ src: d.src
175
+ };
176
+ break;
169
177
  case "template":
170
- if (oe(e, o))
178
+ if (fe(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
+ M(s.type);
181
189
  }
182
190
  }
183
191
  /** This method assumes that all dependencies are already added to the compiler's context */
@@ -190,11 +198,12 @@ class Le {
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 ye(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,10 +297,12 @@ 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:
273
- O(e.type);
305
+ M(e.type);
274
306
  }
275
307
  }
276
308
  checkLibs() {
@@ -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" && fe(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
+ M(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 pe = "[_a-zA-Z][_a-zA-Z0-9]*", O = (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
+ ), 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
+ 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 $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);
356
391
  }
357
- function Ue(t, e, r) {
358
- const s = je(), n = t.split(`
359
- `), o = [];
392
+ function Qe(t, e, r) {
393
+ const o = We(), n = t.split(`
394
+ `), s = [];
360
395
  let i = {
361
396
  isInCommentBlock: !1,
362
397
  tplDepREs: /* @__PURE__ */ new Map()
@@ -364,273 +399,303 @@ 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 = Ye(
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 Ye(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 Ke.exec(t) && (e.isInCommentBlock = !1), { line: t, context: e, artifact: void 0 };
423
+ if (Ve.exec(t))
389
424
  return { line: t, context: e, artifact: void 0 };
390
- if (Je.exec(t))
425
+ if (Ze.exec(t))
391
426
  return e.isInCommentBlock = !0, { line: t, context: e, artifact: void 0 };
392
- const n = pe.exec(t);
427
+ const n = be.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 = _e(t);
430
+ if (s.module === "plapi")
431
+ return e.tplDepREs.has(s.module) || e.tplDepREs.set(s.module, [
432
+ ["template", Ue(s.alias)],
433
+ ["software", qe(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", ue(s.alias)],
437
+ ["software", me(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", ue(s.alias)],
440
+ ["software", me(s.alias)],
441
+ ["asset", Be(s.alias)]
406
442
  ]));
407
- const i = le(o.module, "library", r);
443
+ const i = ge(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 = ge(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 _e(t) {
463
+ const e = Xe.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 ge(t, e, r) {
475
+ const o = He.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 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];
454
490
  function E(t = "debug") {
455
- return j.createLogger({
491
+ return G.createLogger({
456
492
  level: t,
457
- 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}`),
458
494
  transports: [
459
- new j.transports.Console({
495
+ new G.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 R() {
503
+ return JSON.parse(p.readFileSync("package.json").toString());
468
504
  }
469
- function ge(t, e) {
505
+ function ve(t, e) {
470
506
  return f.resolve(e, t, "tengo", "lib");
471
507
  }
472
- function he(t, e) {
508
+ function Ee(t, e) {
473
509
  return f.resolve(e, t, "tengo", "tpl");
474
510
  }
475
- function we(t, e) {
511
+ function Ne(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 Se(t, e) {
515
+ return f.resolve(e, t, "tengo", "asset");
516
+ }
517
+ function ke(t, e, r, o, n = !1) {
518
+ const s = f.resolve(o, "package.json");
519
+ if ($(s) !== "file") {
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);
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 = 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
+ 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 x = JSON.parse(p.readFileSync(s).toString());
530
+ if (x.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 && 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);
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 tt(t, e, r, o, n) {
539
+ for (const s of p.readdirSync(o)) {
540
+ const i = f.resolve(o, s);
541
+ if (!s.endsWith(W)) 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 - W.length),
507
546
  version: e.version
508
- }, c = me(r, i, a, !0);
547
+ }, c = $e(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 st(t, e, r, o, n) {
555
+ for (const s of p.readdirSync(o)) {
556
+ const i = f.resolve(o, s);
557
+ if (!s.endsWith(z)) 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 - z.length),
523
562
  version: e.version
524
- }, c = new de(r, a, { content: u.readFileSync(i) });
563
+ }, c = new ye(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 rt(t, e, r, o, n) {
568
+ for (const s of p.readdirSync(o)) {
569
+ const i = f.resolve(o, s);
570
+ if (!s.endsWith(P))
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 - P.length),
576
+ version: e.version
577
+ }, c = new re(r, a, p.readFileSync(i).toString(), i, []);
578
+ t.debug(`Adding dependency ${m(a)} from ${i}`), n.addSoftware(c);
579
+ }
580
+ }
581
+ function ot(t, e, r, o, n) {
582
+ for (const s of p.readdirSync(o)) {
583
+ const i = f.resolve(o, s);
584
+ if (!s.endsWith(U))
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 - U.length),
537
590
  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}`);
591
+ }, c = new re(r, a, p.readFileSync(i).toString(), i, []);
592
+ t.debug(`Adding dependency ${m(a)} from ${i}`), n.addAsset(c);
540
593
  }
541
594
  }
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);
595
+ function j(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 = j(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 = nt(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 = $e(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 oe(t, e, r) {
619
+ const o = new Pe(r);
620
+ return ke(t, o, e, Ce()), o;
568
621
  }
569
- function He(t, e) {
622
+ function nt(t, e) {
570
623
  const r = { pkg: t.name, version: t.version };
571
- return e.endsWith(W) ? {
624
+ return e.endsWith(B) ? {
572
625
  ...r,
573
- id: e.substring(0, e.length - W.length),
626
+ id: e.substring(0, e.length - B.length),
574
627
  type: "library"
575
- } : e.endsWith(P) ? {
628
+ } : e.endsWith(q) ? {
576
629
  ...r,
577
- id: e.substring(0, e.length - P.length),
630
+ id: e.substring(0, e.length - q.length),
578
631
  type: "template"
579
- } : e.endsWith(U) ? {
632
+ } : e.endsWith(V) ? {
580
633
  ...r,
581
- id: e.substring(0, e.length - U.length),
634
+ id: e.substring(0, e.length - V.length),
582
635
  type: "software"
583
- } : e.endsWith(ce) ? {
636
+ } : e.endsWith(Z) ? {
637
+ ...r,
638
+ id: e.substring(0, e.length - Z.length),
639
+ type: "asset"
640
+ } : e.endsWith(he) ? {
584
641
  ...r,
585
- id: e.substring(0, e.length - ce.length),
642
+ id: e.substring(0, e.length - he.length),
586
643
  type: "test"
587
644
  } : null;
588
645
  }
589
- function Qe(t, e) {
590
- const r = k(), s = Y(t, r, e), n = T(t, r, e, "src", "");
646
+ function it(t, e) {
647
+ const r = R(), o = oe(t, r, e), n = j(t, r, e, "src", "");
591
648
  if (n.length === 0) {
592
649
  const i = [];
593
- for (const a of Ve)
650
+ for (const a of et)
594
651
  i.push(`*${a}`);
595
652
  t.error(`Nothing to compile. Looked for ${i.join(", ")}`), process.exit(1);
596
653
  }
597
654
  t.info(`Compiling '${e}'...`);
598
- const o = s.compileAndAdd(n);
599
- return t.debug("Done."), o;
655
+ const s = o.compileAndAdd(n);
656
+ return t.debug("Done."), s;
600
657
  }
601
- function Ye(t, e, r) {
658
+ function at(t, e, r) {
602
659
  if (e.libs.length > 0) {
603
- const s = ge(r, ".");
604
- u.mkdirSync(s, { recursive: !0 });
660
+ const o = ve(r, ".");
661
+ p.mkdirSync(o, { recursive: !0 });
605
662
  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);
663
+ const s = f.resolve(o, n.fullName.id + W);
664
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
608
665
  }
609
666
  }
610
667
  if (e.templates.length > 0) {
611
- const s = he(r, ".");
612
- u.mkdirSync(s, { recursive: !0 });
668
+ const o = Ee(r, ".");
669
+ p.mkdirSync(o, { recursive: !0 });
613
670
  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);
671
+ const s = f.resolve(o, n.fullName.id + z);
672
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.content);
616
673
  }
617
674
  }
618
675
  if (e.software.length > 0) {
619
- const s = we(r, ".");
620
- u.mkdirSync(s, { recursive: !0 });
676
+ const o = Ne(r, ".");
677
+ p.mkdirSync(o, { recursive: !0 });
678
+ for (const n of e.software) {
679
+ const s = f.resolve(o, n.fullName.id + P);
680
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
681
+ }
682
+ }
683
+ if (e.assets.length > 0) {
684
+ const o = Se(r, ".");
685
+ p.mkdirSync(o, { recursive: !0 });
621
686
  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);
687
+ const s = f.resolve(o, n.fullName.id + U);
688
+ t.info(` - writing ${s}`), p.writeFileSync(s, n.src);
624
689
  }
625
690
  }
626
691
  }
627
- const _ = {
692
+ const ne = {
628
693
  "log-level": F.string({
629
694
  description: "logging level",
630
695
  default: "info",
631
696
  options: ["error", "warn", "info", "debug"]
632
697
  })
633
- }, _e = {
698
+ }, lt = {
634
699
  "generate-tags": F.boolean({
635
700
  description: "generate tags, default false",
636
701
  default: !1
@@ -646,50 +711,50 @@ const _ = {
646
711
  multiple: !0,
647
712
  delimiter: ","
648
713
  })
649
- }, x = class x extends $ {
714
+ }, k = class k extends v {
650
715
  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; };
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("");
718
+ let s = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
654
719
  `;
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 };
720
+ s += `declare type TplName = ${n.templates.map((u) => '"' + u.fullName.id + '"').join(" | ")};
721
+ `, s += `declare const Templates: Record<TplName, TemplateFromFile>;
722
+ `, s += `export { Templates };
658
723
  `;
659
724
  let i = `module.exports = { Templates: {
660
725
  `, a = `import { resolve } from 'node:path';
661
726
  export const Templates = {
662
727
  `;
663
728
  const c = n.templates.map(
664
- (p) => ` '${p.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${p.fullName.id}.plj.gz') }`
729
+ (u) => ` '${u.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${u.fullName.id}.plj.gz') }`
665
730
  ).join(`,
666
731
  `), d = n.templates.map(
667
- (p) => ` '${p.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${p.fullName.id}.plj.gz') }`
732
+ (u) => ` '${u.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${u.fullName.id}.plj.gz') }`
668
733
  ).join(`,
669
734
  `);
670
735
  i += c, a += d, i += `
671
736
  }};
672
737
  `, a += `
673
738
  };
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.");
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.");
675
740
  }
676
741
  };
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
742
+ l(k, "description", "build tengo sources into single distributable pack file"), l(k, "examples", ["<%= config.bin %> <%= command.id %>"]), l(k, "flags", {
743
+ ...ne,
744
+ ...lt
680
745
  });
681
- let q = x;
682
- function et(t) {
746
+ let K = k;
747
+ function ct(t) {
683
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(","));
684
749
  }
685
- function tt(t, e) {
750
+ function ft(t, e) {
686
751
  var a;
687
- const r = f.resolve(e["tags-file"]), s = f.dirname(r), n = e["tags-additional-args"], o = rt(s);
752
+ const r = f.resolve(e["tags-file"]), o = f.dirname(r), n = e["tags-additional-args"], s = dt(o);
688
753
  t.info(
689
- `Generating tags for tengo autocompletion from "${s}" in "${r}", additional arguments: "${n}".
690
- Found ${o.length} tengo files...`
754
+ `Generating tags for tengo autocompletion from "${o}" in "${r}", additional arguments: "${n}".
755
+ Found ${s.length} tengo files...`
691
756
  );
692
- const i = Se(
757
+ const i = Me(
693
758
  "ctags",
694
759
  [
695
760
  "-f",
@@ -702,12 +767,12 @@ Found ${o.length} tengo files...`
702
767
  "--kinddef-tengo=c,constant,constant",
703
768
  '--regex-tengo=/^\\s*(.*) := ("|\\{).*/\\1/c/',
704
769
  "-R",
705
- ...o
770
+ ...s
706
771
  ],
707
772
  {
708
773
  env: process.env,
709
774
  stdio: "inherit",
710
- cwd: s
775
+ cwd: o
711
776
  }
712
777
  );
713
778
  if ((a = i.error) != null && a.message.includes("ENOENT")) {
@@ -721,112 +786,122 @@ For vscode, you should also install ctags extension:
721
786
  https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
722
787
  return;
723
788
  }
724
- ot(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.");
725
790
  }
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, ".");
791
+ function dt(t) {
792
+ const e = p.readdirSync(t, { withFileTypes: !0, recursive: !0 }), r = [];
793
+ return e.forEach((o) => {
794
+ if (!o.isDirectory() && o.name.endsWith(".tengo")) {
795
+ const n = f.join(o.parentPath, o.name).replace(t, ".");
731
796
  r.push(n);
732
797
  }
733
798
  }), r;
734
799
  }
735
- function ot(t, e) {
800
+ function pt(t, e) {
736
801
  t.error && console.log(t.error);
737
802
  const r = e;
738
803
  t.status !== 0 && console.log(`WARN: ${r} the build will continue as-is`);
739
804
  }
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())
805
+ function ie(t, e) {
806
+ const r = R(), o = j(t, r, "dist", "src", ""), n = oe(t, r, "dist");
807
+ for (const s of n.allLibs())
743
808
  t.debug(
744
- `Dumping to pl-tester: ${g(o.fullName)}`
745
- ), e.write(JSON.stringify(o) + `
809
+ `Dumping to pl-tester: ${g(s.fullName)}`
810
+ ), e.write(JSON.stringify(s) + `
746
811
  `);
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) + `
812
+ for (const s of o)
813
+ s.fullName.type === "library" && (t.debug(
814
+ `Dumping to pl-tester: ${g(s.fullName)}`
815
+ ), e.write(JSON.stringify(s) + `
751
816
  `));
752
- for (const o of n.allTemplates())
817
+ for (const s of n.allTemplates())
753
818
  t.debug(
754
- `Dumping to pl-tester: ${g(o.fullName)}`
755
- ), e.write(JSON.stringify(o) + `
819
+ `Dumping to pl-tester: ${g(s.fullName)}`
820
+ ), e.write(JSON.stringify(s) + `
756
821
  `);
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) + `
822
+ for (const s of o)
823
+ s.fullName.type === "template" && (t.debug(
824
+ `Dumping to pl-tester: ${g(s.fullName)} ${s.srcName}`
825
+ ), e.write(JSON.stringify(s) + `
761
826
  `));
762
- for (const o of n.allSoftware())
827
+ for (const s of n.allSoftware())
763
828
  t.debug(
764
- `Dumping to pl-tester: ${g(o.fullName)}`
765
- ), e.write(JSON.stringify(o) + `
829
+ `Dumping to pl-tester: ${g(s.fullName)}`
830
+ ), e.write(JSON.stringify(s) + `
766
831
  `);
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) + `
832
+ for (const s of o)
833
+ s.fullName.type === "software" && (t.debug(
834
+ `Dumping to pl-tester: ${g(s.fullName)}`
835
+ ), e.write(JSON.stringify(s) + `
771
836
  `));
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) + `
837
+ for (const s of n.allAssets())
838
+ t.debug(
839
+ `Dumping to pl-tester: ${g(s.fullName)}`
840
+ ), e.write(JSON.stringify(s) + `
841
+ `);
842
+ for (const s of o)
843
+ s.fullName.type === "asset" && (t.debug(
844
+ `Dumping to pl-tester: ${g(s.fullName)}`
845
+ ), e.write(JSON.stringify(s) + `
846
+ `));
847
+ for (const s of o)
848
+ s.fullName.type === "test" && (t.debug(
849
+ `Dumping to pl-tester: ${g(s.fullName)} ${s.srcName}`
850
+ ), e.write(JSON.stringify(s) + `
776
851
  `));
777
852
  }
778
- function st(t, e, r) {
779
- const s = k(), n = T(t, s, "dist", "src", "");
853
+ function ut(t, e, r) {
854
+ const o = R(), n = j(t, o, "dist", "src", "");
780
855
  if (!e) {
781
856
  for (const i of n)
782
857
  i.fullName.type === "library" && r.write(JSON.stringify(i) + `
783
858
  `);
784
859
  return;
785
860
  }
786
- const o = Y(t, s, "dist");
861
+ const s = oe(t, o, "dist");
787
862
  for (const i of n)
788
- i.fullName.type === "library" && o.addLib(i);
789
- for (const i of o.allLibs())
863
+ i.fullName.type === "library" && s.addLib(i);
864
+ for (const i of s.allLibs())
790
865
  r.write(JSON.stringify(i) + `
791
866
  `);
792
867
  }
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) + `
868
+ function C(t, e, r) {
869
+ const o = R(), n = j(t, o, "dist", "src", "");
870
+ for (const s of n)
871
+ s.fullName.type === r && e.write(JSON.stringify(s) + `
797
872
  `);
798
873
  }
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
- `);
874
+ function mt(t, e) {
875
+ C(t, e, "template");
804
876
  }
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
- `);
877
+ function gt(t, e) {
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");
810
885
  }
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;
886
+ function Ae(t, ...e) {
887
+ const r = Oe(t, e, { stdio: ["pipe", "inherit", "inherit"] });
888
+ return r.stdin.on("error", (o) => {
889
+ o.code;
815
890
  }), r;
816
891
  }
817
- function ve(t) {
892
+ function Te(t) {
818
893
  return new Promise((e, r) => {
819
- t.on("close", (s) => {
820
- e(s);
821
- }), t.on("error", (s) => {
822
- r(s);
894
+ t.on("close", (o) => {
895
+ e(o);
896
+ }), t.on("error", (o) => {
897
+ r(o);
823
898
  });
824
899
  });
825
900
  }
826
- const N = class N extends $ {
901
+ const N = class N extends v {
827
902
  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,
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,
830
905
  "check",
831
906
  "--log-level",
832
907
  e["log-level"],
@@ -835,12 +910,12 @@ const N = class N extends $ {
835
910
  ...n
836
911
  );
837
912
  try {
838
- ee(s, o.stdin);
913
+ ie(o, s.stdin);
839
914
  } catch (i) {
840
- s.error(i);
915
+ o.error(i);
841
916
  } finally {
842
- o.stdin.end();
843
- const i = await ve(o);
917
+ s.stdin.end();
918
+ const i = await Te(s);
844
919
  process.exit(i);
845
920
  }
846
921
  }
@@ -848,45 +923,54 @@ const N = class N extends $ {
848
923
  l(N, "description", "check tengo sources for language processor an"), // static override args = {
849
924
  // "log-level": Args.string({description: 'logging level'}),
850
925
  // }
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 $ {
926
+ l(N, "strict", !1), l(N, "flags", { ...ne }), l(N, "examples", ["<%= config.bin %> <%= command.id %>"]);
927
+ let X = N;
928
+ const S = class S extends v {
854
929
  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,
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,
857
932
  "run",
858
933
  "--log-level",
859
934
  e["log-level"],
860
935
  "--artifacts",
861
936
  "-",
862
- ...s
937
+ ...o
863
938
  );
864
939
  try {
865
- ee(r, n.stdin);
866
- } catch (o) {
867
- r.error(o);
940
+ ie(r, n.stdin);
941
+ } catch (s) {
942
+ r.error(s);
868
943
  } finally {
869
944
  n.stdin.end();
870
- const o = await ve(n);
871
- process.exit(o);
945
+ const s = await Te(n);
946
+ process.exit(s);
872
947
  }
873
948
  }
874
949
  };
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 $ {
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 {
953
+ async run() {
954
+ const e = E();
955
+ ie(e, T);
956
+ }
957
+ }
958
+ l(Q, "description", "parse sources in current package and dump all found artifacts to stdout"), l(Q, "examples", [
959
+ "<%= config.bin %> <%= command.id %>"
960
+ ]);
961
+ class Y extends v {
878
962
  async run() {
879
963
  const e = E();
880
- ee(e, R);
964
+ ht(e, T);
881
965
  }
882
966
  }
883
- l(Z, "description", "parse sources in current package and dump all found artifacts to stdout"), l(Z, "examples", [
967
+ l(Y, "description", "parse sources in current package and dump all found tests to stdout"), l(Y, "examples", [
884
968
  "<%= config.bin %> <%= command.id %>"
885
969
  ]);
886
- const A = class A extends $ {
970
+ const A = class A extends v {
887
971
  async run() {
888
972
  const { flags: e } = await this.parse(A), r = E();
889
- st(r, e.deps, R);
973
+ ut(r, e.deps, T);
890
974
  }
891
975
  };
892
976
  l(A, "description", "parse sources in current package and dump all found templates to stdout"), l(A, "examples", [
@@ -894,45 +978,46 @@ l(A, "description", "parse sources in current package and dump all found templat
894
978
  ]), l(A, "flags", {
895
979
  deps: F.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
896
980
  });
897
- let K = A;
898
- class X extends $ {
981
+ let _ = A;
982
+ class ee extends v {
899
983
  async run() {
900
984
  const e = E();
901
- it(e, R);
985
+ gt(e, T);
902
986
  }
903
987
  }
904
- l(X, "description", "parse sources in current package and dump all found tests to stdout"), l(X, "examples", [
988
+ l(ee, "description", "parse sources in current package and dump all found tests to stdout"), l(ee, "examples", [
905
989
  "<%= config.bin %> <%= command.id %>"
906
990
  ]);
907
- class H extends $ {
991
+ class te extends v {
908
992
  async run() {
909
993
  const e = E();
910
- nt(e, R);
994
+ mt(e, T);
911
995
  }
912
996
  }
913
- l(H, "description", "parse sources in current package and dump all found templates to stdout"), l(H, "examples", [
997
+ l(te, "description", "parse sources in current package and dump all found templates to stdout"), l(te, "examples", [
914
998
  "<%= config.bin %> <%= command.id %>"
915
999
  ]);
916
- class Q extends $ {
1000
+ class se extends v {
917
1001
  async run() {
918
1002
  const e = E();
919
- at(e, R);
1003
+ wt(e, T);
920
1004
  }
921
1005
  }
922
- l(Q, "description", "parse sources in current package and dump all found tests to stdout"), l(Q, "examples", [
1006
+ l(se, "description", "parse sources in current package and dump all found tests to stdout"), l(se, "examples", [
923
1007
  "<%= config.bin %> <%= command.id %>"
924
1008
  ]);
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
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
934
1019
  };
935
1020
  export {
936
- yt as COMMANDS
1021
+ xt as COMMANDS
937
1022
  };
938
1023
  //# sourceMappingURL=index.mjs.map