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.
Files changed (70) hide show
  1. package/dist/common/package.json +3 -0
  2. package/dist/common/src/Node.js +2 -0
  3. package/dist/common/src/PM/main.js +182 -79
  4. package/dist/common/src/PM/node.js +32 -6
  5. package/dist/common/src/PM/web.js +28 -54
  6. package/dist/common/src/Project.js +0 -3
  7. package/dist/common/src/Puppeteer.js +9 -51
  8. package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
  9. package/dist/common/src/Web.js +2 -0
  10. package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
  11. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -41
  12. package/dist/common/src/esbuildConfigs/node.js +10 -3
  13. package/dist/common/src/esbuildConfigs/web.js +6 -2
  14. package/dist/common/src/lib/abstractBase.js +343 -335
  15. package/dist/common/src/lib/basebuilder.js +7 -3
  16. package/dist/common/src/lib/core.js +1 -1
  17. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  18. package/dist/module/package.json +3 -0
  19. package/dist/module/src/Node.js +1 -1
  20. package/dist/module/src/PM/main.js +182 -79
  21. package/dist/module/src/PM/node.js +32 -6
  22. package/dist/module/src/PM/web.js +28 -51
  23. package/dist/module/src/Project.js +0 -3
  24. package/dist/module/src/Puppeteer.js +9 -51
  25. package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
  26. package/dist/module/src/Web.js +1 -1
  27. package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
  28. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -41
  29. package/dist/module/src/esbuildConfigs/node.js +10 -3
  30. package/dist/module/src/esbuildConfigs/web.js +6 -2
  31. package/dist/module/src/lib/abstractBase.js +343 -335
  32. package/dist/module/src/lib/basebuilder.js +7 -3
  33. package/dist/module/src/lib/core.js +1 -1
  34. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  35. package/dist/prebuild/Puppeteer.mjs +82033 -0
  36. package/dist/types/src/Node.d.ts +5 -1
  37. package/dist/types/src/PM/index.d.ts +10 -4
  38. package/dist/types/src/PM/main.d.ts +21 -9
  39. package/dist/types/src/PM/node.d.ts +11 -3
  40. package/dist/types/src/PM/web.d.ts +11 -2
  41. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
  42. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
  43. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
  44. package/dist/types/src/Types.d.ts +2 -2
  45. package/dist/types/src/Web.d.ts +5 -1
  46. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
  47. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
  48. package/dist/types/src/lib/abstractBase.d.ts +5 -5
  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 -41
  52. package/pupBuild.js +18 -0
  53. package/src/Node.ts +1 -3
  54. package/src/PM/index.ts +12 -3
  55. package/src/PM/main.ts +300 -164
  56. package/src/PM/node.ts +40 -6
  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 +1 -1
  63. package/src/esbuildConfigs/featuresPlugin.ts +43 -0
  64. package/src/esbuildConfigs/inputFilesPlugin.ts +98 -66
  65. package/src/esbuildConfigs/node.ts +18 -3
  66. package/src/esbuildConfigs/web.ts +14 -2
  67. package/src/lib/abstractBase.ts +381 -364
  68. package/src/lib/basebuilder.ts +7 -7
  69. package/src/lib/core.ts +1 -1
  70. package/src/lib/types.ts +13 -5
@@ -8,14 +8,9 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const recursive_watch_1 = __importDefault(require("recursive-watch"));
9
9
  const main_js_1 = require("./PM/main.js");
10
10
  const utils_js_1 = require("./utils.js");
11
- // var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
12
- // const node2web: Record<string, string[]> = {};
13
- // const web2node: Record<string, string[]> = {};
14
- // const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
15
11
  readline_1.default.emitKeypressEvents(process.stdin);
16
12
  if (process.stdin.isTTY)
17
13
  process.stdin.setRawMode(true);
18
- // let shutDownMode = false;
19
14
  exports.default = async (partialConfig) => {
20
15
  const config = Object.assign(Object.assign({}, partialConfig), { buildDir: process.cwd() + "/" + partialConfig.outdir });
21
16
  fs_1.default.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2));
@@ -29,9 +24,11 @@ exports.default = async (partialConfig) => {
29
24
  headless: true,
30
25
  dumpio: true,
31
26
  // timeout: 0,
27
+ devtools: true,
32
28
  args: [
33
- // "--auto-open-devtools-for-tabs",
34
- "--disable-features=IsolateOrigins,site-per-process",
29
+ "--auto-open-devtools-for-tabs",
30
+ `--remote-debugging-port=3234`,
31
+ // "--disable-features=IsolateOrigins,site-per-process",
35
32
  "--disable-site-isolation-trials",
36
33
  "--allow-insecure-localhost",
37
34
  "--allow-file-access-from-files",
@@ -54,18 +51,21 @@ exports.default = async (partialConfig) => {
54
51
  // "--single-process",
55
52
  // "--unsafely-treat-insecure-origin-as-secure",
56
53
  // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
57
- `--remote-debugging-port=3234`,
58
54
  // "--disk-cache-dir=/dev/null",
59
55
  // "--disk-cache-size=1",
60
56
  // "--start-maximized",
61
57
  ],
62
58
  }, ".");
