testeranto 0.85.0 → 0.94.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 (98) hide show
  1. package/README.md +1 -3
  2. package/bin/init-docs.js +24 -0
  3. package/bundle.js +53 -0
  4. package/dist/common/dist/module/src/Init.js +40 -0
  5. package/dist/common/src/Init.js +30 -0
  6. package/dist/common/src/Node.js +5 -3
  7. package/dist/common/src/PM/main.js +136 -90
  8. package/dist/common/src/Project.js +82 -0
  9. package/dist/common/src/Puppeteer.js +0 -2
  10. package/dist/common/src/SubPackages/puppeteer.js +1 -1
  11. package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
  12. package/dist/common/src/SubPackages/react/jsx/node.js +7 -2
  13. package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
  14. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  15. package/dist/common/src/Web.js +25 -21
  16. package/dist/common/{run-tests.js → src/build-tests.js} +10 -5
  17. package/dist/common/src/defaultConfig.js +19 -0
  18. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +26 -16
  19. package/dist/common/src/init-docs.js +43 -0
  20. package/dist/common/src/lib/abstractBase.js +29 -248
  21. package/dist/common/src/lib/basebuilder.js +1 -11
  22. package/dist/common/src/lib/classBuilder.js +1 -1
  23. package/dist/common/src/lib/core.js +8 -26
  24. package/dist/common/{build-tests.js → src/run-tests.js} +10 -9
  25. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  26. package/dist/module/src/Init.js +30 -0
  27. package/dist/module/src/Node.js +5 -3
  28. package/dist/module/src/PM/main.js +136 -90
  29. package/dist/module/src/Project.js +82 -0
  30. package/dist/module/src/Puppeteer.js +0 -2
  31. package/dist/module/src/SubPackages/puppeteer.js +1 -1
  32. package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
  33. package/dist/module/src/SubPackages/react/jsx/node.js +7 -2
  34. package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
  35. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  36. package/dist/module/src/Web.js +25 -21
  37. package/dist/module/src/build-tests.js +11 -0
  38. package/dist/module/src/defaultConfig.js +17 -0
  39. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +26 -16
  40. package/dist/module/src/init-docs.js +15 -0
  41. package/dist/module/src/lib/abstractBase.js +29 -248
  42. package/dist/module/src/lib/basebuilder.js +1 -11
  43. package/dist/module/src/lib/classBuilder.js +1 -1
  44. package/dist/module/src/lib/core.js +8 -26
  45. package/dist/module/src/run-tests.js +11 -0
  46. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  47. package/dist/prebuild/build-tests.mjs +553 -0
  48. package/dist/prebuild/init-docs.mjs +48 -0
  49. package/dist/prebuild/run-tests.mjs +871 -0
  50. package/dist/types/dist/module/src/Init.d.ts +2 -0
  51. package/dist/types/src/Node.d.ts +4 -1
  52. package/dist/types/src/PM/main.d.ts +2 -1
  53. package/dist/types/src/SubPackages/react/jsx/node.d.ts +1 -1
  54. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
  55. package/dist/types/src/Web.d.ts +2 -2
  56. package/dist/types/src/build-tests.d.ts +1 -0
  57. package/dist/types/src/defaultConfig.d.ts +3 -0
  58. package/dist/types/src/init-docs.d.ts +1 -0
  59. package/dist/types/src/lib/abstractBase.d.ts +6 -2
  60. package/dist/types/src/lib/core.d.ts +3 -3
  61. package/dist/types/src/lib/types.d.ts +5 -1
  62. package/dist/types/src/run-tests.d.ts +1 -0
  63. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  64. package/package.json +21 -24
  65. package/src/Init.ts +28 -0
  66. package/src/Node.ts +6 -3
  67. package/src/PM/main.ts +168 -110
  68. package/src/Project.ts +103 -0
  69. package/src/Puppeteer.ts +0 -2
  70. package/src/SubPackages/puppeteer.ts +1 -1
  71. package/src/SubPackages/react/jsx/index.ts +15 -7
  72. package/src/SubPackages/react/jsx/node.ts +6 -5
  73. package/src/SubPackages/react-dom/component/web.ts +28 -51
  74. package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
  75. package/src/Web.ts +45 -23
  76. package/src/build-tests.ts +12 -0
  77. package/src/defaultConfig.ts +20 -0
  78. package/src/esbuildConfigs/inputFilesPlugin.ts +46 -17
  79. package/src/init-docs.ts +19 -0
  80. package/src/lib/abstractBase.ts +38 -255
  81. package/src/lib/basebuilder.ts +1 -12
  82. package/src/lib/classBuilder.ts +2 -1
  83. package/src/lib/core.ts +17 -29
  84. package/src/lib/types.ts +3 -1
  85. package/src/run-tests.ts +12 -0
  86. package/tsconfig.json +1 -1
  87. package/build-tests.ts +0 -16
  88. package/dist/common/init-docs.js +0 -8
  89. package/dist/module/build-tests.js +0 -10
  90. package/dist/module/init-docs.js +0 -3
  91. package/dist/module/run-tests.js +0 -6
  92. package/dist/prebuild/Puppeteer.mjs +0 -82033
  93. package/dist/types/build-tests.d.ts +0 -3
  94. package/dist/types/init-docs.d.ts +0 -2
  95. package/dist/types/run-tests.d.ts +0 -2
  96. package/init-docs.ts +0 -5
  97. package/pupBuild.js +0 -18
  98. package/run-tests.ts +0 -9
