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