@platforma-sdk/tengo-builder 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +572 -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,476 @@ 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:/, He = /^\s*\/\/\s+tengo:/, 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
|
-
return { line:
|
|
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
|
+
return t.canDetectOptions ? { line: e, context: t, artifact: void 0, option: rt(e) } : (s.warn(
|
|
485
|
+
`[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'`
|
|
486
|
+
), { line: e, context: t, artifact: void 0, option: void 0 });
|
|
487
|
+
if (He.exec(e) && t.canDetectOptions)
|
|
488
|
+
return s.warn(
|
|
489
|
+
`[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)`
|
|
490
|
+
), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
491
|
+
if (Qe.exec(e))
|
|
492
|
+
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
493
|
+
if (et.exec(e))
|
|
494
|
+
return t.isInCommentBlock = !0, { line: e, context: t, artifact: void 0, option: void 0 };
|
|
495
|
+
if (Xe.exec(e))
|
|
496
|
+
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
497
|
+
t.canDetectOptions = !1;
|
|
498
|
+
const o = be.exec(e);
|
|
499
|
+
if (o) {
|
|
500
|
+
const i = at(e);
|
|
501
|
+
if (i.module === "plapi")
|
|
502
|
+
return t.tplDepREs.has(i.module) || t.tplDepREs.set(i.module, [
|
|
503
|
+
["template", Ve(i.alias)],
|
|
504
|
+
["software", Ze(i.alias)]
|
|
505
|
+
]), { line: e, context: t, artifact: void 0, option: void 0 };
|
|
506
|
+
(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, [
|
|
507
|
+
["template", ue(i.alias)],
|
|
508
|
+
["software", me(i.alias)]
|
|
509
|
+
])), (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, [
|
|
510
|
+
["template", ue(i.alias)],
|
|
511
|
+
["software", me(i.alias)],
|
|
512
|
+
["asset", Ke(i.alias)]
|
|
442
513
|
]));
|
|
443
|
-
const
|
|
444
|
-
return
|
|
514
|
+
const a = ge(i.module, "library", r);
|
|
515
|
+
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
516
|
}
|
|
446
|
-
if (
|
|
447
|
-
for (const [
|
|
448
|
-
for (const [
|
|
449
|
-
const d =
|
|
517
|
+
if (t.tplDepREs.size > 0)
|
|
518
|
+
for (const [i, a] of t.tplDepREs)
|
|
519
|
+
for (const [c, u] of a) {
|
|
520
|
+
const d = u.exec(e);
|
|
450
521
|
if (!d || !d.groups)
|
|
451
522
|
continue;
|
|
452
|
-
const { fnCall:
|
|
453
|
-
if (!
|
|
523
|
+
const { fnCall: y, templateName: w, fnName: b } = d.groups;
|
|
524
|
+
if (!y || !w || !b)
|
|
454
525
|
throw Error("failed to parse template import statement");
|
|
455
|
-
const
|
|
456
|
-
if (!
|
|
526
|
+
const v = ge(w, c, r);
|
|
527
|
+
if (!v)
|
|
457
528
|
throw Error(`failed to parse artifact name in ${b} import statement`);
|
|
458
|
-
return
|
|
529
|
+
return e = e.replace(y, `${b}("${v.pkg}:${v.id}")`), { line: e, context: t, artifact: v, option: void 0 };
|
|
459
530
|
}
|
|
460
|
-
return { line:
|
|
531
|
+
return { line: e, context: t, artifact: void 0, option: void 0 };
|
|
461
532
|
}
|
|
462
|
-
function
|
|
463
|
-
const e =
|
|
533
|
+
function at(s) {
|
|
534
|
+
const e = st.exec(s);
|
|
464
535
|
if (!e || !e.groups)
|
|
465
536
|
throw Error("failed to parse 'import' statement");
|
|
466
|
-
const { importName:
|
|
467
|
-
if (!
|
|
537
|
+
const { importName: t, moduleName: r } = e.groups;
|
|
538
|
+
if (!t || !r)
|
|
468
539
|
throw Error("failed to parse 'import' statement");
|
|
469
540
|
return {
|
|
470
|
-
module:
|
|
471
|
-
alias:
|
|
541
|
+
module: r,
|
|
542
|
+
alias: t
|
|
472
543
|
};
|
|
473
544
|
}
|
|
474
|
-
function ge(
|
|
475
|
-
const
|
|
476
|
-
if (!
|
|
545
|
+
function ge(s, e, t) {
|
|
546
|
+
const r = ot.exec(s);
|
|
547
|
+
if (!r)
|
|
477
548
|
return;
|
|
478
|
-
if (!
|
|
549
|
+
if (!r.groups)
|
|
479
550
|
throw Error(
|
|
480
551
|
"failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'"
|
|
481
552
|
);
|
|
482
|
-
const { pkgName: n, depID:
|
|
483
|
-
if (!
|
|
553
|
+
const { pkgName: n, depID: o } = r.groups;
|
|
554
|
+
if (!o)
|
|
484
555
|
throw Error(
|
|
485
556
|
"failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'"
|
|
486
557
|
);
|
|
487
|
-
return { type: e, pkg: n ??
|
|
488
|
-
}
|
|
489
|
-
const z = ".plj.gz", W = ".lib.tengo", P = ".sw.json", U = ".as.json", he = ".test.tengo", q = ".tpl.tengo", B = ".lib.tengo", V = ".sw.json", Z = ".as.json", et = [B, q, V, Z];
|
|
490
|
-
function E(t = "debug") {
|
|
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
|
-
});
|
|
558
|
+
return { type: e, pkg: n ?? t, id: o };
|
|
501
559
|
}
|
|
502
|
-
|
|
560
|
+
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];
|
|
561
|
+
function M() {
|
|
503
562
|
return JSON.parse(p.readFileSync("package.json").toString());
|
|
504
563
|
}
|
|
505
|
-
function
|
|
506
|
-
return f.resolve(e,
|
|
564
|
+
function Ee(s, e) {
|
|
565
|
+
return f.resolve(e, s, "tengo", "lib");
|
|
507
566
|
}
|
|
508
|
-
function
|
|
509
|
-
return f.resolve(e,
|
|
567
|
+
function $e(s, e) {
|
|
568
|
+
return f.resolve(e, s, "tengo", "tpl");
|
|
510
569
|
}
|
|
511
|
-
function Ne(
|
|
512
|
-
return f.resolve(e,
|
|
570
|
+
function Ne(s, e) {
|
|
571
|
+
return f.resolve(e, s, "tengo", "software");
|
|
513
572
|
}
|
|
514
|
-
function Se(
|
|
515
|
-
return f.resolve(e,
|
|
573
|
+
function Se(s, e) {
|
|
574
|
+
return f.resolve(e, s, "tengo", "asset");
|
|
516
575
|
}
|
|
517
|
-
function ke(
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
for (const ae of p.readdirSync(
|
|
521
|
-
const
|
|
522
|
-
|
|
576
|
+
function ke(s, e, t, r, n = !1) {
|
|
577
|
+
const o = f.resolve(r, "package.json");
|
|
578
|
+
if (E(o) !== "file") {
|
|
579
|
+
for (const ae of p.readdirSync(r)) {
|
|
580
|
+
const De = E(f.join(r, ae)) === "link", le = f.resolve(r, ae);
|
|
581
|
+
E(le) === "dir" && ke(s, e, t, le, De);
|
|
523
582
|
}
|
|
524
583
|
return;
|
|
525
584
|
}
|
|
526
|
-
const i =
|
|
527
|
-
if (!
|
|
585
|
+
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";
|
|
586
|
+
if (!d && !y && !w && !b)
|
|
528
587
|
return;
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
if (
|
|
588
|
+
const v = JSON.parse(p.readFileSync(o).toString());
|
|
589
|
+
if (v.name !== t.name) {
|
|
590
|
+
if (E(f.resolve(r, "node_modules")) === "dir" && n)
|
|
532
591
|
throw new Error(
|
|
533
|
-
`nested node_modules is a sign of library dependencies version incompatibility in ${
|
|
592
|
+
`nested node_modules is a sign of library dependencies version incompatibility in ${r}`
|
|
534
593
|
);
|
|
535
|
-
|
|
594
|
+
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
595
|
}
|
|
537
596
|
}
|
|
538
|
-
function
|
|
539
|
-
for (const
|
|
540
|
-
const i = f.resolve(
|
|
541
|
-
if (!
|
|
597
|
+
function ct(s, e, t, r, n) {
|
|
598
|
+
for (const o of p.readdirSync(r)) {
|
|
599
|
+
const i = f.resolve(r, o);
|
|
600
|
+
if (!o.endsWith(z)) throw new Error(`unexpected file in 'lib' folder: ${i}`);
|
|
542
601
|
const a = {
|
|
543
602
|
type: "library",
|
|
544
603
|
pkg: e.name,
|
|
545
|
-
id:
|
|
604
|
+
id: o.slice(0, o.length - z.length),
|
|
546
605
|
version: e.version
|
|
547
|
-
}, c =
|
|
548
|
-
if (n.addLib(c),
|
|
549
|
-
|
|
550
|
-
for (const
|
|
606
|
+
}, c = ve(s, t, i, a, !0);
|
|
607
|
+
if (n.addLib(c), s.debug(`Adding dependency ${m(a)} from ${i}`), c.dependencies.length > 0) {
|
|
608
|
+
s.debug("Dependencies:");
|
|
609
|
+
for (const u of c.dependencies) s.debug(` - ${g(u)}`);
|
|
551
610
|
}
|
|
552
611
|
}
|
|
553
612
|
}
|
|
554
|
-
function
|
|
555
|
-
for (const
|
|
556
|
-
const i = f.resolve(
|
|
557
|
-
if (!
|
|
613
|
+
function dt(s, e, t, r, n) {
|
|
614
|
+
for (const o of p.readdirSync(r)) {
|
|
615
|
+
const i = f.resolve(r, o);
|
|
616
|
+
if (!o.endsWith(U)) throw new Error(`unexpected file in 'tpl' folder: ${i}`);
|
|
558
617
|
const a = {
|
|
559
618
|
type: "template",
|
|
560
619
|
pkg: e.name,
|
|
561
|
-
id:
|
|
620
|
+
id: o.slice(0, o.length - U.length),
|
|
562
621
|
version: e.version
|
|
563
|
-
}, c = new ye(
|
|
564
|
-
n.addTemplate(c),
|
|
622
|
+
}, c = new ye(t, a, { content: p.readFileSync(i) });
|
|
623
|
+
n.addTemplate(c), s.debug(`Adding dependency ${m(a)} from ${i}`);
|
|
565
624
|
}
|
|
566
625
|
}
|
|
567
|
-
function
|
|
568
|
-
for (const
|
|
569
|
-
const i = f.resolve(
|
|
570
|
-
if (!
|
|
626
|
+
function ft(s, e, t, r, n) {
|
|
627
|
+
for (const o of p.readdirSync(r)) {
|
|
628
|
+
const i = f.resolve(r, o);
|
|
629
|
+
if (!o.endsWith(P))
|
|
571
630
|
throw new Error(`unexpected file in 'software' folder: ${i}`);
|
|
572
631
|
const a = {
|
|
573
632
|
type: "software",
|
|
574
633
|
pkg: e.name,
|
|
575
|
-
id:
|
|
634
|
+
id: o.slice(0, o.length - P.length),
|
|
576
635
|
version: e.version
|
|
577
|
-
}, c = new
|
|
578
|
-
|
|
636
|
+
}, c = new oe(t, a, p.readFileSync(i).toString(), i, [], []);
|
|
637
|
+
s.debug(`Adding dependency ${m(a)} from ${i}`), n.addSoftware(c);
|
|
579
638
|
}
|
|
580
639
|
}
|
|
581
|
-
function
|
|
582
|
-
for (const
|
|
583
|
-
const i = f.resolve(
|
|
584
|
-
if (!
|
|
640
|
+
function pt(s, e, t, r, n) {
|
|
641
|
+
for (const o of p.readdirSync(r)) {
|
|
642
|
+
const i = f.resolve(r, o);
|
|
643
|
+
if (!o.endsWith(W))
|
|
585
644
|
throw new Error(`unexpected file in 'asset' folder: ${i}`);
|
|
586
645
|
const a = {
|
|
587
646
|
type: "asset",
|
|
588
647
|
pkg: e.name,
|
|
589
|
-
id:
|
|
648
|
+
id: o.slice(0, o.length - W.length),
|
|
590
649
|
version: e.version
|
|
591
|
-
}, c = new
|
|
592
|
-
|
|
650
|
+
}, c = new oe(t, a, p.readFileSync(i).toString(), i, [], []);
|
|
651
|
+
s.debug(`Adding dependency ${m(a)} from ${i}`), n.addAsset(c);
|
|
593
652
|
}
|
|
594
653
|
}
|
|
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
|
-
|
|
654
|
+
function L(s, e, t, r, n) {
|
|
655
|
+
const o = [];
|
|
656
|
+
for (const i of p.readdirSync(f.join(r, n))) {
|
|
657
|
+
const a = f.join(n, i), c = f.join(r, a);
|
|
658
|
+
if (E(c) === "dir") {
|
|
659
|
+
const b = L(s, e, t, r, a);
|
|
660
|
+
o.push(...b);
|
|
602
661
|
continue;
|
|
603
662
|
}
|
|
604
|
-
const
|
|
605
|
-
if (!
|
|
663
|
+
const u = i === "index.lib.tengo" ? `${f.basename(n)}.lib.tengo` : a, d = ut(e, u.replaceAll(f.sep, "."));
|
|
664
|
+
if (!d)
|
|
606
665
|
continue;
|
|
607
|
-
const y = f.resolve(
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
for (const
|
|
666
|
+
const y = f.resolve(r, a);
|
|
667
|
+
s.debug(`Parsing ${m(d)} from ${y}`);
|
|
668
|
+
const w = ve(s, t, y, d, !0);
|
|
669
|
+
if (w.dependencies.length > 0) {
|
|
670
|
+
s.debug("Detected dependencies:");
|
|
671
|
+
for (const b of w.dependencies) s.debug(` - ${g(b)}`);
|
|
613
672
|
}
|
|
614
|
-
|
|
673
|
+
o.push(w);
|
|
615
674
|
}
|
|
616
|
-
return
|
|
675
|
+
return o;
|
|
617
676
|
}
|
|
618
|
-
function
|
|
619
|
-
const
|
|
620
|
-
return ke(
|
|
677
|
+
function re(s, e, t) {
|
|
678
|
+
const r = new Be(t);
|
|
679
|
+
return ke(s, r, e, Ce()), r;
|
|
621
680
|
}
|
|
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,
|
|
681
|
+
function ut(s, e) {
|
|
682
|
+
const t = { pkg: s.name, version: s.version };
|
|
683
|
+
return e.endsWith(q) ? {
|
|
684
|
+
...t,
|
|
630
685
|
id: e.substring(0, e.length - q.length),
|
|
686
|
+
type: "library"
|
|
687
|
+
} : e.endsWith(_) ? {
|
|
688
|
+
...t,
|
|
689
|
+
id: e.substring(0, e.length - _.length),
|
|
631
690
|
type: "template"
|
|
691
|
+
} : e.endsWith(B) ? {
|
|
692
|
+
...t,
|
|
693
|
+
id: e.substring(0, e.length - B.length),
|
|
694
|
+
type: "software"
|
|
632
695
|
} : e.endsWith(V) ? {
|
|
633
|
-
...
|
|
696
|
+
...t,
|
|
634
697
|
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
698
|
type: "asset"
|
|
640
699
|
} : e.endsWith(he) ? {
|
|
641
|
-
...
|
|
700
|
+
...t,
|
|
642
701
|
id: e.substring(0, e.length - he.length),
|
|
643
702
|
type: "test"
|
|
644
703
|
} : null;
|
|
645
704
|
}
|
|
646
|
-
function
|
|
647
|
-
const
|
|
705
|
+
function mt(s, e) {
|
|
706
|
+
const t = M(), r = re(s, t, e), n = L(s, t, e, "src", "");
|
|
648
707
|
if (n.length === 0) {
|
|
649
708
|
const i = [];
|
|
650
|
-
for (const a of
|
|
709
|
+
for (const a of lt)
|
|
651
710
|
i.push(`*${a}`);
|
|
652
|
-
|
|
711
|
+
s.error(`Nothing to compile. Looked for ${i.join(", ")}`), process.exit(1);
|
|
653
712
|
}
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
return
|
|
713
|
+
s.info(`Compiling '${e}'...`);
|
|
714
|
+
const o = r.compileAndAdd(n);
|
|
715
|
+
return s.debug("Done."), o;
|
|
657
716
|
}
|
|
658
|
-
function
|
|
717
|
+
function gt(s, e, t) {
|
|
659
718
|
if (e.libs.length > 0) {
|
|
660
|
-
const
|
|
661
|
-
p.mkdirSync(
|
|
719
|
+
const r = Ee(t, ".");
|
|
720
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
662
721
|
for (const n of e.libs) {
|
|
663
|
-
const
|
|
664
|
-
|
|
722
|
+
const o = f.resolve(r, n.fullName.id + z);
|
|
723
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, n.src);
|
|
665
724
|
}
|
|
666
725
|
}
|
|
667
726
|
if (e.templates.length > 0) {
|
|
668
|
-
const
|
|
669
|
-
p.mkdirSync(
|
|
727
|
+
const r = $e(t, ".");
|
|
728
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
670
729
|
for (const n of e.templates) {
|
|
671
|
-
const
|
|
672
|
-
|
|
730
|
+
const o = f.resolve(r, n.fullName.id + U);
|
|
731
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, n.content);
|
|
673
732
|
}
|
|
674
733
|
}
|
|
675
734
|
if (e.software.length > 0) {
|
|
676
|
-
const
|
|
677
|
-
p.mkdirSync(
|
|
735
|
+
const r = Ne(t, ".");
|
|
736
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
678
737
|
for (const n of e.software) {
|
|
679
|
-
const
|
|
680
|
-
|
|
738
|
+
const o = f.resolve(r, n.fullName.id + P);
|
|
739
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, n.src);
|
|
681
740
|
}
|
|
682
741
|
}
|
|
683
742
|
if (e.assets.length > 0) {
|
|
684
|
-
const
|
|
685
|
-
p.mkdirSync(
|
|
743
|
+
const r = Se(t, ".");
|
|
744
|
+
p.mkdirSync(r, { recursive: !0 });
|
|
686
745
|
for (const n of e.software) {
|
|
687
|
-
const
|
|
688
|
-
|
|
746
|
+
const o = f.resolve(r, n.fullName.id + W);
|
|
747
|
+
s.info(` - writing ${o}`), p.writeFileSync(o, n.src);
|
|
689
748
|
}
|
|
690
749
|
}
|
|
691
750
|
}
|
|
692
751
|
const ne = {
|
|
693
|
-
"log-level":
|
|
752
|
+
"log-level": O.string({
|
|
694
753
|
description: "logging level",
|
|
695
754
|
default: "info",
|
|
696
755
|
options: ["error", "warn", "info", "debug"]
|
|
697
756
|
})
|
|
698
|
-
},
|
|
699
|
-
"generate-tags":
|
|
757
|
+
}, ht = {
|
|
758
|
+
"generate-tags": O.boolean({
|
|
700
759
|
description: "generate tags, default false",
|
|
701
760
|
default: !1
|
|
702
761
|
}),
|
|
703
|
-
"tags-file":
|
|
762
|
+
"tags-file": O.file({
|
|
704
763
|
description: 'where to put ".tags" file, it should be a root of VS Code project',
|
|
705
764
|
default: "../../.tags"
|
|
706
765
|
// usually a user opens a directory with all blocks
|
|
707
766
|
}),
|
|
708
|
-
"tags-additional-args":
|
|
767
|
+
"tags-additional-args": O.string({
|
|
709
768
|
description: "additional flags for universal-ctags command: e.g. -e for emacs",
|
|
710
769
|
default: [],
|
|
711
770
|
multiple: !0,
|
|
712
771
|
delimiter: ","
|
|
713
772
|
})
|
|
714
|
-
},
|
|
773
|
+
}, A = class A extends $ {
|
|
715
774
|
async run() {
|
|
716
|
-
const { flags: e } = await this.parse(
|
|
717
|
-
|
|
718
|
-
let
|
|
775
|
+
const { flags: e } = await this.parse(A), t = N(e["log-level"]), r = M(), n = mt(t, "dist");
|
|
776
|
+
gt(t, n, "dist"), t.info("");
|
|
777
|
+
let o = `declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
|
|
719
778
|
`;
|
|
720
|
-
|
|
721
|
-
`,
|
|
722
|
-
`,
|
|
779
|
+
o += `declare type TplName = ${n.templates.map((d) => '"' + d.fullName.id + '"').join(" | ")};
|
|
780
|
+
`, o += `declare const Templates: Record<TplName, TemplateFromFile>;
|
|
781
|
+
`, o += `export { Templates };
|
|
723
782
|
`;
|
|
724
783
|
let i = `module.exports = { Templates: {
|
|
725
784
|
`, a = `import { resolve } from 'node:path';
|
|
726
785
|
export const Templates = {
|
|
727
786
|
`;
|
|
728
787
|
const c = n.templates.map(
|
|
729
|
-
(
|
|
788
|
+
(d) => ` '${d.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${d.fullName.id}.plj.gz') }`
|
|
730
789
|
).join(`,
|
|
731
|
-
`),
|
|
732
|
-
(
|
|
790
|
+
`), u = n.templates.map(
|
|
791
|
+
(d) => ` '${d.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${d.fullName.id}.plj.gz') }`
|
|
733
792
|
).join(`,
|
|
734
793
|
`);
|
|
735
|
-
i += c, a +=
|
|
794
|
+
i += c, a += u, i += `
|
|
736
795
|
}};
|
|
737
796
|
`, a += `
|
|
738
797
|
};
|
|
739
|
-
`, await
|
|
798
|
+
`, 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
799
|
}
|
|
741
800
|
};
|
|
742
|
-
l(
|
|
801
|
+
l(A, "description", "build tengo sources into single distributable pack file"), l(A, "examples", ["<%= config.bin %> <%= command.id %>"]), l(A, "flags", {
|
|
743
802
|
...ne,
|
|
744
|
-
...
|
|
803
|
+
...ht
|
|
745
804
|
});
|
|
746
|
-
let
|
|
747
|
-
function
|
|
748
|
-
process.env.GENERATE_TAGS != null && (
|
|
805
|
+
let Z = A;
|
|
806
|
+
function wt(s) {
|
|
807
|
+
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
808
|
}
|
|
750
|
-
function
|
|
809
|
+
function yt(s, e) {
|
|
751
810
|
var a;
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
`Generating tags for tengo autocompletion from "${
|
|
755
|
-
Found ${
|
|
811
|
+
const t = f.resolve(e["tags-file"]), r = f.dirname(t), n = e["tags-additional-args"], o = bt(r);
|
|
812
|
+
s.info(
|
|
813
|
+
`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${n}".
|
|
814
|
+
Found ${o.length} tengo files...`
|
|
756
815
|
);
|
|
757
|
-
const i =
|
|
816
|
+
const i = Fe(
|
|
758
817
|
"ctags",
|
|
759
818
|
[
|
|
760
819
|
"-f",
|
|
761
|
-
|
|
820
|
+
t,
|
|
762
821
|
...n,
|
|
763
822
|
"--langdef=tengo",
|
|
764
823
|
"--map-tengo=+.tengo",
|
|
@@ -767,12 +826,12 @@ Found ${s.length} tengo files...`
|
|
|
767
826
|
"--kinddef-tengo=c,constant,constant",
|
|
768
827
|
'--regex-tengo=/^\\s*(.*) := ("|\\{).*/\\1/c/',
|
|
769
828
|
"-R",
|
|
770
|
-
...
|
|
829
|
+
...o
|
|
771
830
|
],
|
|
772
831
|
{
|
|
773
832
|
env: process.env,
|
|
774
833
|
stdio: "inherit",
|
|
775
|
-
cwd:
|
|
834
|
+
cwd: r
|
|
776
835
|
}
|
|
777
836
|
);
|
|
778
837
|
if ((a = i.error) != null && a.message.includes("ENOENT")) {
|
|
@@ -786,121 +845,121 @@ For vscode, you should also install ctags extension:
|
|
|
786
845
|
https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
|
|
787
846
|
return;
|
|
788
847
|
}
|
|
789
|
-
|
|
848
|
+
vt(i, "failed to generate ctags"), s.info("Generation of tags is done.");
|
|
790
849
|
}
|
|
791
|
-
function
|
|
792
|
-
const e = p.readdirSync(
|
|
793
|
-
return e.forEach((
|
|
794
|
-
if (!
|
|
795
|
-
const n = f.join(
|
|
796
|
-
|
|
850
|
+
function bt(s) {
|
|
851
|
+
const e = p.readdirSync(s, { withFileTypes: !0, recursive: !0 }), t = [];
|
|
852
|
+
return e.forEach((r) => {
|
|
853
|
+
if (!r.isDirectory() && r.name.endsWith(".tengo")) {
|
|
854
|
+
const n = f.join(r.parentPath, r.name).replace(s, ".");
|
|
855
|
+
t.push(n);
|
|
797
856
|
}
|
|
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(
|
|
857
|
+
}), t;
|
|
858
|
+
}
|
|
859
|
+
function vt(s, e) {
|
|
860
|
+
s.error && console.log(s.error);
|
|
861
|
+
const t = e;
|
|
862
|
+
s.status !== 0 && console.log(`WARN: ${t} the build will continue as-is`);
|
|
863
|
+
}
|
|
864
|
+
function ie(s, e) {
|
|
865
|
+
const t = M(), r = L(s, t, "dist", "src", ""), n = re(s, t, "dist");
|
|
866
|
+
for (const o of n.allLibs())
|
|
867
|
+
s.debug(
|
|
868
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
869
|
+
), e.write(JSON.stringify(o) + `
|
|
811
870
|
`);
|
|
812
|
-
for (const
|
|
813
|
-
|
|
814
|
-
`Dumping to pl-tester: ${g(
|
|
815
|
-
), e.write(JSON.stringify(
|
|
871
|
+
for (const o of r)
|
|
872
|
+
o.fullName.type === "library" && (s.debug(
|
|
873
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
874
|
+
), e.write(JSON.stringify(o) + `
|
|
816
875
|
`));
|
|
817
|
-
for (const
|
|
818
|
-
|
|
819
|
-
`Dumping to pl-tester: ${g(
|
|
820
|
-
), e.write(JSON.stringify(
|
|
876
|
+
for (const o of n.allTemplates())
|
|
877
|
+
s.debug(
|
|
878
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
879
|
+
), e.write(JSON.stringify(o) + `
|
|
821
880
|
`);
|
|
822
|
-
for (const
|
|
823
|
-
|
|
824
|
-
`Dumping to pl-tester: ${g(
|
|
825
|
-
), e.write(JSON.stringify(
|
|
881
|
+
for (const o of r)
|
|
882
|
+
o.fullName.type === "template" && (s.debug(
|
|
883
|
+
`Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`
|
|
884
|
+
), e.write(JSON.stringify(o) + `
|
|
826
885
|
`));
|
|
827
|
-
for (const
|
|
828
|
-
|
|
829
|
-
`Dumping to pl-tester: ${g(
|
|
830
|
-
), e.write(JSON.stringify(
|
|
886
|
+
for (const o of n.allSoftware())
|
|
887
|
+
s.debug(
|
|
888
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
889
|
+
), e.write(JSON.stringify(o) + `
|
|
831
890
|
`);
|
|
832
|
-
for (const
|
|
833
|
-
|
|
834
|
-
`Dumping to pl-tester: ${g(
|
|
835
|
-
), e.write(JSON.stringify(
|
|
891
|
+
for (const o of r)
|
|
892
|
+
o.fullName.type === "software" && (s.debug(
|
|
893
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
894
|
+
), e.write(JSON.stringify(o) + `
|
|
836
895
|
`));
|
|
837
|
-
for (const
|
|
838
|
-
|
|
839
|
-
`Dumping to pl-tester: ${g(
|
|
840
|
-
), e.write(JSON.stringify(
|
|
896
|
+
for (const o of n.allAssets())
|
|
897
|
+
s.debug(
|
|
898
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
899
|
+
), e.write(JSON.stringify(o) + `
|
|
841
900
|
`);
|
|
842
|
-
for (const
|
|
843
|
-
|
|
844
|
-
`Dumping to pl-tester: ${g(
|
|
845
|
-
), e.write(JSON.stringify(
|
|
901
|
+
for (const o of r)
|
|
902
|
+
o.fullName.type === "asset" && (s.debug(
|
|
903
|
+
`Dumping to pl-tester: ${g(o.fullName)}`
|
|
904
|
+
), e.write(JSON.stringify(o) + `
|
|
846
905
|
`));
|
|
847
|
-
for (const
|
|
848
|
-
|
|
849
|
-
`Dumping to pl-tester: ${g(
|
|
850
|
-
), e.write(JSON.stringify(
|
|
906
|
+
for (const o of r)
|
|
907
|
+
o.fullName.type === "test" && (s.debug(
|
|
908
|
+
`Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`
|
|
909
|
+
), e.write(JSON.stringify(o) + `
|
|
851
910
|
`));
|
|
852
911
|
}
|
|
853
|
-
function
|
|
854
|
-
const
|
|
912
|
+
function Et(s, e, t) {
|
|
913
|
+
const r = M(), n = L(s, r, "dist", "src", "");
|
|
855
914
|
if (!e) {
|
|
856
915
|
for (const i of n)
|
|
857
|
-
i.fullName.type === "library" &&
|
|
916
|
+
i.fullName.type === "library" && t.write(JSON.stringify(i) + `
|
|
858
917
|
`);
|
|
859
918
|
return;
|
|
860
919
|
}
|
|
861
|
-
const
|
|
920
|
+
const o = re(s, r, "dist");
|
|
862
921
|
for (const i of n)
|
|
863
|
-
i.fullName.type === "library" &&
|
|
864
|
-
for (const i of
|
|
865
|
-
|
|
922
|
+
i.fullName.type === "library" && o.addLib(i);
|
|
923
|
+
for (const i of o.allLibs())
|
|
924
|
+
t.write(JSON.stringify(i) + `
|
|
866
925
|
`);
|
|
867
926
|
}
|
|
868
|
-
function C(
|
|
869
|
-
const
|
|
870
|
-
for (const
|
|
871
|
-
|
|
927
|
+
function C(s, e, t) {
|
|
928
|
+
const r = M(), n = L(s, r, "dist", "src", "");
|
|
929
|
+
for (const o of n)
|
|
930
|
+
o.fullName.type === t && e.write(JSON.stringify(o) + `
|
|
872
931
|
`);
|
|
873
932
|
}
|
|
874
|
-
function
|
|
875
|
-
C(
|
|
933
|
+
function $t(s, e) {
|
|
934
|
+
C(s, e, "template");
|
|
876
935
|
}
|
|
877
|
-
function
|
|
878
|
-
C(
|
|
936
|
+
function Nt(s, e) {
|
|
937
|
+
C(s, e, "software");
|
|
879
938
|
}
|
|
880
|
-
function
|
|
881
|
-
C(
|
|
939
|
+
function St(s, e) {
|
|
940
|
+
C(s, e, "asset");
|
|
882
941
|
}
|
|
883
|
-
function
|
|
884
|
-
C(
|
|
942
|
+
function kt(s, e) {
|
|
943
|
+
C(s, e, "test");
|
|
885
944
|
}
|
|
886
|
-
function Ae(
|
|
887
|
-
const
|
|
888
|
-
return
|
|
889
|
-
|
|
890
|
-
}),
|
|
945
|
+
function Ae(s, ...e) {
|
|
946
|
+
const t = Re(s, e, { stdio: ["pipe", "inherit", "inherit"] });
|
|
947
|
+
return t.stdin.on("error", (r) => {
|
|
948
|
+
r.code;
|
|
949
|
+
}), t;
|
|
891
950
|
}
|
|
892
|
-
function Te(
|
|
893
|
-
return new Promise((e,
|
|
894
|
-
|
|
895
|
-
e(
|
|
896
|
-
}),
|
|
897
|
-
r
|
|
951
|
+
function Te(s) {
|
|
952
|
+
return new Promise((e, t) => {
|
|
953
|
+
s.on("close", (r) => {
|
|
954
|
+
e(r);
|
|
955
|
+
}), s.on("error", (r) => {
|
|
956
|
+
t(r);
|
|
898
957
|
});
|
|
899
958
|
});
|
|
900
959
|
}
|
|
901
|
-
const
|
|
960
|
+
const S = class S extends $ {
|
|
902
961
|
async run() {
|
|
903
|
-
const { flags: e, argv:
|
|
962
|
+
const { flags: e, argv: t } = await this.parse(S), r = N(e["log-level"]), n = t.length == 0 ? ["./src"] : t, o = Ae(
|
|
904
963
|
we,
|
|
905
964
|
"check",
|
|
906
965
|
"--log-level",
|
|
@@ -910,114 +969,114 @@ const N = class N extends v {
|
|
|
910
969
|
...n
|
|
911
970
|
);
|
|
912
971
|
try {
|
|
913
|
-
ie(
|
|
972
|
+
ie(r, o.stdin);
|
|
914
973
|
} catch (i) {
|
|
915
|
-
|
|
974
|
+
r.error(i);
|
|
916
975
|
} finally {
|
|
917
|
-
|
|
918
|
-
const i = await Te(
|
|
976
|
+
o.stdin.end();
|
|
977
|
+
const i = await Te(o);
|
|
919
978
|
process.exit(i);
|
|
920
979
|
}
|
|
921
980
|
}
|
|
922
981
|
};
|
|
923
|
-
l(
|
|
982
|
+
l(S, "description", "check tengo sources for language processor an"), // static override args = {
|
|
924
983
|
// "log-level": Args.string({description: 'logging level'}),
|
|
925
984
|
// }
|
|
926
|
-
l(
|
|
927
|
-
let
|
|
928
|
-
const
|
|
985
|
+
l(S, "strict", !1), l(S, "flags", { ...ne }), l(S, "examples", ["<%= config.bin %> <%= command.id %>"]);
|
|
986
|
+
let K = S;
|
|
987
|
+
const k = class k extends $ {
|
|
929
988
|
async run() {
|
|
930
|
-
const { flags: e } = await this.parse(
|
|
989
|
+
const { flags: e } = await this.parse(k), t = N(e["log-level"]), r = this.argv.length == 0 ? ["./src"] : this.argv, n = Ae(
|
|
931
990
|
we,
|
|
932
991
|
"run",
|
|
933
992
|
"--log-level",
|
|
934
993
|
e["log-level"],
|
|
935
994
|
"--artifacts",
|
|
936
995
|
"-",
|
|
937
|
-
...
|
|
996
|
+
...r
|
|
938
997
|
);
|
|
939
998
|
try {
|
|
940
|
-
ie(
|
|
941
|
-
} catch (
|
|
942
|
-
|
|
999
|
+
ie(t, n.stdin);
|
|
1000
|
+
} catch (o) {
|
|
1001
|
+
t.error(o);
|
|
943
1002
|
} finally {
|
|
944
1003
|
n.stdin.end();
|
|
945
|
-
const
|
|
946
|
-
process.exit(
|
|
1004
|
+
const o = await Te(n);
|
|
1005
|
+
process.exit(o);
|
|
947
1006
|
}
|
|
948
1007
|
}
|
|
949
1008
|
};
|
|
950
|
-
l(
|
|
951
|
-
let
|
|
952
|
-
class
|
|
1009
|
+
l(k, "description", "run tengo unit tests (.test.tengo)"), l(k, "strict", !1), l(k, "flags", { ...ne }), l(k, "examples", ["<%= config.bin %> <%= command.id %>"]);
|
|
1010
|
+
let X = k;
|
|
1011
|
+
class Y extends $ {
|
|
953
1012
|
async run() {
|
|
954
|
-
const e =
|
|
955
|
-
ie(e,
|
|
1013
|
+
const e = N();
|
|
1014
|
+
ie(e, D);
|
|
956
1015
|
}
|
|
957
1016
|
}
|
|
958
|
-
l(
|
|
1017
|
+
l(Y, "description", "parse sources in current package and dump all found artifacts to stdout"), l(Y, "examples", [
|
|
959
1018
|
"<%= config.bin %> <%= command.id %>"
|
|
960
1019
|
]);
|
|
961
|
-
class
|
|
1020
|
+
class H extends $ {
|
|
962
1021
|
async run() {
|
|
963
|
-
const e =
|
|
964
|
-
|
|
1022
|
+
const e = N();
|
|
1023
|
+
St(e, D);
|
|
965
1024
|
}
|
|
966
1025
|
}
|
|
967
|
-
l(
|
|
1026
|
+
l(H, "description", "parse sources in current package and dump all found tests to stdout"), l(H, "examples", [
|
|
968
1027
|
"<%= config.bin %> <%= command.id %>"
|
|
969
1028
|
]);
|
|
970
|
-
const
|
|
1029
|
+
const T = class T extends $ {
|
|
971
1030
|
async run() {
|
|
972
|
-
const { flags: e } = await this.parse(
|
|
973
|
-
|
|
1031
|
+
const { flags: e } = await this.parse(T), t = N();
|
|
1032
|
+
Et(t, e.deps, D);
|
|
974
1033
|
}
|
|
975
1034
|
};
|
|
976
|
-
l(
|
|
1035
|
+
l(T, "description", "parse sources in current package and dump all found templates to stdout"), l(T, "examples", [
|
|
977
1036
|
"<%= config.bin %> <%= command.id %>"
|
|
978
|
-
]), l(
|
|
979
|
-
deps:
|
|
1037
|
+
]), l(T, "flags", {
|
|
1038
|
+
deps: O.boolean({ name: "deps", description: "add also all libraries found in node_modules" })
|
|
980
1039
|
});
|
|
981
|
-
let
|
|
982
|
-
class ee extends
|
|
1040
|
+
let Q = T;
|
|
1041
|
+
class ee extends $ {
|
|
983
1042
|
async run() {
|
|
984
|
-
const e =
|
|
985
|
-
|
|
1043
|
+
const e = N();
|
|
1044
|
+
Nt(e, D);
|
|
986
1045
|
}
|
|
987
1046
|
}
|
|
988
1047
|
l(ee, "description", "parse sources in current package and dump all found tests to stdout"), l(ee, "examples", [
|
|
989
1048
|
"<%= config.bin %> <%= command.id %>"
|
|
990
1049
|
]);
|
|
991
|
-
class te extends
|
|
1050
|
+
class te extends $ {
|
|
992
1051
|
async run() {
|
|
993
|
-
const e =
|
|
994
|
-
|
|
1052
|
+
const e = N();
|
|
1053
|
+
$t(e, D);
|
|
995
1054
|
}
|
|
996
1055
|
}
|
|
997
1056
|
l(te, "description", "parse sources in current package and dump all found templates to stdout"), l(te, "examples", [
|
|
998
1057
|
"<%= config.bin %> <%= command.id %>"
|
|
999
1058
|
]);
|
|
1000
|
-
class se extends
|
|
1059
|
+
class se extends $ {
|
|
1001
1060
|
async run() {
|
|
1002
|
-
const e =
|
|
1003
|
-
|
|
1061
|
+
const e = N();
|
|
1062
|
+
kt(e, D);
|
|
1004
1063
|
}
|
|
1005
1064
|
}
|
|
1006
1065
|
l(se, "description", "parse sources in current package and dump all found tests to stdout"), l(se, "examples", [
|
|
1007
1066
|
"<%= config.bin %> <%= command.id %>"
|
|
1008
1067
|
]);
|
|
1009
|
-
const
|
|
1010
|
-
build:
|
|
1011
|
-
check:
|
|
1012
|
-
test:
|
|
1013
|
-
"dump:all":
|
|
1014
|
-
"dump:assets":
|
|
1015
|
-
"dump:libs":
|
|
1068
|
+
const jt = {
|
|
1069
|
+
build: Z,
|
|
1070
|
+
check: K,
|
|
1071
|
+
test: X,
|
|
1072
|
+
"dump:all": Y,
|
|
1073
|
+
"dump:assets": H,
|
|
1074
|
+
"dump:libs": Q,
|
|
1016
1075
|
"dump:software": ee,
|
|
1017
1076
|
"dump:templates": te,
|
|
1018
1077
|
"dump:tests": se
|
|
1019
1078
|
};
|
|
1020
1079
|
export {
|
|
1021
|
-
|
|
1080
|
+
jt as COMMANDS
|
|
1022
1081
|
};
|
|
1023
1082
|
//# sourceMappingURL=index.mjs.map
|