package/src/Project.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { spawn } from "child_process";
2
+
1
3
  import esbuild from "esbuild";
2
4
  import fs from "fs";
3
5
  import path from "path";
@@ -12,6 +14,105 @@ import { ITestTypes, IBaseConfig, IRunTime } from "./lib/types.js";
12
14
  readline.emitKeypressEvents(process.stdin);
13
15
  if (process.stdin.isTTY) process.stdin.setRawMode(true);
14
16
 
17
+ const logContent: string[] = [];
18
+
19
+ function parseTsErrors(): void {
20
+ try {
21
+ // const logContent = fs.readFileSync(logPath, "utf-8").split("\n");
22
+ const regex = /(^src(.*?))\(\d*,\d*\): error/gm;
23
+ const brokenFilesToLines: Record<string, Set<number>> = {};
24
+
25
+ for (let i = 0; i < logContent.length - 1; i++) {
26
+ let m;
27
+
28
+ while ((m = regex.exec(logContent[i])) !== null) {
29
+ // This is necessary to avoid infinite loops with zero-width matches
30
+ if (m.index === regex.lastIndex) {
31
+ regex.lastIndex++;
32
+ }
33
+ if (!brokenFilesToLines[m[1]]) {
34
+ brokenFilesToLines[m[1]] = new Set<number>();
35
+ }
36
+ brokenFilesToLines[m[1]].add(i);
37
+ }
38
+ }
39
+
40
+ const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
41
+ mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
42
+ const a = Array.from(brokenFilesToLines[lm]);
43
+
44
+ return Object.keys(a).reduce((mm2, lm2, ndx2) => {
45
+ const acc: string[] = [];
46
+
47
+ let j = a[lm2] + 1;
48
+
49
+ let working = true;
50
+ while (j < logContent.length - 1 && working) {
51
+ if (
52
+ !logContent[j].match(regex) &&
53
+ working &&
54
+ !logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)
55
+ ) {
56
+ acc.push(logContent[j]);
57
+ } else {
58
+ working = false;
59
+ }
60
+
61
+ j++;
62
+ }
63
+
64
+ mm2[lm] = [logContent[l], ...acc];
65
+
66
+ return mm2;
67
+ }, {} as any)[lm];
68
+ });
69
+ return mm;
70
+ }, {});
71
+
72
+ Object.keys(final).forEach((k) => {
73
+ fs.mkdirSync(`./docs/types/${k.split("/").slice(0, -1).join("/")}`, {
74
+ recursive: true,
75
+ });
76
+ fs.writeFileSync(
77
+ `./docs/types/${k}.type_errors.txt`,
78
+ final[k].flat().flat().join("\r\n")
79
+ );
80
+ });
81
+ } catch (error) {
82
+ console.error("Error reading or parsing the log file:", error);
83
+ process.exit(1);
84
+ }
85
+ }
86
+
87
+ const compile = () => {
88
+ return new Promise((resolve, reject) => {
89
+ const tsc = spawn("tsc", ["-noEmit"]);
90
+
91
+ tsc.stdout.on("data", (data) => {
92
+ // console.log(`tsc stdout: ${data}`);
93
+ const lines = data.toString().split("\n");
94
+ logContent.push(...lines);
95
+ });
96
+
97
+ tsc.stderr.on("data", (data) => {
98
+ console.error(`stderr: ${data}`);
99
+ process.exit(-1);
100
+ });
101
+
102
+ tsc.on("close", (code) => {
103
+ parseTsErrors();
104
+ console.log("tsc done");
105
+ resolve(`tsc process exited with code ${code}`);
106
+ // if (code !== 0) {
107
+ // resolve(`tsc process exited with code ${code}`);
108
+ // // reject(`tsc process exited with code ${code}`);
109
+ // } else {
110
+ // resolve({});
111
+ // }
112
+ });
113
+ });
114
+ };
115
+
15
116
  export class ITProject {
16
117
  config: IBaseConfig;
17
118
  mode: `DEV` | `PROD`;
@@ -86,6 +187,8 @@ export class ITProject {
86
187
  });
