testeranto 0.110.0 → 0.111.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 (176) hide show
  1. package/package.json +1 -1
  2. package/src/PM/main.ts +418 -92
  3. package/src/ReportClient.tsx +38 -30
  4. package/src/run.ts +4 -371
  5. package/tsc.log +8 -6
  6. package/dist/common/Init.js +0 -68
  7. package/dist/common/Node.js +0 -27
  8. package/dist/common/PM/index.js +0 -7
  9. package/dist/common/PM/main.js +0 -984
  10. package/dist/common/PM/node.js +0 -128
  11. package/dist/common/PM/web.js +0 -121
  12. package/dist/common/ReportServer.js +0 -22
  13. package/dist/common/SubPackages/react/component/node.js +0 -19
  14. package/dist/common/SubPackages/react/component/web.js +0 -19
  15. package/dist/common/SubPackages/react/jsx/index.js +0 -21
  16. package/dist/common/SubPackages/react/jsx/node.js +0 -10
  17. package/dist/common/SubPackages/react/jsx/web.js +0 -10
  18. package/dist/common/SubPackages/react-dom/component/node.js +0 -88
  19. package/dist/common/SubPackages/react-dom/component/web.js +0 -67
  20. package/dist/common/SubPackages/react-dom/jsx/index.js +0 -2
  21. package/dist/common/SubPackages/react-dom/jsx/node.js +0 -39
  22. package/dist/common/SubPackages/react-dom/jsx/web.js +0 -128
  23. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -54
  24. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -2
  25. package/dist/common/SubPackages/react-test-renderer/component/interface.js +0 -70
  26. package/dist/common/SubPackages/react-test-renderer/component/node.js +0 -8
  27. package/dist/common/SubPackages/react-test-renderer/component/web.js +0 -8
  28. package/dist/common/SubPackages/react-test-renderer/fc/node.js +0 -60
  29. package/dist/common/SubPackages/react-test-renderer/fc/web.js +0 -60
  30. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -67
  31. package/dist/common/SubPackages/react-test-renderer/jsx/node.js +0 -10
  32. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +0 -10
  33. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +0 -52
  34. package/dist/common/SubPackages/react-test-renderer/jsx-promised/node.js +0 -10
  35. package/dist/common/SubPackages/react-test-renderer/jsx-promised/web.js +0 -10
  36. package/dist/common/Types.js +0 -2
  37. package/dist/common/Web.js +0 -49
  38. package/dist/common/build.js +0 -222
  39. package/dist/common/defaultConfig.js +0 -20
  40. package/dist/common/esbuildConfigs/eslint-formatter-testeranto.js +0 -6
  41. package/dist/common/esbuildConfigs/featuresPlugin.js +0 -39
  42. package/dist/common/esbuildConfigs/index.js +0 -21
  43. package/dist/common/esbuildConfigs/inputFilesPlugin.js +0 -27
  44. package/dist/common/esbuildConfigs/node.js +0 -37
  45. package/dist/common/esbuildConfigs/web.js +0 -50
  46. package/dist/common/init-docs.js +0 -53
  47. package/dist/common/lib/abstractBase.js +0 -329
  48. package/dist/common/lib/basebuilder.js +0 -98
  49. package/dist/common/lib/classBuilder.js +0 -40
  50. package/dist/common/lib/core.js +0 -117
  51. package/dist/common/lib/index.js +0 -21
  52. package/dist/common/lib/types.js +0 -2
  53. package/dist/common/package.json +0 -3
  54. package/dist/common/puppeteerConfiger.js +0 -24
  55. package/dist/common/run.js +0 -297
  56. package/dist/common/tsconfig.common.tsbuildinfo +0 -1
  57. package/dist/common/utils.js +0 -43
  58. package/dist/common/web.html.js +0 -22
  59. package/dist/module/Footer.js +0 -4
  60. package/dist/module/Init.js +0 -63
  61. package/dist/module/Node.js +0 -20
  62. package/dist/module/PM/index.js +0 -3
  63. package/dist/module/PM/main.js +0 -944
  64. package/dist/module/PM/node.js +0 -121
  65. package/dist/module/PM/web.js +0 -117
  66. package/dist/module/ReportClient.js +0 -97
  67. package/dist/module/ReportServer.js +0 -17
  68. package/dist/module/SubPackages/react/component/node.js +0 -14
  69. package/dist/module/SubPackages/react/component/web.js +0 -14
  70. package/dist/module/SubPackages/react/jsx/index.js +0 -15
  71. package/dist/module/SubPackages/react/jsx/node.js +0 -5
  72. package/dist/module/SubPackages/react/jsx/web.js +0 -5
  73. package/dist/module/SubPackages/react-dom/component/node.js +0 -80
  74. package/dist/module/SubPackages/react-dom/component/web.js +0 -62
  75. package/dist/module/SubPackages/react-dom/jsx/index.js +0 -1
  76. package/dist/module/SubPackages/react-dom/jsx/node.js +0 -31
  77. package/dist/module/SubPackages/react-dom/jsx/web.js +0 -90
  78. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -16
  79. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  80. package/dist/module/SubPackages/react-test-renderer/component/interface.js +0 -31
  81. package/dist/module/SubPackages/react-test-renderer/component/node.js +0 -3
  82. package/dist/module/SubPackages/react-test-renderer/component/web.js +0 -3
  83. package/dist/module/SubPackages/react-test-renderer/fc/node.js +0 -22
  84. package/dist/module/SubPackages/react-test-renderer/fc/web.js +0 -22
  85. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -28
  86. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +0 -5
  87. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +0 -5
  88. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +0 -16
  89. package/dist/module/SubPackages/react-test-renderer/jsx-promised/node.js +0 -5
  90. package/dist/module/SubPackages/react-test-renderer/jsx-promised/web.js +0 -5
  91. package/dist/module/TestReport.js +0 -91
  92. package/dist/module/Types.js +0 -1
  93. package/dist/module/Web.js +0 -42
  94. package/dist/module/build.js +0 -184
  95. package/dist/module/defaultConfig.js +0 -18
  96. package/dist/module/esbuildConfigs/eslint-formatter-testeranto.js +0 -3
  97. package/dist/module/esbuildConfigs/featuresPlugin.js +0 -34
  98. package/dist/module/esbuildConfigs/index.js +0 -19
  99. package/dist/module/esbuildConfigs/inputFilesPlugin.js +0 -22
  100. package/dist/module/esbuildConfigs/node.js +0 -32
  101. package/dist/module/esbuildConfigs/web.js +0 -45
  102. package/dist/module/init-docs.js +0 -15
  103. package/dist/module/lib/abstractBase.js +0 -321
  104. package/dist/module/lib/basebuilder.js +0 -94
  105. package/dist/module/lib/classBuilder.js +0 -36
  106. package/dist/module/lib/core.js +0 -114
  107. package/dist/module/lib/index.js +0 -17
  108. package/dist/module/lib/types.js +0 -1
  109. package/dist/module/package.json +0 -3
  110. package/dist/module/puppeteerConfiger.js +0 -19
  111. package/dist/module/run.js +0 -259
  112. package/dist/module/tsconfig.module.tsbuildinfo +0 -1
  113. package/dist/module/utils.js +0 -29
  114. package/dist/module/web.html.js +0 -20
  115. package/dist/prebuild/ReportClient.css +0 -11367
  116. package/dist/prebuild/ReportClient.js +0 -23641
  117. package/dist/prebuild/ReportServer.mjs +0 -16
  118. package/dist/prebuild/TestReport.css +0 -11367
  119. package/dist/prebuild/TestReport.js +0 -27484
  120. package/dist/prebuild/build.mjs +0 -376
  121. package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +0 -9
  122. package/dist/prebuild/init-docs.mjs +0 -104
  123. package/dist/prebuild/run.mjs +0 -1190
  124. package/dist/tsconfig.tsbuildinfo +0 -1
  125. package/dist/types/Init.d.ts +0 -2
  126. package/dist/types/Node.d.ts +0 -12
  127. package/dist/types/PM/index.d.ts +0 -34
  128. package/dist/types/PM/main.d.ts +0 -59
  129. package/dist/types/PM/node.d.ts +0 -40
  130. package/dist/types/PM/web.d.ts +0 -38
  131. package/dist/types/ReportServer.d.ts +0 -1
  132. package/dist/types/SubPackages/react/component/node.d.ts +0 -7
  133. package/dist/types/SubPackages/react/component/web.d.ts +0 -7
  134. package/dist/types/SubPackages/react/jsx/index.d.ts +0 -12
  135. package/dist/types/SubPackages/react/jsx/node.d.ts +0 -4
  136. package/dist/types/SubPackages/react/jsx/web.d.ts +0 -4
  137. package/dist/types/SubPackages/react-dom/component/node.d.ts +0 -11
  138. package/dist/types/SubPackages/react-dom/component/web.d.ts +0 -20
  139. package/dist/types/SubPackages/react-dom/jsx/index.d.ts +0 -6
  140. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +0 -7
  141. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +0 -5
  142. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -6
  143. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +0 -13
  144. package/dist/types/SubPackages/react-test-renderer/component/interface.d.ts +0 -9
  145. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +0 -4
  146. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +0 -4
  147. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +0 -8
  148. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +0 -9
  149. package/dist/types/SubPackages/react-test-renderer/jsx/index.d.ts +0 -16
  150. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +0 -9
  151. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +0 -9
  152. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +0 -15
  153. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +0 -5
  154. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +0 -5
  155. package/dist/types/Types.d.ts +0 -61
  156. package/dist/types/Web.d.ts +0 -9
  157. package/dist/types/build.d.ts +0 -1
  158. package/dist/types/defaultConfig.d.ts +0 -3
  159. package/dist/types/esbuildConfigs/eslint-formatter-testeranto.d.ts +0 -2
  160. package/dist/types/esbuildConfigs/featuresPlugin.d.ts +0 -5
  161. package/dist/types/esbuildConfigs/index.d.ts +0 -4
  162. package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +0 -6
  163. package/dist/types/esbuildConfigs/node.d.ts +0 -4
  164. package/dist/types/esbuildConfigs/web.d.ts +0 -4
  165. package/dist/types/init-docs.d.ts +0 -1
  166. package/dist/types/lib/abstractBase.d.ts +0 -110
  167. package/dist/types/lib/basebuilder.d.ts +0 -27
  168. package/dist/types/lib/classBuilder.d.ts +0 -7
  169. package/dist/types/lib/core.d.ts +0 -7
  170. package/dist/types/lib/index.d.ts +0 -83
  171. package/dist/types/lib/types.d.ts +0 -14
  172. package/dist/types/puppeteerConfiger.d.ts +0 -4
  173. package/dist/types/run.d.ts +0 -1
  174. package/dist/types/tsconfig.types.tsbuildinfo +0 -1
  175. package/dist/types/utils.d.ts +0 -9
  176. package/dist/types/web.html.d.ts +0 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testeranto",
