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
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useRef } from "react";
2
2
  import { createElement } from "react";
3
- import ReactDom from "react-dom/client";
3
+ import ReactDom from "react-dom";
4
4
  import Testeranto from "../../../Web.js";
5
5
  const TesterantoComponent = ({ done, innerComp, }) => {
6
6
  const myContainer = useRef(null);
@@ -56,17 +56,17 @@ export default (testImplementations, testSpecifications, testInput) => {
56
56
  });
57
57
  },
58
58
  andWhen: function (s, whenCB, tr, utils) {
59
- return new Promise((resolve, rej) => {
60
- console.log("mark9", s, whenCB);
61
- resolve(whenCB(s, utils));
62
- // process.nextTick(() => {
63
- // resolve(whenCB()(s));
64
- // });
65
- });
59
+ return whenCB(s, utils);
60
+ // return new Promise(async (resolve, rej) => {
61
+ // // resolve(await whenCB(s, utils));
62
+ // // process.nextTick(() => {
63
+ // // resolve(whenCB()(s));
64
+ // // });
65
+ // });
66
66
  },
67
- butThen: async function (s, thenCB) {
67
+ butThen: async function (s, thenCB, tr, utils) {
68
68
  return new Promise((resolve, rej) => {
69
- resolve(thenCB(s));
69
+ resolve(thenCB(s, utils));
70
70
  });
71
71
  },
72
72
  afterEach: async function (store, ndx, artificer) {
@@ -1,15 +1,19 @@
1
1
  import { PM_Web } from "./PM/web";
2
2
  import Testeranto from "./lib/core.js";
3
3
  import { defaultTestResourceRequirement, } from "./lib/index.js";
4
- class WebTesteranto extends Testeranto {
4
+ export class WebTesteranto extends Testeranto {
5
5
  constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
6
6
  super(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
7
7
  }
8
8
  async receiveTestResourceConfig(partialTestResource) {
9
9
  const t = partialTestResource; //JSON.parse(partialTestResource);
10
10
  const pm = new PM_Web(t);
11
- const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
11
+ const { failed, artifacts, logPromise, features } = await this.testJobs[0].receiveTestResourceConfig(pm);
12
12
  pm.customclose();
13
+ return new Promise((res, rej) => {
14
+ res(features);
15
+ });
16
+ // return features;
13
17
  // Promise.all([...artifacts, logPromise]).then(async () => {
14
18
  // console.log("hello world");
15
19
  // pm.customclose();
@@ -0,0 +1,34 @@
1
+ import path from "path";
2
+ export default {
3
+ name: "feature-markdown",
4
+ setup(build) {
5
+ build.onResolve({ filter: /\.md$/ }, (args) => {
6
+ if (args.resolveDir === "")
7
+ return;
8
+ return {
9
+ path: path.isAbsolute(args.path)
10
+ ? args.path
11
+ : path.join(args.resolveDir, args.path),
12
+ namespace: "feature-markdown",
13
+ };
14
+ });
15
+ build.onLoad({ filter: /.*/, namespace: "feature-markdown" }, async (args) => {
16
+ // const markdownContent = new TextDecoder().decode(
17
+ // await fs.readFileSync(args.path)
18
+ // );
19
+ // markdownHTML = marked(markdownContent, options?.markedOptions);
20
+ return {
21
+ contents: `file://${args.path}`,
22
+ loader: "text",
23
+ // contents: JSON.stringify({ path: args.path }),
24
+ // loader: "json",
25
+ // contents: JSON.stringify({
26
+ // // html: markdownHTML,
27
+ // raw: markdownContent,
28
+ // filename: args.path, //path.basename(args.path),
29
+ // }),
30
+ // loader: "json",
31
+ };
32
+ });
33
+ },
34
+ };
@@ -1,74 +1,72 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ const otherInputs = {};
4
+ const register = (entrypoint, sources) => {
5
+ console.log("register", entrypoint, sources);
6
+ if (!otherInputs[entrypoint]) {
7
+ otherInputs[entrypoint] = new Set();
8
+ }
9
+ sources.forEach((s) => otherInputs[entrypoint].add(s));
10
+ };
11
+ function tree(meta, key) {
12
+ return [
13
+ key,
14
+ ...meta.inputs[key].imports
15
+ .filter((x) => x.external !== true)
16
+ .filter((x) => x.path.split("/")[0] !== "node_modules")
17
+ .map((f) => f.path),
18
+ ];
19
+ }
3
20
  export default (platform, entryPoints) => {
4
21
  return {
5
- name: "metafileWriter",
6
- setup(build) {
7
- build.onEnd((result) => {
8
- if (result.errors.length === 0) {
9
- entryPoints.forEach((entryPoint) => {
10
- const filePath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `inputFiles.json`);
11
- const promptPath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `prompt.txt`);
12
- const testPaths = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `tests.json`);
13
- const dirName = path.dirname(filePath);
14
- if (!fs.existsSync(dirName)) {
15
- fs.mkdirSync(dirName, { recursive: true });
16
- }
17
- const j = Object.keys(Object.keys(result.metafile.outputs)
18
- .filter((s) => {
19
- if (!result.metafile.outputs[s].entryPoint) {
20
- return false;
22
+ register,
23
+ inputFilesPluginFactory: {
24
+ name: "metafileWriter",
25
+ setup(build) {
26
+ build.onEnd((result) => {
27
+ fs.writeFileSync(`docs/${platform}/metafile.json`, JSON.stringify(result, null, 2));
28
+ if (result.errors.length === 0) {
29
+ entryPoints.forEach((entryPoint) => {
30
+ const filePath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `inputFiles.json`);
31
+ const dirName = path.dirname(filePath);
32
+ if (!fs.existsSync(dirName)) {
33
+ fs.mkdirSync(dirName, { recursive: true });
21
34
  }
22
- return (path.resolve(result.metafile.outputs[s].entryPoint) ===
23
- path.resolve(entryPoint));
24
- })
25
- .reduce((mm, el) => {
26
- mm.push(result.metafile.outputs[el].inputs);
27
- return mm;
28
- }, [])[0]).filter((f) => {
29
- const regex = /^src\/.*/g;
30
- const matches = f.match(regex);
31
- const passes = (matches === null || matches === void 0 ? void 0 : matches.length) === 1;
32
- return passes;
33
- });
34
- // .filter((f: string) => {
35
- // const regex = /.*\.test\..*/g;
36
- // const matches = f.match(regex);
37
- // const passes = matches?.length === 1;
38
- // return !passes;
39
- // })
40
- const jsonContent = JSON.stringify(j);
41
- fs.writeFileSync(filePath, jsonContent);
42
- fs.writeFileSync(promptPath, `
43
- ${j
44
- .map((x) => {
45
- return `/add ${x}`;
46
- })
47
- .join("\n")}
35
+ const promptPath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `prompt.txt`);
36
+ const testPaths = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `tests.json`);
37
+ const featuresPath = path.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `featurePrompt.txt`); // /read ${featuresPath}
38
+ if (result.metafile) {
39
+ const addableFiles = tree(result.metafile, entryPoint.split("/").slice(1).join("/"))
40
+ .map((y) => {
41
+ if (otherInputs[y]) {
42
+ return Array.from(otherInputs[y]);
43
+ }
44
+ return y;
45
+ })
46
+ .flat();
47
+ fs.writeFileSync(promptPath, `
48
+ ${[...addableFiles]
49
+ .map((x) => {
50
+ return `/add ${x}`;
51
+ })
52
+ .join("\n")}
53
+ ${[...addableFiles]
54
+ .map((x) => {
55
+ const f = `docs/ts/${x}.type_errors.txt`;
56
+ if (fs.existsSync(f)) {
57
+ return `/read ${f}`;
58
+ }
59
+ })
60
+ .join("\n")}
48
61
  /read ${testPaths}
49
-
50
- /code fix the failing tests described in ${filePath}.
62
+ /load ${featuresPath}
63
+ /code Fix the failing tests described in ${testPaths}. Correct any type signature errors. Implement any method which throws "Function not implemented."
51
64
  `);
52
- // fs.writeFileSync(
53
- // promptPath,
54
- // `
55
- // from aider.coders import Coder
56
- // from aider.models import Model
57
- // import os
58
- // model = Model("deepseek")
59
- // coder = Coder.create(main_model=model)
60
- // coder.run("/read-only", "${testPaths}")
61
- // ${j
62
- // .map((x) => {
63
- // return `coder.run("/add", "${x}")`;
64
- // })
65
- // .join("\n")}
66
- // coder.run("fix the failing tests described in ${filePath}.")
67
- // `
68
- // );
69
- });
70
- }
71
- });
65
+ }
66
+ });
67
+ }
68
+ });
69
+ },
72
70
  },
73
71
  };
74
72
  };
@@ -1,6 +1,10 @@
1
1
  import baseEsBuildConfig from "./index.js";
2
2
  import inputFilesPlugin from "./inputFilesPlugin.js";
3
+ import featuresPlugin from "./featuresPlugin";
3
4
  export default (config, entryPoints) => {
5
+ const { inputFilesPluginFactory, register } = inputFilesPlugin("node", entryPoints);
6
+ // const inputFilesPluginFactory = inputFilesPlugin("node", entryPoints);
7
+ // const register = (x) => x;
4
8
  return Object.assign(Object.assign({}, baseEsBuildConfig(config)), { splitting: true, outdir: config.outdir + "/node",
5
9
  // inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
6
10
  metafile: true, supported: {
@@ -12,13 +16,16 @@ export default (config, entryPoints) => {
12
16
  }, platform: "node", external: [
13
17
  // "testeranto.json",
14
18
  // "features.test.js",
15
- // "react",
19
+ "react",
16
20
  // "events",
17
21
  // "ganache"
18
22
  ...config.externals,
19
23
  ], entryPoints: [...entryPoints], plugins: [
20
- ...(config.nodePlugins || []),
21
- inputFilesPlugin("node", entryPoints),
24
+ featuresPlugin,
25
+ // markdownPlugin({}),
26
+ ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
27
+ inputFilesPluginFactory,
28
+ // inputFilesPlugin("node", entryPoints),
22
29
  {
23
30
  name: "rebuild-notify",
24
31
  setup(build) {
@@ -1,7 +1,9 @@
1
1
  import path from "path";
2
2
  import baseEsBuildConfig from "./index.js";
3
3
  import inputFilesPlugin from "./inputFilesPlugin.js";
4
+ import featuresPlugin from "./featuresPlugin.js";
4
5
  export default (config, entryPoints) => {
6
+ const { inputFilesPluginFactory, register } = inputFilesPlugin("web", entryPoints);
5
7
  return Object.assign(Object.assign({}, baseEsBuildConfig(config)), {
6
8
  // inject: ["./node_modules/testeranto/dist/cjs-shim.js"],
7
9
  // banner: {
@@ -33,8 +35,10 @@ export default (config, entryPoints) => {
33
35
  "process",
34
36
  "dns",
35
37
  ], platform: "browser", entryPoints: [...entryPoints], plugins: [
36
- ...(config.webPlugins || []),
37
- inputFilesPlugin("web", entryPoints),
38
+ featuresPlugin,
39
+ // markdownPlugin({}),
40
+ ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
41
+ inputFilesPluginFactory,
38
42
  {
39
43
  name: "rebuild-notify",
40
44
  setup(build) {