testeranto 0.85.0 → 0.90.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/README.md +1 -3
- package/bin/init-docs.js +24 -0
- package/bundle.js +53 -0
- package/dist/common/dist/module/src/Init.js +40 -0
- package/dist/common/src/Init.js +30 -0
- package/dist/common/src/PM/main.js +45 -9
- package/dist/common/src/Project.js +80 -0
- package/dist/common/src/Puppeteer.js +1 -1
- package/dist/common/{run-tests.js → src/build-tests.js} +10 -5
- package/dist/common/src/defaultConfig.js +19 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +27 -15
- package/dist/common/src/init-docs.js +43 -0
- package/dist/common/src/lib/abstractBase.js +0 -64
- package/dist/common/src/lib/core.js +5 -3
- package/dist/common/{build-tests.js → src/run-tests.js} +10 -9
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/Init.js +30 -0
- package/dist/module/src/PM/main.js +45 -9
- package/dist/module/src/Project.js +80 -0
- package/dist/module/src/Puppeteer.js +1 -1
- package/dist/module/src/build-tests.js +11 -0
- package/dist/module/src/defaultConfig.js +17 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +27 -15
- package/dist/module/src/init-docs.js +15 -0
- package/dist/module/src/lib/abstractBase.js +0 -64
- package/dist/module/src/lib/core.js +5 -3
- package/dist/module/src/run-tests.js +11 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/build-tests.mjs +552 -0
- package/dist/prebuild/init-docs.mjs +48 -0
- package/dist/prebuild/run-tests.mjs +907 -0
- package/dist/types/dist/module/src/Init.d.ts +2 -0
- package/dist/types/src/build-tests.d.ts +1 -0
- package/dist/types/src/defaultConfig.d.ts +3 -0
- package/dist/types/src/init-docs.d.ts +1 -0
- package/dist/types/src/run-tests.d.ts +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +9 -12
- package/src/Init.ts +28 -0
- package/src/PM/main.ts +58 -10
- package/src/Project.ts +102 -0
- package/src/Puppeteer.ts +1 -1
- package/src/build-tests.ts +12 -0
- package/src/defaultConfig.ts +20 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +48 -16
- package/src/init-docs.ts +19 -0
- package/src/lib/abstractBase.ts +0 -67
- package/src/lib/core.ts +3 -3
- package/src/run-tests.ts +12 -0
- package/tsconfig.json +1 -1
- package/build-tests.ts +0 -16
- package/dist/common/init-docs.js +0 -8
- package/dist/module/build-tests.js +0 -10
- package/dist/module/init-docs.js +0 -3
- package/dist/module/run-tests.js +0 -6
- package/dist/prebuild/Puppeteer.mjs +0 -82033
- package/dist/types/build-tests.d.ts +0 -3
- package/dist/types/init-docs.d.ts +0 -2
- package/dist/types/run-tests.d.ts +0 -2
- package/init-docs.ts +0 -5
- package/pupBuild.js +0 -18
- package/run-tests.ts +0 -9
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/build-tests.ts
|
|
4
|
+
import process2 from "process";
|
|
5
|
+
|
|
6
|
+
// src/Project.ts
|
|
7
|
+
import { spawn } from "child_process";
|
|
8
|
+
import esbuild from "esbuild";
|
|
9
|
+
import fs2 from "fs";
|
|
10
|
+
import path4 from "path";
|
|
11
|
+
import readline from "readline";
|
|
12
|
+
import { glob } from "glob";
|
|
13
|
+
|
|
14
|
+
// src/esbuildConfigs/index.ts
|
|
15
|
+
var esbuildConfigs_default = (config) => {
|
|
16
|
+
return {
|
|
17
|
+
// packages: "external",
|
|
18
|
+
target: "esnext",
|
|
19
|
+
format: "esm",
|
|
20
|
+
splitting: true,
|
|
21
|
+
outExtension: { ".js": ".mjs" },
|
|
22
|
+
outbase: config.outbase,
|
|
23
|
+
jsx: "transform",
|
|
24
|
+
bundle: true,
|
|
25
|
+
minify: config.minify === true,
|
|
26
|
+
write: true,
|
|
27
|
+
loader: {
|
|
28
|
+
".js": "jsx",
|
|
29
|
+
".png": "binary",
|
|
30
|
+
".jpg": "binary"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/esbuildConfigs/inputFilesPlugin.ts
|
|
36
|
+
import fs from "fs";
|
|
37
|
+
import path from "path";
|
|
38
|
+
var otherInputs = {};
|
|
39
|
+
var register = (entrypoint, sources) => {
|
|
40
|
+
console.log("register", entrypoint, sources);
|
|
41
|
+
if (!otherInputs[entrypoint]) {
|
|
42
|
+
otherInputs[entrypoint] = /* @__PURE__ */ new Set();
|
|
43
|
+
}
|
|
44
|
+
sources.forEach((s) => otherInputs[entrypoint].add(s));
|
|
45
|
+
};
|
|
46
|
+
function tree(meta, key) {
|
|
47
|
+
console.log("searching metafile for", key);
|
|
48
|
+
const outputKey = Object.keys(meta.outputs).find((k) => {
|
|
49
|
+
return meta.outputs[k].entryPoint === key;
|
|
50
|
+
});
|
|
51
|
+
if (!outputKey) {
|
|
52
|
+
console.error("No outputkey found");
|
|
53
|
+
process.exit(-1);
|
|
54
|
+
}
|
|
55
|
+
return Object.keys(meta.outputs[outputKey].inputs).filter(
|
|
56
|
+
(k) => k.startsWith("src")
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
var inputFilesPlugin_default = (platform, entryPoints) => {
|
|
60
|
+
return {
|
|
61
|
+
register,
|
|
62
|
+
inputFilesPluginFactory: {
|
|
63
|
+
name: "metafileWriter",
|
|
64
|
+
setup(build) {
|
|
65
|
+
build.onEnd((result) => {
|
|
66
|
+
fs.writeFileSync(
|
|
67
|
+
`docs/${platform}/metafile.json`,
|
|
68
|
+
JSON.stringify(result, null, 2)
|
|
69
|
+
);
|
|
70
|
+
if (result.errors.length === 0) {
|
|
71
|
+
entryPoints.forEach((entryPoint) => {
|
|
72
|
+
const filePath = path.join(
|
|
73
|
+
"./docs/",
|
|
74
|
+
platform,
|
|
75
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
76
|
+
`inputFiles.json`
|
|
77
|
+
);
|
|
78
|
+
const dirName = path.dirname(filePath);
|
|
79
|
+
if (!fs.existsSync(dirName)) {
|
|
80
|
+
fs.mkdirSync(dirName, { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
const promptPath = path.join(
|
|
83
|
+
"./docs/",
|
|
84
|
+
platform,
|
|
85
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
86
|
+
`prompt.txt`
|
|
87
|
+
);
|
|
88
|
+
const testPaths = path.join(
|
|
89
|
+
"./docs/",
|
|
90
|
+
platform,
|
|
91
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
92
|
+
`tests.json`
|
|
93
|
+
);
|
|
94
|
+
const featuresPath = path.join(
|
|
95
|
+
"./docs/",
|
|
96
|
+
platform,
|
|
97
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
98
|
+
`featurePrompt.txt`
|
|
99
|
+
);
|
|
100
|
+
const stderrPath = path.join(
|
|
101
|
+
"./docs/",
|
|
102
|
+
platform,
|
|
103
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
104
|
+
`stderr.log`
|
|
105
|
+
);
|
|
106
|
+
const stdoutPath = path.join(
|
|
107
|
+
"./docs/",
|
|
108
|
+
platform,
|
|
109
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
110
|
+
`stdout.log`
|
|
111
|
+
);
|
|
112
|
+
if (result.metafile) {
|
|
113
|
+
const addableFiles = tree(
|
|
114
|
+
result.metafile,
|
|
115
|
+
entryPoint.split("/").slice(1).join("/")
|
|
116
|
+
).map((y) => {
|
|
117
|
+
if (otherInputs[y]) {
|
|
118
|
+
return Array.from(otherInputs[y]);
|
|
119
|
+
}
|
|
120
|
+
return y;
|
|
121
|
+
}).flat();
|
|
122
|
+
const typeErrorFiles = addableFiles.map(
|
|
123
|
+
(t) => `docs/types/${t}.type_errors.txt`
|
|
124
|
+
);
|
|
125
|
+
fs.writeFileSync(
|
|
126
|
+
promptPath,
|
|
127
|
+
`
|
|
128
|
+
${addableFiles.map((x) => {
|
|
129
|
+
return `/add ${x}`;
|
|
130
|
+
}).join("\n")}
|
|
131
|
+
|
|
132
|
+
${typeErrorFiles.map((x) => {
|
|
133
|
+
return `/read ${x}`;
|
|
134
|
+
}).join("\n")}
|
|
135
|
+
|
|
136
|
+
/read ${testPaths}
|
|
137
|
+
/read ${stdoutPath}
|
|
138
|
+
/read ${stderrPath}
|
|
139
|
+
|
|
140
|
+
/load ${featuresPath}
|
|
141
|
+
|
|
142
|
+
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(
|
|
143
|
+
", "
|
|
144
|
+
)}]. Implement any method which throws "Function not implemented."
|
|
145
|
+
`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/esbuildConfigs/featuresPlugin.ts
|
|
157
|
+
import path2 from "path";
|
|
158
|
+
var featuresPlugin_default = {
|
|
159
|
+
name: "feature-markdown",
|
|
160
|
+
setup(build) {
|
|
161
|
+
build.onResolve({ filter: /\.md$/ }, (args) => {
|
|
162
|
+
if (args.resolveDir === "")
|
|
163
|
+
return;
|
|
164
|
+
return {
|
|
165
|
+
path: path2.isAbsolute(args.path) ? args.path : path2.join(args.resolveDir, args.path),
|
|
166
|
+
namespace: "feature-markdown"
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
build.onLoad(
|
|
170
|
+
{ filter: /.*/, namespace: "feature-markdown" },
|
|
171
|
+
async (args) => {
|
|
172
|
+
return {
|
|
173
|
+
contents: `file://${args.path}`,
|
|
174
|
+
loader: "text"
|
|
175
|
+
// contents: JSON.stringify({ path: args.path }),
|
|
176
|
+
// loader: "json",
|
|
177
|
+
// contents: JSON.stringify({
|
|
178
|
+
// // html: markdownHTML,
|
|
179
|
+
// raw: markdownContent,
|
|
180
|
+
// filename: args.path, //path.basename(args.path),
|
|
181
|
+
// }),
|
|
182
|
+
// loader: "json",
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/esbuildConfigs/node.ts
|
|
190
|
+
var node_default = (config, entryPoints) => {
|
|
191
|
+
const { inputFilesPluginFactory, register: register2 } = inputFilesPlugin_default(
|
|
192
|
+
"node",
|
|
193
|
+
entryPoints
|
|
194
|
+
);
|
|
195
|
+
return {
|
|
196
|
+
...esbuildConfigs_default(config),
|
|
197
|
+
splitting: true,
|
|
198
|
+
outdir: config.outdir + "/node",
|
|
199
|
+
// inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
|
|
200
|
+
metafile: true,
|
|
201
|
+
supported: {
|
|
202
|
+
"dynamic-import": true
|
|
203
|
+
},
|
|
204
|
+
define: {
|
|
205
|
+
"process.env.FLUENTFFMPEG_COV": "0"
|
|
206
|
+
},
|
|
207
|
+
absWorkingDir: process.cwd(),
|
|
208
|
+
banner: {
|
|
209
|
+
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
|
|
210
|
+
},
|
|
211
|
+
platform: "node",
|
|
212
|
+
external: [
|
|
213
|
+
// "testeranto.json",
|
|
214
|
+
// "features.test.js",
|
|
215
|
+
"react",
|
|
216
|
+
// "events",
|
|
217
|
+
// "ganache"
|
|
218
|
+
...config.externals
|
|
219
|
+
],
|
|
220
|
+
entryPoints: [...entryPoints],
|
|
221
|
+
plugins: [
|
|
222
|
+
featuresPlugin_default,
|
|
223
|
+
// markdownPlugin({}),
|
|
224
|
+
...config.nodePlugins.map((p) => p(register2, entryPoints)) || [],
|
|
225
|
+
inputFilesPluginFactory,
|
|
226
|
+
// inputFilesPlugin("node", entryPoints),
|
|
227
|
+
{
|
|
228
|
+
name: "rebuild-notify",
|
|
229
|
+
setup(build) {
|
|
230
|
+
build.onEnd((result) => {
|
|
231
|
+
console.log(`node build ended with ${result.errors.length} errors`);
|
|
232
|
+
if (result.errors.length > 0) {
|
|
233
|
+
console.log(result);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/esbuildConfigs/web.ts
|
|
243
|
+
import path3 from "path";
|
|
244
|
+
var web_default = (config, entryPoints) => {
|
|
245
|
+
const { inputFilesPluginFactory, register: register2 } = inputFilesPlugin_default(
|
|
246
|
+
"web",
|
|
247
|
+
entryPoints
|
|
248
|
+
);
|
|
249
|
+
return {
|
|
250
|
+
...esbuildConfigs_default(config),
|
|
251
|
+
// inject: ["./node_modules/testeranto/dist/cjs-shim.js"],
|
|
252
|
+
// banner: {
|
|
253
|
+
// js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
|
|
254
|
+
// },
|
|
255
|
+
// splitting: true,
|
|
256
|
+
outdir: config.outdir + "/web",
|
|
257
|
+
alias: {
|
|
258
|
+
react: path3.resolve("./node_modules/react")
|
|
259
|
+
},
|
|
260
|
+
metafile: true,
|
|
261
|
+
external: [
|
|
262
|
+
// "testeranto.json",
|
|
263
|
+
// "features.test.ts",
|
|
264
|
+
// "url",
|
|
265
|
+
// "react",
|
|
266
|
+
"path",
|
|
267
|
+
"fs",
|
|
268
|
+
"stream",
|
|
269
|
+
"http",
|
|
270
|
+
"constants",
|
|
271
|
+
"net",
|
|
272
|
+
"assert",
|
|
273
|
+
"tls",
|
|
274
|
+
"os",
|
|
275
|
+
"child_process",
|
|
276
|
+
"readline",
|
|
277
|
+
"zlib",
|
|
278
|
+
"crypto",
|
|
279
|
+
"https",
|
|
280
|
+
"util",
|
|
281
|
+
"process",
|
|
282
|
+
"dns"
|
|
283
|
+
],
|
|
284
|
+
platform: "browser",
|
|
285
|
+
entryPoints: [...entryPoints],
|
|
286
|
+
plugins: [
|
|
287
|
+
featuresPlugin_default,
|
|
288
|
+
// markdownPlugin({}),
|
|
289
|
+
...config.nodePlugins.map((p) => p(register2, entryPoints)) || [],
|
|
290
|
+
inputFilesPluginFactory,
|
|
291
|
+
{
|
|
292
|
+
name: "rebuild-notify",
|
|
293
|
+
setup(build) {
|
|
294
|
+
build.onEnd((result) => {
|
|
295
|
+
console.log(`web build ended with ${result.errors.length} errors`);
|
|
296
|
+
if (result.errors.length > 0) {
|
|
297
|
+
console.log(result);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// src/web.html.ts
|
|
307
|
+
var web_html_default = (jsfilePath, htmlFilePath) => `
|
|
308
|
+
<!DOCTYPE html>
|
|
309
|
+
<html lang="en">
|
|
310
|
+
|
|
311
|
+
<head>
|
|
312
|
+
<script type="module" src="${jsfilePath}"></script>
|
|
313
|
+
|
|
314
|
+
</head>
|
|
315
|
+
|
|
316
|
+
<body>
|
|
317
|
+
<h1>${htmlFilePath}</h1>
|
|
318
|
+
<div id="root">
|
|
319
|
+
|
|
320
|
+
</div>
|
|
321
|
+
</body>
|
|
322
|
+
|
|
323
|
+
<footer></footer>
|
|
324
|
+
|
|
325
|
+
</html>
|
|
326
|
+
`;
|
|
327
|
+
|
|
328
|
+
// src/Project.ts
|
|
329
|
+
readline.emitKeypressEvents(process.stdin);
|
|
330
|
+
if (process.stdin.isTTY)
|
|
331
|
+
process.stdin.setRawMode(true);
|
|
332
|
+
var logContent = [];
|
|
333
|
+
function parseTsErrors() {
|
|
334
|
+
try {
|
|
335
|
+
const regex = /(^src(.*?))\(\d*,\d*\): error/gm;
|
|
336
|
+
const brokenFilesToLines = {};
|
|
337
|
+
for (let i = 0; i < logContent.length - 1; i++) {
|
|
338
|
+
let m;
|
|
339
|
+
while ((m = regex.exec(logContent[i])) !== null) {
|
|
340
|
+
if (m.index === regex.lastIndex) {
|
|
341
|
+
regex.lastIndex++;
|
|
342
|
+
}
|
|
343
|
+
if (!brokenFilesToLines[m[1]]) {
|
|
344
|
+
brokenFilesToLines[m[1]] = /* @__PURE__ */ new Set();
|
|
345
|
+
}
|
|
346
|
+
brokenFilesToLines[m[1]].add(i);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
|
|
350
|
+
mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
|
|
351
|
+
const a = Array.from(brokenFilesToLines[lm]);
|
|
352
|
+
return Object.keys(a).reduce((mm2, lm2, ndx2) => {
|
|
353
|
+
const acc = [];
|
|
354
|
+
let j = a[lm2] + 1;
|
|
355
|
+
let working = true;
|
|
356
|
+
while (j < logContent.length - 1 && working) {
|
|
357
|
+
if (!logContent[j].match(regex) && working && !logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)) {
|
|
358
|
+
acc.push(logContent[j]);
|
|
359
|
+
} else {
|
|
360
|
+
working = false;
|
|
361
|
+
}
|
|
362
|
+
j++;
|
|
363
|
+
}
|
|
364
|
+
mm2[lm] = [logContent[l], ...acc];
|
|
365
|
+
return mm2;
|
|
366
|
+
}, {})[lm];
|
|
367
|
+
});
|
|
368
|
+
return mm;
|
|
369
|
+
}, {});
|
|
370
|
+
Object.keys(final).forEach((k) => {
|
|
371
|
+
fs2.mkdirSync(`./docs/types/${k.split("/").slice(0, -1).join("/")}`, {
|
|
372
|
+
recursive: true
|
|
373
|
+
});
|
|
374
|
+
fs2.writeFileSync(
|
|
375
|
+
`./docs/types/${k}.type_errors.txt`,
|
|
376
|
+
final[k].flat().flat().join("\r\n")
|
|
377
|
+
);
|
|
378
|
+
});
|
|
379
|
+
} catch (error) {
|
|
380
|
+
console.error("Error reading or parsing the log file:", error);
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
var compile = () => {
|
|
385
|
+
return new Promise((resolve, reject) => {
|
|
386
|
+
const tsc = spawn("tsc", ["-noEmit"]);
|
|
387
|
+
tsc.stdout.on("data", (data) => {
|
|
388
|
+
const lines = data.toString().split("\n");
|
|
389
|
+
logContent.push(...lines);
|
|
390
|
+
});
|
|
391
|
+
tsc.stderr.on("data", (data) => {
|
|
392
|
+
});
|
|
393
|
+
tsc.on("close", (code) => {
|
|
394
|
+
parseTsErrors();
|
|
395
|
+
resolve(`tsc process exited with code ${code}`);
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
var ITProject = class {
|
|
400
|
+
constructor(configs) {
|
|
401
|
+
this.nodeDone = false;
|
|
402
|
+
this.webDone = false;
|
|
403
|
+
this.onNodeDone = () => {
|
|
404
|
+
this.nodeDone = true;
|
|
405
|
+
this.onDone();
|
|
406
|
+
};
|
|
407
|
+
this.onWebDone = () => {
|
|
408
|
+
this.webDone = true;
|
|
409
|
+
this.onDone();
|
|
410
|
+
};
|
|
411
|
+
this.onDone = () => {
|
|
412
|
+
if (this.nodeDone && this.webDone && this.mode === "PROD") {
|
|
413
|
+
console.log("Testeranto-EsBuild is all done. Goodbye!");
|
|
414
|
+
process.exit();
|
|
415
|
+
} else {
|
|
416
|
+
if (this.mode === "PROD") {
|
|
417
|
+
console.log("waiting for tests to finish");
|
|
418
|
+
console.log(
|
|
419
|
+
JSON.stringify(
|
|
420
|
+
{
|
|
421
|
+
nodeDone: this.nodeDone,
|
|
422
|
+
webDone: this.webDone,
|
|
423
|
+
mode: this.mode
|
|
424
|
+
},
|
|
425
|
+
null,
|
|
426
|
+
2
|
|
427
|
+
)
|
|
428
|
+
);
|
|
429
|
+
} else {
|
|
430
|
+
console.log("waiting for tests to change");
|
|
431
|
+
}
|
|
432
|
+
console.log("press 'q' to quit");
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
this.config = configs;
|
|
436
|
+
this.mode = this.config.devMode ? "DEV" : "PROD";
|
|
437
|
+
process.stdin.on("keypress", (str, key) => {
|
|
438
|
+
if (key.name === "q") {
|
|
439
|
+
console.log("Testeranto-EsBuild is shutting down...");
|
|
440
|
+
this.mode = "PROD";
|
|
441
|
+
this.onDone();
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
fs2.writeFileSync(
|
|
445
|
+
`${this.config.outdir}/testeranto.json`,
|
|
446
|
+
JSON.stringify(
|
|
447
|
+
{
|
|
448
|
+
...this.config,
|
|
449
|
+
buildDir: process.cwd() + "/" + this.config.outdir
|
|
450
|
+
},
|
|
451
|
+
null,
|
|
452
|
+
2
|
|
453
|
+
)
|
|
454
|
+
);
|
|
455
|
+
compile();
|
|
456
|
+
Promise.resolve(
|
|
457
|
+
Promise.all(
|
|
458
|
+
[...this.getSecondaryEndpointsPoints("web")].map(
|
|
459
|
+
async (sourceFilePath) => {
|
|
460
|
+
const sourceFileSplit = sourceFilePath.split("/");
|
|
461
|
+
const sourceDir = sourceFileSplit.slice(0, -1);
|
|
462
|
+
const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
|
|
463
|
+
const sourceFileNameMinusJs = sourceFileName.split(".").slice(0, -1).join(".");
|
|
464
|
+
const htmlFilePath = path4.normalize(
|
|
465
|
+
`${process.cwd()}/${this.config.outdir}/web/${sourceDir.join(
|
|
466
|
+
"/"
|
|
467
|
+
)}/${sourceFileNameMinusJs}.html`
|
|
468
|
+
);
|
|
469
|
+
const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
|
|
470
|
+
return fs2.promises.mkdir(path4.dirname(htmlFilePath), { recursive: true }).then(
|
|
471
|
+
(x) => fs2.writeFileSync(
|
|
472
|
+
htmlFilePath,
|
|
473
|
+
web_html_default(jsfilePath, htmlFilePath)
|
|
474
|
+
)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
)
|
|
479
|
+
);
|
|
480
|
+
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
481
|
+
glob(`./${this.config.outdir}/chunk-*.mjs`, {
|
|
482
|
+
ignore: "node_modules/**"
|
|
483
|
+
}).then((chunks) => {
|
|
484
|
+
chunks.forEach((chunk) => {
|
|
485
|
+
fs2.unlinkSync(chunk);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
Promise.all([
|
|
489
|
+
esbuild.context(node_default(this.config, nodeEntryPoints)).then(async (nodeContext) => {
|
|
490
|
+
if (this.config.devMode) {
|
|
491
|
+
await nodeContext.watch().then((v) => {
|
|
492
|
+
this.onNodeDone();
|
|
493
|
+
});
|
|
494
|
+
} else {
|
|
495
|
+
nodeContext.rebuild().then((v) => {
|
|
496
|
+
this.onNodeDone();
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return nodeContext;
|
|
500
|
+
}),
|
|
501
|
+
esbuild.context(web_default(this.config, webEntryPoints)).then(async (webContext) => {
|
|
502
|
+
if (this.config.devMode) {
|
|
503
|
+
await webContext.watch().then((v) => {
|
|
504
|
+
this.onWebDone();
|
|
505
|
+
});
|
|
506
|
+
} else {
|
|
507
|
+
webContext.rebuild().then((v) => {
|
|
508
|
+
this.onWebDone();
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
return webContext;
|
|
512
|
+
})
|
|
513
|
+
]);
|
|
514
|
+
}
|
|
515
|
+
getSecondaryEndpointsPoints(runtime) {
|
|
516
|
+
const meta = (ts, st) => {
|
|
517
|
+
ts.forEach((t) => {
|
|
518
|
+
if (t[1] === runtime) {
|
|
519
|
+
st.add(t[0]);
|
|
520
|
+
}
|
|
521
|
+
if (Array.isArray(t[3])) {
|
|
522
|
+
meta(t[3], st);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
return st;
|
|
526
|
+
};
|
|
527
|
+
return Array.from(meta(this.config.tests, /* @__PURE__ */ new Set()));
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
var getRunnables = (tests, payload = [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()]) => {
|
|
531
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
532
|
+
if (cv[1] === "node") {
|
|
533
|
+
pt[0].add(cv[0]);
|
|
534
|
+
} else if (cv[1] === "web") {
|
|
535
|
+
pt[1].add(cv[0]);
|
|
536
|
+
}
|
|
537
|
+
if (cv[3].length) {
|
|
538
|
+
getRunnables(cv[3], payload);
|
|
539
|
+
}
|
|
540
|
+
return pt;
|
|
541
|
+
}, payload);
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
// src/build-tests.ts
|
|
545
|
+
if (!process2.argv[2]) {
|
|
546
|
+
console.log("You didn't pass a config file");
|
|
547
|
+
process2.exit(-1);
|
|
548
|
+
} else {
|
|
549
|
+
import(process2.cwd() + "/" + process2.argv[2]).then((module) => {
|
|
550
|
+
new ITProject(module.default);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/init-docs.ts
|
|
4
|
+
import fs2 from "fs";
|
|
5
|
+
|
|
6
|
+
// dist/module/src/Init.js
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
var Init_default = async (partialConfig) => {
|
|
9
|
+
const config = Object.assign(Object.assign({}, partialConfig), { buildDir: process.cwd() + "/" + partialConfig.outdir });
|
|
10
|
+
try {
|
|
11
|
+
fs.mkdirSync(`${process.cwd()}/${config.outdir}`);
|
|
12
|
+
} catch (_a) {
|
|
13
|
+
}
|
|
14
|
+
fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2));
|
|
15
|
+
try {
|
|
16
|
+
fs.mkdirSync(`${process.cwd()}/${config.outdir}/node`);
|
|
17
|
+
} catch (_b) {
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
fs.mkdirSync(`${process.cwd()}/${config.outdir}/web`);
|
|
21
|
+
} catch (_c) {
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
fs.mkdirSync(`${process.cwd()}/${config.outdir}/features`);
|
|
25
|
+
} catch (_d) {
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
fs.mkdirSync(`${process.cwd()}/${config.outdir}/ts`);
|
|
29
|
+
} catch (_e) {
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/init-docs.ts
|
|
34
|
+
console.log("Initializing a testeranto project");
|
|
35
|
+
if (!process.argv[2]) {
|
|
36
|
+
console.log("You didn't pass a config file, so I will create one for you.");
|
|
37
|
+
fs2.writeFileSync(
|
|
38
|
+
"testeranto.mts",
|
|
39
|
+
fs2.readFileSync("node_modules/testeranto/src/defaultConfig.ts")
|
|
40
|
+
);
|
|
41
|
+
import(process.cwd() + "/testeranto.mts").then((module) => {
|
|
42
|
+
Init_default(module.default);
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
import(process.cwd() + "/" + process.argv[2]).then((module) => {
|
|
46
|
+
Init_default(module.default);
|
|
47
|
+
});
|
|
48
|
+
}
|