testeranto 0.100.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 (226) hide show
  1. package/README.md +1 -0
  2. package/bundle.js +80 -30
  3. package/package.json +40 -32
  4. package/src/Footer.tsx +4 -0
  5. package/src/Init.ts +48 -0
  6. package/src/Node.ts +23 -17
  7. package/src/PM/index.ts +1 -1
  8. package/src/PM/main.ts +524 -156
  9. package/src/PM/node.ts +2 -2
  10. package/src/PM/web.ts +1 -1
  11. package/src/ReportClient.tsx +163 -0
  12. package/src/ReportServer.ts +21 -0
  13. package/src/SubPackages/react/component/node.ts +68 -24
  14. package/src/SubPackages/react/component/web.ts +68 -25
  15. package/src/SubPackages/react/jsx/index.ts +39 -18
  16. package/src/SubPackages/react/jsx/node.ts +12 -10
  17. package/src/SubPackages/react/jsx/web.ts +27 -14
  18. package/src/SubPackages/react-dom/component/node.ts +42 -50
  19. package/src/SubPackages/react-dom/component/web.ts +28 -10
  20. package/src/SubPackages/react-dom/jsx/node.ts +54 -56
  21. package/src/SubPackages/react-dom/jsx/web.ts +55 -42
  22. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +23 -7
  23. package/src/SubPackages/react-test-renderer/component/index.ts +38 -5
  24. package/src/SubPackages/react-test-renderer/component/node.ts +24 -5
  25. package/src/SubPackages/react-test-renderer/component/web.ts +22 -5
  26. package/src/SubPackages/react-test-renderer/fc/node.ts +41 -7
  27. package/src/SubPackages/react-test-renderer/fc/web.ts +43 -11
  28. package/src/SubPackages/react-test-renderer/jsx/index.ts +39 -16
  29. package/src/SubPackages/react-test-renderer/jsx/node.ts +8 -6
  30. package/src/SubPackages/react-test-renderer/jsx/web.ts +22 -5
  31. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +39 -6
  32. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +27 -10
  33. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +26 -12
  34. package/src/TestReport.tsx +176 -0
  35. package/src/Types.ts +63 -309
  36. package/src/Web.ts +24 -18
  37. package/src/build.ts +240 -0
  38. package/src/defaultConfig.ts +2 -1
  39. package/src/esbuildConfigs/eslint-formatter-testeranto.ts +5 -0
  40. package/src/esbuildConfigs/featuresPlugin.ts +0 -1
  41. package/src/esbuildConfigs/index.ts +1 -1
  42. package/src/esbuildConfigs/inputFilesPlugin.ts +2 -135
  43. package/src/esbuildConfigs/node.ts +4 -13
  44. package/src/esbuildConfigs/web.ts +3 -19
  45. package/src/init-docs.ts +2 -1
  46. package/src/lib/abstractBase.ts +82 -80
  47. package/src/lib/basebuilder.ts +57 -45
  48. package/src/lib/classBuilder.ts +15 -15
  49. package/src/lib/core.ts +44 -35
  50. package/src/lib/index.ts +47 -98
  51. package/src/lib/readme.md +12 -0
  52. package/src/lib/types.ts +53 -70
  53. package/src/run.ts +31 -0
  54. package/src/style.css +8 -0
  55. package/src/utils.ts +74 -2
  56. package/tsc.log +108 -0
  57. package/Bundle.Dockerfile +0 -52
  58. package/bin/init-docs.js +0 -24
  59. package/dist/common/dist/module/src/Init.js +0 -40
  60. package/dist/common/package.json +0 -3
  61. package/dist/common/src/Init.js +0 -40
  62. package/dist/common/src/Node.js +0 -27
  63. package/dist/common/src/PM/index.js +0 -7
  64. package/dist/common/src/PM/main.js +0 -941
  65. package/dist/common/src/PM/node.js +0 -128
  66. package/dist/common/src/PM/web.js +0 -121
  67. package/dist/common/src/SubPackages/puppeteer.js +0 -21
  68. package/dist/common/src/SubPackages/react/component/node.js +0 -19
  69. package/dist/common/src/SubPackages/react/component/web.js +0 -19
  70. package/dist/common/src/SubPackages/react/jsx/index.js +0 -33
  71. package/dist/common/src/SubPackages/react/jsx/node.js +0 -10
  72. package/dist/common/src/SubPackages/react/jsx/web.js +0 -10
  73. package/dist/common/src/SubPackages/react-dom/component/node.js +0 -101
  74. package/dist/common/src/SubPackages/react-dom/component/web.js +0 -67
  75. package/dist/common/src/SubPackages/react-dom/jsx/index.js +0 -2
  76. package/dist/common/src/SubPackages/react-dom/jsx/node.js +0 -39
  77. package/dist/common/src/SubPackages/react-dom/jsx/web.js +0 -117
  78. package/dist/common/src/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -44
  79. package/dist/common/src/SubPackages/react-test-renderer/component/index.js +0 -2
  80. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +0 -60
  81. package/dist/common/src/SubPackages/react-test-renderer/component/node.js +0 -8
  82. package/dist/common/src/SubPackages/react-test-renderer/component/web.js +0 -8
  83. package/dist/common/src/SubPackages/react-test-renderer/fc/node.js +0 -50
  84. package/dist/common/src/SubPackages/react-test-renderer/fc/web.js +0 -50
  85. package/dist/common/src/SubPackages/react-test-renderer/jsx/index.js +0 -63
  86. package/dist/common/src/SubPackages/react-test-renderer/jsx/node.js +0 -10
  87. package/dist/common/src/SubPackages/react-test-renderer/jsx/web.js +0 -10
  88. package/dist/common/src/SubPackages/react-test-renderer/jsx-promised/index.js +0 -42
  89. package/dist/common/src/SubPackages/react-test-renderer/jsx-promised/node.js +0 -10
  90. package/dist/common/src/SubPackages/react-test-renderer/jsx-promised/web.js +0 -10
  91. package/dist/common/src/Types.js +0 -2
  92. package/dist/common/src/Web.js +0 -49
  93. package/dist/common/src/cli.js +0 -439
  94. package/dist/common/src/cli2.js +0 -144
  95. package/dist/common/src/defaultConfig.js +0 -19
  96. package/dist/common/src/esbuildConfigs/featuresPlugin.js +0 -39
  97. package/dist/common/src/esbuildConfigs/index.js +0 -21
  98. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +0 -99
  99. package/dist/common/src/esbuildConfigs/node.js +0 -45
  100. package/dist/common/src/esbuildConfigs/web.js +0 -61
  101. package/dist/common/src/init-docs.js +0 -43
  102. package/dist/common/src/lib/abstractBase.js +0 -324
  103. package/dist/common/src/lib/basebuilder.js +0 -85
  104. package/dist/common/src/lib/classBuilder.js +0 -42
  105. package/dist/common/src/lib/core.js +0 -101
  106. package/dist/common/src/lib/index.js +0 -22
  107. package/dist/common/src/lib/types.js +0 -3
  108. package/dist/common/src/puppeteerConfiger.js +0 -24
  109. package/dist/common/src/utils.js +0 -16
  110. package/dist/common/src/web.html.js +0 -22
  111. package/dist/common/testeranto.js +0 -15
  112. package/dist/common/tsconfig.common.tsbuildinfo +0 -1
  113. package/dist/module/package.json +0 -3
  114. package/dist/module/src/Init.js +0 -35
  115. package/dist/module/src/Node.js +0 -20
  116. package/dist/module/src/PM/index.js +0 -3
  117. package/dist/module/src/PM/main.js +0 -911
  118. package/dist/module/src/PM/node.js +0 -121
  119. package/dist/module/src/PM/web.js +0 -117
  120. package/dist/module/src/SubPackages/puppeteer.js +0 -16
  121. package/dist/module/src/SubPackages/react/component/node.js +0 -14
  122. package/dist/module/src/SubPackages/react/component/web.js +0 -14
  123. package/dist/module/src/SubPackages/react/jsx/index.js +0 -27
  124. package/dist/module/src/SubPackages/react/jsx/node.js +0 -5
  125. package/dist/module/src/SubPackages/react/jsx/web.js +0 -5
  126. package/dist/module/src/SubPackages/react-dom/component/node.js +0 -93
  127. package/dist/module/src/SubPackages/react-dom/component/web.js +0 -62
  128. package/dist/module/src/SubPackages/react-dom/jsx/index.js +0 -1
  129. package/dist/module/src/SubPackages/react-dom/jsx/node.js +0 -31
  130. package/dist/module/src/SubPackages/react-dom/jsx/web.js +0 -89
  131. package/dist/module/src/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -16
  132. package/dist/module/src/SubPackages/react-test-renderer/component/index.js +0 -1
  133. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +0 -31
  134. package/dist/module/src/SubPackages/react-test-renderer/component/node.js +0 -3
  135. package/dist/module/src/SubPackages/react-test-renderer/component/web.js +0 -3
  136. package/dist/module/src/SubPackages/react-test-renderer/fc/node.js +0 -22
  137. package/dist/module/src/SubPackages/react-test-renderer/fc/web.js +0 -22
  138. package/dist/module/src/SubPackages/react-test-renderer/jsx/index.js +0 -34
  139. package/dist/module/src/SubPackages/react-test-renderer/jsx/node.js +0 -5
  140. package/dist/module/src/SubPackages/react-test-renderer/jsx/web.js +0 -5
  141. package/dist/module/src/SubPackages/react-test-renderer/jsx-promised/index.js +0 -16
  142. package/dist/module/src/SubPackages/react-test-renderer/jsx-promised/node.js +0 -5
  143. package/dist/module/src/SubPackages/react-test-renderer/jsx-promised/web.js +0 -5
  144. package/dist/module/src/Types.js +0 -1
  145. package/dist/module/src/Web.js +0 -42
  146. package/dist/module/src/cli.js +0 -411
  147. package/dist/module/src/cli2.js +0 -116
  148. package/dist/module/src/defaultConfig.js +0 -17
  149. package/dist/module/src/esbuildConfigs/featuresPlugin.js +0 -34
  150. package/dist/module/src/esbuildConfigs/index.js +0 -19
  151. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +0 -94
  152. package/dist/module/src/esbuildConfigs/node.js +0 -40
  153. package/dist/module/src/esbuildConfigs/web.js +0 -56
  154. package/dist/module/src/init-docs.js +0 -15
  155. package/dist/module/src/lib/abstractBase.js +0 -316
  156. package/dist/module/src/lib/basebuilder.js +0 -81
  157. package/dist/module/src/lib/classBuilder.js +0 -38
  158. package/dist/module/src/lib/core.js +0 -98
  159. package/dist/module/src/lib/index.js +0 -18
  160. package/dist/module/src/lib/types.js +0 -2
  161. package/dist/module/src/puppeteerConfiger.js +0 -19
  162. package/dist/module/src/utils.js +0 -9
  163. package/dist/module/src/web.html.js +0 -20
  164. package/dist/module/testeranto.js +0 -13
  165. package/dist/module/tsconfig.module.tsbuildinfo +0 -1
  166. package/dist/prebuild/cli.mjs +0 -1491
  167. package/dist/prebuild/cli2.mjs +0 -918
  168. package/dist/prebuild/init-docs.mjs +0 -48
  169. package/dist/types/dist/module/src/Init.d.ts +0 -2
  170. package/dist/types/src/Init.d.ts +0 -2
  171. package/dist/types/src/Node.d.ts +0 -13
  172. package/dist/types/src/PM/index.d.ts +0 -34
  173. package/dist/types/src/PM/main.d.ts +0 -56
  174. package/dist/types/src/PM/node.d.ts +0 -42
  175. package/dist/types/src/PM/web.d.ts +0 -40
  176. package/dist/types/src/SubPackages/puppeteer.d.ts +0 -6
  177. package/dist/types/src/SubPackages/react/component/node.d.ts +0 -7
  178. package/dist/types/src/SubPackages/react/component/web.d.ts +0 -7
  179. package/dist/types/src/SubPackages/react/jsx/index.d.ts +0 -12
  180. package/dist/types/src/SubPackages/react/jsx/node.d.ts +0 -4
  181. package/dist/types/src/SubPackages/react/jsx/web.d.ts +0 -4
  182. package/dist/types/src/SubPackages/react-dom/component/node.d.ts +0 -12
  183. package/dist/types/src/SubPackages/react-dom/component/web.d.ts +0 -11
  184. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +0 -7
  185. package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +0 -6
  186. package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +0 -5
  187. package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -5
  188. package/dist/types/src/SubPackages/react-test-renderer/component/index.d.ts +0 -13
  189. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +0 -9
  190. package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +0 -8
  191. package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +0 -3
  192. package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +0 -8
  193. package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +0 -8
  194. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +0 -17
  195. package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +0 -9
  196. package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +0 -8
  197. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +0 -16
  198. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
  199. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
  200. package/dist/types/src/Types.d.ts +0 -90
  201. package/dist/types/src/Web.d.ts +0 -10
  202. package/dist/types/src/cli.d.ts +0 -1
  203. package/dist/types/src/cli2.d.ts +0 -1
  204. package/dist/types/src/defaultConfig.d.ts +0 -3
  205. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +0 -5
  206. package/dist/types/src/esbuildConfigs/index.d.ts +0 -4
  207. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +0 -7
  208. package/dist/types/src/esbuildConfigs/node.d.ts +0 -4
  209. package/dist/types/src/esbuildConfigs/web.d.ts +0 -4
  210. package/dist/types/src/init-docs.d.ts +0 -1
  211. package/dist/types/src/lib/abstractBase.d.ts +0 -110
  212. package/dist/types/src/lib/basebuilder.d.ts +0 -27
  213. package/dist/types/src/lib/classBuilder.d.ts +0 -7
  214. package/dist/types/src/lib/core.d.ts +0 -8
  215. package/dist/types/src/lib/index.d.ts +0 -60
  216. package/dist/types/src/lib/types.d.ts +0 -40
  217. package/dist/types/src/puppeteerConfiger.d.ts +0 -4
  218. package/dist/types/src/utils.d.ts +0 -2
  219. package/dist/types/src/web.html.d.ts +0 -2
  220. package/dist/types/testeranto.d.ts +0 -16
  221. package/dist/types/tsconfig.types.tsbuildinfo +0 -1
  222. package/docker-compose.yml +0 -37
  223. package/src/SubPackages/puppeteer.ts +0 -51
  224. package/src/cli.ts +0 -535
  225. package/src/cli2.ts +0 -157
  226. package/testeranto.ts +0 -13