3
3
  "description": "the AI powered BDD test framework for typescript projects",
4
- "version": "0.110.0",
4
+ "version": "0.111.0",
5
5
  "engines": {
6
6
  "node": "18.18.0"
7
7
  },
package/src/PM/main.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import ts from "typescript";
2
+
1
3
  import { CdpPage, Page } from "puppeteer-core/lib/esm/puppeteer";
2
- import fs from "fs";
4
+ import fs, { watch } from "fs";
3
5
  import path from "path";
4
6
  import puppeteer, {
5
7
  Browser,
@@ -10,21 +12,39 @@ import puppeteer, {
10
12
  } from "puppeteer-core";
11
13
  import { PassThrough } from "stream";
12
14
  import ansiC from "ansi-colors";
13
-
15
+ import crypto from "node:crypto";
16
+ import { ESLint } from "eslint";
17
+ import tsc from "tsc-prog";
14
18
  import {
15
19
  IBuiltConfig,
16
20
  IFinalResults,
21
+ IRunnables,
17
22
  ITestTypes,
18
23
  ITLog,
19
24
  } from "../lib/index.js";
20
25
  import {
21
26
  bddExitCodePather,
22
27
  lintExitCodePather,
28
+ lintPather,
23
29
  tscExitCodePather,
30
+ tscPather,
24
31
  } from "../utils";
25
32
 
26
33
  import { PM } from "./index.js";
27
34
 
35
+ type IOutputs = Record<
36
+ string,
37
+ {
38
+ entryPoint: string;
39
+ inputs: Record<string, string>;
40
+ }
41
+ >;
42
+ const eslint = new ESLint();
43
+ const formatter = await eslint.loadFormatter(
44
+ "./node_modules/testeranto/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs"
45
+ );
46
+ const changes: Record<string, string> = {};
47
+ const fileHashes = {};
28
48
  const fileStreams3: fs.WriteStream[] = [];
29
49
  type IFPaths = string[];
30
50
  const fPaths: IFPaths = [];
@@ -32,6 +52,52 @@ const files: Record<string, Set<string>> = {};
32
52
  const recorders: Record<string, ScreenRecorder> = {};
33
53
  const screenshots: Record<string, Promise<Uint8Array>[]> = {};
34
54
 
55
+ async function fileHash(filePath, algorithm = "md5") {
56
+ return new Promise<string>((resolve, reject) => {
57
+ const hash = crypto.createHash(algorithm);
58
+ const fileStream = fs.createReadStream(filePath);
59
+
60
+ fileStream.on("data", (data) => {
61
+ hash.update(data);
62
+ });
63
+
64
+ fileStream.on("end", () => {
65
+ const fileHash = hash.digest("hex");
66
+ resolve(fileHash);
67
+ });
68
+
69
+ fileStream.on("error", (error) => {
70
+ reject(`Error reading file: ${error.message}`);
71
+ });
72
+ });
73
+ }
74
+
75
+ const getRunnables = (
76
+ tests: ITestTypes[],
77
+ payload = {
78
+ nodeEntryPoints: {},
79
+ webEntryPoints: {},
80
+ }
81
+ ): IRunnables => {
82
+ return tests.reduce((pt, cv, cndx, cry) => {
83
+ if (cv[1] === "node") {
84
+ pt.nodeEntryPoints[cv[0]] = path.resolve(
85
+ `./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
86
+ );
87
+ } else if (cv[1] === "web") {
88
+ pt.webEntryPoints[cv[0]] = path.resolve(
89
+ `./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
90
+ );
91
+ }
92
+
93
+ if (cv[3].length) {
94
+ getRunnables(cv[3], payload);
95
+ }
96
+
97
+ return pt;
98
+ }, payload as IRunnables);
99
+ };
100
+
35
101
  const statusMessagePretty = (failures: number, test: string) => {
36
102
  if (failures === 0) {
37
103
  console.log(ansiC.green(ansiC.inverse(`> ${test} completed successfully`)));
@@ -68,25 +134,50 @@ export class PM_Main extends PM {
68
134
  ports: Record<number, boolean>;
69
135
  queue: any[];
70
136
 
137
+ mode: "DEV" | "PROD";
138
+
71
139
  bigBoard: Record<
72
140
  string,
73
141
  {
74
- status: "?" | "running" | "waiting";
75
- runTimeError?: number;
76
- typeErrors?: string;
77
- staticErrors?: string;
142
+ // status: "?" | "running" | "waiting";
143
+ runTimeError?: number | "?";
144
+ typeErrors?: number | "?";
145
+ staticErrors?: number | "?";
146
+ prompt?: string | "?";
78
147
  }
79
148
  > = {};
149
+ webMetafileWatcher: fs.FSWatcher;
150
+ nodeMetafileWatcher: fs.FSWatcher;
80
151
 
81
152
  constructor(configs: IBuiltConfig) {
82
153
  super();
154
+
155
+ this.mode = configs.devMode ? "DEV" : "PROD";
156
+
157
+ process.stdin.on("keypress", (str, key) => {
158
+ if (key.name === "q") {
159
+ console.log(
160
+ ansiC.inverse("Testeranto-Run is shutting down gracefully...")
161
+ );
162
+ this.mode = "PROD";
163
+ // onDone();
164
+ this.nodeMetafileWatcher.close();
165
+ this.webMetafileWatcher.close();
166
+ this.shutDown();
167
+ }
168
+ });
169
+
83
170
  this.server = {};
84
171
  this.configs = configs;
85
172
  this.ports = {};
86
173
 
87
174
  this.configs.tests.forEach(([t]) => {
88
175
  this.bigBoard[t] = {
89
- status: "?",
176
+ // status: "?",
177
+ runTimeError: "?",
178
+ typeErrors: "?",
179
+ staticErrors: "?",
180
+ prompt: "?",
90
181
  };
91
182
  });
92
183
 
@@ -178,32 +269,6 @@ export class PM_Main extends PM {
178
269
  fileStreams3[uid].end();
179
270
  };
180
271
 
181
- // async (ssOpts: ScreenshotOptions, testName: string) => {
182
- // const p = ssOpts.path as string;
183
- // const dir = path.dirname(p);
184
- // fs.mkdirSync(dir, {
185
- // recursive: true,
186
- // });
187
- // if (!files[testName]) {
188
- // files[testName] = new Set();
189
- // }
190
- // files[testName].add(ssOpts.path as string);
191
-
192
- // const sPromise = page.screenshot({
193
- // ...ssOpts,
194
- // path: p,
195
- // });
196
-
197
- // if (!screenshots[testName]) {
198
- // screenshots[testName] = [];
199
- // }
200
- // screenshots[testName].push(sPromise);
201
- // // sPromise.then(())
202
- // await sPromise;
203
- // return sPromise;
204
- // // page.evaluate(`window["screenshot done"]`);
205
- // };
206
-
207
272
  globalThis["customScreenShot"] = async (
208
273
  opts: { path: string },
209
274
  pageKey: string,
@@ -262,20 +327,18 @@ export class PM_Main extends PM {
262
327
 
263
328
  return opts.path;
264
329
  };
265
-
266
- // globalThis["customclose"] = (p: string, testName: string) => {
267
- // if (!files[testName]) {
268
- // files[testName] = new Set();
269
- // }
270
-
271
- // fs.writeFileSync(
272
- // p + "/manifest.json",
273
- // JSON.stringify(Array.from(files[testName]))
274
- // );
275
- // delete files[testName];
276
- // };
277
330
  }
278
331
 
332
+ filesHash = async (files: string[], algorithm = "md5") => {
333
+ return new Promise<string>((resolve, reject) => {
334
+ resolve(
335
+ files.reduce(async (mm: Promise<string>, f) => {
336
+ return (await mm) + (await fileHash(f));
337
+ }, Promise.resolve(""))
338
+ );
339
+ });
340
+ };
341
+
279
342
  customclose() {
280
343
  throw new Error("Method not implemented.");
281
344
  }
@@ -404,11 +467,149 @@ export class PM_Main extends PM {
404
467
  }
405
468
  ////////////////////////////////////////////////////////////////////////////////
406
469
 
407
- async startPuppeteer(
408
- options: LaunchOptions,
409
- destfolder: string
410
- ): Promise<any> {
411
- this.browser = (await puppeteer.launch(options)) as any;
470
+ async metafileOutputs(platform: "web" | "node") {
471
+ const metafile = JSON.parse(
472
+ fs.readFileSync(`docs/${platform}/metafile.json`).toString()
473
+ ).metafile;
474
+
475
+ if (!metafile) return;
476
+
477
+ const outputs: IOutputs = metafile.outputs;
478
+
479
+ Object.keys(outputs).forEach(async (k) => {
480
+ const addableFiles = Object.keys(outputs[k].inputs).filter((i) => {
481
+ if (!fs.existsSync(i)) return false;
482
+ if (i.startsWith("node_modules")) return false;
483
+ return true;
484
+ });
485
+
486
+ const f = `${k.split(".").slice(0, -1).join(".")}/`;
487
+ if (!fs.existsSync(f)) {
488
+ fs.mkdirSync(f);
489
+ }
490
+
491
+ const entrypoint = outputs[k].entryPoint;
492
+
493
+ if (entrypoint) {
494
+ const changeDigest = await this.filesHash(addableFiles);
495
+
496
+ if (changeDigest === changes[entrypoint]) {
497
+ // skip
498
+ } else {
499
+ changes[entrypoint] = changeDigest;
500
+ this.tscCheck({
501
+ platform,
502
+ addableFiles,
503
+ entrypoint: "./" + entrypoint,
504
+ });
505
+ this.eslintCheck("./" + entrypoint, platform, addableFiles);
506
+ this.makePrompt("./" + entrypoint, addableFiles, platform);
507
+ }
508
+ }
509
+ });
510
+ }
511
+
512
+ async start(): Promise<any> {
513
+ this.browser = (await puppeteer.launch({
514
+ slowMo: 1,
515
+ // timeout: 1,
516
+ waitForInitialPage: false,
517
+ executablePath:
518
+ // process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
519
+ "/opt/homebrew/bin/chromium",
520
+ headless: true,
521
+ dumpio: true,
522
+ // timeout: 0,
523
+ devtools: true,
524
+
525
+ args: [
526
+ "--auto-open-devtools-for-tabs",
527
+ `--remote-debugging-port=3234`,
528
+
529
+ // "--disable-features=IsolateOrigins,site-per-process",
530
+ "--disable-site-isolation-trials",
531
+ "--allow-insecure-localhost",
532
+ "--allow-file-access-from-files",
533
+ "--allow-running-insecure-content",
534
+
535
+ "--disable-dev-shm-usage",
536
+ "--disable-extensions",
537
+ "--disable-gpu",
538
+ "--disable-setuid-sandbox",
539
+ "--disable-site-isolation-trials",
540
+ "--disable-web-security",
541
+ "--no-first-run",
542
+ "--no-sandbox",
543
+ "--no-startup-window",
544
+ // "--no-zygote",
545
+ "--reduce-security-for-testing",
546
+ "--remote-allow-origins=*",
547
+ "--unsafely-treat-insecure-origin-as-secure=*",
548
+ // "--disable-features=IsolateOrigins",
549
+ // "--remote-allow-origins=ws://localhost:3234",
550
+ // "--single-process",
551
+ // "--unsafely-treat-insecure-origin-as-secure",
552
+ // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
553
+
554
+ // "--disk-cache-dir=/dev/null",
555
+ // "--disk-cache-size=1",
556
+ // "--start-maximized",
557
+ ],
558
+ })) as any;
559
+
560
+ const { nodeEntryPoints, webEntryPoints } = getRunnables(
561
+ this.configs.tests
562
+ );
563
+
564
+ Object.entries(nodeEntryPoints).forEach(
565
+ ([k, outputFile]: [string, string]) => {
566
+ this.launchNode(k, outputFile);
567
+ try {
568
+ watch(outputFile, async (e, filename) => {
569
+ const hash = await fileHash(outputFile);
570
+ if (fileHashes[k] !== hash) {
571
+ fileHashes[k] = hash;
572
+ console.log(ansiC.green(ansiC.inverse(`< ${e} ${filename}`)));
573
+ this.launchNode(k, outputFile);
574
+ }
575
+ });
576
+ } catch (e) {
577
+ console.error(e);
578
+ }
579
+ }
580
+ );
581
+
582
+ Object.entries(webEntryPoints).forEach(
583
+ ([k, outputFile]: [string, string]) => {
584
+ this.launchWeb(k, outputFile);
585
+ watch(outputFile, async (e, filename) => {
586
+ const hash = await fileHash(outputFile);
587
+ if (fileHashes[k] !== hash) {
588
+ fileHashes[k] = hash;
589
+ console.log(ansiC.green(ansiC.inverse(`< ${e} ${filename}`)));
590
+ this.launchWeb(k, outputFile);
591
+ }
592
+ });
593
+ }
594
+ );
595
+
596
+ this.metafileOutputs("node");
597
+ this.nodeMetafileWatcher = watch(
598
+ "docs/node/metafile.json",
599
+ async (e, filename) => {
600
+ console.log(ansiC.green(ansiC.inverse(`< ${e} ${filename} (node)`)));
601
+ this.metafileOutputs("node");
602
+ }
603
+ );
604
+
605
+ this.metafileOutputs("web");
606
+ this.webMetafileWatcher = watch(
607
+ "docs/web/metafile.json",
608
+ async (e, filename) => {
609
+ console.log(ansiC.green(ansiC.inverse(`< ${e} ${filename} (web)`)));
610
+ this.metafileOutputs("web");
611
+ }
612
+ );
412
613
  }
413
614
 
414
615
  // goodbye = () => {
@@ -419,6 +620,157 @@ export class PM_Main extends PM {
419
620
  // });
420
621
  // };
421
622
 
623
+ tscCheck = async ({
624
+ entrypoint,
625
+ addableFiles,
626
+ platform,
627
+ }: {
628
+ platform: "web" | "node";
629
+ entrypoint: string;
630
+ addableFiles: string[];
631
+ }) => {
632
+ console.log(ansiC.green(ansiC.inverse(`tsc < ${entrypoint}`)));
633
+ console.log(JSON.stringify(this.bigBoard));
634
+ this.bigBoard[entrypoint].typeErrors = "?";
635
+
636
+ const program = tsc.createProgramFromConfig({
637
+ basePath: process.cwd(), // always required, used for relative paths
638
+ configFilePath: "tsconfig.json", // config to inherit from (optional)
639
+ compilerOptions: {
640
+ rootDir: "src",
641
+ outDir: tscPather(entrypoint, platform),
642
+ // declaration: true,
643
+ // skipLibCheck: true,
644
+ noEmit: true,
645
+ },
646
+ include: addableFiles, //["src/**/*"],
647
+ // exclude: ["**/*.test.ts", "**/*.spec.ts"],
648
+ });
649
+ const tscPath = tscPather(entrypoint, platform);
650
+
651
+ let allDiagnostics = program.getSemanticDiagnostics();
652
+
653
+ const d: string[] = [];
654
+ allDiagnostics.forEach((diagnostic) => {
655
+ if (diagnostic.file) {
656
+ let { line, character } = ts.getLineAndCharacterOfPosition(
657
+ diagnostic.file,
658
+ diagnostic.start!
659
+ );
660
+ let message = ts.flattenDiagnosticMessageText(
661
+ diagnostic.messageText,
662
+ "\n"
663
+ );
664
+ d.push(
665
+ `${diagnostic.file.fileName} (${line + 1},${
666
+ character + 1
667
+ }): ${message}`
668
+ );
669
+ } else {
670
+ d.push(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
671
+ }
672
+ });
673
+
674
+ fs.writeFileSync(tscPath, d.join("\n"));
675
+ this.bigBoard[entrypoint].typeErrors = d.length;
676
+ if (this.shutdownMode) {
677
+ this.checkForShutdown();
678
+ }
679
+ // fs.writeFileSync(
680
+ // tscExitCodePather(entrypoint, platform),
681
+ // d.length.toString()
682
+ // );
683
+ };
684
+
685
+ eslintCheck = async (
686
+ entrypoint: string,
687
+ platform: "web" | "node",
688
+ addableFiles: string[]
689
+ ) => {
690
+ this.bigBoard[entrypoint].staticErrors = "?";
691
+ console.log(ansiC.green(ansiC.inverse(`eslint < ${entrypoint}`)));
692
+ const results = (await eslint.lintFiles(addableFiles))
693
+ .filter((r) => r.messages.length)
694
+ .filter((r) => {
695
+ return r.messages[0].ruleId !== null;
696
+ })
697
+ .map((r) => {
698
+ delete r.source;
699
+ return r;
700
+ });
701
+
702
+ fs.writeFileSync(
703
+ lintPather(entrypoint, platform),
704
+ await formatter.format(results)
705
+ );
706
+ this.bigBoard[entrypoint].staticErrors = results.length;
707
+ if (this.shutdownMode) {
708
+ this.checkForShutdown();
709
+ }
710
+ // fs.writeFileSync(
711
+ // lintExitCodePather(entrypoint, platform),
712
+ // results.length.toString()
713
+ // );
714
+ };
715
+
716
+ makePrompt = async (
717
+ entryPoint: string,
718
+ addableFiles: string[],
719
+ platform: "web" | "node"
720
+ ) => {
721
+ this.bigBoard[entryPoint].prompt = "?";
722
+ const promptPath = path.join(
723
+ "./docs/",
724
+ platform,
725
+ entryPoint.split(".").slice(0, -1).join("."),
726
+ `prompt.txt`
727
+ );
728
+
729
+ const testPaths = path.join(
730
+ "./docs/",
731
+ platform,
732
+ entryPoint.split(".").slice(0, -1).join("."),
733
+ `tests.json`
734
+ );
735
+
736
+ const featuresPath = path.join(
737
+ "./docs/",
738
+ platform,
739
+ entryPoint.split(".").slice(0, -1).join("."),
740
+ `featurePrompt.txt`
741
+ );
742
+
743
+ fs.writeFileSync(
744
+ promptPath,
745
+ `
746
+ ${addableFiles
747
+ .map((x) => {
748
+ return `/add ${x}`;
749
+ })
750
+ .join("\n")}
751
+
752
+ /read ${lintPather(entryPoint, platform)}
753
+ /read ${tscPather(entryPoint, platform)}
754
+ /read ${testPaths}
755
+
756
+ /load ${featuresPath}
757
+
758
+ /code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files ${tscPather(
759
+ entryPoint,
760
+ platform
761
+ )}. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPather(
762
+ entryPoint,
763
+ platform
764
+ )}"
765
+ `
766
+ );
767
+ this.bigBoard[entryPoint].prompt =
768
+ "aider --model deepseek/deepseek-chat --load docs/web/./src/Rectangle/Rectangle.test.web/prompt.txt";
769
+ if (this.shutdownMode) {
770
+ this.checkForShutdown();
771
+ }
772
+ };
773
+
422
774
  shutDown() {
423
775
  this.shutdownMode = true;
424
776
  this.checkForShutdown();
@@ -426,34 +778,22 @@ export class PM_Main extends PM {
426
778
 
427
779
  checkForShutdown = () => {
428
780
  const anyRunning: boolean =
429
- Object.values(this.bigBoard).filter((x) => x.status === "running")
430
- .length > 0;
781
+ Object.values(this.bigBoard).filter((x) => x.prompt === "?").length +
782
+ Object.values(this.bigBoard).filter((x) => x.runTimeError === "?")
783
+ .length +
784
+ Object.values(this.bigBoard).filter((x) => x.staticErrors === "?")
785
+ .length +
786
+ Object.values(this.bigBoard).filter((x) => x.typeErrors === "?")
787
+ .length >
788
+ 0;
431
789
  if (anyRunning) {
790
+ console.log(ansiC.inverse("Shutting down. Please wait"));
432
791
  } else {
433
792
  this.browser.disconnect().then(() => {
434
- const final = {
435
- timestamp: Date.now(),
436
- tests: this.configs.tests.reduce((mm, t) => {
437
- const bddErrors = fs
438
- .readFileSync(bddExitCodePather(t[0], t[1]))
439
- .toString();
440
- const lintErrors = fs
441
- .readFileSync(lintExitCodePather(t[0], t[1]))
442
- .toString();
443
- const typeErrors = fs
444
- .readFileSync(tscExitCodePather(t[0], t[1]))
445
- .toString();
446
- mm[t[0]] = {
447
- bddErrors,
448
- lintErrors,
449
- typeErrors,
450
- };
451
- return mm;
452
- }, {}),
453
- };
454
-
455
- const s = JSON.stringify(final, null, 2);
456
- fs.writeFileSync("docs/summary.json", s);
793
+ fs.writeFileSync(
794
+ "docs/summary.json",
795
+ JSON.stringify(this.bigBoard, null, 2)
796
+ );
457
797
  console.log(ansiC.inverse("Goodbye"));
458
798
  process.exit();
459
799
  });
@@ -591,16 +931,8 @@ export class PM_Main extends PM {
591
931
  testConfig: ITestTypes
592
932
  ): Promise<Page> => {
593
933
  const d = dest + ".mjs";
594
- // console.log(green, "launchWebSideCar", src, dest, d);
595
- console.log(ansiC.green(ansiC.inverse(`launchWebSideCar ${src}`)));
596
934
 
597
- const destFolder = dest.replace(".mjs", "");
598
- // const webArgz = JSON.stringify({
599
- // name: dest,
600
- // ports: [].toString(),
601
- // fs: destFolder,
602
- // browserWSEndpoint: this.browser.wsEndpoint(),
603
- // });
935
+ console.log(ansiC.green(ansiC.inverse(`launchWebSideCar ${src}`)));
604
936
 
605
937
  const fileStreams2: fs.WriteStream[] = [];
606
938
  const doneFileStream2: Promise<any>[] = [];
@@ -743,7 +1075,6 @@ export class PM_Main extends PM {
743
1075
  testConfig: ITestTypes
744
1076
  ) => {
745
1077
  const d = dest + ".mjs";
746
- // console.log(green, "launchNodeSideCar", src, dest, d);
747
1078
  console.log(ansiC.green(ansiC.inverse(`launchNodeSideCar ${src}`)));
748
1079
 
749
1080
  const destFolder = dest.replace(".mjs", "");
@@ -792,10 +1123,6 @@ export class PM_Main extends PM {
792
1123
 
793
1124
  const builtfile = dest + ".mjs";
794
1125
 
795
- // console.log(
796
- // "node builtfile",
797
- // (await import(`${builtfile}?cacheBust=${Date.now()}`)).default
798
- // );
799
1126
  this.server[builtfile] = await import(
800
1127
  `${builtfile}?cacheBust=${Date.now()}`
801
1128
  ).then((module) => {
@@ -817,7 +1144,6 @@ export class PM_Main extends PM {
817
1144
  });
818
1145
  });
819
1146
 
820
- // console.log("portsToUse", portsToUse);
821
1147
  for (let i = 0; i <= portsToUse.length; i++) {
822
1148
  if (portsToUse[i]) {
823
1149
  this.ports[portsToUse[i]] = "true"; //port is open again
@@ -1245,7 +1571,7 @@ export class PM_Main extends PM {
1245
1571
  );
1246
1572
  });
1247
1573
 
1248
- this.writeBigBoard();
1574
+ // this.writeBigBoard();
1249
1575
  };
1250
1576
 
1251
1577
  receiveExitCode = (srcTest: string, failures: number) => {
@@ -1255,7 +1581,7 @@ export class PM_Main extends PM {
1255
1581
 
1256
1582
  writeBigBoard = () => {
1257
1583
  fs.writeFileSync(
1258
- "./docs/bigBoard.json",
1584
+ "./docs/summary.json",
1259
1585
  JSON.stringify(this.bigBoard, null, 2)
1260
1586
  );
1261
1587
  };