@platforma-sdk/tengo-builder 1.14.11 → 1.14.12
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/commands/build.d.ts +5 -4
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/check.d.ts +2 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/dump/libs.d.ts +2 -1
- package/dist/commands/dump/libs.d.ts.map +1 -1
- package/dist/commands/index.d.ts +10 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/test.d.ts +2 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/index.js +25 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +461 -374
- package/dist/index.mjs.map +1 -1
- package/dist/shared/basecmd.d.ts +5 -4
- package/dist/shared/basecmd.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/commands/index.ts +12 -1
package/dist/index.mjs
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { spawnSync as
|
|
5
|
-
import { Flags as
|
|
6
|
-
import * as
|
|
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
|
|
9
|
-
import { gunzipSync as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import * as
|
|
13
|
-
import { TengoTesterBinaryPath as
|
|
14
|
-
|
|
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
|
|
18
|
+
function Fe() {
|
|
18
19
|
let t = process.cwd();
|
|
19
20
|
for (; t; ) {
|
|
20
|
-
const e =
|
|
21
|
+
const e = f.join(t, "node_modules");
|
|
21
22
|
if (u.existsSync(e)) return e;
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
t =
|
|
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
|
|
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
|
|
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
|
|
53
|
+
function L(t) {
|
|
53
54
|
return { name: y(t), version: t.version };
|
|
54
55
|
}
|
|
55
|
-
function
|
|
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
|
|
62
|
+
function se(t) {
|
|
62
63
|
return `${t.pkg}:${t.id}:${t.version}`;
|
|
63
64
|
}
|
|
64
|
-
const
|
|
65
|
-
class
|
|
66
|
-
constructor(e,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.compileMode = e, this.fullName =
|
|
70
|
-
let { data: n, content:
|
|
71
|
-
if (n === 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 &&
|
|
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(
|
|
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
|
-
|
|
78
|
-
const i =
|
|
79
|
-
if (i.pkg !==
|
|
80
|
-
throw new Error(`Compiled template name don't match it's package and file names: ${
|
|
81
|
-
this.data = n, this.content =
|
|
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
|
|
88
|
+
class C {
|
|
88
89
|
constructor(e) {
|
|
89
|
-
|
|
90
|
+
l(this, "map", /* @__PURE__ */ new Map());
|
|
90
91
|
this.nameExtractor = e;
|
|
91
92
|
}
|
|
92
|
-
add(e,
|
|
93
|
-
const s =
|
|
94
|
-
return 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(
|
|
98
|
+
return this.map.get(re(e));
|
|
98
99
|
}
|
|
99
100
|
get array() {
|
|
100
101
|
const e = [];
|
|
101
|
-
return this.map.forEach((
|
|
102
|
+
return this.map.forEach((r) => e.push(r)), e;
|
|
102
103
|
}
|
|
103
104
|
forEach(e) {
|
|
104
|
-
this.map.forEach((
|
|
105
|
+
this.map.forEach((r) => e(r, this.nameExtractor(r)));
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
return new
|
|
108
|
+
function je() {
|
|
109
|
+
return new C((t) => t);
|
|
109
110
|
}
|
|
110
|
-
class
|
|
111
|
+
class I {
|
|
111
112
|
constructor(e) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.nameExtractor = e, this.dev = new
|
|
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,
|
|
117
|
+
add(e, r, s = !0) {
|
|
117
118
|
switch (e) {
|
|
118
119
|
case "dist":
|
|
119
|
-
return this.dist.add(
|
|
120
|
+
return this.dist.add(r, s);
|
|
120
121
|
default:
|
|
121
|
-
|
|
122
|
+
O(e);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
get(e,
|
|
125
|
+
get(e, r) {
|
|
125
126
|
switch (e) {
|
|
126
127
|
case "dist":
|
|
127
|
-
return this.dist.get(
|
|
128
|
+
return this.dist.get(r);
|
|
128
129
|
default:
|
|
129
|
-
|
|
130
|
+
O(e);
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
array(e) {
|
|
133
|
-
const
|
|
134
|
-
return this.forEach(e, (s) =>
|
|
134
|
+
const r = [];
|
|
135
|
+
return this.forEach(e, (s) => r.push(s)), r;
|
|
135
136
|
}
|
|
136
|
-
forEach(e,
|
|
137
|
-
this.dist.forEach((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
|
|
141
|
+
class Le {
|
|
141
142
|
constructor(e) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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,
|
|
148
|
-
for (const
|
|
149
|
-
switch (
|
|
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(
|
|
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(
|
|
154
|
+
let p = `library import recursion detected: ${n.slice(a).join(" -> ")} -> ${y(o)}`;
|
|
154
155
|
throw new Error(p);
|
|
155
156
|
}
|
|
156
|
-
|
|
157
|
-
...
|
|
157
|
+
r.libs[y(o)] = {
|
|
158
|
+
...L(i.fullName),
|
|
158
159
|
src: i.src
|
|
159
|
-
}, this.populateTemplateDataFromDependencies(e,
|
|
160
|
+
}, this.populateTemplateDataFromDependencies(e, r, i.dependencies, [...n, y(o)]);
|
|
160
161
|
break;
|
|
161
162
|
case "software":
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
...
|
|
165
|
-
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 (
|
|
170
|
+
if (oe(e, o))
|
|
170
171
|
continue;
|
|
171
|
-
const
|
|
172
|
-
|
|
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(
|
|
177
|
+
`dependencies tree error: tests should never be part of template: ${g(o)} is dependency of ${y(e)}`
|
|
177
178
|
);
|
|
178
179
|
default:
|
|
179
|
-
|
|
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
|
|
187
|
+
const r = {
|
|
187
188
|
type: "pl.tengo-template.v2",
|
|
188
|
-
...
|
|
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,
|
|
195
|
-
const s = new
|
|
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
|
|
200
|
-
if (
|
|
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(
|
|
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
|
|
215
|
-
if (!
|
|
215
|
+
const r = this.getLib(e);
|
|
216
|
+
if (!r)
|
|
216
217
|
throw new Error(`library not found: ${y(e)}`);
|
|
217
|
-
return
|
|
218
|
+
return r;
|
|
218
219
|
}
|
|
219
220
|
addSoftware(e) {
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
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(
|
|
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
|
|
236
|
-
if (!
|
|
236
|
+
const r = this.getSoftware(e);
|
|
237
|
+
if (!r)
|
|
237
238
|
throw new Error(`software info not found: ${y(e)}`);
|
|
238
|
-
return
|
|
239
|
+
return r;
|
|
239
240
|
}
|
|
240
241
|
addTemplate(e) {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
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(
|
|
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
|
|
257
|
-
if (!
|
|
257
|
+
const r = this.getTemplate(e);
|
|
258
|
+
if (!r)
|
|
258
259
|
throw new Error(`template not found: ${y(e)}`);
|
|
259
|
-
return
|
|
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
|
-
|
|
273
|
+
O(e.type);
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
checkLibs() {
|
|
276
277
|
this.libs.forEach(this.compileMode, (e) => {
|
|
277
|
-
for (const
|
|
278
|
-
if (
|
|
279
|
-
throw new Error(`test should never be dependency of production code: ${g(
|
|
280
|
-
if (!this.getArtefact(
|
|
281
|
-
throw new Error(`unresolved dependency ${g(
|
|
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
|
|
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),
|
|
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
|
|
293
|
-
const i =
|
|
293
|
+
for (const o of s) {
|
|
294
|
+
const i = o.dependencies.filter(
|
|
294
295
|
(a) => !this.getArtefact(a) && // allow self reference for templates
|
|
295
|
-
!(
|
|
296
|
+
!(o.fullName.type === "template" && oe(o.fullName, a))
|
|
296
297
|
);
|
|
297
298
|
if (i.length > 0) {
|
|
298
|
-
let a = `Unsatisfied dependencies in ${m(
|
|
299
|
+
let a = `Unsatisfied dependencies in ${m(o.fullName)}:
|
|
299
300
|
`;
|
|
300
|
-
for (const
|
|
301
|
-
a += ` - ${g(
|
|
301
|
+
for (const c of i)
|
|
302
|
+
a += ` - ${g(c)}
|
|
302
303
|
`;
|
|
303
|
-
n.push({ src:
|
|
304
|
+
n.push({ src: o, err: Error(a) });
|
|
304
305
|
continue;
|
|
305
306
|
}
|
|
306
|
-
switch (
|
|
307
|
+
switch (o.fullName.type) {
|
|
307
308
|
case "library":
|
|
308
|
-
this.addLib(
|
|
309
|
+
this.addLib(o), r.libs.push(o);
|
|
309
310
|
break;
|
|
310
311
|
case "software":
|
|
311
|
-
this.addSoftware(
|
|
312
|
+
this.addSoftware(o), r.software.push(o);
|
|
312
313
|
break;
|
|
313
314
|
case "template":
|
|
314
315
|
try {
|
|
315
|
-
const a = this.compileAndAddTemplate(
|
|
316
|
-
|
|
316
|
+
const a = this.compileAndAddTemplate(o);
|
|
317
|
+
r.templates.push(a);
|
|
317
318
|
} catch (a) {
|
|
318
|
-
let
|
|
319
|
+
let c = `Unsatisfied dependencies in ${m(o.fullName)}:
|
|
319
320
|
`;
|
|
320
|
-
|
|
321
|
-
`, n.push({ src:
|
|
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
|
-
|
|
328
|
+
O(o.fullName.type);
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
331
|
if (s.length === n.length) {
|
|
331
|
-
let
|
|
332
|
+
let o = "";
|
|
332
333
|
for (const i of n)
|
|
333
|
-
|
|
334
|
+
o += `
|
|
334
335
|
${i.err.message}`;
|
|
335
|
-
throw new Error(
|
|
336
|
+
throw new Error(o);
|
|
336
337
|
}
|
|
337
|
-
s = n.map(({ src:
|
|
338
|
+
s = n.map(({ src: o }) => o);
|
|
338
339
|
}
|
|
339
|
-
return
|
|
340
|
+
return r;
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
|
-
const
|
|
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
|
-
),
|
|
345
|
-
`\\b(?<importName>${
|
|
346
|
-
),
|
|
347
|
-
class
|
|
348
|
-
constructor(e,
|
|
349
|
-
this.compileMode = e, this.fullName =
|
|
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
|
|
353
|
-
const n =
|
|
354
|
-
return new
|
|
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
|
|
357
|
-
const s =
|
|
358
|
-
`),
|
|
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
|
|
364
|
+
for (const c of n) {
|
|
364
365
|
a++;
|
|
365
366
|
try {
|
|
366
|
-
const
|
|
367
|
-
|
|
367
|
+
const d = qe(
|
|
368
|
+
c,
|
|
368
369
|
i,
|
|
369
370
|
e.pkg,
|
|
370
|
-
|
|
371
|
+
r
|
|
371
372
|
);
|
|
372
|
-
|
|
373
|
-
} catch (
|
|
374
|
-
throw new Error(`[line ${a}]: ${
|
|
375
|
-
${
|
|
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:
|
|
380
|
+
normalized: o.join(`
|
|
380
381
|
`),
|
|
381
382
|
deps: s
|
|
382
383
|
};
|
|
383
384
|
}
|
|
384
|
-
function
|
|
385
|
+
function qe(t, e, r, s) {
|
|
385
386
|
if (e.isInCommentBlock)
|
|
386
|
-
return
|
|
387
|
-
if (
|
|
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 (
|
|
390
|
+
if (Je.exec(t))
|
|
390
391
|
return e.isInCommentBlock = !0, { line: t, context: e, artifact: void 0 };
|
|
391
|
-
const n =
|
|
392
|
+
const n = pe.exec(t);
|
|
392
393
|
if (n) {
|
|
393
|
-
const
|
|
394
|
-
if (
|
|
395
|
-
return e.tplDepREs.has(
|
|
396
|
-
["template",
|
|
397
|
-
["software",
|
|
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
|
-
(
|
|
400
|
-
["template",
|
|
401
|
-
["software",
|
|
402
|
-
])), (
|
|
403
|
-
["template",
|
|
404
|
-
["software",
|
|
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 =
|
|
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 [
|
|
411
|
-
for (const [a,
|
|
412
|
-
const
|
|
413
|
-
if (!
|
|
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 } =
|
|
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 =
|
|
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
|
|
426
|
-
const e =
|
|
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:
|
|
430
|
-
if (!
|
|
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:
|
|
435
|
+
alias: r
|
|
435
436
|
};
|
|
436
437
|
}
|
|
437
|
-
function
|
|
438
|
-
const s =
|
|
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:
|
|
446
|
-
if (!
|
|
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 ??
|
|
451
|
+
return { type: e, pkg: n ?? r, id: o };
|
|
451
452
|
}
|
|
452
|
-
const
|
|
453
|
-
function
|
|
454
|
-
return
|
|
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:
|
|
457
|
+
format: j.format.printf(({ level: e, message: r }) => `${e.padStart(6, " ")}: ${r}`),
|
|
457
458
|
transports: [
|
|
458
|
-
new
|
|
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
|
|
466
|
+
function k() {
|
|
466
467
|
return JSON.parse(u.readFileSync("package.json").toString());
|
|
467
468
|
}
|
|
468
|
-
function
|
|
469
|
-
return
|
|
469
|
+
function ge(t, e) {
|
|
470
|
+
return f.resolve(e, t, "tengo", "lib");
|
|
470
471
|
}
|
|
471
|
-
function
|
|
472
|
-
return
|
|
472
|
+
function he(t, e) {
|
|
473
|
+
return f.resolve(e, t, "tengo", "tpl");
|
|
473
474
|
}
|
|
474
|
-
function
|
|
475
|
-
return
|
|
475
|
+
function we(t, e) {
|
|
476
|
+
return f.resolve(e, t, "tengo", "software");
|
|
476
477
|
}
|
|
477
|
-
function
|
|
478
|
-
const
|
|
479
|
-
if (v(
|
|
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
|
|
482
|
-
v(
|
|
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 =
|
|
487
|
-
if (!
|
|
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(
|
|
490
|
-
if (h.name !==
|
|
491
|
-
if (v(
|
|
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
|
-
|
|
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
|
|
499
|
-
for (const
|
|
500
|
-
const i =
|
|
501
|
-
if (!
|
|
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:
|
|
506
|
+
id: o.slice(0, o.length - J.length),
|
|
506
507
|
version: e.version
|
|
507
|
-
},
|
|
508
|
-
if (n.addLib(
|
|
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
|
|
511
|
+
for (const d of c.dependencies) t.debug(` - ${g(d)}`);
|
|
511
512
|
}
|
|
512
513
|
}
|
|
513
514
|
}
|
|
514
|
-
function
|
|
515
|
-
for (const
|
|
516
|
-
const i =
|
|
517
|
-
if (!
|
|
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:
|
|
522
|
+
id: o.slice(0, o.length - G.length),
|
|
522
523
|
version: e.version
|
|
523
|
-
},
|
|
524
|
-
n.addTemplate(
|
|
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
|
|
528
|
-
for (const
|
|
529
|
-
const i =
|
|
530
|
-
if (!
|
|
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:
|
|
536
|
+
id: o.slice(0, o.length - z.length),
|
|
536
537
|
version: e.version
|
|
537
|
-
},
|
|
538
|
-
n.addSoftware(
|
|
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
|
|
542
|
-
const
|
|
543
|
-
for (const i of u.readdirSync(
|
|
544
|
-
const a =
|
|
545
|
-
if (v(
|
|
546
|
-
const w =
|
|
547
|
-
|
|
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
|
|
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 =
|
|
554
|
+
const b = f.resolve(s, a);
|
|
554
555
|
t.debug(`Parsing ${m(p)} from ${b}`);
|
|
555
|
-
const h =
|
|
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
|
-
|
|
561
|
+
o.push(h);
|
|
561
562
|
}
|
|
562
|
-
return
|
|
563
|
+
return o;
|
|
563
564
|
}
|
|
564
|
-
function
|
|
565
|
-
const s = new
|
|
566
|
-
return
|
|
565
|
+
function Y(t, e, r) {
|
|
566
|
+
const s = new Le(r);
|
|
567
|
+
return ye(t, s, e, Fe()), s;
|
|
567
568
|
}
|
|
568
|
-
function
|
|
569
|
-
const
|
|
570
|
-
return e.endsWith(
|
|
571
|
-
...
|
|
572
|
-
id: e.substring(0, e.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(
|
|
575
|
-
...
|
|
576
|
-
id: e.substring(0, e.length -
|
|
575
|
+
} : e.endsWith(P) ? {
|
|
576
|
+
...r,
|
|
577
|
+
id: e.substring(0, e.length - P.length),
|
|
577
578
|
type: "template"
|
|
578
|
-
} : e.endsWith(
|
|
579
|
-
...
|
|
580
|
-
id: e.substring(0, e.length -
|
|
579
|
+
} : e.endsWith(U) ? {
|
|
580
|
+
...r,
|
|
581
|
+
id: e.substring(0, e.length - U.length),
|
|
581
582
|
type: "software"
|
|
582
|
-
} : e.endsWith(
|
|
583
|
-
...
|
|
584
|
-
id: e.substring(0, e.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
|
|
589
|
-
const
|
|
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
|
|
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
|
|
598
|
-
return t.debug("Done."),
|
|
598
|
+
const o = s.compileAndAdd(n);
|
|
599
|
+
return t.debug("Done."), o;
|
|
599
600
|
}
|
|
600
|
-
function
|
|
601
|
+
function Ye(t, e, r) {
|
|
601
602
|
if (e.libs.length > 0) {
|
|
602
|
-
const s =
|
|
603
|
+
const s = ge(r, ".");
|
|
603
604
|
u.mkdirSync(s, { recursive: !0 });
|
|
604
605
|
for (const n of e.libs) {
|
|
605
|
-
const
|
|
606
|
-
t.info(` - writing ${
|
|
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 =
|
|
611
|
+
const s = he(r, ".");
|
|
611
612
|
u.mkdirSync(s, { recursive: !0 });
|
|
612
613
|
for (const n of e.templates) {
|
|
613
|
-
const
|
|
614
|
-
t.info(` - writing ${
|
|
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 =
|
|
619
|
+
const s = we(r, ".");
|
|
619
620
|
u.mkdirSync(s, { recursive: !0 });
|
|
620
621
|
for (const n of e.software) {
|
|
621
|
-
const
|
|
622
|
-
t.info(` - writing ${
|
|
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
|
|
627
|
-
"log-level":
|
|
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
|
-
},
|
|
633
|
-
"generate-tags":
|
|
633
|
+
}, _e = {
|
|
634
|
+
"generate-tags": F.boolean({
|
|
634
635
|
description: "generate tags, default false",
|
|
635
636
|
default: !1
|
|
636
637
|
}),
|
|
637
|
-
"tags-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":
|
|
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
|
-
},
|
|
649
|
+
}, x = class x extends $ {
|
|
649
650
|
async run() {
|
|
650
|
-
const { flags: e } = await this.parse(
|
|
651
|
-
|
|
652
|
-
let
|
|
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
|
-
|
|
655
|
-
`,
|
|
656
|
-
`,
|
|
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
|
|
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
|
-
`),
|
|
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 +=
|
|
670
|
+
i += c, a += d, i += `
|
|
670
671
|
}};
|
|
671
672
|
`, a += `
|
|
672
673
|
};
|
|
673
|
-
`, await
|
|
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
|
-
|
|
677
|
-
...
|
|
678
|
-
...
|
|
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
|
|
681
|
-
function
|
|
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
|
|
685
|
+
function tt(t, e) {
|
|
685
686
|
var a;
|
|
686
|
-
const
|
|
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 "${
|
|
689
|
-
Found ${
|
|
689
|
+
`Generating tags for tengo autocompletion from "${s}" in "${r}", additional arguments: "${n}".
|
|
690
|
+
Found ${o.length} tengo files...`
|
|
690
691
|
);
|
|
691
|
-
const i =
|
|
692
|
+
const i = Se(
|
|
692
693
|
"ctags",
|
|
693
694
|
[
|
|
694
695
|
"-f",
|
|
695
|
-
|
|
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
|
-
...
|
|
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
|
-
|
|
724
|
+
ot(i, "failed to generate ctags"), t.info("Generation of tags is done.");
|
|
724
725
|
}
|
|
725
|
-
function
|
|
726
|
-
const e = u.readdirSync(t, { withFileTypes: !0, recursive: !0 }),
|
|
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 =
|
|
730
|
-
|
|
730
|
+
const n = f.join(s.parentPath, s.name).replace(t, ".");
|
|
731
|
+
r.push(n);
|
|
731
732
|
}
|
|
732
|
-
}),
|
|
733
|
+
}), r;
|
|
733
734
|
}
|
|
734
|
-
function
|
|
735
|
+
function ot(t, e) {
|
|
735
736
|
t.error && console.log(t.error);
|
|
736
|
-
const
|
|
737
|
-
t.status !== 0 && console.log(`WARN: ${
|
|
737
|
+
const r = e;
|
|
738
|
+
t.status !== 0 && console.log(`WARN: ${r} the build will continue as-is`);
|
|
738
739
|
}
|
|
739
|
-
function
|
|
740
|
-
const
|
|
741
|
-
for (const
|
|
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(
|
|
744
|
-
), e.write(JSON.stringify(
|
|
744
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
745
|
+
), e.write(JSON.stringify(o) + `
|
|
745
746
|
`);
|
|
746
|
-
for (const
|
|
747
|
-
|
|
748
|
-
`Dumping to pl-tester: ${g(
|
|
749
|
-
), e.write(JSON.stringify(
|
|
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
|
|
752
|
+
for (const o of n.allTemplates())
|
|
752
753
|
t.debug(
|
|
753
|
-
`Dumping to pl-tester: ${g(
|
|
754
|
-
), e.write(JSON.stringify(
|
|
754
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
755
|
+
), e.write(JSON.stringify(o) + `
|
|
755
756
|
`);
|
|
756
|
-
for (const
|
|
757
|
-
|
|
758
|
-
`Dumping to pl-tester: ${g(
|
|
759
|
-
), e.write(JSON.stringify(
|
|
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
|
|
762
|
+
for (const o of n.allSoftware())
|
|
762
763
|
t.debug(
|
|
763
|
-
`Dumping to pl-tester: ${g(
|
|
764
|
-
), e.write(JSON.stringify(
|
|
764
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
765
|
+
), e.write(JSON.stringify(o) + `
|
|
765
766
|
`);
|
|
766
|
-
for (const
|
|
767
|
-
|
|
768
|
-
`Dumping to pl-tester: ${g(
|
|
769
|
-
), e.write(JSON.stringify(
|
|
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
|
|
772
|
-
|
|
773
|
-
`Dumping to pl-tester: ${g(
|
|
774
|
-
), e.write(JSON.stringify(
|
|
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
|
|
778
|
-
const
|
|
779
|
-
|
|
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
|
-
}),
|
|
815
|
+
}), r;
|
|
782
816
|
}
|
|
783
|
-
function
|
|
784
|
-
return new Promise((e,
|
|
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
|
-
|
|
822
|
+
r(s);
|
|
789
823
|
});
|
|
790
824
|
});
|
|
791
825
|
}
|
|
792
|
-
const
|
|
826
|
+
const N = class N extends $ {
|
|
793
827
|
async run() {
|
|
794
|
-
const { flags: e, argv:
|
|
795
|
-
|
|
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
|
-
|
|
838
|
+
ee(s, o.stdin);
|
|
805
839
|
} catch (i) {
|
|
806
840
|
s.error(i);
|
|
807
841
|
} finally {
|
|
808
|
-
|
|
809
|
-
const i = await
|
|
842
|
+
o.stdin.end();
|
|
843
|
+
const i = await ve(o);
|
|
810
844
|
process.exit(i);
|
|
811
845
|
}
|
|
812
846
|
}
|
|
813
847
|
};
|
|
814
|
-
|
|
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
|
-
|
|
818
|
-
let
|
|
819
|
-
const
|
|
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(
|
|
822
|
-
|
|
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
|
-
|
|
832
|
-
} catch (
|
|
833
|
-
|
|
865
|
+
ee(r, n.stdin);
|
|
866
|
+
} catch (o) {
|
|
867
|
+
r.error(o);
|
|
834
868
|
} finally {
|
|
835
869
|
n.stdin.end();
|
|
836
|
-
const
|
|
837
|
-
process.exit(
|
|
870
|
+
const o = await ve(n);
|
|
871
|
+
process.exit(o);
|
|
838
872
|
}
|
|
839
873
|
}
|
|
840
874
|
};
|
|
841
|
-
|
|
842
|
-
let
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
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
|
-
|
|
936
|
+
yt as COMMANDS
|
|
850
937
|
};
|
|
851
938
|
//# sourceMappingURL=index.mjs.map
|