package/src/cli.ts DELETED
@@ -1,535 +0,0 @@
1
- import { spawn } from "child_process";
2
- import fs, { watch } from "fs";
3
- import path from "path";
4
- import readline from "readline";
5
- import { glob } from "glob";
6
- import crypto from "node:crypto";
7
-
8
- import { debounceWatch } from "@bscotch/debounce-watch";
9
- import type { DebouncedEventsProcessor } from "@bscotch/debounce-watch";
10
-
11
- import esbuild from "esbuild";
12
- import tseslint from "typescript-eslint";
13
- import { ESLint } from "eslint";
14
-
15
- import esbuildNodeConfiger from "./esbuildConfigs/node.js";
16
- import esbuildWebConfiger from "./esbuildConfigs/web.js";
17
- import webHtmlFrame from "./web.html.js";
18
- import {
19
- ITestTypes,
20
- IBaseConfig,
21
- IRunTime,
22
- IBuiltConfig,
23
- } from "./lib/types.js";
24
- import { PM_Main } from "./PM/main.js";
25
-
26
- readline.emitKeypressEvents(process.stdin);
27
- if (process.stdin.isTTY) process.stdin.setRawMode(true);
28
-
29
- function parseTsErrors(logContent): void {
30
- fs.writeFileSync("docs/types/log.txt", logContent.join("\n"));
31
-
32
- try {
33
- const regex = /(^src(.*?))\(\d*,\d*\): error/gm;
34
- const brokenFilesToLines: Record<string, Set<number>> = {};
35
-
36
- for (let i = 0; i < logContent.length - 1; i++) {
37
- let m;
38
-
39
- while ((m = regex.exec(logContent[i])) !== null) {
40
- // This is necessary to avoid infinite loops with zero-width matches
41
- if (m.index === regex.lastIndex) {
42
- regex.lastIndex++;
43
- }
44
- if (!brokenFilesToLines[m[1]]) {
45
- brokenFilesToLines[m[1]] = new Set<number>();
46
- }
47
- brokenFilesToLines[m[1]].add(i);
48
- }
49
- }
50
-
51
- const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
52
- mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
53
- const a = Array.from(brokenFilesToLines[lm]);
54
-
55
- return Object.keys(a).reduce((mm2, lm2, ndx2) => {
56
- const acc: string[] = [];
57
-
58
- let j = a[lm2] + 1;
59
-
60
- let working = true;
61
- while (j < logContent.length - 1 && working) {
62
- if (
63
- !logContent[j].match(regex) &&
64
- working &&
65
- !logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)
66
- ) {
67
- acc.push(logContent[j]);
68
- } else {
69
- working = false;
70
- }
71
-
72
- j++;
73
- }
74
-
75
- mm2[lm] = [logContent[l], ...acc];
76
-
77
- return mm2;
78
- }, {} as any)[lm];
79
- });
80
- return mm;
81
- }, {});
82
-
83
- Object.keys(final).forEach((k) => {
84
- fs.mkdirSync(`./docs/types/${k.split("/").slice(0, -1).join("/")}`, {
85
- recursive: true,
86
- });
87
- fs.writeFileSync(
88
- `./docs/types/${k}.type_errors.txt`,
89
- 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
-
98
- function parseLintErrors(logContent): void {
99
- fs.writeFileSync("docs/eslint/log.txt", logContent.join("\n"));
100
-
101
- try {
102
- const regex = new RegExp(`^${process.cwd()}/(.*?)`, "gm");
103
- const brokenFilesToLines: Record<string, Set<number>> = {};
104
-
105
- for (let i = 0; i < logContent.length - 1; i++) {
106
- let m;
107
-
108
- while ((m = regex.exec(logContent[i])) !== null) {
109
- // This is necessary to avoid infinite loops with zero-width matches
110
- if (m.index === regex.lastIndex) {
111
- regex.lastIndex++;
112
- }
113
- if (!brokenFilesToLines[m[1]]) {
114
- brokenFilesToLines[m[1]] = new Set<number>();
115
- }
116
- brokenFilesToLines[m[1]].add(i);
117
- }
118
- }
119
-
120
- const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
121
- mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
122
- const a = Array.from(brokenFilesToLines[lm]);
123
-
124
- return Object.keys(a).reduce((mm2, lm2, ndx2) => {
125
- const acc: string[] = [];
126
-
127
- let j = a[lm2] + 1;
128
-
129
- let working = true;
130
- while (j < logContent.length - 1 && working) {
131
- if (
132
- !logContent[j].match(regex) &&
133
- working
134
- // &&
135
- // !logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)
136
- ) {
137
- acc.push(logContent[j]);
138
- } else {
139
- working = false;
140
- }
141
-
142
- j++;
143
- }
144
-
145
- mm2[lm] = [logContent[l], ...acc];
146
-
147
- return mm2;
148
- }, {} as any)[lm];
149
- });
150
- return mm;
151
- }, {});
152
-
153
- Object.keys(final).forEach((k) => {
154
- fs.mkdirSync(`./docs/eslint/${k.split("/").slice(0, -1).join("/")}`, {
155
- recursive: true,
156
- });
157
- fs.writeFileSync(
158
- `./docs/eslint/${k}.lint_errors.txt`,
159
- final[k].flat().flat().join("\r\n")
160
- );
161
- });
162
- } catch (error) {
163
- console.error("Error reading or parsing the log file:", error);
164
- process.exit(1);
165
- }
166
- }
167
-
168
- const typecheck = () => {
169
- const logContent: string[] = [];
170
- fs.rmSync("docs/types", { force: true, recursive: true });
171
- fs.mkdirSync("docs/types");
172
-
173
- const tsc = spawn("tsc", ["-noEmit"]);
174
-
175
- tsc.stdout.on("data", (data) => {
176
- const lines = data.toString().split("\n");
177
- logContent.push(...lines);
178
- });
179
-
180
- tsc.stderr.on("data", (data) => {
181
- console.error(`stderr: ${data}`);
182
- process.exit(-1);
183
- });
184
-
185
- tsc.on("close", (code) => {
186
- parseTsErrors(logContent);
187
- });
188
- };
189
-
190
- const eslint = () => {
191
- const logContent: string[] = [];
192
- fs.rmSync("docs/eslint", { force: true, recursive: true });
193
- fs.mkdirSync("docs/eslint");
194
-
195
- const tsc = spawn("eslint", ["./src"]);
196
-
197
- tsc.stdout.on("data", (data) => {
198
- const lines = data.toString().split("\n");
199
- logContent.push(...lines);
200
- });
201
-
202
- tsc.stderr.on("data", (data) => {
203
- console.error(`stderr: ${data}`);
204
- process.exit(-1);
205
- });
206
-
207
- tsc.on("close", (code) => {
208
- parseLintErrors(logContent);
209
- });
210
- };
211
-
212
- type IRunnables = {
213
- nodeEntryPoints: Record<string, string>;
214
- webEntryPoints: Record<string, string>;
215
- };
216
-
217
- const getRunnables = (
218
- tests: ITestTypes[],
219
- payload = {
220
- nodeEntryPoints: {},
221
- webEntryPoints: {},
222
- }
223
- ): IRunnables => {
224
- return tests.reduce((pt, cv, cndx, cry) => {
225
- if (cv[1] === "node") {
226
- pt.nodeEntryPoints[cv[0]] = path.resolve(
227
- `./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
228
- );
229
- } else if (cv[1] === "web") {
230
- pt.webEntryPoints[cv[0]] = path.resolve(
231
- `./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
232
- );
233
- }
234
-
235
- if (cv[3].length) {
236
- getRunnables(cv[3], payload);
237
- }
238
-
239
- return pt;
240
- }, payload as IRunnables);
241
- };
242
-
243
- import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
244
- const rawConfig: IBaseConfig = module.default;
245
-
246
- const getSecondaryEndpointsPoints = (runtime?: IRunTime): string[] => {
247
- const meta = (ts: ITestTypes[], st: Set<string>): Set<string> => {
248
- ts.forEach((t) => {
249
- if (t[1] === runtime) {
250
- st.add(t[0]);
251
- }
252
- if (Array.isArray(t[3])) {
253
- meta(t[3], st);
254
- }
255
- });
256
- return st;
257
- };
258
- return Array.from(meta(config.tests, new Set()));
259
- };
260
-
261
- const config: IBuiltConfig = {
262
- ...rawConfig,
263
- buildDir: process.cwd() + "/" + rawConfig.outdir,
264
- };
265
-
266
- let nodeDone: boolean = false;
267
- let webDone: boolean = false;
268
- let mode = config.devMode ? "DEV" : "PROD";
269
- let status: "build" | "built" = "build";
270
- let pm: PM_Main | undefined = new PM_Main(config);
271
- const fileHashes = {};
272
- const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
273
-
274
- const onNodeDone = () => {
275
- nodeDone = true;
276
- onDone();
277
- };
278
-
279
- const onWebDone = () => {
280
- webDone = true;
281
- onDone();
282
- };
283
-
284
- // async function fileHash(filePath, algorithm = "md5") {
285
- // return new Promise((resolve, reject) => {
286
- // const hash = crypto.createHash(algorithm);
287
- // const fileStream = fs.createReadStream(filePath);
288
-
289
- // fileStream.on("data", (data) => {
290
- // hash.update(data);
291
- // });
292
-
293
- // fileStream.on("end", () => {
294
- // const fileHash = hash.digest("hex");
295
- // resolve(fileHash);
296
- // });
297
-
298
- // fileStream.on("error", (error) => {
299
- // reject(`Error reading file: ${error.message}`);
300
- // });
301
- // });
302
- // }
303
-
304
- const onDone = async () => {
305
- if (nodeDone && webDone) {
306
- status = "built";
307
- }
308
- if (nodeDone && webDone && status === "built") {
309
- // Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
310
- // console.log("watching", outputFile);
311
- // try {
312
- // watch(outputFile, async (filename) => {
313
- // const hash = await fileHash(outputFile);
314
- // if (fileHashes[k] !== hash) {
315
- // fileHashes[k] = hash;
316
- // console.log(`< ${filename} `);
317
- // pm.launchNode(k, outputFile);
318
- // }
319
- // });
320
- // } catch (e) {
321
- // console.error(e);
322
- // }
323
- // });
324
- // Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
325
- // console.log("watching", outputFile);
326
- // watch(outputFile, async (filename) => {
327
- // const hash = await fileHash(outputFile);
328
- // console.log(`< ${filename} ${hash}`);
329
- // if (fileHashes[k] !== hash) {
330
- // fileHashes[k] = hash;
331
- // pm.launchWeb(k, outputFile);
332
- // }
333
- // });
334
- // });
335
- }
336
-
337
- if (nodeDone && webDone && mode === "PROD") {
338
- console.log("Testeranto-EsBuild is all done. Goodbye!");
339
- process.exit();
340
- } else {
341
- if (mode === "PROD") {
342
- console.log("waiting for tests to finish");
343
- console.log(
344
- JSON.stringify(
345
- {
346
- nodeDone: nodeDone,
347
- webDone: webDone,
348
- mode: mode,
349
- },
350
- null,
351
- 2
352
- )
353
- );
354
- } else {
355
- console.log("waiting for tests to change");
356
- }
357
- console.log("press 'q' to quit");
358
-
359
- if (config.devMode) {
360
- console.log("ready and watching for changes...");
361
- } else {
362
- pm.shutDown();
363
- }
364
- ////////////////////////////////////////////////////////////////////////////////
365
- }
366
- };
367
-
368
- console.log(
369
- `Press 'q' to shutdown gracefully. Press 'x' to shutdown forcefully.`
370
- );
371
- process.stdin.on("keypress", (str, key) => {
372
- if (key.name === "q") {
373
- console.log("Testeranto-EsBuild is shutting down...");
374
- mode = "PROD";
375
- onDone();
376
- }
377
- });
378
-
379
- // const eslint = new ESLint();
380
- // const configEslint = await eslint.calculateConfigForFile(
381
- // "./src/eslint.config.mjs"
382
- // );
383
- // // console.log(`configEslint`, configEslint);
384
- // fs.watch("src", { recursive: true }, async (eventType, filename) => {
385
- // if (eventType === "change") {
386
- // console.log(`File ${filename} has been modified.`);
387
- // const x = await eslint.lintFiles([`./src/${filename}`]);
388
- // console.log(x[0].messages);
389
- // } else if (eventType === "rename") {
390
- // console.log(`File ${filename} has been created or deleted.`);
391
- // }
392
- // });
393
-
394
- fs.writeFileSync(
395
- `${config.outdir}/testeranto.json`,
396
- JSON.stringify(config, null, 2)
397
- );
398
-
399
- Promise.resolve(
400
- Promise.all(
401
- [...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
402
- const sourceFileSplit = sourceFilePath.split("/");
403
- const sourceDir = sourceFileSplit.slice(0, -1);
404
- const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
405
- const sourceFileNameMinusJs = sourceFileName
406
- .split(".")
407
- .slice(0, -1)
408
- .join(".");
409
-
410
- const htmlFilePath = path.normalize(
411
- `${process.cwd()}/${config.outdir}/web/${sourceDir.join(
412
- "/"
413
- )}/${sourceFileNameMinusJs}.html`
414
- );
415
- const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
416
-
417
- return fs.promises
418
- .mkdir(path.dirname(htmlFilePath), { recursive: true })
419
- .then((x) =>
420
- fs.writeFileSync(
421
- htmlFilePath,
422
- webHtmlFrame(jsfilePath, htmlFilePath)
423
- )
424
- );
425
- })
426
- )
427
- );
428
-
429
- glob(`./${config.outdir}/chunk-*.mjs`, {
430
- ignore: "node_modules/**",
431
- }).then((chunks) => {
432
- chunks.forEach((chunk) => {
433
- fs.unlinkSync(chunk);
434
- });
435
- });
436
-
437
- // const processDebouncedEvents: DebouncedEventsProcessor = (events) => {
438
- // typecheck();
439
- // };
440
-
441
- debounceWatch(
442
- (events) => {
443
- typecheck();
444
- eslint();
445
- },
446
- "./src",
447
- {
448
- onlyFileExtensions: ["ts", "tsx", "mts"],
449
- debounceWaitSeconds: 0.2,
450
- allowOverlappingRuns: false,
451
- }
452
- );
453
-
454
- await pm.startPuppeteer(
455
- {
456
- slowMo: 1,
457
- // timeout: 1,
458
- waitForInitialPage: false,
459
- executablePath:
460
- // process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
461
- "/opt/homebrew/bin/chromium",
462
- headless: true,
463
- dumpio: true,
464
- // timeout: 0,
465
- devtools: true,
466
-
467
- args: [
468
- "--auto-open-devtools-for-tabs",
469
- `--remote-debugging-port=3234`,
470
-
471
- // "--disable-features=IsolateOrigins,site-per-process",
472
- "--disable-site-isolation-trials",
473
- "--allow-insecure-localhost",
474
- "--allow-file-access-from-files",
475
- "--allow-running-insecure-content",
476
-
477
- "--disable-dev-shm-usage",
478
- "--disable-extensions",
479
- "--disable-gpu",
480
- "--disable-setuid-sandbox",
481
- "--disable-site-isolation-trials",
482
- "--disable-web-security",
483
- "--no-first-run",
484
- "--no-sandbox",
485
- "--no-startup-window",
486
- // "--no-zygote",
487
- "--reduce-security-for-testing",
488
- "--remote-allow-origins=*",
489
- "--unsafely-treat-insecure-origin-as-secure=*",
490
- // "--disable-features=IsolateOrigins",
491
- // "--remote-allow-origins=ws://localhost:3234",
492
- // "--single-process",
493
- // "--unsafely-treat-insecure-origin-as-secure",
494
- // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
495
-
496
- // "--disk-cache-dir=/dev/null",
497
- // "--disk-cache-size=1",
498
- // "--start-maximized",
499
- ],
500
- },
501
- "."
502
- );
503
-
504
- await Promise.all([
505
- esbuild
506
- .context(esbuildNodeConfiger(config, Object.keys(nodeEntryPoints)))
507
- .then(async (nodeContext) => {
508
- if (config.devMode) {
509
- await nodeContext.watch().then((v) => {
510
- onNodeDone();
511
- });
512
- } else {
513
- nodeContext.rebuild().then((v) => {
514
- onNodeDone();
515
- });
516
- }
517
-
518
- return nodeContext;
519
- }),
520
- esbuild
521
- .context(esbuildWebConfiger(config, Object.keys(webEntryPoints)))
522
- .then(async (webContext) => {
523
- if (config.devMode) {
524
- await webContext.watch().then((v) => {
525
- onWebDone();
526
- });
527
- } else {
528
- webContext.rebuild().then((v) => {
529
- onWebDone();
530
- });
531
- }
532
- return webContext;
533
- }),
534
- ]);
535
- });
package/src/cli2.ts DELETED
@@ -1,157 +0,0 @@
1
- import { watch } from "fs";
2
- import { config } from "process";
3
- import { PM_Main } from "./PM/main";
4
- import { IBaseConfig, IBuiltConfig, ITestTypes } from "./lib/types";
5
- import path from "path";
6
- import crypto from "node:crypto";
7
- import fs from "fs";
8
-
9
- type IRunnables = {
10
- nodeEntryPoints: Record<string, string>;
11
- webEntryPoints: Record<string, string>;
12
- };
13
-
14
- const fileHashes = {};
15
-
16
- async function fileHash(filePath, algorithm = "md5") {
17
- return new Promise((resolve, reject) => {
18
- const hash = crypto.createHash(algorithm);
19
- const fileStream = fs.createReadStream(filePath);
20
-
21
- fileStream.on("data", (data) => {
22
- hash.update(data);
23
- });
24
-
25
- fileStream.on("end", () => {
26
- const fileHash = hash.digest("hex");
27
- resolve(fileHash);
28
- });
29
-
30
- fileStream.on("error", (error) => {
31
- reject(`Error reading file: ${error.message}`);
32
- });
33
- });
34
- }
35
-
36
- const getRunnables = (
37
- tests: ITestTypes[],
38
- payload = {
39
- nodeEntryPoints: {},
40
- webEntryPoints: {},
41
- }
42
- ): IRunnables => {
43
- return tests.reduce((pt, cv, cndx, cry) => {
44
- if (cv[1] === "node") {
45
- pt.nodeEntryPoints[cv[0]] = path.resolve(
46
- `./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
47
- );
48
- } else if (cv[1] === "web") {
49
- pt.webEntryPoints[cv[0]] = path.resolve(
50
- `./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
51
- );
52
- }
53
-
54
- if (cv[3].length) {
55
- getRunnables(cv[3], payload);
56
- }
57
-
58
- return pt;
59
- }, payload as IRunnables);
60
- };
61
-
62
- import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
63
- const rawConfig: IBaseConfig = module.default;
64
-
65
- const config: IBuiltConfig = {
66
- ...rawConfig,
67
- buildDir: process.cwd() + "/" + rawConfig.outdir,
68
- };
69
-
70
- let pm: PM_Main | undefined = new PM_Main(config);
71
-
72
- await pm.startPuppeteer(
73
- {
74
- slowMo: 1,
75
- // timeout: 1,
76
- waitForInitialPage: false,
77
- executablePath:
78
- // process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
79
- "/opt/homebrew/bin/chromium",
80
- headless: true,
81
- dumpio: true,
82
- // timeout: 0,
83
- devtools: true,
84
-
85
- args: [
86
- "--auto-open-devtools-for-tabs",
87
- `--remote-debugging-port=3234`,
88
-
89
- // "--disable-features=IsolateOrigins,site-per-process",
90
- "--disable-site-isolation-trials",
91
- "--allow-insecure-localhost",
92
- "--allow-file-access-from-files",
93
- "--allow-running-insecure-content",
94
-
95
- "--disable-dev-shm-usage",
96
- "--disable-extensions",
97
- "--disable-gpu",
98
- "--disable-setuid-sandbox",
99
- "--disable-site-isolation-trials",
100
- "--disable-web-security",
101
- "--no-first-run",
102
- "--no-sandbox",
103
- "--no-startup-window",
104
- // "--no-zygote",
105
- "--reduce-security-for-testing",
106
- "--remote-allow-origins=*",
107
- "--unsafely-treat-insecure-origin-as-secure=*",
108
- // "--disable-features=IsolateOrigins",
109
- // "--remote-allow-origins=ws://localhost:3234",
110
- // "--single-process",
111
- // "--unsafely-treat-insecure-origin-as-secure",
112
- // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
113
-
114
- // "--disk-cache-dir=/dev/null",
115
- // "--disk-cache-size=1",
116
- // "--start-maximized",
117
- ],
118
- },
119
- "."
120
- );
121
-
122
- const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
123
-
124
- Object.entries(nodeEntryPoints).forEach(
125
- ([k, outputFile]: [string, string]) => {
126
- console.log("watching and running", outputFile);
127
- pm.launchNode(k, outputFile);
128
- try {
129
- watch(outputFile, async (e, filename) => {
130
- const hash = await fileHash(outputFile);
131
- if (fileHashes[k] !== hash) {
132
- fileHashes[k] = hash;
133
- console.log(`< ${e} ${filename} ${hash}`);
134
- pm.launchNode(k, outputFile);
135
- }
136
- });
137
- } catch (e) {
138
- console.error(e);
139
- }
140
- }
141
- );
142
-
143
- Object.entries(webEntryPoints).forEach(
144
- ([k, outputFile]: [string, string]) => {
145
- console.log("watching and running", outputFile);
146
- pm.launchWeb(k, outputFile);
147
- watch(outputFile, async (e, filename) => {
148
- const hash = await fileHash(outputFile);
149
- console.log(`< ${e} ${filename} ${hash}`);
150
- if (fileHashes[k] !== hash) {
151
- fileHashes[k] = hash;
152
- pm.launchWeb(k, outputFile);
153
- }
154
- });
155
- }
156
- );
157
- });
package/testeranto.ts DELETED
@@ -1,13 +0,0 @@
1
- export default {
2
- botEmail: "adamwong246@gmail.com",
3
- taskman: "adamwong246/kokomobay-taskman",
4
- outdir: "docs",
5
- tests: [["./src/LoginButton.test.tsx", "web", { ports: 0 }, []]],
6
- debugger: true,
7
- clearScreen: false,
8
- devMode: true,
9
- minify: false,
10
- outbase: ".",
11
- ports: [],
12
- externals: [],
13
- };