testeranto 0.81.3 → 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.
Files changed (71) hide show
  1. package/dist/common/src/Node.js +4 -2
  2. package/dist/common/src/PM/main.js +188 -61
  3. package/dist/common/src/PM/node.js +32 -7
  4. package/dist/common/src/PM/web.js +28 -54
  5. package/dist/common/src/Project.js +0 -3
  6. package/dist/common/src/Puppeteer.js +9 -51
  7. package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
  8. package/dist/common/src/Web.js +7 -1
  9. package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
  10. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -64
  11. package/dist/common/src/esbuildConfigs/node.js +10 -3
  12. package/dist/common/src/esbuildConfigs/web.js +6 -2
  13. package/dist/common/src/lib/abstractBase.js +348 -337
  14. package/dist/common/src/lib/basebuilder.js +9 -4
  15. package/dist/common/src/lib/core.js +1 -1
  16. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  17. package/dist/module/src/Node.js +3 -3
  18. package/dist/module/src/PM/main.js +188 -61
  19. package/dist/module/src/PM/node.js +32 -7
  20. package/dist/module/src/PM/web.js +28 -51
  21. package/dist/module/src/Project.js +0 -3
  22. package/dist/module/src/Puppeteer.js +9 -51
  23. package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
  24. package/dist/module/src/Web.js +6 -2
  25. package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
  26. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -64
  27. package/dist/module/src/esbuildConfigs/node.js +10 -3
  28. package/dist/module/src/esbuildConfigs/web.js +6 -2
  29. package/dist/module/src/lib/abstractBase.js +348 -337
  30. package/dist/module/src/lib/basebuilder.js +9 -4
  31. package/dist/module/src/lib/core.js +1 -1
  32. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  33. package/dist/prebuild/Puppeteer.mjs +82033 -0
  34. package/dist/types/src/Node.d.ts +5 -1
  35. package/dist/types/src/PM/index.d.ts +10 -4
  36. package/dist/types/src/PM/main.d.ts +21 -9
  37. package/dist/types/src/PM/node.d.ts +11 -3
  38. package/dist/types/src/PM/web.d.ts +11 -2
  39. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
  40. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
  41. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
  42. package/dist/types/src/Types.d.ts +2 -2
  43. package/dist/types/src/Web.d.ts +5 -1
  44. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
  45. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
  46. package/dist/types/src/lib/abstractBase.d.ts +5 -4
  47. package/dist/types/src/lib/core.d.ts +1 -1
  48. package/dist/types/src/lib/index.d.ts +1 -0
  49. package/dist/types/src/lib/types.d.ts +7 -5
  50. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  51. package/package.json +18 -45
  52. package/pupBuild.js +18 -0
  53. package/src/Node.ts +3 -5
  54. package/src/PM/index.ts +12 -3
  55. package/src/PM/main.ts +306 -140
  56. package/src/PM/node.ts +40 -7
  57. package/src/PM/web.ts +108 -58
  58. package/src/Project.ts +0 -8
  59. package/src/Puppeteer.ts +11 -57
  60. package/src/SubPackages/react-dom/jsx/web.ts +15 -10
  61. package/src/Types.ts +5 -2
  62. package/src/Web.ts +6 -2
  63. package/src/esbuildConfigs/featuresPlugin.ts +43 -0
  64. package/src/esbuildConfigs/inputFilesPlugin.ts +97 -90
  65. package/src/esbuildConfigs/node.ts +18 -3
  66. package/src/esbuildConfigs/web.ts +14 -2
  67. package/src/lib/abstractBase.ts +388 -366
  68. package/src/lib/basebuilder.ts +9 -9
  69. package/src/lib/core.ts +4 -2
  70. package/src/lib/index.ts +1 -0
  71. package/src/lib/types.ts +14 -6
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
- customScreenShot(opts: object) {
19
- window["customScreenShot"](opts);
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
- const name = this.testResourceConfiguration.name;
113
-
114
- return fetch(`http://localhost:3234/json/version`)
115
- .then((v) => {
116
- return v.json();
117
- })
118
- .then((json) => {
119
- return puppeteer
120
- .connect({
121
- browserWSEndpoint: json.webSocketDebuggerUrl,
122
- })
123
- .then((b) => {
124
- this.browser = b;
125
- const handler2 = {
126
- get(target, prop, receiver) {
127
- if (prop === "screenshot") {
128
- return async (x) => {
129
- return await window["custom-screenshot"](
130
- {
131
- ...x,
132
- // path: destFolder + "/" + x.path,
133
- path: x.path,
134
- },
135
- name
136
- );
137
- };
138
- } else if (prop === "mainFrame") {
139
- return () => target[prop](...arguments);
140
- } else {
141
- return Reflect.get(...arguments);
142
- }
143
- },
144
- };
145
- const handler1 = {
146
- get(target, prop, receiver) {
147
- if (prop === "pages") {
148
- return async () => {
149
- return target.pages().then((pages) => {
150
- return pages.map((p) => {
151
- return new Proxy(p, handler2);
152
- });
153
- });
154
- };
155
- }
156
-
157
- return Reflect.get(...arguments);
158
- },
159
- };
160
-
161
- const proxy3 = new Proxy(this.browser, handler1);
162
- this.browser = proxy3;
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
- // "--auto-open-devtools-for-tabs",
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("\n Puppeteer is running. Press 'q' to quit\n");
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/client";
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 new Promise((resolve, rej) => {
104
- console.log("mark9", s, whenCB);
105
- resolve(whenCB(s, utils));
106
- // process.nextTick(() => {
107
- // resolve(whenCB()(s));
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 (s: IStore, thenCB): Promise<ISelection> {
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
- ) => (zel: ITestShape["iselection"], utils: PM) => ITestShape["when"];
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
@@ -12,7 +12,7 @@ import {
12
12
  } from "./lib/index.js";
13
13
  import { ITestInterface, IWebTestInterface } from "./lib/types";
14
14
 
15
- class WebTesteranto<
15
+ export class WebTesteranto<
16
16
  TestShape extends IBaseTest<
17
17
  unknown,
18
18
  unknown,
@@ -47,9 +47,13 @@ class WebTesteranto<
47
47
  async receiveTestResourceConfig(partialTestResource: any) {
48
48
  const t: ITTestResourceConfiguration = partialTestResource; //JSON.parse(partialTestResource);
49
49
  const pm = new PM_Web(t);
50
- const { failed, artifacts, logPromise } =
50
+ const { failed, artifacts, logPromise, features } =
51
51
  await this.testJobs[0].receiveTestResourceConfig(pm);
52
52
  pm.customclose();
53
+ return new Promise<string[]>((res, rej) => {
54
+ res(features);
55
+ });
56
+ // return features;
53
57
  // Promise.all([...artifacts, logPromise]).then(async () => {
54
58
  // console.log("hello world");
55
59
  // pm.customclose();
@@ -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,112 +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
- name: "metafileWriter",
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
- );
33
+ register,
32
34
 
33
- const dirName = path.dirname(filePath);
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
+ );
34
43
 
35
- if (!fs.existsSync(dirName)) {
36
- fs.mkdirSync(dirName, { recursive: true });
37
- }
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);
38
53
 
39
- const j = Object.keys(
40
- Object.keys(result.metafile.outputs)
41
- .filter((s: string) => {
42
- if (!result.metafile.outputs[s].entryPoint) {
43
- return false;
44
- }
45
- return (
46
- path.resolve(result.metafile.outputs[s].entryPoint) ===
47
- path.resolve(entryPoint)
48
- );
49
- })
50
- .reduce((mm: string[], el) => {
51
- mm.push(result.metafile.outputs[el].inputs);
52
- return mm;
53
- }, [])[0]
54
- ).filter((f: string) => {
55
- const regex = /^src\/.*/g;
56
- const matches = f.match(regex);
57
- const passes = matches?.length === 1;
58
- return passes;
59
- });
60
- // .filter((f: string) => {
61
- // const regex = /.*\.test\..*/g;
62
- // const matches = f.match(regex);
63
- // const passes = matches?.length === 1;
64
- // return !passes;
65
- // })
54
+ if (!fs.existsSync(dirName)) {
55
+ fs.mkdirSync(dirName, { recursive: true });
56
+ }
66
57
 
67
- const jsonContent = JSON.stringify(j);
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}
68
76
 
69
- fs.writeFileSync(filePath, jsonContent);
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();
70
89
 
71
- fs.writeFileSync(
72
- promptPath,
73
- `
74
- ${j
90
+ fs.writeFileSync(
91
+ promptPath,
92
+ `
93
+ ${[...addableFiles]
75
94
  .map((x) => {
76
95
  return `/add ${x}`;
77
96
  })
78
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")}
79
107
  /read ${testPaths}
80
-
81
- /code fix the failing tests described in ${filePath}.
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."
82
110
  `
83
- );
84
-
85
- // fs.writeFileSync(
86
- // promptPath,
87
- // `
88
- // from aider.coders import Coder
89
- // from aider.models import Model
90
- // import os
91
-
92
- // model = Model("deepseek")
93
-
94
- // coder = Coder.create(main_model=model)
95
-
96
- // coder.run("/read-only", "${testPaths}")
97
-
98
- // ${j
99
- // .map((x) => {
100
- // return `coder.run("/add", "${x}")`;
101
- // })
102
- // .join("\n")}
103
-
104
- // coder.run("fix the failing tests described in ${filePath}.")
105
- // `
106
- // );
107
- });
108
- }
109
- });
111
+ );
112
+ }
113
+ });
114
+ }
115
+ });
116
+ },
110
117
  },
111
118
  };
112
119
  };