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