testeranto 0.94.0 → 0.100.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/bundle.js +4 -7
- package/dist/common/src/PM/main.js +160 -42
- package/dist/common/src/PM/node.js +20 -5
- package/dist/common/src/PM/web.js +19 -4
- package/dist/common/src/SubPackages/react/jsx/node.js +1 -6
- package/dist/common/src/cli.js +439 -0
- package/dist/common/src/cli2.js +144 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -6
- package/dist/common/src/esbuildConfigs/node.js +1 -4
- package/dist/common/src/esbuildConfigs/web.js +1 -1
- package/dist/common/src/lib/abstractBase.js +14 -91
- package/dist/common/src/lib/types.js +1 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/PM/main.js +160 -42
- package/dist/module/src/PM/node.js +20 -5
- package/dist/module/src/PM/web.js +19 -4
- package/dist/module/src/SubPackages/react/jsx/node.js +1 -6
- package/dist/module/src/cli.js +411 -0
- package/dist/module/src/cli2.js +116 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -6
- package/dist/module/src/esbuildConfigs/node.js +1 -4
- package/dist/module/src/esbuildConfigs/web.js +1 -1
- package/dist/module/src/lib/abstractBase.js +14 -91
- package/dist/module/src/lib/types.js +1 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/cli.mjs +1491 -0
- package/dist/prebuild/{run-tests.mjs → cli2.mjs} +203 -156
- package/dist/types/src/Node.d.ts +2 -2
- package/dist/types/src/PM/index.d.ts +10 -2
- package/dist/types/src/PM/main.d.ts +13 -7
- package/dist/types/src/PM/node.d.ts +9 -2
- package/dist/types/src/PM/web.d.ts +9 -3
- package/dist/types/src/SubPackages/puppeteer.d.ts +1 -1
- package/dist/types/src/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/src/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/src/SubPackages/react/jsx/node.d.ts +3 -3
- package/dist/types/src/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +3 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +2 -2
- package/dist/types/src/Types.d.ts +60 -21
- package/dist/types/src/Web.d.ts +2 -2
- package/dist/types/src/lib/index.d.ts +1 -1
- package/dist/types/src/lib/types.d.ts +2 -30
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +11 -8
- package/src/PM/index.ts +12 -8
- package/src/PM/main.ts +218 -62
- package/src/PM/node.ts +42 -7
- package/src/PM/web.ts +33 -5
- package/src/SubPackages/react/jsx/node.ts +16 -5
- package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
- package/src/Types.ts +362 -114
- package/src/cli.ts +535 -0
- package/src/cli2.ts +157 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +27 -6
- package/src/esbuildConfigs/node.ts +4 -7
- package/src/esbuildConfigs/web.ts +4 -3
- package/src/lib/abstractBase.ts +58 -115
- package/src/lib/types.ts +3 -177
- package/dist/common/src/Aider.js +0 -143
- package/dist/common/src/Project.js +0 -227
- package/dist/common/src/Puppeteer.js +0 -111
- package/dist/common/src/build-tests.js +0 -39
- package/dist/common/src/esbuildConfigs/features.js +0 -14
- package/dist/common/src/esbuildConfigs/report.js +0 -14
- package/dist/common/src/esbuildConfigs/tests.js +0 -13
- package/dist/common/src/run-tests.js +0 -39
- package/dist/module/src/Aider.js +0 -136
- package/dist/module/src/Project.js +0 -220
- package/dist/module/src/Puppeteer.js +0 -106
- package/dist/module/src/build-tests.js +0 -11
- package/dist/module/src/esbuildConfigs/features.js +0 -12
- package/dist/module/src/esbuildConfigs/report.js +0 -14
- package/dist/module/src/esbuildConfigs/tests.js +0 -11
- package/dist/module/src/run-tests.js +0 -11
- package/dist/prebuild/build-tests.mjs +0 -553
- package/dist/types/src/Aider.d.ts +0 -1
- package/dist/types/src/Project.d.ts +0 -12
- package/dist/types/src/Puppeteer.d.ts +0 -2
- package/dist/types/src/esbuildConfigs/features.d.ts +0 -4
- package/dist/types/src/esbuildConfigs/report.d.ts +0 -0
- package/dist/types/src/esbuildConfigs/tests.d.ts +0 -4
- package/src/Aider.ts +0 -168
- package/src/Project.ts +0 -292
- package/src/Puppeteer.ts +0 -143
- package/src/build-tests.ts +0 -12
- package/src/esbuildConfigs/features.ts +0 -17
- package/src/esbuildConfigs/report.ts +0 -15
- package/src/esbuildConfigs/tests.ts +0 -14
- package/src/run-tests.ts +0 -12
- /package/dist/types/src/{build-tests.d.ts → cli.d.ts} +0 -0
- /package/dist/types/src/{run-tests.d.ts → cli2.d.ts} +0 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import readline from "readline";
|
|
5
|
+
import { glob } from "glob";
|
|
6
|
+
import { debounceWatch } from "@bscotch/debounce-watch";
|
|
7
|
+
import esbuild from "esbuild";
|
|
8
|
+
import esbuildNodeConfiger from "./esbuildConfigs/node.js";
|
|
9
|
+
import esbuildWebConfiger from "./esbuildConfigs/web.js";
|
|
10
|
+
import webHtmlFrame from "./web.html.js";
|
|
11
|
+
import { PM_Main } from "./PM/main.js";
|
|
12
|
+
readline.emitKeypressEvents(process.stdin);
|
|
13
|
+
if (process.stdin.isTTY)
|
|
14
|
+
process.stdin.setRawMode(true);
|
|
15
|
+
function parseTsErrors(logContent) {
|
|
16
|
+
fs.writeFileSync("docs/types/log.txt", logContent.join("\n"));
|
|
17
|
+
try {
|
|
18
|
+
const regex = /(^src(.*?))\(\d*,\d*\): error/gm;
|
|
19
|
+
const brokenFilesToLines = {};
|
|
20
|
+
for (let i = 0; i < logContent.length - 1; i++) {
|
|
21
|
+
let m;
|
|
22
|
+
while ((m = regex.exec(logContent[i])) !== null) {
|
|
23
|
+
// This is necessary to avoid infinite loops with zero-width matches
|
|
24
|
+
if (m.index === regex.lastIndex) {
|
|
25
|
+
regex.lastIndex++;
|
|
26
|
+
}
|
|
27
|
+
if (!brokenFilesToLines[m[1]]) {
|
|
28
|
+
brokenFilesToLines[m[1]] = new Set();
|
|
29
|
+
}
|
|
30
|
+
brokenFilesToLines[m[1]].add(i);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
|
|
34
|
+
mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
|
|
35
|
+
const a = Array.from(brokenFilesToLines[lm]);
|
|
36
|
+
return Object.keys(a).reduce((mm2, lm2, ndx2) => {
|
|
37
|
+
const acc = [];
|
|
38
|
+
let j = a[lm2] + 1;
|
|
39
|
+
let working = true;
|
|
40
|
+
while (j < logContent.length - 1 && working) {
|
|
41
|
+
if (!logContent[j].match(regex) &&
|
|
42
|
+
working &&
|
|
43
|
+
!logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)) {
|
|
44
|
+
acc.push(logContent[j]);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
working = false;
|
|
48
|
+
}
|
|
49
|
+
j++;
|
|
50
|
+
}
|
|
51
|
+
mm2[lm] = [logContent[l], ...acc];
|
|
52
|
+
return mm2;
|
|
53
|
+
}, {})[lm];
|
|
54
|
+
});
|
|
55
|
+
return mm;
|
|
56
|
+
}, {});
|
|
57
|
+
Object.keys(final).forEach((k) => {
|
|
58
|
+
fs.mkdirSync(`./docs/types/${k.split("/").slice(0, -1).join("/")}`, {
|
|
59
|
+
recursive: true,
|
|
60
|
+
});
|
|
61
|
+
fs.writeFileSync(`./docs/types/${k}.type_errors.txt`, final[k].flat().flat().join("\r\n"));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error("Error reading or parsing the log file:", error);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function parseLintErrors(logContent) {
|
|
70
|
+
fs.writeFileSync("docs/eslint/log.txt", logContent.join("\n"));
|
|
71
|
+
try {
|
|
72
|
+
const regex = new RegExp(`^${process.cwd()}/(.*?)`, "gm");
|
|
73
|
+
const brokenFilesToLines = {};
|
|
74
|
+
for (let i = 0; i < logContent.length - 1; i++) {
|
|
75
|
+
let m;
|
|
76
|
+
while ((m = regex.exec(logContent[i])) !== null) {
|
|
77
|
+
// This is necessary to avoid infinite loops with zero-width matches
|
|
78
|
+
if (m.index === regex.lastIndex) {
|
|
79
|
+
regex.lastIndex++;
|
|
80
|
+
}
|
|
81
|
+
if (!brokenFilesToLines[m[1]]) {
|
|
82
|
+
brokenFilesToLines[m[1]] = new Set();
|
|
83
|
+
}
|
|
84
|
+
brokenFilesToLines[m[1]].add(i);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
|
|
88
|
+
mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
|
|
89
|
+
const a = Array.from(brokenFilesToLines[lm]);
|
|
90
|
+
return Object.keys(a).reduce((mm2, lm2, ndx2) => {
|
|
91
|
+
const acc = [];
|
|
92
|
+
let j = a[lm2] + 1;
|
|
93
|
+
let working = true;
|
|
94
|
+
while (j < logContent.length - 1 && working) {
|
|
95
|
+
if (!logContent[j].match(regex) &&
|
|
96
|
+
working
|
|
97
|
+
// &&
|
|
98
|
+
// !logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)
|
|
99
|
+
) {
|
|
100
|
+
acc.push(logContent[j]);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
working = false;
|
|
104
|
+
}
|
|
105
|
+
j++;
|
|
106
|
+
}
|
|
107
|
+
mm2[lm] = [logContent[l], ...acc];
|
|
108
|
+
return mm2;
|
|
109
|
+
}, {})[lm];
|
|
110
|
+
});
|
|
111
|
+
return mm;
|
|
112
|
+
}, {});
|
|
113
|
+
Object.keys(final).forEach((k) => {
|
|
114
|
+
fs.mkdirSync(`./docs/eslint/${k.split("/").slice(0, -1).join("/")}`, {
|
|
115
|
+
recursive: true,
|
|
116
|
+
});
|
|
117
|
+
fs.writeFileSync(`./docs/eslint/${k}.lint_errors.txt`, final[k].flat().flat().join("\r\n"));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.error("Error reading or parsing the log file:", error);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const typecheck = () => {
|
|
126
|
+
const logContent = [];
|
|
127
|
+
fs.rmSync("docs/types", { force: true, recursive: true });
|
|
128
|
+
fs.mkdirSync("docs/types");
|
|
129
|
+
const tsc = spawn("tsc", ["-noEmit"]);
|
|
130
|
+
tsc.stdout.on("data", (data) => {
|
|
131
|
+
const lines = data.toString().split("\n");
|
|
132
|
+
logContent.push(...lines);
|
|
133
|
+
});
|
|
134
|
+
tsc.stderr.on("data", (data) => {
|
|
135
|
+
console.error(`stderr: ${data}`);
|
|
136
|
+
process.exit(-1);
|
|
137
|
+
});
|
|
138
|
+
tsc.on("close", (code) => {
|
|
139
|
+
parseTsErrors(logContent);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const eslint = () => {
|
|
143
|
+
const logContent = [];
|
|
144
|
+
fs.rmSync("docs/eslint", { force: true, recursive: true });
|
|
145
|
+
fs.mkdirSync("docs/eslint");
|
|
146
|
+
const tsc = spawn("eslint", ["./src"]);
|
|
147
|
+
tsc.stdout.on("data", (data) => {
|
|
148
|
+
const lines = data.toString().split("\n");
|
|
149
|
+
logContent.push(...lines);
|
|
150
|
+
});
|
|
151
|
+
tsc.stderr.on("data", (data) => {
|
|
152
|
+
console.error(`stderr: ${data}`);
|
|
153
|
+
process.exit(-1);
|
|
154
|
+
});
|
|
155
|
+
tsc.on("close", (code) => {
|
|
156
|
+
parseLintErrors(logContent);
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const getRunnables = (tests, payload = {
|
|
160
|
+
nodeEntryPoints: {},
|
|
161
|
+
webEntryPoints: {},
|
|
162
|
+
}) => {
|
|
163
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
164
|
+
if (cv[1] === "node") {
|
|
165
|
+
pt.nodeEntryPoints[cv[0]] = path.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
166
|
+
}
|
|
167
|
+
else if (cv[1] === "web") {
|
|
168
|
+
pt.webEntryPoints[cv[0]] = path.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
169
|
+
}
|
|
170
|
+
if (cv[3].length) {
|
|
171
|
+
getRunnables(cv[3], payload);
|
|
172
|
+
}
|
|
173
|
+
return pt;
|
|
174
|
+
}, payload);
|
|
175
|
+
};
|
|
176
|
+
import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
|
|
177
|
+
const rawConfig = module.default;
|
|
178
|
+
const getSecondaryEndpointsPoints = (runtime) => {
|
|
179
|
+
const meta = (ts, st) => {
|
|
180
|
+
ts.forEach((t) => {
|
|
181
|
+
if (t[1] === runtime) {
|
|
182
|
+
st.add(t[0]);
|
|
183
|
+
}
|
|
184
|
+
if (Array.isArray(t[3])) {
|
|
185
|
+
meta(t[3], st);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
return st;
|
|
189
|
+
};
|
|
190
|
+
return Array.from(meta(config.tests, new Set()));
|
|
191
|
+
};
|
|
192
|
+
const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/" + rawConfig.outdir });
|
|
193
|
+
let nodeDone = false;
|
|
194
|
+
let webDone = false;
|
|
195
|
+
let mode = config.devMode ? "DEV" : "PROD";
|
|
196
|
+
let status = "build";
|
|
197
|
+
let pm = new PM_Main(config);
|
|
198
|
+
const fileHashes = {};
|
|
199
|
+
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
200
|
+
const onNodeDone = () => {
|
|
201
|
+
nodeDone = true;
|
|
202
|
+
onDone();
|
|
203
|
+
};
|
|
204
|
+
const onWebDone = () => {
|
|
205
|
+
webDone = true;
|
|
206
|
+
onDone();
|
|
207
|
+
};
|
|
208
|
+
// async function fileHash(filePath, algorithm = "md5") {
|
|
209
|
+
// return new Promise((resolve, reject) => {
|
|
210
|
+
// const hash = crypto.createHash(algorithm);
|
|
211
|
+
// const fileStream = fs.createReadStream(filePath);
|
|
212
|
+
// fileStream.on("data", (data) => {
|
|
213
|
+
// hash.update(data);
|
|
214
|
+
// });
|
|
215
|
+
// fileStream.on("end", () => {
|
|
216
|
+
// const fileHash = hash.digest("hex");
|
|
217
|
+
// resolve(fileHash);
|
|
218
|
+
// });
|
|
219
|
+
// fileStream.on("error", (error) => {
|
|
220
|
+
// reject(`Error reading file: ${error.message}`);
|
|
221
|
+
// });
|
|
222
|
+
// });
|
|
223
|
+
// }
|
|
224
|
+
const onDone = async () => {
|
|
225
|
+
if (nodeDone && webDone) {
|
|
226
|
+
status = "built";
|
|
227
|
+
}
|
|
228
|
+
if (nodeDone && webDone && status === "built") {
|
|
229
|
+
// Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
|
|
230
|
+
// console.log("watching", outputFile);
|
|
231
|
+
// try {
|
|
232
|
+
// watch(outputFile, async (filename) => {
|
|
233
|
+
// const hash = await fileHash(outputFile);
|
|
234
|
+
// if (fileHashes[k] !== hash) {
|
|
235
|
+
// fileHashes[k] = hash;
|
|
236
|
+
// console.log(`< ${filename} `);
|
|
237
|
+
// pm.launchNode(k, outputFile);
|
|
238
|
+
// }
|
|
239
|
+
// });
|
|
240
|
+
// } catch (e) {
|
|
241
|
+
// console.error(e);
|
|
242
|
+
// }
|
|
243
|
+
// });
|
|
244
|
+
// Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
|
|
245
|
+
// console.log("watching", outputFile);
|
|
246
|
+
// watch(outputFile, async (filename) => {
|
|
247
|
+
// const hash = await fileHash(outputFile);
|
|
248
|
+
// console.log(`< ${filename} ${hash}`);
|
|
249
|
+
// if (fileHashes[k] !== hash) {
|
|
250
|
+
// fileHashes[k] = hash;
|
|
251
|
+
// pm.launchWeb(k, outputFile);
|
|
252
|
+
// }
|
|
253
|
+
// });
|
|
254
|
+
// });
|
|
255
|
+
}
|
|
256
|
+
if (nodeDone && webDone && mode === "PROD") {
|
|
257
|
+
console.log("Testeranto-EsBuild is all done. Goodbye!");
|
|
258
|
+
process.exit();
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
if (mode === "PROD") {
|
|
262
|
+
console.log("waiting for tests to finish");
|
|
263
|
+
console.log(JSON.stringify({
|
|
264
|
+
nodeDone: nodeDone,
|
|
265
|
+
webDone: webDone,
|
|
266
|
+
mode: mode,
|
|
267
|
+
}, null, 2));
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
console.log("waiting for tests to change");
|
|
271
|
+
}
|
|
272
|
+
console.log("press 'q' to quit");
|
|
273
|
+
if (config.devMode) {
|
|
274
|
+
console.log("ready and watching for changes...");
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
pm.shutDown();
|
|
278
|
+
}
|
|
279
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
console.log(`Press 'q' to shutdown gracefully. Press 'x' to shutdown forcefully.`);
|
|
283
|
+
process.stdin.on("keypress", (str, key) => {
|
|
284
|
+
if (key.name === "q") {
|
|
285
|
+
console.log("Testeranto-EsBuild is shutting down...");
|
|
286
|
+
mode = "PROD";
|
|
287
|
+
onDone();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
// const eslint = new ESLint();
|
|
291
|
+
// const configEslint = await eslint.calculateConfigForFile(
|
|
292
|
+
// "./src/eslint.config.mjs"
|
|
293
|
+
// );
|
|
294
|
+
// // console.log(`configEslint`, configEslint);
|
|
295
|
+
// fs.watch("src", { recursive: true }, async (eventType, filename) => {
|
|
296
|
+
// if (eventType === "change") {
|
|
297
|
+
// console.log(`File ${filename} has been modified.`);
|
|
298
|
+
// const x = await eslint.lintFiles([`./src/${filename}`]);
|
|
299
|
+
// console.log(x[0].messages);
|
|
300
|
+
// } else if (eventType === "rename") {
|
|
301
|
+
// console.log(`File ${filename} has been created or deleted.`);
|
|
302
|
+
// }
|
|
303
|
+
// });
|
|
304
|
+
fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(config, null, 2));
|
|
305
|
+
Promise.resolve(Promise.all([...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
|
|
306
|
+
const sourceFileSplit = sourceFilePath.split("/");
|
|
307
|
+
const sourceDir = sourceFileSplit.slice(0, -1);
|
|
308
|
+
const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
|
|
309
|
+
const sourceFileNameMinusJs = sourceFileName
|
|
310
|
+
.split(".")
|
|
311
|
+
.slice(0, -1)
|
|
312
|
+
.join(".");
|
|
313
|
+
const htmlFilePath = path.normalize(`${process.cwd()}/${config.outdir}/web/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
|
|
314
|
+
const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
|
|
315
|
+
return fs.promises
|
|
316
|
+
.mkdir(path.dirname(htmlFilePath), { recursive: true })
|
|
317
|
+
.then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
|
|
318
|
+
})));
|
|
319
|
+
glob(`./${config.outdir}/chunk-*.mjs`, {
|
|
320
|
+
ignore: "node_modules/**",
|
|
321
|
+
}).then((chunks) => {
|
|
322
|
+
chunks.forEach((chunk) => {
|
|
323
|
+
fs.unlinkSync(chunk);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
// const processDebouncedEvents: DebouncedEventsProcessor = (events) => {
|
|
327
|
+
// typecheck();
|
|
328
|
+
// };
|
|
329
|
+
debounceWatch((events) => {
|
|
330
|
+
typecheck();
|
|
331
|
+
eslint();
|
|
332
|
+
}, "./src", {
|
|
333
|
+
onlyFileExtensions: ["ts", "tsx", "mts"],
|
|
334
|
+
debounceWaitSeconds: 0.2,
|
|
335
|
+
allowOverlappingRuns: false,
|
|
336
|
+
});
|
|
337
|
+
await pm.startPuppeteer({
|
|
338
|
+
slowMo: 1,
|
|
339
|
+
// timeout: 1,
|
|
340
|
+
waitForInitialPage: false,
|
|
341
|
+
executablePath:
|
|
342
|
+
// process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
|
|
343
|
+
"/opt/homebrew/bin/chromium",
|
|
344
|
+
headless: true,
|
|
345
|
+
dumpio: true,
|
|
346
|
+
// timeout: 0,
|
|
347
|
+
devtools: true,
|
|
348
|
+
args: [
|
|
349
|
+
"--auto-open-devtools-for-tabs",
|
|
350
|
+
`--remote-debugging-port=3234`,
|
|
351
|
+
// "--disable-features=IsolateOrigins,site-per-process",
|
|
352
|
+
"--disable-site-isolation-trials",
|
|
353
|
+
"--allow-insecure-localhost",
|
|
354
|
+
"--allow-file-access-from-files",
|
|
355
|
+
"--allow-running-insecure-content",
|
|
356
|
+
"--disable-dev-shm-usage",
|
|
357
|
+
"--disable-extensions",
|
|
358
|
+
"--disable-gpu",
|
|
359
|
+
"--disable-setuid-sandbox",
|
|
360
|
+
"--disable-site-isolation-trials",
|
|
361
|
+
"--disable-web-security",
|
|
362
|
+
"--no-first-run",
|
|
363
|
+
"--no-sandbox",
|
|
364
|
+
"--no-startup-window",
|
|
365
|
+
// "--no-zygote",
|
|
366
|
+
"--reduce-security-for-testing",
|
|
367
|
+
"--remote-allow-origins=*",
|
|
368
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
369
|
+
// "--disable-features=IsolateOrigins",
|
|
370
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
371
|
+
// "--single-process",
|
|
372
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
373
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
374
|
+
// "--disk-cache-dir=/dev/null",
|
|
375
|
+
// "--disk-cache-size=1",
|
|
376
|
+
// "--start-maximized",
|
|
377
|
+
],
|
|
378
|
+
}, ".");
|
|
379
|
+
await Promise.all([
|
|
380
|
+
esbuild
|
|
381
|
+
.context(esbuildNodeConfiger(config, Object.keys(nodeEntryPoints)))
|
|
382
|
+
.then(async (nodeContext) => {
|
|
383
|
+
if (config.devMode) {
|
|
384
|
+
await nodeContext.watch().then((v) => {
|
|
385
|
+
onNodeDone();
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
nodeContext.rebuild().then((v) => {
|
|
390
|
+
onNodeDone();
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return nodeContext;
|
|
394
|
+
}),
|
|
395
|
+
esbuild
|
|
396
|
+
.context(esbuildWebConfiger(config, Object.keys(webEntryPoints)))
|
|
397
|
+
.then(async (webContext) => {
|
|
398
|
+
if (config.devMode) {
|
|
399
|
+
await webContext.watch().then((v) => {
|
|
400
|
+
onWebDone();
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
webContext.rebuild().then((v) => {
|
|
405
|
+
onWebDone();
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return webContext;
|
|
409
|
+
}),
|
|
410
|
+
]);
|
|
411
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { watch } from "fs";
|
|
2
|
+
import { PM_Main } from "./PM/main";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import crypto from "node:crypto";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
const fileHashes = {};
|
|
7
|
+
async function fileHash(filePath, algorithm = "md5") {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const hash = crypto.createHash(algorithm);
|
|
10
|
+
const fileStream = fs.createReadStream(filePath);
|
|
11
|
+
fileStream.on("data", (data) => {
|
|
12
|
+
hash.update(data);
|
|
13
|
+
});
|
|
14
|
+
fileStream.on("end", () => {
|
|
15
|
+
const fileHash = hash.digest("hex");
|
|
16
|
+
resolve(fileHash);
|
|
17
|
+
});
|
|
18
|
+
fileStream.on("error", (error) => {
|
|
19
|
+
reject(`Error reading file: ${error.message}`);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const getRunnables = (tests, payload = {
|
|
24
|
+
nodeEntryPoints: {},
|
|
25
|
+
webEntryPoints: {},
|
|
26
|
+
}) => {
|
|
27
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
28
|
+
if (cv[1] === "node") {
|
|
29
|
+
pt.nodeEntryPoints[cv[0]] = path.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
30
|
+
}
|
|
31
|
+
else if (cv[1] === "web") {
|
|
32
|
+
pt.webEntryPoints[cv[0]] = path.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
33
|
+
}
|
|
34
|
+
if (cv[3].length) {
|
|
35
|
+
getRunnables(cv[3], payload);
|
|
36
|
+
}
|
|
37
|
+
return pt;
|
|
38
|
+
}, payload);
|
|
39
|
+
};
|
|
40
|
+
import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
|
|
41
|
+
const rawConfig = module.default;
|
|
42
|
+
const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/" + rawConfig.outdir });
|
|
43
|
+
let pm = new PM_Main(config);
|
|
44
|
+
await pm.startPuppeteer({
|
|
45
|
+
slowMo: 1,
|
|
46
|
+
// timeout: 1,
|
|
47
|
+
waitForInitialPage: false,
|
|
48
|
+
executablePath:
|
|
49
|
+
// process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
|
|
50
|
+
"/opt/homebrew/bin/chromium",
|
|
51
|
+
headless: true,
|
|
52
|
+
dumpio: true,
|
|
53
|
+
// timeout: 0,
|
|
54
|
+
devtools: true,
|
|
55
|
+
args: [
|
|
56
|
+
"--auto-open-devtools-for-tabs",
|
|
57
|
+
`--remote-debugging-port=3234`,
|
|
58
|
+
// "--disable-features=IsolateOrigins,site-per-process",
|
|
59
|
+
"--disable-site-isolation-trials",
|
|
60
|
+
"--allow-insecure-localhost",
|
|
61
|
+
"--allow-file-access-from-files",
|
|
62
|
+
"--allow-running-insecure-content",
|
|
63
|
+
"--disable-dev-shm-usage",
|
|
64
|
+
"--disable-extensions",
|
|
65
|
+
"--disable-gpu",
|
|
66
|
+
"--disable-setuid-sandbox",
|
|
67
|
+
"--disable-site-isolation-trials",
|
|
68
|
+
"--disable-web-security",
|
|
69
|
+
"--no-first-run",
|
|
70
|
+
"--no-sandbox",
|
|
71
|
+
"--no-startup-window",
|
|
72
|
+
// "--no-zygote",
|
|
73
|
+
"--reduce-security-for-testing",
|
|
74
|
+
"--remote-allow-origins=*",
|
|
75
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
76
|
+
// "--disable-features=IsolateOrigins",
|
|
77
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
78
|
+
// "--single-process",
|
|
79
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
80
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
81
|
+
// "--disk-cache-dir=/dev/null",
|
|
82
|
+
// "--disk-cache-size=1",
|
|
83
|
+
// "--start-maximized",
|
|
84
|
+
],
|
|
85
|
+
}, ".");
|
|
86
|
+
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
87
|
+
Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
|
|
88
|
+
console.log("watching and running", outputFile);
|
|
89
|
+
pm.launchNode(k, outputFile);
|
|
90
|
+
try {
|
|
91
|
+
watch(outputFile, async (e, filename) => {
|
|
92
|
+
const hash = await fileHash(outputFile);
|
|
93
|
+
if (fileHashes[k] !== hash) {
|
|
94
|
+
fileHashes[k] = hash;
|
|
95
|
+
console.log(`< ${e} ${filename} ${hash}`);
|
|
96
|
+
pm.launchNode(k, outputFile);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(e);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
|
|
105
|
+
console.log("watching and running", outputFile);
|
|
106
|
+
pm.launchWeb(k, outputFile);
|
|
107
|
+
watch(outputFile, async (e, filename) => {
|
|
108
|
+
const hash = await fileHash(outputFile);
|
|
109
|
+
console.log(`< ${e} ${filename} ${hash}`);
|
|
110
|
+
if (fileHashes[k] !== hash) {
|
|
111
|
+
fileHashes[k] = hash;
|
|
112
|
+
pm.launchWeb(k, outputFile);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { spawn } from "child_process";
|
|
3
4
|
const otherInputs = {};
|
|
4
5
|
const register = (entrypoint, sources) => {
|
|
5
6
|
if (!otherInputs[entrypoint]) {
|
|
@@ -47,6 +48,7 @@ export default (platform, entryPoints) => {
|
|
|
47
48
|
})
|
|
48
49
|
.flat();
|
|
49
50
|
const typeErrorFiles = addableFiles.map((t) => `docs/types/${t}.type_errors.txt`);
|
|
51
|
+
const lintPath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `lint_errors.txt`);
|
|
50
52
|
fs.writeFileSync(promptPath, `
|
|
51
53
|
${addableFiles
|
|
52
54
|
.map((x) => {
|
|
@@ -56,22 +58,32 @@ ${addableFiles
|
|
|
56
58
|
|
|
57
59
|
${typeErrorFiles
|
|
58
60
|
.map((x) => {
|
|
59
|
-
// const f = `docs/types/${x}.type_errors.txt`;
|
|
60
61
|
return `/read ${x}`;
|
|
61
|
-
// if (fs.existsSync(f)) {
|
|
62
|
-
// return `/read ${f}`;
|
|
63
|
-
// }
|
|
64
62
|
})
|
|
65
63
|
.join("\n")}
|
|
66
|
-
|
|
64
|
+
|
|
65
|
+
/read ${lintPath}
|
|
67
66
|
/read ${testPaths}
|
|
68
67
|
/read ${stdoutPath}
|
|
69
68
|
/read ${stderrPath}
|
|
70
69
|
|
|
71
70
|
/load ${featuresPath}
|
|
72
71
|
|
|
73
|
-
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(", ")}]. Implement any method which throws "Function not implemented."
|
|
72
|
+
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(", ")}]. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPath}"
|
|
74
73
|
`);
|
|
74
|
+
const logContent = [];
|
|
75
|
+
const tsc = spawn("eslint", addableFiles);
|
|
76
|
+
tsc.stdout.on("data", (data) => {
|
|
77
|
+
const lines = data.toString().split("\n");
|
|
78
|
+
logContent.push(...lines);
|
|
79
|
+
});
|
|
80
|
+
tsc.stderr.on("data", (data) => {
|
|
81
|
+
console.error(`stderr: ${data}`);
|
|
82
|
+
process.exit(-1);
|
|
83
|
+
});
|
|
84
|
+
tsc.on("close", (code) => {
|
|
85
|
+
fs.writeFileSync(lintPath, logContent.join("\n"));
|
|
86
|
+
});
|
|
75
87
|
}
|
|
76
88
|
});
|
|
77
89
|
}
|
|
@@ -3,8 +3,6 @@ import inputFilesPlugin from "./inputFilesPlugin.js";
|
|
|
3
3
|
import featuresPlugin from "./featuresPlugin";
|
|
4
4
|
export default (config, entryPoints) => {
|
|
5
5
|
const { inputFilesPluginFactory, register } = inputFilesPlugin("node", entryPoints);
|
|
6
|
-
// const inputFilesPluginFactory = inputFilesPlugin("node", entryPoints);
|
|
7
|
-
// const register = (x) => x;
|
|
8
6
|
return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: config.outdir + "/node",
|
|
9
7
|
// inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
|
|
10
8
|
metafile: true, supported: {
|
|
@@ -22,7 +20,6 @@ export default (config, entryPoints) => {
|
|
|
22
20
|
...config.externals,
|
|
23
21
|
], entryPoints: [...entryPoints], plugins: [
|
|
24
22
|
featuresPlugin,
|
|
25
|
-
// markdownPlugin({}),
|
|
26
23
|
...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
|
|
27
24
|
inputFilesPluginFactory,
|
|
28
25
|
// inputFilesPlugin("node", entryPoints),
|
|
@@ -30,7 +27,7 @@ export default (config, entryPoints) => {
|
|
|
30
27
|
name: "rebuild-notify",
|
|
31
28
|
setup(build) {
|
|
32
29
|
build.onEnd((result) => {
|
|
33
|
-
console.log(
|
|
30
|
+
console.log(`> node build ended with ${result.errors.length} errors`);
|
|
34
31
|
if (result.errors.length > 0) {
|
|
35
32
|
console.log(result);
|
|
36
33
|
}
|
|
@@ -43,7 +43,7 @@ export default (config, entryPoints) => {
|
|
|
43
43
|
name: "rebuild-notify",
|
|
44
44
|
setup(build) {
|
|
45
45
|
build.onEnd((result) => {
|
|
46
|
-
console.log(
|
|
46
|
+
console.log(`> web build ended with ${result.errors.length} errors`);
|
|
47
47
|
if (result.errors.length > 0) {
|
|
48
48
|
console.log(result);
|
|
49
49
|
}
|