testeranto 0.62.0 → 0.73.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 (186) hide show
  1. package/README.md +38 -26
  2. package/dist/cjs-shim.js +2 -2
  3. package/dist/common/Node.js +14 -51
  4. package/dist/common/PM/index.js +71 -0
  5. package/dist/common/PM/main.js +361 -0
  6. package/dist/common/PM/node.js +176 -0
  7. package/dist/common/PM/web.js +174 -0
  8. package/dist/common/Project.js +121 -266
  9. package/dist/common/Puppeteer.js +109 -0
  10. package/dist/common/Reporter.js +119 -0
  11. package/dist/common/Scheduler.js +1 -0
  12. package/dist/common/SubPackages/puppeteer.js +3 -1
  13. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  14. package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
  15. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  16. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
  17. package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
  18. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
  19. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
  20. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  21. package/dist/common/Types.js +2 -32
  22. package/dist/common/Web.js +25 -37
  23. package/dist/common/esbuildConfigs/index.js +5 -5
  24. package/dist/common/esbuildConfigs/node.js +17 -15
  25. package/dist/common/esbuildConfigs/report.js +12 -47
  26. package/dist/common/esbuildConfigs/tests.js +0 -1
  27. package/dist/common/esbuildConfigs/web.js +17 -12
  28. package/dist/common/lib/abstractBase.js +190 -35
  29. package/dist/common/lib/basebuilder.js +56 -29
  30. package/dist/common/lib/classBuilder.js +8 -5
  31. package/dist/common/lib/core.js +42 -17
  32. package/dist/common/lib/index.js +11 -8
  33. package/dist/common/lib/types.js +2 -0
  34. package/dist/common/preload.js +14 -28
  35. package/dist/common/puppeteerConfiger.js +24 -0
  36. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  37. package/dist/module/Node.js +14 -51
  38. package/dist/module/PM/index.js +67 -0
  39. package/dist/module/PM/main.js +331 -0
  40. package/dist/module/PM/node.js +168 -0
  41. package/dist/module/PM/web.js +167 -0
  42. package/dist/module/Project.js +122 -267
  43. package/dist/module/Puppeteer.js +104 -0
  44. package/dist/module/Reporter.js +114 -0
  45. package/dist/module/Scheduler.js +1 -0
  46. package/dist/module/SubPackages/puppeteer.js +3 -1
  47. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  48. package/dist/module/SubPackages/react/jsx/web.js +1 -1
  49. package/dist/module/SubPackages/react-dom/component/node.js +2 -2
  50. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  51. package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
  52. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  53. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  54. package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
  55. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
  56. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
  57. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  58. package/dist/module/Types.js +3 -30
  59. package/dist/module/Web.js +26 -38
  60. package/dist/module/esbuildConfigs/index.js +5 -5
  61. package/dist/module/esbuildConfigs/node.js +17 -15
  62. package/dist/module/esbuildConfigs/report.js +11 -48
  63. package/dist/module/esbuildConfigs/tests.js +0 -1
  64. package/dist/module/esbuildConfigs/web.js +17 -12
  65. package/dist/module/lib/abstractBase.js +190 -35
  66. package/dist/module/lib/basebuilder.js +56 -29
  67. package/dist/module/lib/classBuilder.js +8 -5
  68. package/dist/module/lib/core.js +44 -19
  69. package/dist/module/lib/index.js +11 -8
  70. package/dist/module/preload.js +15 -27
  71. package/dist/module/puppeteerConfiger.js +19 -0
  72. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  73. package/dist/prebuild/Report.css +1616 -584
  74. package/dist/prebuild/Report.js +2635 -2506
  75. package/dist/types/Node.d.ts +3 -2
  76. package/dist/types/PM/index.d.ts +19 -0
  77. package/dist/types/PM/main.d.ts +28 -0
  78. package/dist/types/PM/node.d.ts +26 -0
  79. package/dist/types/PM/web.d.ts +24 -0
  80. package/dist/types/Project.d.ts +1 -2
  81. package/dist/types/Puppeteer.d.ts +1 -0
  82. package/dist/types/Reporter.d.ts +1 -0
  83. package/dist/types/Scheduler.d.ts +0 -0
  84. package/dist/types/SubPackages/puppeteer.d.ts +3 -3
  85. package/dist/types/SubPackages/react/component/node.d.ts +1 -1
  86. package/dist/types/SubPackages/react/component/web.d.ts +1 -1
  87. package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
  88. package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
  89. package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
  90. package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
  91. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  92. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
  93. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
  94. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
  95. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
  96. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
  97. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
  98. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
  99. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
  100. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
  101. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
  102. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
  103. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
  104. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
  105. package/dist/types/Types.d.ts +19 -100
  106. package/dist/types/Web.d.ts +3 -2
  107. package/dist/types/esbuildConfigs/features.d.ts +1 -1
  108. package/dist/types/esbuildConfigs/index.d.ts +1 -1
  109. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  110. package/dist/types/esbuildConfigs/report.d.ts +4 -0
  111. package/dist/types/esbuildConfigs/tests.d.ts +1 -1
  112. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  113. package/dist/types/lib/abstractBase.d.ts +26 -24
  114. package/dist/types/lib/basebuilder.d.ts +10 -7
  115. package/dist/types/lib/classBuilder.d.ts +4 -3
  116. package/dist/types/lib/core.d.ts +5 -4
  117. package/dist/types/lib/index.d.ts +7 -5
  118. package/dist/types/lib/types.d.ts +62 -0
  119. package/dist/types/preload.d.ts +0 -1
  120. package/dist/types/puppeteerConfiger.d.ts +4 -0
  121. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  122. package/package.json +6 -7
  123. package/src/Node.ts +30 -85
  124. package/src/PM/index.ts +102 -0
  125. package/src/PM/main.ts +420 -0
  126. package/src/PM/node.ts +515 -0
  127. package/src/PM/web.ts +497 -0
  128. package/src/Project.ts +183 -619
  129. package/src/Puppeteer.ts +131 -0
  130. package/src/Report.tsx +158 -44
  131. package/src/Reporter.ts +134 -0
  132. package/src/Scheduler.ts +0 -0
  133. package/src/SubPackages/puppeteer.ts +19 -14
  134. package/src/SubPackages/react/component/node.ts +20 -32
  135. package/src/SubPackages/react/component/web.ts +20 -30
  136. package/src/SubPackages/react/jsx/index.ts +13 -24
  137. package/src/SubPackages/react/jsx/node.ts +5 -8
  138. package/src/SubPackages/react/jsx/web.ts +10 -8
  139. package/src/SubPackages/react-dom/component/node.ts +17 -23
  140. package/src/SubPackages/react-dom/component/web.ts +134 -95
  141. package/src/SubPackages/react-dom/jsx/web.ts +41 -48
  142. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
  143. package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
  144. package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
  145. package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
  146. package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
  147. package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
  148. package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
  149. package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
  150. package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
  151. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
  152. package/src/Types.ts +73 -307
  153. package/src/Web.ts +40 -81
  154. package/src/cjs-shim.js +2 -2
  155. package/src/esbuildConfigs/features.ts +3 -4
  156. package/src/esbuildConfigs/index.ts +8 -8
  157. package/src/esbuildConfigs/node.ts +21 -20
  158. package/src/esbuildConfigs/report.ts +15 -51
  159. package/src/esbuildConfigs/tests.ts +3 -9
  160. package/src/esbuildConfigs/web.ts +22 -20
  161. package/src/lib/abstractBase.ts +312 -164
  162. package/src/lib/basebuilder.ts +123 -127
  163. package/src/lib/classBuilder.ts +30 -48
  164. package/src/lib/core.ts +115 -84
  165. package/src/lib/index.ts +58 -56
  166. package/src/lib/types.ts +197 -0
  167. package/src/preload.ts +14 -30
  168. package/src/puppeteerConfiger.ts +26 -0
  169. package/src/web.html.ts +1 -1
  170. package/dist/common/NodeWriter.js +0 -56
  171. package/dist/common/electron.js +0 -196
  172. package/dist/common/lib/browser.js +0 -26
  173. package/dist/common/nodeWriterElectron.js +0 -55
  174. package/dist/module/NodeWriter.js +0 -50
  175. package/dist/module/electron.js +0 -191
  176. package/dist/module/lib/browser.js +0 -22
  177. package/dist/module/nodeWriterElectron.js +0 -52
  178. package/dist/types/NodeWriter.d.ts +0 -2
  179. package/dist/types/lib/browser.d.ts +0 -6
  180. package/dist/types/nodeWriterElectron.d.ts +0 -2
  181. package/src/NodeWriter.ts +0 -69
  182. package/src/electron.ts +0 -250
  183. package/src/lib/browser.ts +0 -34
  184. package/src/nodeWriterElectron.ts +0 -71
  185. package/yarn-error.log +0 -3144
  186. /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
