testeranto 0.70.0 → 0.74.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 +9 -18
- package/dist/common/Node.js +7 -34
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +370 -0
- package/dist/common/PM/node.js +84 -0
- package/dist/common/PM/web.js +129 -0
- package/dist/common/Project.js +20 -2
- 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/jsx/index.js +14 -2
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/common/Web.js +24 -44
- package/dist/common/esbuildConfigs/web.js +3 -1
- package/dist/common/lib/abstractBase.js +189 -41
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +6 -2
- package/dist/common/lib/core.js +41 -45
- package/dist/common/lib/index.js +2 -1
- package/dist/common/preload.js +14 -18
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +7 -34
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +340 -0
- package/dist/module/PM/node.js +77 -0
- package/dist/module/PM/web.js +122 -0
- package/dist/module/Project.js +20 -2
- 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/index.js +11 -2
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/module/Web.js +24 -44
- package/dist/module/esbuildConfigs/web.js +3 -1
- package/dist/module/lib/abstractBase.js +189 -41
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +6 -2
- package/dist/module/lib/core.js +41 -45
- package/dist/module/lib/index.js +2 -1
- package/dist/module/preload.js +15 -14
- 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/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +26 -0
- package/dist/types/PM/node.d.ts +25 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/react/jsx/index.d.ts +2 -5
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +13 -12
- package/dist/types/lib/basebuilder.d.ts +4 -2
- package/dist/types/lib/classBuilder.d.ts +2 -2
- package/dist/types/lib/core.d.ts +4 -4
- package/dist/types/lib/index.d.ts +6 -5
- package/dist/types/lib/types.d.ts +16 -24
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/Node.ts +8 -47
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +452 -0
- package/src/PM/node.ts +122 -0
- package/src/PM/web.ts +162 -0
- package/src/Project.ts +21 -2
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +160 -46
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +3 -3
- package/src/SubPackages/react/jsx/index.ts +13 -3
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react-dom/component/web.ts +126 -67
- package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
- package/src/Web.ts +25 -69
- package/src/esbuildConfigs/web.ts +4 -2
- package/src/lib/abstractBase.ts +260 -65
- package/src/lib/basebuilder.ts +121 -100
- package/src/lib/classBuilder.ts +5 -4
- package/src/lib/core.ts +58 -59
- package/src/lib/index.ts +10 -9
- package/src/lib/types.ts +18 -27
- package/src/preload.ts +14 -14
- package/dist/common/NodeWriter.js +0 -54
- package/dist/common/electron.js +0 -266
- package/dist/module/NodeWriter.js +0 -48
- package/dist/module/electron.js +0 -261
- package/dist/types/NodeWriter.d.ts +0 -2
- package/src/NodeWriter.ts +0 -72
- package/src/electron.ts +0 -317
- package/yarn-error.log +0 -3144
- /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
package/src/lib/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IBaseTest } from "../Types";
|
|
2
2
|
|
|
3
|
-
import puppeteer from "puppeteer-core";
|
|
3
|
+
// import puppeteer from "puppeteer-core";
|
|
4
4
|
import {
|
|
5
5
|
IGivens,
|
|
6
6
|
BaseCheck,
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
BaseThen,
|
|
11
11
|
} from "./abstractBase";
|
|
12
12
|
import { ITTestResourceConfiguration, ITestArtificer } from ".";
|
|
13
|
+
import { PM } from "../PM/index";
|
|
13
14
|
|
|
14
15
|
export type IRunTime = `node` | `web`;
|
|
15
16
|
|
|
16
|
-
export type ITestTypes = [string, IRunTime, ITestTypes[]];
|
|
17
|
+
export type ITestTypes = [string, IRunTime, { ports: number }, ITestTypes[]];
|
|
17
18
|
|
|
18
19
|
export type IJsonConfig = {
|
|
19
20
|
outdir: string;
|
|
@@ -38,17 +39,6 @@ export type IBaseConfig = {
|
|
|
38
39
|
|
|
39
40
|
export type IBuiltConfig = { buildDir: string } & IBaseConfig;
|
|
40
41
|
|
|
41
|
-
export type INodeUtils = {
|
|
42
|
-
browser: puppeteer.Browser;
|
|
43
|
-
ipc: Electron.ParentPort;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type IWebUtils = {
|
|
47
|
-
browser: puppeteer.Browser;
|
|
48
|
-
ipc: Electron.IpcRenderer;
|
|
49
|
-
};
|
|
50
|
-
export type IUtils = INodeUtils | IWebUtils;
|
|
51
|
-
|
|
52
42
|
export type IWebTestInterface<ITestShape extends IBaseTest> = {
|
|
53
43
|
assertThis: (x: ITestShape["then"]) => void;
|
|
54
44
|
|
|
@@ -66,27 +56,27 @@ export type IWebTestInterface<ITestShape extends IBaseTest> = {
|
|
|
66
56
|
afterAll: (
|
|
67
57
|
store: ITestShape["istore"],
|
|
68
58
|
artificer: ITestArtificer,
|
|
69
|
-
|
|
59
|
+
utils: PM
|
|
70
60
|
) => any;
|
|
71
61
|
afterEach: (
|
|
72
62
|
store: ITestShape["istore"],
|
|
73
63
|
key: string,
|
|
74
64
|
artificer: ITestArtificer,
|
|
75
|
-
utils:
|
|
65
|
+
utils: PM
|
|
76
66
|
) => Promise<unknown>;
|
|
77
67
|
beforeAll: (
|
|
78
68
|
input: ITestShape["iinput"],
|
|
79
69
|
testResource: ITTestResourceConfiguration,
|
|
80
70
|
artificer: ITestArtificer,
|
|
81
|
-
utils:
|
|
71
|
+
utils: PM
|
|
82
72
|
) => Promise<ITestShape["isubject"]>;
|
|
83
73
|
beforeEach: (
|
|
84
74
|
subject: ITestShape["isubject"],
|
|
85
75
|
initializer: (c?) => ITestShape["given"],
|
|
86
76
|
artificer: ITestArtificer,
|
|
87
77
|
testResource: ITTestResourceConfiguration,
|
|
88
|
-
initialValues
|
|
89
|
-
|
|
78
|
+
initialValues,
|
|
79
|
+
utils: PM
|
|
90
80
|
) => Promise<ITestShape["istore"]>;
|
|
91
81
|
};
|
|
92
82
|
// & ITestInterface<ITestShape>;
|
|
@@ -106,19 +96,19 @@ export type INodeTestInterface<ITestShape extends IBaseTest> = {
|
|
|
106
96
|
afterAll: (
|
|
107
97
|
store: ITestShape["istore"],
|
|
108
98
|
artificer: ITestArtificer,
|
|
109
|
-
|
|
99
|
+
pm: PM
|
|
110
100
|
) => any;
|
|
111
101
|
afterEach: (
|
|
112
102
|
store: ITestShape["istore"],
|
|
113
103
|
key: string,
|
|
114
104
|
artificer: ITestArtificer,
|
|
115
|
-
|
|
105
|
+
pm: PM
|
|
116
106
|
) => Promise<unknown>;
|
|
117
107
|
beforeAll: (
|
|
118
108
|
input: ITestShape["iinput"],
|
|
119
109
|
testResource: ITTestResourceConfiguration,
|
|
120
110
|
artificer: ITestArtificer,
|
|
121
|
-
|
|
111
|
+
pm: PM
|
|
122
112
|
) => Promise<ITestShape["isubject"]>;
|
|
123
113
|
beforeEach: (
|
|
124
114
|
subject: ITestShape["isubject"],
|
|
@@ -137,7 +127,8 @@ export type ITestInterface<ITestShape extends IBaseTest> = {
|
|
|
137
127
|
andWhen: (
|
|
138
128
|
store: ITestShape["istore"],
|
|
139
129
|
whenCB: ITestShape["when"],
|
|
140
|
-
testResource: ITTestResourceConfiguration
|
|
130
|
+
testResource: ITTestResourceConfiguration,
|
|
131
|
+
pm: PM
|
|
141
132
|
) => Promise<ITestShape["istore"]>;
|
|
142
133
|
butThen: (
|
|
143
134
|
store: ITestShape["istore"],
|
|
@@ -148,27 +139,27 @@ export type ITestInterface<ITestShape extends IBaseTest> = {
|
|
|
148
139
|
afterAll: (
|
|
149
140
|
store: ITestShape["istore"],
|
|
150
141
|
artificer: ITestArtificer,
|
|
151
|
-
|
|
142
|
+
pm: PM
|
|
152
143
|
) => any;
|
|
153
144
|
afterEach: (
|
|
154
145
|
store: ITestShape["istore"],
|
|
155
146
|
key: string,
|
|
156
147
|
artificer: ITestArtificer,
|
|
157
|
-
|
|
148
|
+
pm: PM
|
|
158
149
|
) => Promise<unknown>;
|
|
159
150
|
beforeAll: (
|
|
160
151
|
input: ITestShape["iinput"],
|
|
161
152
|
testResource: ITTestResourceConfiguration,
|
|
162
153
|
artificer: ITestArtificer,
|
|
163
|
-
|
|
154
|
+
pm: PM
|
|
164
155
|
) => Promise<ITestShape["isubject"]>;
|
|
165
156
|
beforeEach: (
|
|
166
157
|
subject: ITestShape["isubject"],
|
|
167
158
|
initializer: (c?) => ITestShape["given"],
|
|
168
159
|
artificer: ITestArtificer,
|
|
169
160
|
testResource: ITTestResourceConfiguration,
|
|
170
|
-
initialValues
|
|
171
|
-
|
|
161
|
+
initialValues,
|
|
162
|
+
pm: PM
|
|
172
163
|
) => Promise<ITestShape["istore"]>;
|
|
173
164
|
};
|
|
174
165
|
|
package/src/preload.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import puppeteer from "puppeteer-core";
|
|
1
|
+
// import puppeteer from "puppeteer-core";
|
|
2
2
|
|
|
3
|
-
import { NodeWriter } from "./NodeWriter";
|
|
4
|
-
import puppeteerConfiger from "./puppeteerConfiger";
|
|
3
|
+
// import { NodeWriter } from "./NodeWriter";
|
|
4
|
+
// import puppeteerConfiger from "./puppeteerConfiger";
|
|
5
5
|
|
|
6
|
-
(window as any).NodeWriter = NodeWriter;
|
|
6
|
+
// (window as any).NodeWriter = NodeWriter;
|
|
7
7
|
|
|
8
|
-
(window as any).browser = new Promise(async (res, rej) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
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
|
+
// });
|
|
@@ -1,54 +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) => fs_1.default.createWriteStream(filepath),
|
|
12
|
-
writeFileSync: (fp, contents) => fs_1.default.writeFileSync(fp, contents),
|
|
13
|
-
mkdirSync: async (destFolder) => {
|
|
14
|
-
if (!fs_1.default.existsSync(destFolder)) {
|
|
15
|
-
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
|
|
19
|
-
callback(new Promise((res, rej) => {
|
|
20
|
-
tLog("testArtiFactory =>", fPath);
|
|
21
|
-
const cleanPath = path_1.default.resolve(fPath);
|
|
22
|
-
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
23
|
-
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
24
|
-
fs_1.default.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
25
|
-
if (error) {
|
|
26
|
-
console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
27
|
-
}
|
|
28
|
-
fs_1.default.writeFileSync(path_1.default.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
|
|
29
|
-
encoding: "utf-8",
|
|
30
|
-
});
|
|
31
|
-
if (Buffer.isBuffer(value)) {
|
|
32
|
-
fs_1.default.writeFileSync(fPath, value, "binary");
|
|
33
|
-
res();
|
|
34
|
-
}
|
|
35
|
-
else if (`string` === typeof value) {
|
|
36
|
-
fs_1.default.writeFileSync(fPath, value.toString(), {
|
|
37
|
-
encoding: "utf-8",
|
|
38
|
-
});
|
|
39
|
-
res();
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
/* @ts-ignore:next-line */
|
|
43
|
-
const pipeStream = value;
|
|
44
|
-
const myFile = fs_1.default.createWriteStream(fPath);
|
|
45
|
-
pipeStream.pipe(myFile);
|
|
46
|
-
pipeStream.on("close", () => {
|
|
47
|
-
myFile.close();
|
|
48
|
-
res();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}));
|
|
53
|
-
},
|
|
54
|
-
};
|
package/dist/common/electron.js
DELETED
|
@@ -1,266 +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 readline_1 = __importDefault(require("readline"));
|
|
7
|
-
const electron_1 = require("electron");
|
|
8
|
-
const puppeteer_in_electron_1 = __importDefault(require("puppeteer-in-electron"));
|
|
9
|
-
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const jsonc_1 = require("jsonc");
|
|
13
|
-
const uuid_1 = require("uuid");
|
|
14
|
-
var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
15
|
-
console.log("hello electron", mode);
|
|
16
|
-
const nodeChildren = {};
|
|
17
|
-
const webChildren = {};
|
|
18
|
-
const node2web = {};
|
|
19
|
-
const web2node = {};
|
|
20
|
-
const childProcesses = {};
|
|
21
|
-
readline_1.default.emitKeypressEvents(process.stdin);
|
|
22
|
-
if (process.stdin.isTTY)
|
|
23
|
-
process.stdin.setRawMode(true);
|
|
24
|
-
console.log("\n Electron is running. Press 'q' to quit\n");
|
|
25
|
-
process.stdin.on("keypress", (str, key) => {
|
|
26
|
-
if (key.name === "q") {
|
|
27
|
-
mode = "PROD";
|
|
28
|
-
// process.exit();
|
|
29
|
-
console.log("Switching to prod mode. Begin shutdown sequence...");
|
|
30
|
-
// process.exit(-1);
|
|
31
|
-
const allDone = Object.values(childProcesses).every((v) => v === "done");
|
|
32
|
-
if (allDone && mode === "PROD") {
|
|
33
|
-
console.log("Goodbye Testeranto by manual shutdown");
|
|
34
|
-
process.exit();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
console.log(childProcesses);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const onDone = (test) => {
|
|
42
|
-
console.log("onDone", test);
|
|
43
|
-
childProcesses[test] = "done";
|
|
44
|
-
const allDone = Object.values(childProcesses).every((v) => v === "done");
|
|
45
|
-
if (allDone && mode === "PROD") {
|
|
46
|
-
console.log("Goodbye Testeranto by auto shutdown");
|
|
47
|
-
process.exit();
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
console.log(childProcesses);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
process.on("message", function (message) {
|
|
54
|
-
console.log("message: " + message);
|
|
55
|
-
process.exit();
|
|
56
|
-
});
|
|
57
|
-
const remoteMain = require("@electron/remote/main");
|
|
58
|
-
remoteMain.initialize();
|
|
59
|
-
const main = async () => {
|
|
60
|
-
const configs = jsonc_1.jsonc.parse((await fs_1.default.readFileSync("./docs/testeranto.json")).toString());
|
|
61
|
-
const loadReport = (configs) => {
|
|
62
|
-
const win = new electron_1.BrowserWindow({
|
|
63
|
-
show: true,
|
|
64
|
-
webPreferences: {
|
|
65
|
-
offscreen: false,
|
|
66
|
-
devTools: true,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
win.loadFile(`/${configs.buildDir}/report.html`).then(async (x) => {
|
|
70
|
-
// pie.connect(app, puppeteer).then(async (browser) => {
|
|
71
|
-
// pie.getPage(browser, win).then(async (page) => {
|
|
72
|
-
// await page.screenshot({
|
|
73
|
-
// path: 'electron-puppeteer-screenshot1.jpg'
|
|
74
|
-
// });
|
|
75
|
-
// })
|
|
76
|
-
// })
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const launchNode = (src, dest) => {
|
|
80
|
-
var _a, _b;
|
|
81
|
-
console.log("launchNode", src);
|
|
82
|
-
childProcesses[src] = "running";
|
|
83
|
-
const destFolder = dest.replace(".mjs", "");
|
|
84
|
-
const argz = JSON.stringify({
|
|
85
|
-
scheduled: true,
|
|
86
|
-
name: src,
|
|
87
|
-
ports: [3333],
|
|
88
|
-
// fs: path.resolve(configs.buildDir, "web", destFolder + "/"),
|
|
89
|
-
// fs: destFolder,
|
|
90
|
-
fs: ".",
|
|
91
|
-
});
|
|
92
|
-
// console.log("launchNode", src, dest, " -> ", destFolder, argz);
|
|
93
|
-
const child = electron_1.utilityProcess.fork(dest + ".mjs", [argz], {
|
|
94
|
-
cwd: destFolder,
|
|
95
|
-
stdio: "pipe",
|
|
96
|
-
});
|
|
97
|
-
const nodeGuid = (0, uuid_1.v4)();
|
|
98
|
-
nodeChildren[nodeGuid] = child;
|
|
99
|
-
if (!fs_1.default.existsSync(destFolder)) {
|
|
100
|
-
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
|
101
|
-
}
|
|
102
|
-
fs_1.default.rmSync(`${destFolder}/stdout.log`, { force: true });
|
|
103
|
-
fs_1.default.rmSync(`${destFolder}/stderr.log`, { force: true });
|
|
104
|
-
const stdout = fs_1.default.createWriteStream(`${destFolder}/stdout.log`);
|
|
105
|
-
const stderr = fs_1.default.createWriteStream(`${destFolder}/stderr.log`);
|
|
106
|
-
child
|
|
107
|
-
.on("message", (data) => {
|
|
108
|
-
console.log("from child", JSON.stringify(data));
|
|
109
|
-
if (data.launchWeb) {
|
|
110
|
-
const guid = (0, uuid_1.v4)();
|
|
111
|
-
const webChild = launchWebSecondary(process.cwd() + data.launchWeb);
|
|
112
|
-
// child.postMessage({ webLaunched: guid });
|
|
113
|
-
webChild.webContents.on("did-finish-load", () => {
|
|
114
|
-
// webChild.webContents.send("message", "hello world");
|
|
115
|
-
child.postMessage({ webLaunched: guid });
|
|
116
|
-
webChildren[guid] = webChild;
|
|
117
|
-
node2web[nodeGuid] = [...(node2web[nodeGuid] || []), guid];
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (data.teardown) {
|
|
121
|
-
webChildren[data.teardown].close();
|
|
122
|
-
delete webChildren[data.teardown];
|
|
123
|
-
node2web[nodeGuid] = node2web[nodeGuid].filter((x) => x !== data.teardown);
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
.on("exit", (data) => {
|
|
127
|
-
stdout.close();
|
|
128
|
-
stderr.close();
|
|
129
|
-
console.log(`ending node ${src}`);
|
|
130
|
-
onDone(src);
|
|
131
|
-
});
|
|
132
|
-
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(stdout);
|
|
133
|
-
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.pipe(stderr);
|
|
134
|
-
};
|
|
135
|
-
const launchWebSecondary = (htmlFile) => {
|
|
136
|
-
console.log("launchWebSecondary", htmlFile);
|
|
137
|
-
const subWin = new electron_1.BrowserWindow({
|
|
138
|
-
show: false,
|
|
139
|
-
webPreferences: {
|
|
140
|
-
nodeIntegration: true,
|
|
141
|
-
nodeIntegrationInWorker: true,
|
|
142
|
-
contextIsolation: false,
|
|
143
|
-
preload: path_1.default.join(electron_1.app.getAppPath(), "preload.js"),
|
|
144
|
-
offscreen: false,
|
|
145
|
-
devTools: true,
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
remoteMain.enable(subWin.webContents);
|
|
149
|
-
subWin.webContents.openDevTools();
|
|
150
|
-
subWin.loadFile(htmlFile);
|
|
151
|
-
return subWin;
|
|
152
|
-
// const uuid = uuidv4();
|
|
153
|
-
// windows[uuid] = subWin;
|
|
154
|
-
// return uuid;
|
|
155
|
-
};
|
|
156
|
-
const launchWeb = (t, dest) => {
|
|
157
|
-
console.log("launchWeb", t);
|
|
158
|
-
childProcesses[t] = "running";
|
|
159
|
-
const destFolder = dest.replace(".mjs", "");
|
|
160
|
-
const subWin = new electron_1.BrowserWindow({
|
|
161
|
-
show: true,
|
|
162
|
-
webPreferences: {
|
|
163
|
-
nodeIntegration: true,
|
|
164
|
-
nodeIntegrationInWorker: true,
|
|
165
|
-
contextIsolation: false,
|
|
166
|
-
preload: path_1.default.join(electron_1.app.getAppPath(), "preload.js"),
|
|
167
|
-
offscreen: false,
|
|
168
|
-
devTools: true,
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
webChildren[(0, uuid_1.v4)()] = subWin;
|
|
172
|
-
remoteMain.enable(subWin.webContents);
|
|
173
|
-
const webArgz = JSON.stringify({
|
|
174
|
-
name: dest,
|
|
175
|
-
ports: [].toString(),
|
|
176
|
-
fs: destFolder,
|
|
177
|
-
});
|
|
178
|
-
// console.log("webArgz", webArgz);
|
|
179
|
-
subWin.loadFile(`${dest}.html`, {
|
|
180
|
-
query: {
|
|
181
|
-
requesting: encodeURIComponent(webArgz),
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
if (!fs_1.default.existsSync(destFolder)) {
|
|
185
|
-
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
|
186
|
-
}
|
|
187
|
-
const stdout = fs_1.default.createWriteStream(`${destFolder}/stdout.log`);
|
|
188
|
-
subWin.webContents.on("console-message", (event, level, message, line, sourceId) => {
|
|
189
|
-
stdout.write(JSON.stringify({
|
|
190
|
-
event,
|
|
191
|
-
level,
|
|
192
|
-
message: JSON.stringify(message),
|
|
193
|
-
line,
|
|
194
|
-
sourceId,
|
|
195
|
-
}, null, 2));
|
|
196
|
-
stdout.write("\n");
|
|
197
|
-
});
|
|
198
|
-
subWin.on("closed", () => {
|
|
199
|
-
stdout.close();
|
|
200
|
-
console.log(`ending web ${t}`);
|
|
201
|
-
// childProcesses[t] = "done";
|
|
202
|
-
onDone(t);
|
|
203
|
-
});
|
|
204
|
-
electron_1.ipcMain.on("message", (message, data) => {
|
|
205
|
-
console.log("ipcMain message: " + JSON.stringify(data));
|
|
206
|
-
// process.exit();
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
const destinationOfRuntime = (f, r) => {
|
|
210
|
-
return path_1.default
|
|
211
|
-
.normalize(`${configs.buildDir}/${r}/${f}`)
|
|
212
|
-
.split(".")
|
|
213
|
-
.slice(0, -1)
|
|
214
|
-
.join(".");
|
|
215
|
-
};
|
|
216
|
-
puppeteer_in_electron_1.default.initialize(electron_1.app, 2999).then(async () => {
|
|
217
|
-
electron_1.app.on("ready", () => {
|
|
218
|
-
loadReport(configs);
|
|
219
|
-
console.log("running all the tests once initially");
|
|
220
|
-
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
221
|
-
childProcesses[test] = "loaded";
|
|
222
|
-
if (runtime === "node") {
|
|
223
|
-
launchNode(test, destinationOfRuntime(test, "node"));
|
|
224
|
-
}
|
|
225
|
-
else if (runtime === "web") {
|
|
226
|
-
launchWeb(test, destinationOfRuntime(test, "web"));
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
console.error("runtime makes no sense", runtime);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
console.log("ready and watching for changes...", configs.buildDir);
|
|
233
|
-
fs_1.default.watch(configs.buildDir, {
|
|
234
|
-
recursive: true,
|
|
235
|
-
}, (eventType, changedFile) => {
|
|
236
|
-
// console.log(eventType);
|
|
237
|
-
if (changedFile) {
|
|
238
|
-
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
239
|
-
if (eventType === "change" || eventType === "rename") {
|
|
240
|
-
if (changedFile ===
|
|
241
|
-
test
|
|
242
|
-
.replace("./", "node/")
|
|
243
|
-
.split(".")
|
|
244
|
-
.slice(0, -1)
|
|
245
|
-
.concat("mjs")
|
|
246
|
-
.join(".")) {
|
|
247
|
-
launchNode(test, destinationOfRuntime(test, "node"));
|
|
248
|
-
}
|
|
249
|
-
if (changedFile ===
|
|
250
|
-
test
|
|
251
|
-
.replace("./", "web/")
|
|
252
|
-
.split(".")
|
|
253
|
-
.slice(0, -1)
|
|
254
|
-
.concat("mjs")
|
|
255
|
-
.join(".")) {
|
|
256
|
-
launchWeb(test, destinationOfRuntime(test, "web"));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
await puppeteer_in_electron_1.default.connect(electron_1.app, puppeteer_core_1.default);
|
|
265
|
-
};
|
|
266
|
-
main();
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
const fPaths = [];
|
|
4
|
-
export const NodeWriter = {
|
|
5
|
-
createWriteStream: (filepath) => fs.createWriteStream(filepath),
|
|
6
|
-
writeFileSync: (fp, contents) => fs.writeFileSync(fp, contents),
|
|
7
|
-
mkdirSync: async (destFolder) => {
|
|
8
|
-
if (!fs.existsSync(destFolder)) {
|
|
9
|
-
fs.mkdirSync(destFolder, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
|
|
13
|
-
callback(new Promise((res, rej) => {
|
|
14
|
-
tLog("testArtiFactory =>", fPath);
|
|
15
|
-
const cleanPath = path.resolve(fPath);
|
|
16
|
-
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
17
|
-
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
18
|
-
fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
19
|
-
if (error) {
|
|
20
|
-
console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
21
|
-
}
|
|
22
|
-
fs.writeFileSync(path.resolve(targetDir.split("/").slice(0, -1).join("/"), "manifest"), fPaths.join(`\n`), {
|
|
23
|
-
encoding: "utf-8",
|
|
24
|
-
});
|
|
25
|
-
if (Buffer.isBuffer(value)) {
|
|
26
|
-
fs.writeFileSync(fPath, value, "binary");
|
|
27
|
-
res();
|
|
28
|
-
}
|
|
29
|
-
else if (`string` === typeof value) {
|
|
30
|
-
fs.writeFileSync(fPath, value.toString(), {
|
|
31
|
-
encoding: "utf-8",
|
|
32
|
-
});
|
|
33
|
-
res();
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
/* @ts-ignore:next-line */
|
|
37
|
-
const pipeStream = value;
|
|
38
|
-
const myFile = fs.createWriteStream(fPath);
|
|
39
|
-
pipeStream.pipe(myFile);
|
|
40
|
-
pipeStream.on("close", () => {
|
|
41
|
-
myFile.close();
|
|
42
|
-
res();
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}));
|
|
47
|
-
},
|
|
48
|
-
};
|