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.
- package/README.md +38 -26
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +14 -51
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +361 -0
- package/dist/common/PM/node.js +176 -0
- package/dist/common/PM/web.js +174 -0
- package/dist/common/Project.js +121 -266
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/common/Types.js +2 -32
- package/dist/common/Web.js +25 -37
- package/dist/common/esbuildConfigs/index.js +5 -5
- package/dist/common/esbuildConfigs/node.js +17 -15
- package/dist/common/esbuildConfigs/report.js +12 -47
- package/dist/common/esbuildConfigs/tests.js +0 -1
- package/dist/common/esbuildConfigs/web.js +17 -12
- package/dist/common/lib/abstractBase.js +190 -35
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +8 -5
- package/dist/common/lib/core.js +42 -17
- package/dist/common/lib/index.js +11 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +14 -28
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -51
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +331 -0
- package/dist/module/PM/node.js +168 -0
- package/dist/module/PM/web.js +167 -0
- package/dist/module/Project.js +122 -267
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-dom/component/node.js +2 -2
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/module/Types.js +3 -30
- package/dist/module/Web.js +26 -38
- package/dist/module/esbuildConfigs/index.js +5 -5
- package/dist/module/esbuildConfigs/node.js +17 -15
- package/dist/module/esbuildConfigs/report.js +11 -48
- package/dist/module/esbuildConfigs/tests.js +0 -1
- package/dist/module/esbuildConfigs/web.js +17 -12
- package/dist/module/lib/abstractBase.js +190 -35
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +8 -5
- package/dist/module/lib/core.js +44 -19
- package/dist/module/lib/index.js +11 -8
- package/dist/module/preload.js +15 -27
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/Node.d.ts +3 -2
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +28 -0
- package/dist/types/PM/node.d.ts +26 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Project.d.ts +1 -2
- package/dist/types/Puppeteer.d.ts +1 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/puppeteer.d.ts +3 -3
- package/dist/types/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
- package/dist/types/Types.d.ts +19 -100
- package/dist/types/Web.d.ts +3 -2
- package/dist/types/esbuildConfigs/features.d.ts +1 -1
- package/dist/types/esbuildConfigs/index.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +26 -24
- package/dist/types/lib/basebuilder.d.ts +10 -7
- package/dist/types/lib/classBuilder.d.ts +4 -3
- package/dist/types/lib/core.d.ts +5 -4
- package/dist/types/lib/index.d.ts +7 -5
- package/dist/types/lib/types.d.ts +62 -0
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -7
- package/src/Node.ts +30 -85
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +420 -0
- package/src/PM/node.ts +515 -0
- package/src/PM/web.ts +497 -0
- package/src/Project.ts +183 -619
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +158 -44
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +19 -14
- package/src/SubPackages/react/component/node.ts +20 -32
- package/src/SubPackages/react/component/web.ts +20 -30
- package/src/SubPackages/react/jsx/index.ts +13 -24
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react/jsx/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +134 -95
- package/src/SubPackages/react-dom/jsx/web.ts +41 -48
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
- package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
- package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
- package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
- package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
- package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
- package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
- package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
- package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
- package/src/Types.ts +73 -307
- package/src/Web.ts +40 -81
- package/src/cjs-shim.js +2 -2
- package/src/esbuildConfigs/features.ts +3 -4
- package/src/esbuildConfigs/index.ts +8 -8
- package/src/esbuildConfigs/node.ts +21 -20
- package/src/esbuildConfigs/report.ts +15 -51
- package/src/esbuildConfigs/tests.ts +3 -9
- package/src/esbuildConfigs/web.ts +22 -20
- package/src/lib/abstractBase.ts +312 -164
- package/src/lib/basebuilder.ts +123 -127
- package/src/lib/classBuilder.ts +30 -48
- package/src/lib/core.ts +115 -84
- package/src/lib/index.ts +58 -56
- package/src/lib/types.ts +197 -0
- package/src/preload.ts +14 -30
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/NodeWriter.js +0 -56
- package/dist/common/electron.js +0 -196
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/NodeWriter.js +0 -50
- package/dist/module/electron.js +0 -191
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/NodeWriter.d.ts +0 -2
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/NodeWriter.ts +0 -69
- package/src/electron.ts +0 -250
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
- package/yarn-error.log +0 -3144
- /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { PM } from "./index.js";
|
|
2
|
+
import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
|
|
3
|
+
function waitForFunctionCall() {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
window["myFunction"] = () => {
|
|
6
|
+
// Do something when myFunction is called
|
|
7
|
+
console.log("myFunction was called!");
|
|
8
|
+
resolve(); // Resolve the promise
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const files = new Set();
|
|
13
|
+
export class PM_Web extends PM {
|
|
14
|
+
// testResourceConfiguration: ITTestResourceConfiguration;
|
|
15
|
+
constructor(t) {
|
|
16
|
+
super();
|
|
17
|
+
this.server = {};
|
|
18
|
+
this.testResourceConfiguration = t;
|
|
19
|
+
}
|
|
20
|
+
existsSync(destFolder) {
|
|
21
|
+
return window["existsSync"](destFolder);
|
|
22
|
+
}
|
|
23
|
+
mkdirSync() {
|
|
24
|
+
return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
25
|
+
}
|
|
26
|
+
write(writeObject, contents) {
|
|
27
|
+
return window["write"](writeObject.uid, contents);
|
|
28
|
+
}
|
|
29
|
+
writeFileSync(filepath, contents) {
|
|
30
|
+
console.log("WEB writeFileSync", filepath);
|
|
31
|
+
files.add(filepath);
|
|
32
|
+
return window["writeFileSync"](this.testResourceConfiguration.fs + "/" + filepath, contents);
|
|
33
|
+
}
|
|
34
|
+
createWriteStream(filepath) {
|
|
35
|
+
files.add(filepath);
|
|
36
|
+
return window["createWriteStream"](this.testResourceConfiguration.fs + "/" + filepath);
|
|
37
|
+
}
|
|
38
|
+
end(writeObject) {
|
|
39
|
+
return window["end"](writeObject.uid);
|
|
40
|
+
}
|
|
41
|
+
customclose() {
|
|
42
|
+
window["writeFileSync"](this.testResourceConfiguration.fs + "/manifest.json",
|
|
43
|
+
// files.entries()
|
|
44
|
+
JSON.stringify(Array.from(files))).then(() => {
|
|
45
|
+
window["customclose"]();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
testArtiFactoryfileWriter(tLog, callback) {
|
|
49
|
+
return (fPath, value) => {
|
|
50
|
+
callback(new Promise((res, rej) => {
|
|
51
|
+
tLog("testArtiFactory =>", fPath);
|
|
52
|
+
// const cleanPath = path.resolve(fPath);
|
|
53
|
+
// fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
54
|
+
// const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
55
|
+
// fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
56
|
+
// if (error) {
|
|
57
|
+
// console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
58
|
+
// }
|
|
59
|
+
// fs.writeFileSync(
|
|
60
|
+
// path.resolve(
|
|
61
|
+
// targetDir.split("/").slice(0, -1).join("/"),
|
|
62
|
+
// "manifest"
|
|
63
|
+
// ),
|
|
64
|
+
// fPaths.join(`\n`),
|
|
65
|
+
// {
|
|
66
|
+
// encoding: "utf-8",
|
|
67
|
+
// }
|
|
68
|
+
// );
|
|
69
|
+
// if (Buffer.isBuffer(value)) {
|
|
70
|
+
// fs.writeFileSync(fPath, value, "binary");
|
|
71
|
+
// res();
|
|
72
|
+
// } else if (`string` === typeof value) {
|
|
73
|
+
// fs.writeFileSync(fPath, value.toString(), {
|
|
74
|
+
// encoding: "utf-8",
|
|
75
|
+
// });
|
|
76
|
+
// res();
|
|
77
|
+
// } else {
|
|
78
|
+
// /* @ts-ignore:next-line */
|
|
79
|
+
// const pipeStream: PassThrough = value;
|
|
80
|
+
// const myFile = fs.createWriteStream(fPath);
|
|
81
|
+
// pipeStream.pipe(myFile);
|
|
82
|
+
// pipeStream.on("close", () => {
|
|
83
|
+
// myFile.close();
|
|
84
|
+
// res();
|
|
85
|
+
// });
|
|
86
|
+
// }
|
|
87
|
+
// });
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
startPuppeteer(options, destFolder) {
|
|
92
|
+
return fetch(`http://localhost:3234/json/version`)
|
|
93
|
+
.then((v) => {
|
|
94
|
+
return v.json();
|
|
95
|
+
})
|
|
96
|
+
.then((json) => {
|
|
97
|
+
console.log("found endpoint", json.webSocketDebuggerUrl);
|
|
98
|
+
return puppeteer
|
|
99
|
+
.connect({
|
|
100
|
+
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
101
|
+
})
|
|
102
|
+
.then((b) => {
|
|
103
|
+
this.browser = b;
|
|
104
|
+
const handler2 = {
|
|
105
|
+
get(target, prop, receiver) {
|
|
106
|
+
if (prop === "screenshot") {
|
|
107
|
+
return async (x) => {
|
|
108
|
+
// debugger;
|
|
109
|
+
files.add(x.path);
|
|
110
|
+
console.log("aloha", files);
|
|
111
|
+
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: destFolder + "/" + x.path }));
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
else if (prop === "mainFrame") {
|
|
115
|
+
return () => target[prop](...arguments);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return Reflect.get(...arguments);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const handler1 = {
|
|
123
|
+
get(target, prop, receiver) {
|
|
124
|
+
if (prop === "pages") {
|
|
125
|
+
return async () => {
|
|
126
|
+
return target.pages().then((pages) => {
|
|
127
|
+
return pages.map((p) => {
|
|
128
|
+
return new Proxy(p, handler2);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return Reflect.get(...arguments);
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
const proxy3 = new Proxy(this.browser, handler1);
|
|
137
|
+
this.browser = proxy3;
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
// console.log("connecting to ws://localhost:3234/devtools/browser/RANDOM");
|
|
141
|
+
// return puppeteer
|
|
142
|
+
// .connect({
|
|
143
|
+
// ...options,
|
|
144
|
+
// })
|
|
145
|
+
// .finally(() => {
|
|
146
|
+
// console.log("idk");
|
|
147
|
+
// });
|
|
148
|
+
// return new Promise<Browser>(async (res, rej) => {
|
|
149
|
+
// console.log("connecting with options", options);
|
|
150
|
+
// this.browser = await puppeteer.connect({
|
|
151
|
+
// ...options,
|
|
152
|
+
// });
|
|
153
|
+
// res(this.browser);
|
|
154
|
+
// });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// class PuppetMasterServer extends AbstractPuppetMaster {
|
|
158
|
+
// // constructor(...z: []) {
|
|
159
|
+
// // super(...z);
|
|
160
|
+
// // }
|
|
161
|
+
// // // pages(): Promise<Page[]>;
|
|
162
|
+
// // pages(): Promise<Page[]> {
|
|
163
|
+
// // return new Promise<Page[]>((res, rej) => {
|
|
164
|
+
// // res(super.pages());
|
|
165
|
+
// // });
|
|
166
|
+
// // }
|
|
167
|
+
// }
|
package/dist/module/Project.js
CHANGED
|
@@ -1,115 +1,148 @@
|
|
|
1
1
|
import esbuild from "esbuild";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import readline from
|
|
4
|
+
import readline from "readline";
|
|
5
5
|
import { glob } from "glob";
|
|
6
6
|
import esbuildNodeConfiger from "./esbuildConfigs/node.js";
|
|
7
7
|
import esbuildWebConfiger from "./esbuildConfigs/web.js";
|
|
8
8
|
import esbuildFeaturesConfiger from "./esbuildConfigs/features.js";
|
|
9
9
|
import webHtmlFrame from "./web.html.js";
|
|
10
10
|
import reportHtmlFrame from "./report.html.js";
|
|
11
|
-
|
|
11
|
+
var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
12
12
|
readline.emitKeypressEvents(process.stdin);
|
|
13
13
|
if (process.stdin.isTTY)
|
|
14
14
|
process.stdin.setRawMode(true);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
process.stdin.on("keypress", (str, key) => {
|
|
16
|
+
if (key.name === "q") {
|
|
17
|
+
console.log("Testeranto-EsBuild is shutting down...");
|
|
18
|
+
mode = "PROD";
|
|
19
|
+
onDone();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// setInterval(() => {
|
|
23
|
+
// const memoryUsage = process.memoryUsage();
|
|
24
|
+
// console.log("Memory usage:", memoryUsage);
|
|
25
|
+
// }, 10000); // Check every 10 seconds
|
|
26
|
+
let featuresDone, nodeDone, webDone = false;
|
|
27
|
+
const onFeaturesDone = () => {
|
|
28
|
+
featuresDone = true;
|
|
29
|
+
onDone();
|
|
30
|
+
};
|
|
31
|
+
const onNodeDone = () => {
|
|
32
|
+
nodeDone = true;
|
|
33
|
+
onDone();
|
|
34
|
+
};
|
|
35
|
+
const onWebDone = () => {
|
|
36
|
+
webDone = true;
|
|
37
|
+
onDone();
|
|
38
|
+
};
|
|
39
|
+
const onDone = () => {
|
|
40
|
+
console.log(JSON.stringify({
|
|
41
|
+
featuresDone,
|
|
42
|
+
nodeDone,
|
|
43
|
+
webDone,
|
|
44
|
+
mode,
|
|
45
|
+
}, null, 2));
|
|
46
|
+
if (featuresDone && nodeDone && webDone && mode === "PROD") {
|
|
47
|
+
console.log("Testeranto-EsBuild is all done. Goodbye!");
|
|
48
|
+
process.exit();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.log("Testeranto-EsBuild is still working...");
|
|
52
|
+
}
|
|
28
53
|
};
|
|
29
54
|
export class ITProject {
|
|
30
55
|
constructor(config) {
|
|
31
|
-
var _a;
|
|
32
56
|
this.mode = `up`;
|
|
33
57
|
this.config = config;
|
|
34
|
-
|
|
35
|
-
if (key.name === 'q') {
|
|
36
|
-
this.initiateShutdown("'q' command");
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
process.stdin.on('keypress', (str, key) => {
|
|
40
|
-
if (key.name === 'x') {
|
|
41
|
-
console.log("Shutting down hard!");
|
|
42
|
-
process.exit(-1);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const childElectron = childProcess.spawn("yarn", ["electron", "node_modules/testeranto/dist/common/electron.js"]);
|
|
46
|
-
// childElectron.stdout.on('data', function (msg) {
|
|
47
|
-
// console.log(msg.toString())
|
|
48
|
-
// });
|
|
49
|
-
const fileStream = fs.createWriteStream(`./${this.config.outdir}/electron.log`);
|
|
50
|
-
(_a = childElectron.stdout) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
|
|
51
|
-
Promise.resolve(Promise.all([
|
|
52
|
-
...this.getSecondaryEndpointsPoints("web"),
|
|
53
|
-
]
|
|
54
|
-
.map(async (sourceFilePath) => {
|
|
58
|
+
Promise.resolve(Promise.all([...this.getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
|
|
55
59
|
const sourceFileSplit = sourceFilePath.split("/");
|
|
56
60
|
const sourceDir = sourceFileSplit.slice(0, -1);
|
|
57
61
|
const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
|
|
58
|
-
const sourceFileNameMinusJs = sourceFileName
|
|
62
|
+
const sourceFileNameMinusJs = sourceFileName
|
|
63
|
+
.split(".")
|
|
64
|
+
.slice(0, -1)
|
|
65
|
+
.join(".");
|
|
59
66
|
const htmlFilePath = path.normalize(`${process.cwd()}/${config.outdir}/web/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
|
|
60
67
|
const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
|
|
61
|
-
return fs.promises
|
|
68
|
+
return fs.promises
|
|
69
|
+
.mkdir(path.dirname(htmlFilePath), { recursive: true })
|
|
70
|
+
.then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
|
|
62
71
|
})));
|
|
63
72
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
// nodeEntryPoints.forEach((nep) => {
|
|
74
|
+
// const f = `${process.cwd()}/${nep}`;
|
|
75
|
+
// console.log("nep", f);
|
|
76
|
+
// import(f).then((module) => {
|
|
77
|
+
// return module.default.then((defaultModule) => {
|
|
78
|
+
// console.log("defaultModule", defaultModule);
|
|
79
|
+
// // defaultModule
|
|
80
|
+
// // .receiveTestResourceConfig(argz)
|
|
81
|
+
// // .then((x) => {
|
|
82
|
+
// // console.log("then", x);
|
|
83
|
+
// // return x;
|
|
84
|
+
// // })
|
|
85
|
+
// // .catch((e) => {
|
|
86
|
+
// // console.log("catch", e);
|
|
87
|
+
// // });
|
|
88
|
+
// });
|
|
89
|
+
// });
|
|
90
|
+
// });
|
|
91
|
+
glob(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then((chunks) => {
|
|
66
92
|
chunks.forEach((chunk) => {
|
|
67
|
-
console.log("deleting chunk", chunk);
|
|
68
93
|
fs.unlinkSync(chunk);
|
|
69
94
|
});
|
|
70
95
|
});
|
|
71
|
-
fs.copyFileSync("node_modules/testeranto/dist/prebuild/
|
|
72
|
-
fs.copyFileSync("node_modules/testeranto/dist/prebuild/
|
|
96
|
+
fs.copyFileSync("./node_modules/testeranto/dist/prebuild/Report.js", "./docs/Report.js");
|
|
97
|
+
fs.copyFileSync("./node_modules/testeranto/dist/prebuild/Report.css", "./docs/Report.css");
|
|
73
98
|
fs.writeFileSync(`${config.outdir}/report.html`, reportHtmlFrame());
|
|
74
99
|
Promise.all([
|
|
75
|
-
|
|
100
|
+
fs.promises.writeFile(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2)),
|
|
101
|
+
esbuild
|
|
102
|
+
.context(esbuildFeaturesConfiger(config))
|
|
76
103
|
.then(async (featuresContext) => {
|
|
77
|
-
|
|
78
|
-
|
|
104
|
+
if (mode == "DEV") {
|
|
105
|
+
await featuresContext.watch();
|
|
106
|
+
onFeaturesDone();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
featuresContext.rebuild().then((v) => {
|
|
110
|
+
onFeaturesDone();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
79
113
|
return featuresContext;
|
|
80
114
|
}),
|
|
81
|
-
esbuild
|
|
115
|
+
esbuild
|
|
116
|
+
.context(esbuildNodeConfiger(config, nodeEntryPoints))
|
|
82
117
|
.then(async (nodeContext) => {
|
|
83
|
-
|
|
84
|
-
|
|
118
|
+
if (mode == "DEV") {
|
|
119
|
+
await nodeContext.watch().then((v) => {
|
|
120
|
+
onNodeDone();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
nodeContext.rebuild().then((v) => {
|
|
125
|
+
onNodeDone();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
85
128
|
return nodeContext;
|
|
86
129
|
}),
|
|
87
|
-
esbuild
|
|
88
|
-
.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
130
|
+
esbuild
|
|
131
|
+
.context(esbuildWebConfiger(config, webEntryPoints))
|
|
132
|
+
.then(async (webContext) => {
|
|
133
|
+
if (mode == "DEV") {
|
|
134
|
+
await webContext.watch().then((v) => {
|
|
135
|
+
onWebDone();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
webContext.rebuild().then((v) => {
|
|
140
|
+
onWebDone();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return webContext;
|
|
92
144
|
}),
|
|
93
|
-
])
|
|
94
|
-
Promise.all(config.tests.map(async ([test, runtime]) => {
|
|
95
|
-
return {
|
|
96
|
-
test,
|
|
97
|
-
runtime
|
|
98
|
-
};
|
|
99
|
-
})).then(async (modules) => {
|
|
100
|
-
fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify({
|
|
101
|
-
modules,
|
|
102
|
-
buildDir: process.cwd() + "/" + config.outdir
|
|
103
|
-
}, null, 2));
|
|
104
|
-
});
|
|
105
|
-
if (config.devMode === false) {
|
|
106
|
-
console.log("Your tests were built but not run because devMode was false. Exiting gracefully");
|
|
107
|
-
process.exit(0);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// no-op
|
|
111
|
-
}
|
|
112
|
-
});
|
|
145
|
+
]);
|
|
113
146
|
}
|
|
114
147
|
getSecondaryEndpointsPoints(runtime) {
|
|
115
148
|
const meta = (ts, st) => {
|
|
@@ -125,196 +158,18 @@ export class ITProject {
|
|
|
125
158
|
};
|
|
126
159
|
return Array.from(meta(this.config.tests, new Set()));
|
|
127
160
|
}
|
|
128
|
-
initiateShutdown(reason) {
|
|
129
|
-
console.log("Shutdown initiated because", reason);
|
|
130
|
-
this.mode = "down";
|
|
131
|
-
}
|
|
132
161
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// });
|
|
148
|
-
// webSocketServer.on('close', (data) => {
|
|
149
|
-
// console.log('webSocketServer close: %s', data);
|
|
150
|
-
// });
|
|
151
|
-
// webSocketServer.on('listening', () => {
|
|
152
|
-
// console.log("webSocketServer listening", webSocketServer.address());
|
|
153
|
-
// });
|
|
154
|
-
// webSocketServer.on('connection', (webSocket: WebSocket) => {
|
|
155
|
-
// webSocket.on('message', (webSocketData) => {
|
|
156
|
-
// const payload = JSON.parse(webSocketData.valueOf().toString() as any);
|
|
157
|
-
// const messageType = payload.type;
|
|
158
|
-
// if (messageType === "testeranto:hola") {
|
|
159
|
-
// const name = payload.data.requirement.name;
|
|
160
|
-
// const requestedResources = payload.data;
|
|
161
|
-
// this.websockets[name] = webSocket
|
|
162
|
-
// console.log('hola WS! connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets))
|
|
163
|
-
// this.requestResource(requestedResources.requirement, 'ws');
|
|
164
|
-
// } else if (messageType === "testeranto:adios") {
|
|
165
|
-
// console.log("adios WS", payload.data.testResourceConfiguration.name);
|
|
166
|
-
// this.releaseTestResourceWs(payload as any);
|
|
167
|
-
// }
|
|
168
|
-
// });
|
|
169
|
-
// });
|
|
170
|
-
// const makePath = (fPath: string, rt: IRunTime): string => {
|
|
171
|
-
// return path.resolve("./" + config.outdir + "/" +
|
|
172
|
-
// rt +
|
|
173
|
-
// // (rt === "electron" || rt === "chromium" ? "web" : "node") +
|
|
174
|
-
// "/" + fPath.replace(path.extname(fPath), "") + ".mjs");
|
|
175
|
-
// };
|
|
176
|
-
// const bootInterval = setInterval(async () => {
|
|
177
|
-
// const filesToLookup = this.tests
|
|
178
|
-
// .map(([p, rt]) => {
|
|
179
|
-
// const filepath = makePath(p, rt);
|
|
180
|
-
// return {
|
|
181
|
-
// filepath,
|
|
182
|
-
// exists: fsExists(filepath),
|
|
183
|
-
// };
|
|
184
|
-
// });
|
|
185
|
-
// const allFilesExist = (
|
|
186
|
-
// await Promise.all(filesToLookup.map((f) => f.exists))
|
|
187
|
-
// ).every((b) => b);
|
|
188
|
-
// if (!allFilesExist) {
|
|
189
|
-
// console.log(this.spinner(), "waiting for files to build...")
|
|
190
|
-
// filesToLookup.forEach((f) => {
|
|
191
|
-
// console.log(f.exists, "\t", f.filepath);
|
|
192
|
-
// })
|
|
193
|
-
// } else {
|
|
194
|
-
// clearInterval(bootInterval);
|
|
195
|
-
// pm2.launchBus((err, pm2_bus) => {
|
|
196
|
-
// pm2_bus.on("testeranto:hola", (packet: { data: { requirement: ITTestResourceRequirement } }) => {
|
|
197
|
-
// this.requestResource(
|
|
198
|
-
// packet.data.requirement,
|
|
199
|
-
// 'ipc'
|
|
200
|
-
// );
|
|
201
|
-
// });
|
|
202
|
-
// pm2_bus.on("testeranto:adios", (payload: IAdiosIPC) => {
|
|
203
|
-
// this.releaseTestResourcePm2(payload.data);
|
|
204
|
-
// });
|
|
205
|
-
// });
|
|
206
|
-
// this
|
|
207
|
-
// .tests
|
|
208
|
-
// .reduce((m, [inputFilePath, runtime]) => {
|
|
209
|
-
// const script = makePath(inputFilePath, runtime);
|
|
210
|
-
// const partialTestResourceByCommandLineArg = `${script} '${JSON.stringify(
|
|
211
|
-
// {
|
|
212
|
-
// name: inputFilePath,
|
|
213
|
-
// ports: [],
|
|
214
|
-
// fs: path.resolve(
|
|
215
|
-
// process.cwd(),
|
|
216
|
-
// config.outdir,
|
|
217
|
-
// inputFilePath
|
|
218
|
-
// ),
|
|
219
|
-
// }
|
|
220
|
-
// )}'`;
|
|
221
|
-
// if (runtime === "web") {
|
|
222
|
-
// pm2.start(electron_pm2_StartOptions(
|
|
223
|
-
// partialTestResourceByCommandLineArg,
|
|
224
|
-
// inputFilePath,
|
|
225
|
-
// config
|
|
226
|
-
// ),
|
|
227
|
-
// (err, proc) => {
|
|
228
|
-
// if (err) {
|
|
229
|
-
// console.error(err);
|
|
230
|
-
// return pm2.disconnect();
|
|
231
|
-
// }
|
|
232
|
-
// }
|
|
233
|
-
// );
|
|
234
|
-
// // } else if (runtime === "chromium") {
|
|
235
|
-
// // pm2.start(
|
|
236
|
-
// // chromium_pm2_StartOptions(
|
|
237
|
-
// // partialTestResourceByCommandLineArg,
|
|
238
|
-
// // inputFilePath,
|
|
239
|
-
// // config,
|
|
240
|
-
// // ),
|
|
241
|
-
// // (err, proc) => {
|
|
242
|
-
// // if (err) {
|
|
243
|
-
// // console.error(err);
|
|
244
|
-
// // return pm2.disconnect();
|
|
245
|
-
// // }
|
|
246
|
-
// // }
|
|
247
|
-
// // );
|
|
248
|
-
// } else if (runtime === "node") {
|
|
249
|
-
// const resolvedPath = path.resolve(script);
|
|
250
|
-
// console.log("watching", resolvedPath);
|
|
251
|
-
// pm2.start(node_pm2_StartOptions(
|
|
252
|
-
// partialTestResourceByCommandLineArg,
|
|
253
|
-
// inputFilePath,
|
|
254
|
-
// config,
|
|
255
|
-
// resolvedPath
|
|
256
|
-
// ), (err, proc) => {
|
|
257
|
-
// if (err) {
|
|
258
|
-
// console.error(err);
|
|
259
|
-
// return pm2.disconnect();
|
|
260
|
-
// }
|
|
261
|
-
// });
|
|
262
|
-
// }
|
|
263
|
-
// this.exitCodes[inputFilePath] = null;
|
|
264
|
-
// return [inputFilePath, ...m];
|
|
265
|
-
// }, []);
|
|
266
|
-
// setInterval(this.mainLoop, TIMEOUT).unref();
|
|
267
|
-
// }
|
|
268
|
-
// }, TIMEOUT).unref();
|
|
269
|
-
// });
|
|
270
|
-
// public requestResource(
|
|
271
|
-
// requirement: ITTestResourceRequirement,
|
|
272
|
-
// protocol: ISchedulerProtocols
|
|
273
|
-
// ) {
|
|
274
|
-
// this.resourceQueue.push({ requirement, protocol });
|
|
275
|
-
// }
|
|
276
|
-
// const OPEN_PORT = "";
|
|
277
|
-
// type ISchedulerProtocols = `ipc` | `ws`;
|
|
278
|
-
// type IAdios = {
|
|
279
|
-
// name: string;
|
|
280
|
-
// failed: any;
|
|
281
|
-
// testResourceConfiguration: {
|
|
282
|
-
// name: string;
|
|
283
|
-
// };
|
|
284
|
-
// results: {
|
|
285
|
-
// fails: any[];
|
|
286
|
-
// givens: any[];
|
|
287
|
-
// name: string;
|
|
288
|
-
// };
|
|
289
|
-
// };
|
|
290
|
-
// type IAdiosIPC = {
|
|
291
|
-
// process: {
|
|
292
|
-
// namespace: string;
|
|
293
|
-
// versioning: object;
|
|
294
|
-
// name: string;
|
|
295
|
-
// pm_id: number;
|
|
296
|
-
// };
|
|
297
|
-
// data: IAdios
|
|
298
|
-
// at: string;
|
|
299
|
-
// };
|
|
300
|
-
// clearScreen: boolean;
|
|
301
|
-
// devMode: boolean;
|
|
302
|
-
// exitCodes: Record<number, string> = {};
|
|
303
|
-
// features: TesterantoFeatures;
|
|
304
|
-
// ports: Record<string, string> = {};
|
|
305
|
-
// tests: ITestTypes[];
|
|
306
|
-
// websockets: Record<string, WebSocket> = {};
|
|
307
|
-
// resourceQueue: {
|
|
308
|
-
// requirement: ITTestResourceRequirement,
|
|
309
|
-
// protocol: ISchedulerProtocols,
|
|
310
|
-
// }[] = [];
|
|
311
|
-
// private spinCycle = 0;
|
|
312
|
-
// private spinAnimation = "←↖↑↗→↘↓↙";
|
|
313
|
-
// console.log("sending", JSON.stringify(this.tests));
|
|
314
|
-
// childElectron.stdin.write(JSON.stringify(this.tests));
|
|
315
|
-
// not necessary
|
|
316
|
-
// this.esWebServerDetails = await eWeb.serve({
|
|
317
|
-
// servedir: jsonConfig.outdir,
|
|
318
|
-
// });
|
|
319
|
-
// fs.copyFileSync("node_modules/testeranto/dist/index.css", "index.css")
|
|
320
|
-
//
|
|
162
|
+
const getRunnables = (tests, payload = [new Set(), new Set()]) => {
|
|
163
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
164
|
+
if (cv[1] === "node") {
|
|
165
|
+
pt[0].add(cv[0]);
|
|
166
|
+
}
|
|
167
|
+
else if (cv[1] === "web") {
|
|
168
|
+
pt[1].add(cv[0]);
|
|
169
|
+
}
|
|
170
|
+
if (cv[3].length) {
|
|
171
|
+
getRunnables(cv[3], payload);
|
|
172
|
+
}
|
|
173
|
+
return pt;
|
|
174
|
+
}, payload);
|
|
175
|
+
};
|