package/src/preload.ts CHANGED
@@ -1,33 +1,17 @@
1
- import { ipcRenderer } from "electron";
1
+ // import puppeteer from "puppeteer-core";
2
2
 
3
- console.log("hello preloader");
4
- import { NodeWriter } from "./NodeWriter";
3
+ // import { NodeWriter } from "./NodeWriter";
4
+ // import puppeteerConfiger from "./puppeteerConfiger";
5
5
 
6
- (window as any).NodeWriter = NodeWriter;
7
- (window as any).exit = (x) => {
8
- ipcRenderer.invoke('quit-app', x);
9
- }
6
+ // (window as any).NodeWriter = NodeWriter;
10
7
 
11
- // var oldLog = console.log;
12
- // console.log = function (message) {
13
- // ipcRenderer.invoke('web-log', message.toString());
14
- // oldLog.apply(console, arguments);
15
- // };
16
-
17
- // var oldLog = console.error;
18
- // console.error = function (message) {
19
- // ipcRenderer.invoke('web-error', message.toString());
20
- // oldLog.apply(console, arguments);
21
- // };
22
-
23
- // var oldLog = console.warn;
24
- // console.warn = function (message) {
25
- // ipcRenderer.invoke('web-warn', message.toString());
26
- // oldLog.apply(console, arguments);
27
- // };
28
-
29
- // var oldLog = console.info;
30
- // console.info = function (message) {
31
- // ipcRenderer.invoke('web-info', message.toString());
32
- // oldLog.apply(console, arguments);
33
- // };
8
+ // (window as any).browser = new Promise(async (res, rej) => {
9
+ // const browser = await puppeteerConfiger("2999").then(async (json) => {
10
+ // const b = await puppeteer.connect({
11
+ // browserWSEndpoint: json.webSocketDebuggerUrl,
12
+ // defaultViewport: null,
13
+ // });
14
+ // console.log("connected!", b.isConnected());
15
+ // return res(b);
16
+ // });
17
+ // });
@@ -0,0 +1,26 @@
1
+ import http from "http";
2
+
3
+ export default async (
4
+ port: string
5
+ ): Promise<{ webSocketDebuggerUrl: string }> =>
6
+ new Promise((resolve, reject) => {
7
+ let json = "";
8
+ const request = http.request(
9
+ {
10
+ host: "127.0.0.1",
11
+ path: "/json/version",
12
+ port,
13
+ },
14
+ (response) => {
15
+ response.on("error", reject);
16
+ response.on("data", (chunk: Buffer) => {
17
+ json += chunk.toString();
18
+ });
19
+ response.on("end", () => {
20
+ resolve(JSON.parse(json));
21
+ });
22
+ }
23
+ );
24
+ request.on("error", reject);
25
+ request.end();
26
+ });
package/src/web.html.ts CHANGED
@@ -17,4 +17,4 @@ export default (jsfilePath: string, htmlFilePath: string) => `
17
17
  <footer></footer>
18
18
 
19
19
  </html>
20
- `
20
+ `;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NodeWriter = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const fPaths = [];
10
- exports.NodeWriter = {
11
- createWriteStream: (filepath) => {
12
- return fs_1.default.createWriteStream(filepath);
13
- },
14
- writeFileSync: (fp, contents) => {
15
- fs_1.default.writeFileSync(fp, contents);
16
- },
17
- mkdirSync: async (fp) => {
18
- await fs_1.default.mkdirSync(fp, { recursive: true });
19
- },
20
- testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
21
- callback(new Promise((res, rej) => {
22
- tLog("testArtiFactory =>", fPath);
23
- const cleanPath = path_1.default.resolve(fPath);
24
- fPaths.push(cleanPath.replace(process.cwd(), ``));
25
- const targetDir = cleanPath.split("/").slice(0, -1).join("/");
26
- fs_1.default.mkdir(targetDir, { recursive: true }, async (error) => {
27
- if (error) {
28
- console.error(`❗️testArtiFactory failed`, targetDir, error);
29
- }
30
- fs_1.default.writeFileSync(path_1.default.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
31
- encoding: "utf-8",
32
- });
33
- if (Buffer.isBuffer(value)) {
34
- fs_1.default.writeFileSync(fPath, value, "binary");
35
- res();
36
- }
37
- else if (`string` === typeof value) {
38
- fs_1.default.writeFileSync(fPath, value.toString(), {
39
- encoding: "utf-8",
40
- });
41
- res();
42
- }
43
- else {
44
- /* @ts-ignore:next-line */
45
- const pipeStream = value;
46
- const myFile = fs_1.default.createWriteStream(fPath);
47
- pipeStream.pipe(myFile);
48
- pipeStream.on("close", () => {
49
- myFile.close();
50
- res();
51
- });
52
- }
53
- });
54
- }));
55
- }
56
- };
@@ -1,196 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const electron_1 = require("electron");
7
- const puppeteer_in_electron_1 = __importDefault(require("puppeteer-in-electron"));
8
- const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const jsonc_1 = require("jsonc");
12
- const remoteMain = require("@electron/remote/main");
13
- remoteMain.initialize();
14
- const main = async () => {
15
- const configs = jsonc_1.jsonc.parse((await fs_1.default.readFileSync("./docs/testeranto.json")).toString());
16
- const loadReport = (configs) => {
17
- const win = new electron_1.BrowserWindow({
18
- show: true,
19
- webPreferences: {
20
- offscreen: false,
21
- devTools: true,
22
- }
23
- });
24
- win.loadFile(`/${configs.buildDir}/report.html`).then(async (x) => {
25
- // pie.connect(app, puppeteer).then(async (browser) => {
26
- // pie.getPage(browser, win).then(async (page) => {
27
- // await page.screenshot({
28
- // path: 'electron-puppeteer-screenshot1.jpg'
29
- // });
30
- // })
31
- // })
32
- });
33
- };
34
- const launchNode = (t, x) => {
35
- var _a;
36
- const f = x.replace(".ts", ".mjs");
37
- const a = JSON.stringify({
38
- scheduled: true,
39
- name: x,
40
- ports: [],
41
- fs: path_1.default.resolve(configs.buildDir, "node", t),
42
- });
43
- console.log("launchNode", f, a);
44
- const child = electron_1.utilityProcess.fork(f, [a], {});
45
- child.postMessage({ message: 'hello' });
46
- child.on('message', (data) => {
47
- console.log("from child", data);
48
- launchWebSecondary(process.cwd() + data);
49
- });
50
- child.on('exit', (data) => {
51
- console.log("node process ended with: ", data);
52
- fileStream.close();
53
- });
54
- // child.stdout
55
- // child..on("", (data) => {
56
- // console.log("from child", data) // hello world!
57
- // launchWebSecondary(process.cwd() + data);
58
- // })
59
- // Create a write stream for the file
60
- const fileStream = fs_1.default.createWriteStream('errors.txt');
61
- // Pipe the child process's stdout to the file
62
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
63
- // // Handle errors
64
- // child.on('error', (err) => {
65
- // console.error('Error spawning child process:', err);
66
- // });
67
- // fileStream.on('error', (err) => {
68
- // console.error('Error writing to file:', err);
69
- // });
70
- // // Log a message when the child process exits
71
- // child.on('close', (code) => {
72
- // console.log(`Child process exited with code ${code}`);
73
- // });
74
- // console.log("child", child);
75
- // child.stdout?.on("data", (x) => {
76
- // console.log("x", x)
77
- // })
78
- };
79
- const launchWebSecondary = (htmlFile) => {
80
- console.log("launchWebSecondary", htmlFile);
81
- const subWin = new electron_1.BrowserWindow({
82
- show: true,
83
- webPreferences: {
84
- nodeIntegration: true,
85
- nodeIntegrationInWorker: true,
86
- contextIsolation: false,
87
- preload: path_1.default.join(electron_1.app.getAppPath(), 'preload.js'),
88
- offscreen: false,
89
- devTools: false,
90
- }
91
- });
92
- remoteMain.enable(subWin.webContents);
93
- subWin.webContents.openDevTools();
94
- subWin.loadFile(htmlFile);
95
- };
96
- const launchWeb = (t, changedFile) => {
97
- console.log("launchWeb", changedFile);
98
- const subWin = new electron_1.BrowserWindow({
99
- show: true,
100
- webPreferences: {
101
- nodeIntegration: true,
102
- nodeIntegrationInWorker: true,
103
- contextIsolation: false,
104
- preload: path_1.default.join(electron_1.app.getAppPath(), 'preload.js'),
105
- offscreen: false,
106
- devTools: true,
107
- }
108
- });
109
- remoteMain.enable(subWin.webContents);
110
- // subWin.webContents.openDevTools()
111
- const htmlFile = changedFile.split(".").slice(0, -1).concat("html").join(".");
112
- subWin.loadFile(htmlFile, {
113
- query: {
114
- requesting: encodeURIComponent(JSON.stringify({
115
- name: changedFile,
116
- ports: [].toString(),
117
- fs: path_1.default.resolve(configs.buildDir, "web", t),
118
- }))
119
- }
120
- });
121
- };
122
- const watcher = (test, runtime) => {
123
- return path_1.default.normalize(`${configs.buildDir}/${runtime}/${test.split('.').slice(0, -1).concat('mjs').join('.')}`);
124
- };
125
- const changer = (f) => {
126
- return path_1.default.normalize(`${configs.buildDir}/${f}`);
127
- };
128
- const changer2 = (f, r) => {
129
- return path_1.default.normalize(`${configs.buildDir}/${r}/${f}`);
130
- };
131
- puppeteer_in_electron_1.default.initialize(electron_1.app, 2999).then(async () => {
132
- electron_1.app.on("ready", () => {
133
- loadReport(configs);
134
- console.log("running all the tests once initially");
135
- ;
136
- configs.modules.forEach((t) => {
137
- if (t.runtime === "node") {
138
- launchNode(t.test, changer2(t.test, "node"));
139
- }
140
- else if (t.runtime === "web") {
141
- launchWeb(t.test, changer2(t.test, "web"));
142
- }
143
- else {
144
- console.error("runtime makes no sense", t.runtime);
145
- }
146
- });
147
- console.log("ready and watching for changes...", configs.buildDir);
148
- fs_1.default.watch(configs.buildDir, {
149
- recursive: true,
150
- }, (eventType, changedFile) => {
151
- console.log(eventType, changedFile);
152
- if (changedFile) {
153
- configs.modules.forEach((t) => {
154
- if (watcher(t.test, t.runtime) === changer(changedFile)) {
155
- if (t.runtime === "node") {
156
- launchNode(t.test, changer(changedFile));
157
- }
158
- else if (t.runtime === "web") {
159
- launchWeb(t.test, changer(changedFile));
160
- }
161
- else {
162
- console.error("runtime makes no sense", t.runtime);
163
- }
164
- }
165
- });
166
- }
167
- });
168
- });
169
- });
170
- await puppeteer_in_electron_1.default.connect(electron_1.app, puppeteer_core_1.default);
171
- };
172
- main();
173
- // ipcMain.handle('web-log', (x, message: string) => {
174
- // console.log("web-log)", message);
175
- // });
176
- // ipcMain.handle('web-error', (x, message: string) => {
177
- // console.log("web-error)", message);
178
- // });
179
- // ipcMain.handle('web-warn', (x, message: string) => {
180
- // console.log("web-warn)", message);
181
- // });
182
- // ipcMain.handle('web-info', (x, message: string) => {
183
- // console.log("web-info)", message);
184
- // });
185
- // ipcMain.handle('quit-app', (x, failed: number) => {
186
- // console.log("quit-app", failed);
187
- // app.exit(failed);
188
- // });
189
- // process.stdin.on("data", (configTests) => {
190
- // main(JSON.parse(configTests.toString()) as ITestTypes[]);
191
- // });
192
- // const watchables = (tests: ITestTypes[]) => {
193
- // return tests.map((t) => {
194
- // return [t[1], `dist/${t[1]}/${t[0].replace(".mts", ".mjs")}`]
195
- // })
196
- // }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TBrowser = void 0;
4
- class TBrowser {
5
- constructor(browser) {
6
- this.browser = browser;
7
- }
8
- pages() {
9
- return new Promise(async (res, rej) => {
10
- res((await this.browser.pages()).map((p) => {
11
- // const handler = {
12
- // apply: function (target, thisArg, argumentsList) {
13
- // console.log('screenshot was called with ' + JSON.stringify(argumentsList));
14
- // const x: ScreenshotOptions = argumentsList[0]
15
- // x.path = "./dist/" + x.path;
16
- // console.log('x.path' + x.path, target, thisArg);
17
- // return target(...argumentsList);
18
- // }
19
- // };
20
- // p.screenshot = new Proxy(p.screenshot, handler);
21
- return p;
22
- }));
23
- });
24
- }
25
- }
26
- exports.TBrowser = TBrowser;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeWriterElectron = void 0;
4
- // import fs from "fs";
5
- const fs = require("fs");
6
- // import path from "path";
7
- const path = require("path");
8
- const fPaths = [];
9
- exports.NodeWriterElectron = {
10
- createWriteStream: (filepath) => {
11
- return fs.createWriteStream(filepath);
12
- },
13
- writeFileSync: (fp, contents) => {
14
- fs.writeFileSync(fp, contents);
15
- },
16
- mkdirSync: async (fp) => {
17
- await fs.mkdirSync(fp, { recursive: true });
18
- },
19
- testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
20
- callback(new Promise((res, rej) => {
21
- tLog("testArtiFactory =>", fPath);
22
- const cleanPath = path.resolve(fPath);
23
- fPaths.push(cleanPath.replace(process.cwd(), ``));
24
- const targetDir = cleanPath.split("/").slice(0, -1).join("/");
25
- fs.mkdir(targetDir, { recursive: true }, async (error) => {
26
- if (error) {
27
- console.error(`❗️testArtiFactory failed`, targetDir, error);
28
- }
29
- fs.writeFileSync(path.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
30
- encoding: "utf-8",
31
- });
32
- if (Buffer.isBuffer(value)) {
33
- fs.writeFileSync(fPath, value, "binary");
34
- res();
35
- }
36
- else if (`string` === typeof value) {
37
- fs.writeFileSync(fPath, value.toString(), {
38
- encoding: "utf-8",
39
- });
40
- res();
41
- }
42
- else {
43
- /* @ts-ignore:next-line */
44
- const pipeStream = value;
45
- const myFile = fs.createWriteStream(fPath);
46
- pipeStream.pipe(myFile);
47
- pipeStream.on("close", () => {
48
- myFile.close();
49
- res();
50
- });
51
- }
52
- });
53
- }));
54
- }
55
- };
@@ -1,50 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- const fPaths = [];
4
- export const NodeWriter = {
5
- createWriteStream: (filepath) => {
6
- return fs.createWriteStream(filepath);
7
- },
8
- writeFileSync: (fp, contents) => {
9
- fs.writeFileSync(fp, contents);
10
- },
11
- mkdirSync: async (fp) => {
12
- await fs.mkdirSync(fp, { recursive: true });
13
- },
14
- testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
15
- callback(new Promise((res, rej) => {
16
- tLog("testArtiFactory =>", fPath);
17
- const cleanPath = path.resolve(fPath);
18
- fPaths.push(cleanPath.replace(process.cwd(), ``));
19
- const targetDir = cleanPath.split("/").slice(0, -1).join("/");
20
- fs.mkdir(targetDir, { recursive: true }, async (error) => {
21
- if (error) {
22
- console.error(`❗️testArtiFactory failed`, targetDir, error);
23
- }
24
- fs.writeFileSync(path.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
25
- encoding: "utf-8",
26
- });
27
- if (Buffer.isBuffer(value)) {
28
- fs.writeFileSync(fPath, value, "binary");
29
- res();
30
- }
31
- else if (`string` === typeof value) {
32
- fs.writeFileSync(fPath, value.toString(), {
33
- encoding: "utf-8",
34
- });
35
- res();
36
- }
37
- else {
38
- /* @ts-ignore:next-line */
39
- const pipeStream = value;
40
- const myFile = fs.createWriteStream(fPath);
41
- pipeStream.pipe(myFile);
42
- pipeStream.on("close", () => {
43
- myFile.close();
44
- res();
45
- });
46
- }
47
- });
48
- }));
49
- }
50
- };
@@ -1,191 +0,0 @@
1
- import { app, BrowserWindow, utilityProcess } from "electron";
2
- import pie from "puppeteer-in-electron";
3
- import puppeteer from "puppeteer-core";
4
- import fs from "fs";
5
- import path from "path";
6
- import { jsonc } from 'jsonc';
7
- const remoteMain = require("@electron/remote/main");
8
- remoteMain.initialize();
9
- const main = async () => {
10
- const configs = jsonc.parse((await fs.readFileSync("./docs/testeranto.json")).toString());
11
- const loadReport = (configs) => {
12
- const win = new BrowserWindow({
13
- show: true,
14
- webPreferences: {
15
- offscreen: false,
16
- devTools: true,
17
- }
18
- });
19
- win.loadFile(`/${configs.buildDir}/report.html`).then(async (x) => {
20
- // pie.connect(app, puppeteer).then(async (browser) => {
21
- // pie.getPage(browser, win).then(async (page) => {
22
- // await page.screenshot({
23
- // path: 'electron-puppeteer-screenshot1.jpg'
24
- // });
25
- // })
26
- // })
27
- });
28
- };
29
- const launchNode = (t, x) => {
30
- var _a;
31
- const f = x.replace(".ts", ".mjs");
32
- const a = JSON.stringify({
33
- scheduled: true,
34
- name: x,
35
- ports: [],
36
- fs: path.resolve(configs.buildDir, "node", t),
37
- });
38
- console.log("launchNode", f, a);
39
- const child = utilityProcess.fork(f, [a], {});
40
- child.postMessage({ message: 'hello' });
41
- child.on('message', (data) => {
42
- console.log("from child", data);
43
- launchWebSecondary(process.cwd() + data);
44
- });
45
- child.on('exit', (data) => {
46
- console.log("node process ended with: ", data);
47
- fileStream.close();
48
- });
49
- // child.stdout
50
- // child..on("", (data) => {
51
- // console.log("from child", data) // hello world!
52
- // launchWebSecondary(process.cwd() + data);
53
- // })
54
- // Create a write stream for the file
55
- const fileStream = fs.createWriteStream('errors.txt');
56
- // Pipe the child process's stdout to the file
57
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
58
- // // Handle errors
59
- // child.on('error', (err) => {
60
- // console.error('Error spawning child process:', err);
61
- // });
62
- // fileStream.on('error', (err) => {
63
- // console.error('Error writing to file:', err);
64
- // });
65
- // // Log a message when the child process exits
66
- // child.on('close', (code) => {
67
- // console.log(`Child process exited with code ${code}`);
68
- // });
69
- // console.log("child", child);
70
- // child.stdout?.on("data", (x) => {
71
- // console.log("x", x)
72
- // })
73
- };
74
- const launchWebSecondary = (htmlFile) => {
75
- console.log("launchWebSecondary", htmlFile);
76
- const subWin = new BrowserWindow({
77
- show: true,
78
- webPreferences: {
79
- nodeIntegration: true,
80
- nodeIntegrationInWorker: true,
81
- contextIsolation: false,
82
- preload: path.join(app.getAppPath(), 'preload.js'),
83
- offscreen: false,
84
- devTools: false,
85
- }
86
- });
87
- remoteMain.enable(subWin.webContents);
88
- subWin.webContents.openDevTools();
89
- subWin.loadFile(htmlFile);
90
- };
91
- const launchWeb = (t, changedFile) => {
92
- console.log("launchWeb", changedFile);
93
- const subWin = new BrowserWindow({
94
- show: true,
95
- webPreferences: {
96
- nodeIntegration: true,
97
- nodeIntegrationInWorker: true,
98
- contextIsolation: false,
99
- preload: path.join(app.getAppPath(), 'preload.js'),
100
- offscreen: false,
101
- devTools: true,
102
- }
103
- });
104
- remoteMain.enable(subWin.webContents);
105
- // subWin.webContents.openDevTools()
106
- const htmlFile = changedFile.split(".").slice(0, -1).concat("html").join(".");
107
- subWin.loadFile(htmlFile, {
108
- query: {
109
- requesting: encodeURIComponent(JSON.stringify({
110
- name: changedFile,
111
- ports: [].toString(),
112
- fs: path.resolve(configs.buildDir, "web", t),
113
- }))
114
- }
115
- });
116
- };
117
- const watcher = (test, runtime) => {
118
- return path.normalize(`${configs.buildDir}/${runtime}/${test.split('.').slice(0, -1).concat('mjs').join('.')}`);
119
- };
120
- const changer = (f) => {
121
- return path.normalize(`${configs.buildDir}/${f}`);
122
- };
123
- const changer2 = (f, r) => {
124
- return path.normalize(`${configs.buildDir}/${r}/${f}`);
125
- };
126
- pie.initialize(app, 2999).then(async () => {
127
- app.on("ready", () => {
128
- loadReport(configs);
129
- console.log("running all the tests once initially");
130
- ;
131
- configs.modules.forEach((t) => {
132
- if (t.runtime === "node") {
133
- launchNode(t.test, changer2(t.test, "node"));
134
- }
135
- else if (t.runtime === "web") {
136
- launchWeb(t.test, changer2(t.test, "web"));
137
- }
138
- else {
139
- console.error("runtime makes no sense", t.runtime);
140
- }
141
- });
142
- console.log("ready and watching for changes...", configs.buildDir);
143
- fs.watch(configs.buildDir, {
144
- recursive: true,
145
- }, (eventType, changedFile) => {
146
- console.log(eventType, changedFile);
147
- if (changedFile) {
148
- configs.modules.forEach((t) => {
149
- if (watcher(t.test, t.runtime) === changer(changedFile)) {
150
- if (t.runtime === "node") {
151
- launchNode(t.test, changer(changedFile));
152
- }
153
- else if (t.runtime === "web") {
154
- launchWeb(t.test, changer(changedFile));
155
- }
156
- else {
157
- console.error("runtime makes no sense", t.runtime);
158
- }
159
- }
160
- });
161
- }
162
- });
163
- });
164
- });
165
- await pie.connect(app, puppeteer);
166
- };
167
- main();
168
- // ipcMain.handle('web-log', (x, message: string) => {
169
- // console.log("web-log)", message);
170
- // });
171
- // ipcMain.handle('web-error', (x, message: string) => {
172
- // console.log("web-error)", message);
173
- // });
174
- // ipcMain.handle('web-warn', (x, message: string) => {
175
- // console.log("web-warn)", message);
176
- // });
177
- // ipcMain.handle('web-info', (x, message: string) => {
178
- // console.log("web-info)", message);
179
- // });
180
- // ipcMain.handle('quit-app', (x, failed: number) => {
181
- // console.log("quit-app", failed);
182
- // app.exit(failed);
183
- // });
184
- // process.stdin.on("data", (configTests) => {
185
- // main(JSON.parse(configTests.toString()) as ITestTypes[]);
186
- // });
187
- // const watchables = (tests: ITestTypes[]) => {
188
- // return tests.map((t) => {
189
- // return [t[1], `dist/${t[1]}/${t[0].replace(".mts", ".mjs")}`]
190
- // })
191
- // }