63
- console.log("\n Puppeteer is running. Press 'q' to quit\n");
59
+ console.log("\n Puppeteer is running. Press 'q' to shutdown softly. Press 'x' to shutdown forcefully.\n");
64
60
  process.stdin.on("keypress", (str, key) => {
65
61
  if (key.name === "q") {
66
62
  pm.shutDown();
67
63
  // process.exit();
68
64
  }
65
+ if (key.name === "x") {
66
+ // pm.shutDown();
67
+ process.exit(-1);
68
+ }
69
69
  });
70
70
  config.tests.forEach(([test, runtime, tr, sidecars]) => {
71
71
  if (runtime === "node") {
@@ -110,46 +110,4 @@ exports.default = async (partialConfig) => {
110
110
  else {
111
111
  pm.shutDown();
112
112
  }
113
- // pm.browser.close();
114
- // does not work on linux
115
- // fs.watch(
116
- // config.buildDir,
117
- // {
118
- // recursive: true,
119
- // },
120
- // (eventType, changedFile) => {
121
- // if (changedFile) {
122
- // config.tests.forEach(([test, runtime, tr, sidecars]) => {
123
- // if (eventType === "change" || eventType === "rename") {
124
- // if (
125
- // changedFile ===
126
- // test
127
- // .replace("./", "node/")
128
- // .split(".")
129
- // .slice(0, -1)
130
- // .concat("mjs")
131
- // .join(".")
132
- // ) {
133
- // pm.launchNode(test, destinationOfRuntime(test, "node", config));
134
- // }
135
- // if (
136
- // changedFile ===
137
- // test
138
- // .replace("./", "web/")
139
- // .split(".")
140
- // .slice(0, -1)
141
- // .concat("mjs")
142
- // .join(".")
143
- // ) {
144
- // pm.launchWeb(
145
- // test,
146
- // destinationOfRuntime(test, "web", config),
147
- // sidecars
148
- // );
149
- // }
150
- // }
151
- // });
152
- // }
153
- // }
154
- // );
155
113
  };
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const react_1 = __importStar(require("react"));
30
30
  const react_2 = require("react");
31
- const client_1 = __importDefault(require("react-dom/client"));
31
+ const react_dom_1 = __importDefault(require("react-dom"));
32
32
  const Web_js_1 = __importDefault(require("../../../Web.js"));
33
33
  const TesterantoComponent = ({ done, innerComp, }) => {
34
34
  const myContainer = (0, react_1.useRef)(null);
@@ -44,7 +44,7 @@ exports.default = (testImplementations, testSpecifications, testInput) => {
44
44
  return await new Promise((resolve, rej) => {
45
45
  const htmlElement = document.getElementById("root");
46
46
  if (htmlElement) {
47
- const domRoot = client_1.default.createRoot(htmlElement);
47
+ const domRoot = react_dom_1.default.createRoot(htmlElement);
48
48
  domRoot.render((0, react_2.createElement)(TesterantoComponent, {
49
49
  // ...initialProps,
50
50
  innerComp: reactElement,
@@ -84,17 +84,17 @@ exports.default = (testImplementations, testSpecifications, testInput) => {
84
84
  });
85
85
  },
86
86
  andWhen: function (s, whenCB, tr, utils) {
87
- return new Promise((resolve, rej) => {
88
- console.log("mark9", s, whenCB);
89
- resolve(whenCB(s, utils));
90
- // process.nextTick(() => {
91
- // resolve(whenCB()(s));
92
- // });
93
- });
87
+ return whenCB(s, utils);
88
+ // return new Promise(async (resolve, rej) => {
89
+ // // resolve(await whenCB(s, utils));
90
+ // // process.nextTick(() => {
91
+ // // resolve(whenCB()(s));
92
+ // // });
93
+ // });
94
94
  },
95
- butThen: async function (s, thenCB) {
95
+ butThen: async function (s, thenCB, tr, utils) {
96
96
  return new Promise((resolve, rej) => {
97
- resolve(thenCB(s));
97
+ resolve(thenCB(s, utils));
98
98
  });
99
99
  },
100
100
  afterEach: async function (store, ndx, artificer) {
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WebTesteranto = void 0;
6
7
  const web_1 = require("./PM/web");
7
8
  const core_js_1 = __importDefault(require("./lib/core.js"));
8
9
  const index_js_1 = require("./lib/index.js");
@@ -38,6 +39,7 @@ class WebTesteranto extends core_js_1.default {
38
39
  // });
39
40
  }
40
41
  }
42
+ exports.WebTesteranto = WebTesteranto;
41
43
  exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
42
44
  return new WebTesteranto(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
43
45
  };
@@ -0,0 +1,39 @@
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 path_1 = __importDefault(require("path"));
7
+ exports.default = {
8
+ name: "feature-markdown",
9
+ setup(build) {
10
+ build.onResolve({ filter: /\.md$/ }, (args) => {
11
+ if (args.resolveDir === "")
12
+ return;
13
+ return {
14
+ path: path_1.default.isAbsolute(args.path)
15
+ ? args.path
16
+ : path_1.default.join(args.resolveDir, args.path),
17
+ namespace: "feature-markdown",
18
+ };
19
+ });
20
+ build.onLoad({ filter: /.*/, namespace: "feature-markdown" }, async (args) => {
21
+ // const markdownContent = new TextDecoder().decode(
22
+ // await fs.readFileSync(args.path)
23
+ // );
24
+ // markdownHTML = marked(markdownContent, options?.markedOptions);
25
+ return {
26
+ contents: `file://${args.path}`,
27
+ loader: "text",
28
+ // contents: JSON.stringify({ path: args.path }),
29
+ // loader: "json",
30
+ // contents: JSON.stringify({
31
+ // // html: markdownHTML,
32
+ // raw: markdownContent,
33
+ // filename: args.path, //path.basename(args.path),
34
+ // }),
35
+ // loader: "json",
36
+ };
37
+ });
38
+ },
39
+ };
@@ -5,52 +5,73 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
7
  const path_1 = __importDefault(require("path"));
8
+ const otherInputs = {};
9
+ const register = (entrypoint, sources) => {
10
+ console.log("register", entrypoint, sources);
11
+ if (!otherInputs[entrypoint]) {
12
+ otherInputs[entrypoint] = new Set();
13
+ }
14
+ sources.forEach((s) => otherInputs[entrypoint].add(s));
15
+ };
16
+ function tree(meta, key) {
17
+ return [
18
+ key,
19
+ ...meta.inputs[key].imports
20
+ .filter((x) => x.external !== true)
21
+ .filter((x) => x.path.split("/")[0] !== "node_modules")
22
+ .map((f) => f.path),
23
+ ];
24
+ }
8
25
  exports.default = (platform, entryPoints) => {
9
26
  return {
10
- name: "metafileWriter",
11
- setup(build) {
12
- build.onEnd((result) => {
13
- if (result.errors.length === 0) {
14
- entryPoints.forEach((entryPoint) => {
15
- const filePath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `inputFiles.json`);
16
- const promptPath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `prompt.txt`);
17
- const testPaths = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `tests.json`);
18
- const featuresPath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `features.json`);
19
- const dirName = path_1.default.dirname(filePath);
20
- if (!fs_1.default.existsSync(dirName)) {
21
- fs_1.default.mkdirSync(dirName, { recursive: true });
22
- }
23
- const j = Object.keys(Object.keys(result.metafile.outputs)
24
- .filter((s) => {
25
- if (!result.metafile.outputs[s].entryPoint) {
26
- return false;
27
+ register,
28
+ inputFilesPluginFactory: {
29
+ name: "metafileWriter",
30
+ setup(build) {
31
+ build.onEnd((result) => {
32
+ fs_1.default.writeFileSync(`docs/${platform}/metafile.json`, JSON.stringify(result, null, 2));
33
+ if (result.errors.length === 0) {
34
+ entryPoints.forEach((entryPoint) => {
35
+ const filePath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `inputFiles.json`);
36
+ const dirName = path_1.default.dirname(filePath);
37
+ if (!fs_1.default.existsSync(dirName)) {
38
+ fs_1.default.mkdirSync(dirName, { recursive: true });
27
39
  }
28
- return (path_1.default.resolve(result.metafile.outputs[s].entryPoint) ===
29
- path_1.default.resolve(entryPoint));
30
- })
31
- .reduce((mm, el) => {
32
- mm.push(result.metafile.outputs[el].inputs);
33
- return mm;
34
- }, [])[0]).filter((f) => {
35
- const regex = /^src\/.*/g;
36
- const matches = f.match(regex);
37
- const passes = (matches === null || matches === void 0 ? void 0 : matches.length) === 1;
38
- return passes;
39
- });
40
- fs_1.default.writeFileSync(filePath, JSON.stringify(j));
41
- fs_1.default.writeFileSync(promptPath, `
42
- ${j
43
- .map((x) => {
44
- return `/add ${x}`;
45
- })
46
- .join("\n")}
40
+ const promptPath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `prompt.txt`);
41
+ const testPaths = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `tests.json`);
42
+ const featuresPath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `featurePrompt.txt`); // /read ${featuresPath}
43
+ if (result.metafile) {
44
+ const addableFiles = tree(result.metafile, entryPoint.split("/").slice(1).join("/"))
45
+ .map((y) => {
46
+ if (otherInputs[y]) {
47
+ return Array.from(otherInputs[y]);
48
+ }
49
+ return y;
50
+ })
51
+ .flat();
52
+ fs_1.default.writeFileSync(promptPath, `
53
+ ${[...addableFiles]
54
+ .map((x) => {
55
+ return `/add ${x}`;
56
+ })
57
+ .join("\n")}
58
+ ${[...addableFiles]
59
+ .map((x) => {
60
+ const f = `docs/ts/${x}.type_errors.txt`;
61
+ if (fs_1.default.existsSync(f)) {
62
+ return `/read ${f}`;
63
+ }
64
+ })
65
+ .join("\n")}
47
66
  /read ${testPaths}
48
- /read ${featuresPath}
49
- /code fix the failing tests described in ${testPaths}.
67
+ /load ${featuresPath}
68
+ /code Fix the failing tests described in ${testPaths}. Correct any type signature errors. Implement any method which throws "Function not implemented."
50
69
  `);
51
- });
52
- }
53
- });
70
+ }
71
+ });
72
+ }
73
+ });
74
+ },
54
75
  },
55
76
  };
56
77
  };
@@ -5,7 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const index_js_1 = __importDefault(require("./index.js"));
7
7
  const inputFilesPlugin_js_1 = __importDefault(require("./inputFilesPlugin.js"));
8
+ const featuresPlugin_1 = __importDefault(require("./featuresPlugin"));
8
9
  exports.default = (config, entryPoints) => {
10
+ const { inputFilesPluginFactory, register } = (0, inputFilesPlugin_js_1.default)("node", entryPoints);
11
+ // const inputFilesPluginFactory = inputFilesPlugin("node", entryPoints);
12
+ // const register = (x) => x;
9
13
  return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), { splitting: true, outdir: config.outdir + "/node",
10
14
  // inject: [`./node_modules/testeranto/dist/cjs-shim.js`],
11
15
  metafile: true, supported: {
@@ -17,13 +21,16 @@ exports.default = (config, entryPoints) => {
17
21
  }, platform: "node", external: [
18
22
  // "testeranto.json",
19
23
  // "features.test.js",
20
- // "react",
24
+ "react",
21
25
  // "events",
22
26
  // "ganache"
23
27
  ...config.externals,
24
28
  ], entryPoints: [...entryPoints], plugins: [
25
- ...(config.nodePlugins || []),
26
- (0, inputFilesPlugin_js_1.default)("node", entryPoints),
29
+ featuresPlugin_1.default,
30
+ // markdownPlugin({}),
31
+ ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
32
+ inputFilesPluginFactory,
33
+ // inputFilesPlugin("node", entryPoints),
27
34
  {
28
35
  name: "rebuild-notify",
29
36
  setup(build) {
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const index_js_1 = __importDefault(require("./index.js"));
8
8
  const inputFilesPlugin_js_1 = __importDefault(require("./inputFilesPlugin.js"));
9
+ const featuresPlugin_js_1 = __importDefault(require("./featuresPlugin.js"));
9
10
  exports.default = (config, entryPoints) => {
11
+ const { inputFilesPluginFactory, register } = (0, inputFilesPlugin_js_1.default)("web", entryPoints);
10
12
  return Object.assign(Object.assign({}, (0, index_js_1.default)(config)), {
11
13
  // inject: ["./node_modules/testeranto/dist/cjs-shim.js"],
12
14
  // banner: {
@@ -38,8 +40,10 @@ exports.default = (config, entryPoints) => {
38
40
  "process",
39
41
  "dns",
40
42
  ], platform: "browser", entryPoints: [...entryPoints], plugins: [
41
- ...(config.webPlugins || []),
42
- (0, inputFilesPlugin_js_1.default)("web", entryPoints),
43
+ featuresPlugin_js_1.default,
44
+ // markdownPlugin({}),
45
+ ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
46
+ inputFilesPluginFactory,
43
47
  {
44
48
  name: "rebuild-notify",
45
49
  setup(build) {