@platforma-sdk/tengo-builder 1.14.11 → 1.14.13

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