87
188
 
88
189
  Promise.all([
190
+ compile(),
191
+
89
192
  esbuild
90
193
  .context(esbuildNodeConfiger(this.config, nodeEntryPoints))
91
194
  .then(async (nodeContext) => {
package/src/Puppeteer.ts CHANGED
@@ -83,10 +83,8 @@ export default async (partialConfig) => {
83
83
  process.stdin.on("keypress", (str, key) => {
84
84
  if (key.name === "q") {
85
85
  pm.shutDown();
86
- // process.exit();
87
86
  }
88
87
  if (key.name === "x") {
89
- // pm.shutDown();
90
88
  process.exit(-1);
91
89
  }
92
90
  });
@@ -29,7 +29,7 @@ export default <ITestShape extends IBaseTest>(
29
29
  testSpecifications,
30
30
  testImplementations,
31
31
  {
32
- beforeAll(x) {
32
+ beforeAll: (x) => {
33
33
  // process.parentPort.postMessage(
34
34
  // `/docs/web/src/ClassicalComponent/test.html`
35
35
  // );
@@ -1,4 +1,5 @@
1
1
  import { CElement } from "react";
2
+ import React from "react";
2
3
 
3
4
  import {
4
5
  IBaseTest,
@@ -6,7 +7,6 @@ import {
6
7
  ITestImplementation,
7
8
  ITestSpecification,
8
9
  } from "../../../Types";
9
- import React from "react";
10
10
 
11
11
  export type IWhenShape = any;
12
12
  export type IThenShape = any;
@@ -29,14 +29,22 @@ export const testInterface: IPartialInterface<any> = {
29
29
  // // resolve(x());
30
30
  // // });
31
31
  // },
32
- beforeEach: async (subject, initializer, artificer): Promise<IStore> => {
32
+ // beforeEach: async (subject, initializer, artificer): Promise<IStore> => {
33
+ // return new Promise((resolve, rej) => {
34
+ // resolve(React.createElement(subject));
35
+ // });
36
+ // },
37
+ andWhen: async (s: IStore, whenCB): Promise<IStore> => {
38
+ await whenCB(s());
33
39
  return new Promise((resolve, rej) => {
34
- const x = React.createElement(subject);
35
- console.log("react-element", x);
36
- resolve(x);
40
+ resolve(React.createElement(s));
37
41
  });
42
+ // return whenCB(s);
38
43
  },
39
- andWhen: function (s: IStore, whenCB): Promise<ISelection> {
40
- return whenCB(s);
44
+ butThen: async (subject, thenCB) => {
45
+ await thenCB(subject());
46
+ return new Promise((resolve, rej) => {
47
+ resolve(React.createElement(subject));
48
+ });
41
49
  },
42
50
  };
@@ -12,15 +12,16 @@ export default <ITestShape extends IBaseTest>(
12
12
  testImplementations: ITestImpl<ITestShape>,
13
13
  testSpecifications: ITestSpec<ITestShape>,
14
14
  testInput: IInput,
15
- testInterface: IPartialInterface<ITestShape>
15
+ testInterface: IPartialInterface<ITestShape> = baseInterface
16
16
  ) => {
17
17
  return Testeranto<ITestShape>(
18
18
  testInput,
19
19
  testSpecifications,
20
20
  testImplementations,
21
- {
22
- ...baseInterface,
23
- ...testInterface,
24
- }
21
+ testInterface
22
+ // {
23
+ // ...baseInterface,
24
+ // ...testInterface,
25
+ // }
25
26
  );
26
27
  };
@@ -25,7 +25,7 @@ export type IStore = {
25
25
 
26
26
  type ISubject = {
27
27
  htmlElement: HTMLElement;
28
- reactElement: any; //CElement<any, any>,
28
+ // reactElement: any; //CElement<any, any>,
29
29
  domRoot: ReactDom.Root;
30
30
  };
31
31
 
@@ -52,63 +52,40 @@ export default <ITestShape extends IBaseTest, IWhen, IGiven>(
52
52
  testSpecifications,
53
53
  testImplementations,
54
54
  {
55
- beforeAll: async (initialProps, artificer): Promise<ISubject> => {
55
+ beforeAll: async (subject, artificer): Promise<ISubject> => {
56
56
  return await new Promise((resolve, rej) => {
57
57
  const htmlElement = document.getElementById("root");
58
58
  if (htmlElement) {
59
59
  const domRoot = ReactDom.createRoot(htmlElement);
60
- // Ignore these type errors
61
- domRoot.render(
62
- createElement(
63
- TesterantoComponent,
64
- {
65
- ...initialProps,
66
- done: (reactElement) => {
67
- resolve({
68
- htmlElement,
69
- reactElement,
70
- domRoot,
71
- });
72
- },
73
- },
74
- []
75
- )
76
- );
77
-
78
- // resolve({ htmlElement });
60
+ resolve({ domRoot, htmlElement });
79
61
  }
80
62
  });
81
63
  },
82
- // beforeEach: async (
83
- // s,
84
- // initializer,
85
- // testResource,
86
- // artificer,
87
- // initialValues
88
- // ): Promise<IStore> => {
89
- // return new Promise((resolve, rej) => {
90
- // console.log("beforeEach" + TesterantoComponent);
91
-
92
- // // const domRoot = ReactDom.createRoot(htmlElement);
93
- // // // Ignore these type errors
94
- // // domRoot.render(
95
- // // createElement(
96
- // // TesterantoComponent,
97
- // // {
98
- // // ...initializer,
99
- // // done: (reactElement) => {
100
- // // resolve({
101
- // // htmlElement,
102
- // // reactElement,
103
- // // domRoot,
104
- // // });
105
- // // },
106
- // // },
107
- // // []
108
- // // )
109
- // // );
110
- // });
111
- // },
64
+ beforeEach: async (
65
+ { domRoot, htmlElement },
66
+ initialValues,
67
+ testResource,
68
+ artificer
69
+ ): Promise<IStore> => {
70
+ return new Promise(async (resolve, rej) => {
71
+ domRoot.render(
72
+ createElement(
73
+ TesterantoComponent,
74
+ {
75
+ ...initialValues,
76
+ done: (reactElement) => {
77
+ resolve({
78
+ htmlElement,
79
+ reactElement,
80
+ domRoot,
81
+ });
82
+ },
83
+ },
84
+ []
85
+ )
86
+ );
87
+ });
88
+ },
112
89
  andWhen: function (s: IStore, whenCB): Promise<ISelection> {
113
90
  return whenCB(s);
114
91
  },
@@ -1,21 +1,18 @@
1
1
  import React from "react";
2
2
  import renderer, { act } from "react-test-renderer";
3
+
3
4
  import { ISelection, IStore } from ".";
4
5
 
5
6
  export const testInterface = {
6
7
  beforeEach: function (
7
8
  CComponent,
8
- propsAndChildren
9
+ propsAndChildren: () => any
9
10
  ): Promise<renderer.ReactTestRenderer> {
10
- function Link(props) {
11
- const p = props.props;
12
- const c = props.children;
13
- return React.createElement(CComponent, p, c);
11
+ function Link(proper) {
12
+ return React.createElement(CComponent, proper(), []);
14
13
  }
15
14
  return new Promise((res, rej) => {
16
15
  act(async () => {
17
- const p = propsAndChildren;
18
- const y = new CComponent(p.props);
19
16
  const testRenderer = await renderer.create(Link(propsAndChildren));
20
17
  res(testRenderer);
21
18
  });
@@ -25,7 +22,6 @@ export const testInterface = {
25
22
  renderer: renderer.ReactTestRenderer,
26
23
  whenCB: any
27
24
  ): Promise<renderer.ReactTestRenderer> {
28
- // console.log("andWhen", whenCB)
29
25
  await act(() => whenCB(renderer));
30
26
  return renderer;
31
27
  },
@@ -34,15 +30,12 @@ export const testInterface = {
34
30
  // return whenCB()(s);
35
31
  // },
36
32
  butThen: async function (s: IStore, thenCB, tr): Promise<ISelection> {
37
- console.log("butThen", thenCB.toString());
38
33
  return thenCB(s);
39
34
  },
40
35
  afterEach: async function (store: IStore, ndx, artificer) {
41
- // console.log("afterEach", store);
42
36
  return {};
43
37
  },
44
38
  afterAll: (store: IStore, artificer) => {
45
- // console.log("afterAll", store);
46
39
  return;
47
40
  },
48
41
  };
package/src/Web.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { error } from "console";
1
2
  import { PM_Web } from "./PM/web";
2
3
  import type {
3
4
  IBaseTest,
@@ -10,7 +11,14 @@ import {
10
11
  ITTestResourceRequest,
11
12
  defaultTestResourceRequirement,
12
13
  } from "./lib/index.js";
13
- import { ITestInterface, IWebTestInterface } from "./lib/types";
14
+ import { IFinalResults, ITestInterface, IWebTestInterface } from "./lib/types";
15
+
16
+ let errorCallback = (e: any) => {};
17
+ let unhandledrejectionCallback = (event: PromiseRejectionEvent) => {
18
+ console.log("window.addEventListener unhandledrejection", event);
19
+ // cb({ error: event.reason.message });
20
+ // throw event;
21
+ };
14
22
 
15
23
  export class WebTesteranto<
16
24
  TestShape extends IBaseTest<
@@ -40,7 +48,40 @@ export class WebTesteranto<
40
48
  testSpecification,
41
49
  testImplementation,
42
50
  testResourceRequirement,
43
- testInterface
51
+ testInterface,
52
+ (cb) => {
53
+ window.removeEventListener("error", errorCallback);
54
+
55
+ errorCallback = (e) => {
56
+ console.log("window.addEventListener error", e);
57
+ cb(e);
58
+ // throw e;
59
+ };
60
+
61
+ window.addEventListener("error", errorCallback);
62
+
63
+ window.removeEventListener(
64
+ "unhandledrejection",
65
+ unhandledrejectionCallback
66
+ );
67
+ /////////////////////
68
+
69
+ window.removeEventListener(
70
+ "unhandledrejection",
71
+ unhandledrejectionCallback
72
+ );
73
+
74
+ unhandledrejectionCallback = (event: PromiseRejectionEvent) => {
75
+ console.log("window.addEventListener unhandledrejection", event);
76
+ cb({ error: event.reason.message });
77
+ // throw event;
78
+ };
79
+
80
+ window.addEventListener(
81
+ "unhandledrejection",
82
+ unhandledrejectionCallback
83
+ );
84
+ }
44
85
  );
45
86
  }
46
87
 
@@ -49,28 +90,9 @@ export class WebTesteranto<
49
90
  const pm = new PM_Web(t);
50
91
  const { failed, artifacts, logPromise, features } =
51
92
  await this.testJobs[0].receiveTestResourceConfig(pm);
52
- pm.customclose();
53
- return new Promise<string[]>((res, rej) => {
54
- res(features);
93
+ return new Promise<IFinalResults>((res, rej) => {
94
+ res({ features, failed });
55
95
  });
56
- // return features;
57
- // Promise.all([...artifacts, logPromise]).then(async () => {
58
- // console.log("hello world");
59
- // pm.customclose();
60
- // // we can't close the window becuase we might be taking a screenshot
61
- // // window.close();
62
- // // console.log(
63
- // // "(window as any).browser",
64
- // // JSON.stringify(await (window as any).browser)
65
- // // );
66
- // // var currentWindow = (await (window as any).browser).getCurrentWindow();
67
- // // window.close();
68
- // // var customWindow = window.open("", "_blank", "");
69
- // // customWindow.close();
70
- // // this.puppetMaster.browser.page
71
- // // window["customclose"]();
72
- // // console.log("goodbye", window["customclose"]());
73
- // });
74
96
  }
75
97
  }
76
98
 
@@ -0,0 +1,12 @@
1
+ import process from "process";
2
+
3
+ import { ITProject } from "./Project";
4
+
5
+ if (!process.argv[2]) {
6
+ console.log("You didn't pass a config file");
7
+ process.exit(-1);
8
+ } else {
9
+ import(process.cwd() + "/" + process.argv[2]).then((module) => {
10
+ new ITProject(module.default);
11
+ });
12
+ }
@@ -0,0 +1,20 @@
1
+ import { IBaseConfig } from "testeranto/src/lib/types.js";
2
+
3
+ const config: IBaseConfig = {
4
+ outdir: "docs",
5
+ tests: [],
6
+ debugger: true,
7
+ clearScreen: false,
8
+ devMode: true,
9
+ minify: false,
10
+ outbase: ".",
11
+ ports: ["3001"],
12
+ externals: [],
13
+ nodePlugins: [],
14
+ webPlugins: [],
15
+ featureIngestor: function (s: string): Promise<string> {
16
+ throw new Error("Function not implemented.");
17
+ },
18
+ };
19
+
20
+ export default config;
@@ -5,7 +5,6 @@ import type { ImportKind, Metafile, Plugin } from "esbuild";
5
5
  const otherInputs: Record<string, Set<string>> = {};
6
6
 
7
7
  const register = (entrypoint: string, sources: string[]): void => {
8
- console.log("register", entrypoint, sources);
9
8
  if (!otherInputs[entrypoint]) {
10
9
  otherInputs[entrypoint] = new Set();
11
10
  }
@@ -13,13 +12,18 @@ const register = (entrypoint: string, sources: string[]): void => {
13
12
  };
14
13
 
15
14
  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
- ];
15
+ const outputKey = Object.keys(meta.outputs).find((k) => {
16
+ return meta.outputs[k].entryPoint === key;
17
+ });
18
+
19
+ if (!outputKey) {
20
+ console.error("No outputkey found");
21
+ process.exit(-1);
22
+ }
23
+
24
+ return Object.keys(meta.outputs[outputKey].inputs).filter((k) =>
25
+ k.startsWith("src")
26
+ );
23
27
  }
24
28
 
25
29
  export default (
@@ -72,7 +76,20 @@ export default (
72
76
  platform,
73
77
  entryPoint.split(".").slice(0, -1).join("."),
74
78
  `featurePrompt.txt`
75
- ); // /read ${featuresPath}
79
+ );
80
+
81
+ const stderrPath = path.join(
82
+ "./docs/",
83
+ platform,
84
+ entryPoint.split(".").slice(0, -1).join("."),
85
+ `stderr.log`
86
+ );
87
+ const stdoutPath = path.join(
88
+ "./docs/",
89
+ platform,
90
+ entryPoint.split(".").slice(0, -1).join("."),
91
+ `stdout.log`
92
+ );
76
93
 
77
94
  if (result.metafile) {
78
95
  const addableFiles = tree(
@@ -87,26 +104,38 @@ export default (
87
104
  })
88
105
  .flat();
89
106
 
107
+ const typeErrorFiles = addableFiles.map(
108
+ (t) => `docs/types/${t}.type_errors.txt`
109
+ );
110
+
90
111
  fs.writeFileSync(
91
112
  promptPath,
92
113
  `
93
- ${[...addableFiles]
114
+ ${addableFiles
94
115
  .map((x) => {
95
116
  return `/add ${x}`;
96
117
  })
97
118
  .join("\n")}
98
- ${[...addableFiles]
119
+
120
+ ${typeErrorFiles
99
121
  .map((x) => {
100
- const f = `docs/ts/${x}.type_errors.txt`;
101
-
102
- if (fs.existsSync(f)) {
103
- return `/read ${f}`;
104
- }
122
+ // const f = `docs/types/${x}.type_errors.txt`;
123
+ return `/read ${x}`;
124
+ // if (fs.existsSync(f)) {
125
+ // return `/read ${f}`;
126
+ // }
105
127
  })
106
128
  .join("\n")}
129
+
107
130
  /read ${testPaths}
131
+ /read ${stdoutPath}
132
+ /read ${stderrPath}
133
+
108
134
  /load ${featuresPath}
109
- /code Fix the failing tests described in ${testPaths}. Correct any type signature errors. Implement any method which throws "Function not implemented."
135
+
136
+ /code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(
137
+ ", "
138
+ )}]. Implement any method which throws "Function not implemented."
110
139
  `
111
140
  );
112
141
  }
@@ -0,0 +1,19 @@
1
+ import fs from "fs";
2
+ import Init from "../dist/module/src/Init";
3
+ console.log("Initializing a testeranto project");
4
+
5
+ if (!process.argv[2]) {
6
+ console.log("You didn't pass a config file, so I will create one for you.");
7
+
8
+ fs.writeFileSync(
9
+ "testeranto.mts",
10
+ fs.readFileSync("node_modules/testeranto/src/defaultConfig.ts")
11
+ );
12
+ import(process.cwd() + "/" + "testeranto.mts").then((module) => {
13
+ Init(module.default);
14
+ });
15
+ } else {
16
+ import(process.cwd() + "/" + process.argv[2]).then((module) => {
17
+ Init(module.default);
18
+ });
19
+ }