testeranto 0.82.0 → 0.84.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/dist/common/package.json +3 -0
- package/dist/common/src/Node.js +2 -0
- package/dist/common/src/PM/main.js +182 -79
- package/dist/common/src/PM/node.js +32 -6
- package/dist/common/src/PM/web.js +28 -54
- package/dist/common/src/Project.js +0 -3
- package/dist/common/src/Puppeteer.js +9 -51
- package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
- package/dist/common/src/Web.js +2 -0
- package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -41
- package/dist/common/src/esbuildConfigs/node.js +10 -3
- package/dist/common/src/esbuildConfigs/web.js +6 -2
- package/dist/common/src/lib/abstractBase.js +343 -335
- package/dist/common/src/lib/basebuilder.js +7 -3
- package/dist/common/src/lib/core.js +1 -1
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/package.json +3 -0
- package/dist/module/src/Node.js +1 -1
- package/dist/module/src/PM/main.js +182 -79
- package/dist/module/src/PM/node.js +32 -6
- package/dist/module/src/PM/web.js +28 -51
- package/dist/module/src/Project.js +0 -3
- package/dist/module/src/Puppeteer.js +9 -51
- package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
- package/dist/module/src/Web.js +1 -1
- package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -41
- package/dist/module/src/esbuildConfigs/node.js +10 -3
- package/dist/module/src/esbuildConfigs/web.js +6 -2
- package/dist/module/src/lib/abstractBase.js +343 -335
- package/dist/module/src/lib/basebuilder.js +7 -3
- package/dist/module/src/lib/core.js +1 -1
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Puppeteer.mjs +82033 -0
- package/dist/types/src/Node.d.ts +5 -1
- package/dist/types/src/PM/index.d.ts +10 -4
- package/dist/types/src/PM/main.d.ts +21 -9
- package/dist/types/src/PM/node.d.ts +11 -3
- package/dist/types/src/PM/web.d.ts +11 -2
- package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
- package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
- package/dist/types/src/Types.d.ts +2 -2
- package/dist/types/src/Web.d.ts +5 -1
- package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
- package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
- package/dist/types/src/lib/abstractBase.d.ts +5 -5
- package/dist/types/src/lib/types.d.ts +7 -5
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +18 -41
- package/pupBuild.js +18 -0
- package/src/Node.ts +1 -3
- package/src/PM/index.ts +12 -3
- package/src/PM/main.ts +300 -164
- package/src/PM/node.ts +40 -6
- package/src/PM/web.ts +108 -58
- package/src/Project.ts +0 -8
- package/src/Puppeteer.ts +11 -57
- package/src/SubPackages/react-dom/jsx/web.ts +15 -10
- package/src/Types.ts +5 -2
- package/src/Web.ts +1 -1
- package/src/esbuildConfigs/featuresPlugin.ts +43 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +98 -66
- package/src/esbuildConfigs/node.ts +18 -3
- package/src/esbuildConfigs/web.ts +14 -2
- package/src/lib/abstractBase.ts +381 -364
- package/src/lib/basebuilder.ts +7 -7
- package/src/lib/core.ts +1 -1
- package/src/lib/types.ts +13 -5
package/src/PM/web.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PassThrough } from "stream";
|
|
2
|
-
import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
|
|
3
2
|
|
|
4
3
|
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
4
|
+
|
|
5
5
|
import { PM } from "./index.js";
|
|
6
|
+
import { ScreenshotOptions } from "puppeteer-core";
|
|
6
7
|
|
|
7
8
|
type PuppetMasterServer = Record<string, Promise<any>>;
|
|
8
9
|
|
|
@@ -15,8 +16,48 @@ export class PM_Web extends PM {
|
|
|
15
16
|
this.testResourceConfiguration = t;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
window["
|
|
19
|
+
$(selector: string): boolean {
|
|
20
|
+
return window["$"](selector);
|
|
21
|
+
}
|
|
22
|
+
screencast(opts: object) {
|
|
23
|
+
throw new Error("Method not implemented.");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
isDisabled(selector: string): boolean {
|
|
27
|
+
return window["isDisabled"](selector);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getAttribute(selector: string, attribute: string) {
|
|
31
|
+
return window["getValue"](selector, attribute);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getValue(selector: string) {
|
|
35
|
+
return window["getValue"](selector);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
focusOn(selector: string) {
|
|
39
|
+
return window["focusOn"](selector);
|
|
40
|
+
}
|
|
41
|
+
typeInto(value: string) {
|
|
42
|
+
return window["typeInto"](value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
page(): string | undefined {
|
|
46
|
+
return window["page"]();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
click(selector: string): any {
|
|
50
|
+
return window["click"](selector);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
customScreenShot(opts: ScreenshotOptions) {
|
|
54
|
+
return window["customScreenShot"](
|
|
55
|
+
{
|
|
56
|
+
...opts,
|
|
57
|
+
path: this.testResourceConfiguration.fs + "/" + opts.path,
|
|
58
|
+
},
|
|
59
|
+
this.testResourceConfiguration.name
|
|
60
|
+
);
|
|
20
61
|
}
|
|
21
62
|
|
|
22
63
|
existsSync(destFolder: string): boolean {
|
|
@@ -108,59 +149,68 @@ export class PM_Web extends PM {
|
|
|
108
149
|
};
|
|
109
150
|
}
|
|
110
151
|
|
|
111
|
-
startPuppeteer(options, destFolder: string): Promise<any> {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
152
|
+
// startPuppeteer(options, destFolder: string): Promise<any> {
|
|
153
|
+
// const name = this.testResourceConfiguration.name;
|
|
154
|
+
|
|
155
|
+
// return fetch(`http://localhost:3234/json/version`)
|
|
156
|
+
// .then((v) => {
|
|
157
|
+
// return v.json();
|
|
158
|
+
// })
|
|
159
|
+
// .then((json) => {
|
|
160
|
+
// console.log(json);
|
|
161
|
+
|
|
162
|
+
// return puppeteer
|
|
163
|
+
// .connect({
|
|
164
|
+
// // "ws://localhost:3234/devtools/browser/01cc60a5-dad6-4b65-a848-09d77764a3fa"
|
|
165
|
+
// // browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
166
|
+
// browserURL: "http://localhost:3234/json/version",
|
|
167
|
+
// })
|
|
168
|
+
// .then(async (b) => {
|
|
169
|
+
// this.browser = b;
|
|
170
|
+
|
|
171
|
+
// // const t = this.browser.targets()[2];
|
|
172
|
+
// // const s = this.browser.defaultBrowserContext().
|
|
173
|
+
// console.log(this.browser);
|
|
174
|
+
// console.log(this.browser.browserContexts());
|
|
175
|
+
// // const handler2 = {
|
|
176
|
+
// // get(target, prop, receiver) {
|
|
177
|
+
// // if (prop === "screenshot") {
|
|
178
|
+
// // return async (x) => {
|
|
179
|
+
// // return await window["custom-screenshot"](
|
|
180
|
+
// // {
|
|
181
|
+
// // ...x,
|
|
182
|
+
// // // path: destFolder + "/" + x.path,
|
|
183
|
+
// // path: x.path,
|
|
184
|
+
// // },
|
|
185
|
+
// // name
|
|
186
|
+
// // );
|
|
187
|
+
// // };
|
|
188
|
+
// // } else if (prop === "mainFrame") {
|
|
189
|
+
// // return () => target[prop](...arguments);
|
|
190
|
+
// // } else {
|
|
191
|
+
// // return Reflect.get(...arguments);
|
|
192
|
+
// // }
|
|
193
|
+
// // },
|
|
194
|
+
// // };
|
|
195
|
+
// // const handler1 = {
|
|
196
|
+
// // get(target, prop, receiver) {
|
|
197
|
+
// // if (prop === "pages") {
|
|
198
|
+
// // return async () => {
|
|
199
|
+
// // return target.pages().then((pages) => {
|
|
200
|
+
// // return pages.map((p) => {
|
|
201
|
+
// // return new Proxy(p, handler2);
|
|
202
|
+
// // });
|
|
203
|
+
// // });
|
|
204
|
+
// // };
|
|
205
|
+
// // }
|
|
206
|
+
|
|
207
|
+
// // return Reflect.get(...arguments);
|
|
208
|
+
// // },
|
|
209
|
+
// // };
|
|
210
|
+
|
|
211
|
+
// // const proxy3 = new Proxy(this.browser, handler1);
|
|
212
|
+
// // this.browser = proxy3;
|
|
213
|
+
// });
|
|
214
|
+
// });
|
|
215
|
+
// }
|
|
166
216
|
}
|
package/src/Project.ts
CHANGED
|
@@ -9,8 +9,6 @@ import esbuildWebConfiger from "./esbuildConfigs/web.js";
|
|
|
9
9
|
import webHtmlFrame from "./web.html.js";
|
|
10
10
|
import { ITestTypes, IBaseConfig, IRunTime } from "./lib/types.js";
|
|
11
11
|
|
|
12
|
-
// var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
13
|
-
|
|
14
12
|
readline.emitKeypressEvents(process.stdin);
|
|
15
13
|
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
16
14
|
|
|
@@ -79,11 +77,6 @@ export class ITProject {
|
|
|
79
77
|
|
|
80
78
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
81
79
|
|
|
82
|
-
console.log(
|
|
83
|
-
`this.getSecondaryEndpointsPoints("web")`,
|
|
84
|
-
this.getSecondaryEndpointsPoints("web")
|
|
85
|
-
);
|
|
86
|
-
|
|
87
80
|
glob(`./${this.config.outdir}/chunk-*.mjs`, {
|
|
88
81
|
ignore: "node_modules/**",
|
|
89
82
|
}).then((chunks) => {
|
|
@@ -163,7 +156,6 @@ export class ITProject {
|
|
|
163
156
|
public getSecondaryEndpointsPoints(runtime?: IRunTime): string[] {
|
|
164
157
|
const meta = (ts: ITestTypes[], st: Set<string>): Set<string> => {
|
|
165
158
|
ts.forEach((t) => {
|
|
166
|
-
console.log("getSecondaryEndpointsPoints", t);
|
|
167
159
|
if (t[1] === runtime) {
|
|
168
160
|
st.add(t[0]);
|
|
169
161
|
}
|
package/src/Puppeteer.ts
CHANGED
|
@@ -4,20 +4,11 @@ import watch from "recursive-watch";
|
|
|
4
4
|
|
|
5
5
|
import { PM_Main } from "./PM/main.js";
|
|
6
6
|
import { destinationOfRuntime } from "./utils.js";
|
|
7
|
-
import { timeout } from "puppeteer-core/lib/esm/puppeteer/index.js";
|
|
8
7
|
import { IBaseConfig, IBuiltConfig } from "./lib/types.js";
|
|
9
8
|
|
|
10
|
-
// var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
11
|
-
|
|
12
|
-
// const node2web: Record<string, string[]> = {};
|
|
13
|
-
// const web2node: Record<string, string[]> = {};
|
|
14
|
-
// const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
|
|
15
|
-
|
|
16
9
|
readline.emitKeypressEvents(process.stdin);
|
|
17
10
|
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
18
11
|
|
|
19
|
-
// let shutDownMode = false;
|
|
20
|
-
|
|
21
12
|
export default async (partialConfig) => {
|
|
22
13
|
const config: IBuiltConfig = {
|
|
23
14
|
...partialConfig,
|
|
@@ -48,10 +39,12 @@ export default async (partialConfig) => {
|
|
|
48
39
|
headless: true,
|
|
49
40
|
dumpio: true,
|
|
50
41
|
// timeout: 0,
|
|
42
|
+
devtools: true,
|
|
51
43
|
args: [
|
|
52
|
-
|
|
44
|
+
"--auto-open-devtools-for-tabs",
|
|
45
|
+
`--remote-debugging-port=3234`,
|
|
53
46
|
|
|
54
|
-
"--disable-features=IsolateOrigins,site-per-process",
|
|
47
|
+
// "--disable-features=IsolateOrigins,site-per-process",
|
|
55
48
|
"--disable-site-isolation-trials",
|
|
56
49
|
"--allow-insecure-localhost",
|
|
57
50
|
"--allow-file-access-from-files",
|
|
@@ -75,7 +68,6 @@ export default async (partialConfig) => {
|
|
|
75
68
|
// "--single-process",
|
|
76
69
|
// "--unsafely-treat-insecure-origin-as-secure",
|
|
77
70
|
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
78
|
-
`--remote-debugging-port=3234`,
|
|
79
71
|
|
|
80
72
|
// "--disk-cache-dir=/dev/null",
|
|
81
73
|
// "--disk-cache-size=1",
|
|
@@ -85,12 +77,18 @@ export default async (partialConfig) => {
|
|
|
85
77
|
"."
|
|
86
78
|
);
|
|
87
79
|
|
|
88
|
-
console.log(
|
|
80
|
+
console.log(
|
|
81
|
+
"\n Puppeteer is running. Press 'q' to shutdown softly. Press 'x' to shutdown forcefully.\n"
|
|
82
|
+
);
|
|
89
83
|
process.stdin.on("keypress", (str, key) => {
|
|
90
84
|
if (key.name === "q") {
|
|
91
85
|
pm.shutDown();
|
|
92
86
|
// process.exit();
|
|
93
87
|
}
|
|
88
|
+
if (key.name === "x") {
|
|
89
|
+
// pm.shutDown();
|
|
90
|
+
process.exit(-1);
|
|
91
|
+
}
|
|
94
92
|
});
|
|
95
93
|
|
|
96
94
|
config.tests.forEach(([test, runtime, tr, sidecars]) => {
|
|
@@ -144,48 +142,4 @@ export default async (partialConfig) => {
|
|
|
144
142
|
} else {
|
|
145
143
|
pm.shutDown();
|
|
146
144
|
}
|
|
147
|
-
// pm.browser.close();
|
|
148
|
-
|
|
149
|
-
// does not work on linux
|
|
150
|
-
// fs.watch(
|
|
151
|
-
// config.buildDir,
|
|
152
|
-
// {
|
|
153
|
-
// recursive: true,
|
|
154
|
-
// },
|
|
155
|
-
// (eventType, changedFile) => {
|
|
156
|
-
// if (changedFile) {
|
|
157
|
-
// config.tests.forEach(([test, runtime, tr, sidecars]) => {
|
|
158
|
-
// if (eventType === "change" || eventType === "rename") {
|
|
159
|
-
// if (
|
|
160
|
-
// changedFile ===
|
|
161
|
-
// test
|
|
162
|
-
// .replace("./", "node/")
|
|
163
|
-
// .split(".")
|
|
164
|
-
// .slice(0, -1)
|
|
165
|
-
// .concat("mjs")
|
|
166
|
-
// .join(".")
|
|
167
|
-
// ) {
|
|
168
|
-
// pm.launchNode(test, destinationOfRuntime(test, "node", config));
|
|
169
|
-
// }
|
|
170
|
-
|
|
171
|
-
// if (
|
|
172
|
-
// changedFile ===
|
|
173
|
-
// test
|
|
174
|
-
// .replace("./", "web/")
|
|
175
|
-
// .split(".")
|
|
176
|
-
// .slice(0, -1)
|
|
177
|
-
// .concat("mjs")
|
|
178
|
-
// .join(".")
|
|
179
|
-
// ) {
|
|
180
|
-
// pm.launchWeb(
|
|
181
|
-
// test,
|
|
182
|
-
// destinationOfRuntime(test, "web", config),
|
|
183
|
-
// sidecars
|
|
184
|
-
// );
|
|
185
|
-
// }
|
|
186
|
-
// }
|
|
187
|
-
// });
|
|
188
|
-
// }
|
|
189
|
-
// }
|
|
190
|
-
// );
|
|
191
145
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import { CElement, createElement } from "react";
|
|
3
|
-
import ReactDom from "react-dom
|
|
3
|
+
import ReactDom from "react-dom";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
|
|
6
6
|
import Testeranto from "../../../Web.js";
|
|
@@ -100,17 +100,22 @@ export default <ITestShape extends IBaseTest>(
|
|
|
100
100
|
});
|
|
101
101
|
},
|
|
102
102
|
andWhen: function (s: IStore, whenCB, tr, utils): Promise<ISelection> {
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
103
|
+
return whenCB(s, utils);
|
|
104
|
+
// return new Promise(async (resolve, rej) => {
|
|
105
|
+
// // resolve(await whenCB(s, utils));
|
|
106
|
+
// // process.nextTick(() => {
|
|
107
|
+
// // resolve(whenCB()(s));
|
|
108
|
+
// // });
|
|
109
|
+
// });
|
|
110
110
|
},
|
|
111
|
-
butThen: async function (
|
|
111
|
+
butThen: async function (
|
|
112
|
+
s: IStore,
|
|
113
|
+
thenCB,
|
|
114
|
+
tr,
|
|
115
|
+
utils
|
|
116
|
+
): Promise<ISelection> {
|
|
112
117
|
return new Promise((resolve, rej) => {
|
|
113
|
-
resolve(thenCB(s));
|
|
118
|
+
resolve(thenCB(s, utils));
|
|
114
119
|
});
|
|
115
120
|
},
|
|
116
121
|
afterEach: async function (store: IStore, ndx, artificer) {
|
package/src/Types.ts
CHANGED
|
@@ -161,12 +161,15 @@ export type ITestImplementation<
|
|
|
161
161
|
whens: {
|
|
162
162
|
[K in keyof ITestShape["whens"]]: (
|
|
163
163
|
...Iw: ITestShape["whens"][K]
|
|
164
|
-
) => (
|
|
164
|
+
) => (
|
|
165
|
+
zel: ITestShape["iselection"],
|
|
166
|
+
utils: PM
|
|
167
|
+
) => Promise<ITestShape["when"]>;
|
|
165
168
|
};
|
|
166
169
|
thens: {
|
|
167
170
|
[K in keyof ITestShape["thens"]]: (
|
|
168
171
|
...It: ITestShape["thens"][K]
|
|
169
|
-
) => (ssel: ITestShape["iselection"]) => ITestShape["then"];
|
|
172
|
+
) => (ssel: ITestShape["iselection"], utils: PM) => ITestShape["then"];
|
|
170
173
|
};
|
|
171
174
|
checks: {
|
|
172
175
|
[K in keyof ITestShape["checks"]]: (
|
package/src/Web.ts
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
name: "feature-markdown",
|
|
6
|
+
setup(build) {
|
|
7
|
+
build.onResolve({ filter: /\.md$/ }, (args) => {
|
|
8
|
+
if (args.resolveDir === "") return;
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
path: path.isAbsolute(args.path)
|
|
12
|
+
? args.path
|
|
13
|
+
: path.join(args.resolveDir, args.path),
|
|
14
|
+
namespace: "feature-markdown",
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
build.onLoad(
|
|
19
|
+
{ filter: /.*/, namespace: "feature-markdown" },
|
|
20
|
+
async (args) => {
|
|
21
|
+
// const markdownContent = new TextDecoder().decode(
|
|
22
|
+
// await fs.readFileSync(args.path)
|
|
23
|
+
// );
|
|
24
|
+
// markdownHTML = marked(markdownContent, options?.markedOptions);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
contents: `file://${args.path}`,
|
|
28
|
+
loader: "text",
|
|
29
|
+
|
|
30
|
+
// contents: JSON.stringify({ path: args.path }),
|
|
31
|
+
// loader: "json",
|
|
32
|
+
|
|
33
|
+
// contents: JSON.stringify({
|
|
34
|
+
// // html: markdownHTML,
|
|
35
|
+
// raw: markdownContent,
|
|
36
|
+
// filename: args.path, //path.basename(args.path),
|
|
37
|
+
// }),
|
|
38
|
+
// loader: "json",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -1,87 +1,119 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import type { ImportKind, Metafile, Plugin } from "esbuild";
|
|
4
|
+
|
|
5
|
+
const otherInputs: Record<string, Set<string>> = {};
|
|
6
|
+
|
|
7
|
+
const register = (entrypoint: string, sources: string[]): void => {
|
|
8
|
+
console.log("register", entrypoint, sources);
|
|
9
|
+
if (!otherInputs[entrypoint]) {
|
|
10
|
+
otherInputs[entrypoint] = new Set();
|
|
11
|
+
}
|
|
12
|
+
sources.forEach((s) => otherInputs[entrypoint].add(s));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function tree(meta: Metafile, key: string) {
|
|
16
|
+
return [
|
|
17
|
+
key,
|
|
18
|
+
...meta.inputs[key].imports
|
|
19
|
+
.filter((x) => x.external !== true)
|
|
20
|
+
.filter((x) => x.path.split("/")[0] !== "node_modules")
|
|
21
|
+
.map((f) => f.path),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
3
24
|
|
|
4
25
|
export default (
|
|
5
26
|
platform: "web" | "node",
|
|
6
27
|
entryPoints: Set<string> | string[]
|
|
7
|
-
)
|
|
28
|
+
): {
|
|
29
|
+
register: (entrypoint: string, sources: string[]) => void;
|
|
30
|
+
inputFilesPluginFactory: Plugin;
|
|
31
|
+
} => {
|
|
8
32
|
return {
|
|
9
|
-
|
|
10
|
-
setup(build) {
|
|
11
|
-
build.onEnd((result) => {
|
|
12
|
-
if (result.errors.length === 0) {
|
|
13
|
-
entryPoints.forEach((entryPoint) => {
|
|
14
|
-
const filePath = path.join(
|
|
15
|
-
"./docs/",
|
|
16
|
-
platform,
|
|
17
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
18
|
-
`inputFiles.json`
|
|
19
|
-
);
|
|
20
|
-
const promptPath = path.join(
|
|
21
|
-
"./docs/",
|
|
22
|
-
platform,
|
|
23
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
24
|
-
`prompt.txt`
|
|
25
|
-
);
|
|
26
|
-
const testPaths = path.join(
|
|
27
|
-
"./docs/",
|
|
28
|
-
platform,
|
|
29
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
30
|
-
`tests.json`
|
|
31
|
-
);
|
|
32
|
-
const featuresPath = path.join(
|
|
33
|
-
"./docs/",
|
|
34
|
-
platform,
|
|
35
|
-
entryPoint.split(".").slice(0, -1).join("."),
|
|
36
|
-
`features.json`
|
|
37
|
-
);
|
|
33
|
+
register,
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
inputFilesPluginFactory: {
|
|
36
|
+
name: "metafileWriter",
|
|
37
|
+
setup(build) {
|
|
38
|
+
build.onEnd((result) => {
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
`docs/${platform}/metafile.json`,
|
|
41
|
+
JSON.stringify(result, null, 2)
|
|
42
|
+
);
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
if (result.errors.length === 0) {
|
|
45
|
+
entryPoints.forEach((entryPoint) => {
|
|
46
|
+
const filePath = path.join(
|
|
47
|
+
"./docs/",
|
|
48
|
+
platform,
|
|
49
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
50
|
+
`inputFiles.json`
|
|
51
|
+
);
|
|
52
|
+
const dirName = path.dirname(filePath);
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
if (!fs.existsSync(dirName)) {
|
|
55
|
+
fs.mkdirSync(dirName, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const promptPath = path.join(
|
|
59
|
+
"./docs/",
|
|
60
|
+
platform,
|
|
61
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
62
|
+
`prompt.txt`
|
|
63
|
+
);
|
|
64
|
+
const testPaths = path.join(
|
|
65
|
+
"./docs/",
|
|
66
|
+
platform,
|
|
67
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
68
|
+
`tests.json`
|
|
69
|
+
);
|
|
70
|
+
const featuresPath = path.join(
|
|
71
|
+
"./docs/",
|
|
72
|
+
platform,
|
|
73
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
74
|
+
`featurePrompt.txt`
|
|
75
|
+
); // /read ${featuresPath}
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
if (result.metafile) {
|
|
78
|
+
const addableFiles = tree(
|
|
79
|
+
result.metafile,
|
|
80
|
+
entryPoint.split("/").slice(1).join("/")
|
|
81
|
+
)
|
|
82
|
+
.map((y) => {
|
|
83
|
+
if (otherInputs[y]) {
|
|
84
|
+
return Array.from(otherInputs[y]);
|
|
85
|
+
}
|
|
86
|
+
return y;
|
|
87
|
+
})
|
|
88
|
+
.flat();
|
|
68
89
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
${
|
|
90
|
+
fs.writeFileSync(
|
|
91
|
+
promptPath,
|
|
92
|
+
`
|
|
93
|
+
${[...addableFiles]
|
|
73
94
|
.map((x) => {
|
|
74
95
|
return `/add ${x}`;
|
|
75
96
|
})
|
|
76
97
|
.join("\n")}
|
|
98
|
+
${[...addableFiles]
|
|
99
|
+
.map((x) => {
|
|
100
|
+
const f = `docs/ts/${x}.type_errors.txt`;
|
|
101
|
+
|
|
102
|
+
if (fs.existsSync(f)) {
|
|
103
|
+
return `/read ${f}`;
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.join("\n")}
|
|
77
107
|
/read ${testPaths}
|
|
78
|
-
/
|
|
79
|
-
/code
|
|
108
|
+
/load ${featuresPath}
|
|
109
|
+
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors. Implement any method which throws "Function not implemented."
|
|
80
110
|
`
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
},
|
|
85
117
|
},
|
|
86
118
|
};
|
|
87
119
|
};
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { BuildOptions } from "esbuild";
|
|
2
|
+
// import pkg from "esbuild-plugin-markdown";
|
|
3
|
+
// const { markdownPlugin } = pkg;
|
|
2
4
|
|
|
3
5
|
import { IBaseConfig } from "../lib/types";
|
|
4
6
|
|
|
5
7
|
import baseEsBuildConfig from "./index.js";
|
|
6
8
|
import inputFilesPlugin from "./inputFilesPlugin.js";
|
|
9
|
+
import featuresPlugin from "./featuresPlugin";
|
|
7
10
|
|
|
8
11
|
export default (
|
|
9
12
|
config: IBaseConfig,
|
|
10
13
|
entryPoints: Set<string> | string[]
|
|
11
14
|
): BuildOptions => {
|
|
15
|
+
const { inputFilesPluginFactory, register } = inputFilesPlugin(
|
|
16
|
+
"node",
|
|
17
|
+
entryPoints
|
|
18
|
+
);
|
|
19
|
+
// const inputFilesPluginFactory = inputFilesPlugin("node", entryPoints);
|
|
20
|
+
// const register = (x) => x;
|
|
21
|
+
|
|
12
22
|
return {
|
|
13
23
|
...baseEsBuildConfig(config),
|
|
14
24
|
|
|
@@ -34,7 +44,7 @@ export default (
|
|
|
34
44
|
external: [
|
|
35
45
|
// "testeranto.json",
|
|
36
46
|
// "features.test.js",
|
|
37
|
-
|
|
47
|
+
"react",
|
|
38
48
|
// "events",
|
|
39
49
|
// "ganache"
|
|
40
50
|
...config.externals,
|
|
@@ -42,8 +52,13 @@ export default (
|
|
|
42
52
|
|
|
43
53
|
entryPoints: [...entryPoints],
|
|
44
54
|
plugins: [
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
featuresPlugin,
|
|
56
|
+
// markdownPlugin({}),
|
|
57
|
+
...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
|
|
58
|
+
|
|
59
|
+
inputFilesPluginFactory,
|
|
60
|
+
// inputFilesPlugin("node", entryPoints),
|
|
61
|
+
|
|
47
62
|
{
|
|
48
63
|
name: "rebuild-notify",
|
|
49
64
|
setup(build) {
|