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