testeranto 0.90.0 → 0.100.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 (133) hide show
  1. package/bundle.js +4 -7
  2. package/dist/common/src/Node.js +5 -3
  3. package/dist/common/src/PM/main.js +254 -126
  4. package/dist/common/src/PM/node.js +20 -5
  5. package/dist/common/src/PM/web.js +19 -4
  6. package/dist/common/src/SubPackages/puppeteer.js +1 -1
  7. package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
  8. package/dist/common/src/SubPackages/react/jsx/node.js +2 -2
  9. package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
  10. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  11. package/dist/common/src/Web.js +25 -21
  12. package/dist/common/src/cli.js +439 -0
  13. package/dist/common/src/cli2.js +144 -0
  14. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -8
  15. package/dist/common/src/esbuildConfigs/node.js +1 -4
  16. package/dist/common/src/esbuildConfigs/web.js +1 -1
  17. package/dist/common/src/lib/abstractBase.js +31 -263
  18. package/dist/common/src/lib/basebuilder.js +1 -11
  19. package/dist/common/src/lib/classBuilder.js +1 -1
  20. package/dist/common/src/lib/core.js +8 -28
  21. package/dist/common/src/lib/types.js +1 -0
  22. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  23. package/dist/module/src/Node.js +5 -3
  24. package/dist/module/src/PM/main.js +254 -126
  25. package/dist/module/src/PM/node.js +20 -5
  26. package/dist/module/src/PM/web.js +19 -4
  27. package/dist/module/src/SubPackages/puppeteer.js +1 -1
  28. package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
  29. package/dist/module/src/SubPackages/react/jsx/node.js +2 -2
  30. package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
  31. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  32. package/dist/module/src/Web.js +25 -21
  33. package/dist/module/src/cli.js +411 -0
  34. package/dist/module/src/cli2.js +116 -0
  35. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -8
  36. package/dist/module/src/esbuildConfigs/node.js +1 -4
  37. package/dist/module/src/esbuildConfigs/web.js +1 -1
  38. package/dist/module/src/lib/abstractBase.js +31 -263
  39. package/dist/module/src/lib/basebuilder.js +1 -11
  40. package/dist/module/src/lib/classBuilder.js +1 -1
  41. package/dist/module/src/lib/core.js +8 -28
  42. package/dist/module/src/lib/types.js +1 -0
  43. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  44. package/dist/prebuild/cli.mjs +1491 -0
  45. package/dist/prebuild/{run-tests.mjs → cli2.mjs} +223 -212
  46. package/dist/types/src/Node.d.ts +6 -3
  47. package/dist/types/src/PM/index.d.ts +10 -2
  48. package/dist/types/src/PM/main.d.ts +14 -7
  49. package/dist/types/src/PM/node.d.ts +9 -2
  50. package/dist/types/src/PM/web.d.ts +9 -3
  51. package/dist/types/src/SubPackages/puppeteer.d.ts +1 -1
  52. package/dist/types/src/SubPackages/react/component/node.d.ts +1 -1
  53. package/dist/types/src/SubPackages/react/component/web.d.ts +1 -1
  54. package/dist/types/src/SubPackages/react/jsx/node.d.ts +3 -3
  55. package/dist/types/src/SubPackages/react/jsx/web.d.ts +2 -2
  56. package/dist/types/src/SubPackages/react-dom/component/node.d.ts +2 -2
  57. package/dist/types/src/SubPackages/react-dom/component/web.d.ts +1 -1
  58. package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +1 -1
  59. package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +2 -2
  60. package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
  61. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
  62. package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +2 -2
  63. package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +2 -2
  64. package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +2 -2
  65. package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +2 -2
  66. package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +3 -2
  67. package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +2 -2
  68. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +2 -2
  69. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +2 -2
  70. package/dist/types/src/Types.d.ts +60 -21
  71. package/dist/types/src/Web.d.ts +3 -3
  72. package/dist/types/src/lib/abstractBase.d.ts +6 -2
  73. package/dist/types/src/lib/core.d.ts +3 -3
  74. package/dist/types/src/lib/index.d.ts +1 -1
  75. package/dist/types/src/lib/types.d.ts +6 -30
  76. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  77. package/package.json +23 -20
  78. package/src/Node.ts +6 -3
  79. package/src/PM/index.ts +12 -8
  80. package/src/PM/main.ts +331 -165
  81. package/src/PM/node.ts +42 -7
  82. package/src/PM/web.ts +33 -5
  83. package/src/SubPackages/puppeteer.ts +1 -1
  84. package/src/SubPackages/react/jsx/index.ts +15 -7
  85. package/src/SubPackages/react/jsx/node.ts +18 -6
  86. package/src/SubPackages/react-dom/component/web.ts +28 -51
  87. package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
  88. package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
  89. package/src/Types.ts +362 -114
  90. package/src/Web.ts +45 -23
  91. package/src/cli.ts +535 -0
  92. package/src/cli2.ts +157 -0
  93. package/src/esbuildConfigs/inputFilesPlugin.ts +27 -9
  94. package/src/esbuildConfigs/node.ts +4 -7
  95. package/src/esbuildConfigs/web.ts +4 -3
  96. package/src/lib/abstractBase.ts +84 -291
  97. package/src/lib/basebuilder.ts +1 -12
  98. package/src/lib/classBuilder.ts +2 -1
  99. package/src/lib/core.ts +17 -29
  100. package/src/lib/types.ts +5 -177
  101. package/dist/common/src/Aider.js +0 -143
  102. package/dist/common/src/Project.js +0 -225
  103. package/dist/common/src/Puppeteer.js +0 -113
  104. package/dist/common/src/build-tests.js +0 -39
  105. package/dist/common/src/esbuildConfigs/features.js +0 -14
  106. package/dist/common/src/esbuildConfigs/report.js +0 -14
  107. package/dist/common/src/esbuildConfigs/tests.js +0 -13
  108. package/dist/common/src/run-tests.js +0 -39
  109. package/dist/module/src/Aider.js +0 -136
  110. package/dist/module/src/Project.js +0 -218
  111. package/dist/module/src/Puppeteer.js +0 -108
  112. package/dist/module/src/build-tests.js +0 -11
  113. package/dist/module/src/esbuildConfigs/features.js +0 -12
  114. package/dist/module/src/esbuildConfigs/report.js +0 -14
  115. package/dist/module/src/esbuildConfigs/tests.js +0 -11
  116. package/dist/module/src/run-tests.js +0 -11
  117. package/dist/prebuild/build-tests.mjs +0 -552
  118. package/dist/types/src/Aider.d.ts +0 -1
  119. package/dist/types/src/Project.d.ts +0 -12
  120. package/dist/types/src/Puppeteer.d.ts +0 -2
  121. package/dist/types/src/esbuildConfigs/features.d.ts +0 -4
  122. package/dist/types/src/esbuildConfigs/report.d.ts +0 -0
  123. package/dist/types/src/esbuildConfigs/tests.d.ts +0 -4
  124. package/src/Aider.ts +0 -168
  125. package/src/Project.ts +0 -291
  126. package/src/Puppeteer.ts +0 -145
  127. package/src/build-tests.ts +0 -12
  128. package/src/esbuildConfigs/features.ts +0 -17
  129. package/src/esbuildConfigs/report.ts +0 -15
  130. package/src/esbuildConfigs/tests.ts +0 -14
  131. package/src/run-tests.ts +0 -12
  132. /package/dist/types/src/{build-tests.d.ts → cli.d.ts} +0 -0
  133. /package/dist/types/src/{run-tests.d.ts → cli2.d.ts} +0 -0
@@ -1,218 +0,0 @@
1
- import { spawn } from "child_process";
2
- import esbuild from "esbuild";
3
- import fs from "fs";
4
- import path from "path";
5
- import readline from "readline";
6
- import { glob } from "glob";
7
- import esbuildNodeConfiger from "./esbuildConfigs/node.js";
8
- import esbuildWebConfiger from "./esbuildConfigs/web.js";
9
- import webHtmlFrame from "./web.html.js";
10
- readline.emitKeypressEvents(process.stdin);
11
- if (process.stdin.isTTY)
12
- process.stdin.setRawMode(true);
13
- const logContent = [];
14
- function parseTsErrors() {
15
- try {
16
- // const logContent = fs.readFileSync(logPath, "utf-8").split("\n");
17
- const regex = /(^src(.*?))\(\d*,\d*\): error/gm;
18
- const brokenFilesToLines = {};
19
- for (let i = 0; i < logContent.length - 1; i++) {
20
- let m;
21
- while ((m = regex.exec(logContent[i])) !== null) {
22
- // This is necessary to avoid infinite loops with zero-width matches
23
- if (m.index === regex.lastIndex) {
24
- regex.lastIndex++;
25
- }
26
- if (!brokenFilesToLines[m[1]]) {
27
- brokenFilesToLines[m[1]] = new Set();
28
- }
29
- brokenFilesToLines[m[1]].add(i);
30
- }
31
- }
32
- const final = Object.keys(brokenFilesToLines).reduce((mm, lm, ndx) => {
33
- mm[lm] = Array.from(brokenFilesToLines[lm]).map((l, ndx3) => {
34
- const a = Array.from(brokenFilesToLines[lm]);
35
- return Object.keys(a).reduce((mm2, lm2, ndx2) => {
36
- const acc = [];
37
- let j = a[lm2] + 1;
38
- let working = true;
39
- while (j < logContent.length - 1 && working) {
40
- if (!logContent[j].match(regex) &&
41
- working &&
42
- !logContent[j].match(/^..\/(.*?)\(\d*,\d*\)/)) {
43
- acc.push(logContent[j]);
44
- }
45
- else {
46
- working = false;
47
- }
48
- j++;
49
- }
50
- mm2[lm] = [logContent[l], ...acc];
51
- return mm2;
52
- }, {})[lm];
53
- });
54
- return mm;
55
- }, {});
56
- Object.keys(final).forEach((k) => {
57
- fs.mkdirSync(`./docs/types/${k.split("/").slice(0, -1).join("/")}`, {
58
- recursive: true,
59
- });
60
- fs.writeFileSync(`./docs/types/${k}.type_errors.txt`, final[k].flat().flat().join("\r\n"));
61
- });
62
- }
63
- catch (error) {
64
- console.error("Error reading or parsing the log file:", error);
65
- process.exit(1);
66
- }
67
- }
68
- const compile = () => {
69
- return new Promise((resolve, reject) => {
70
- const tsc = spawn("tsc", ["-noEmit"]);
71
- tsc.stdout.on("data", (data) => {
72
- // console.log(`stdout: ${data}`);
73
- const lines = data.toString().split("\n");
74
- logContent.push(...lines);
75
- });
76
- tsc.stderr.on("data", (data) => {
77
- // console.error(`stderr: ${data}`);
78
- });
79
- tsc.on("close", (code) => {
80
- parseTsErrors();
81
- resolve(`tsc process exited with code ${code}`);
82
- // if (code !== 0) {
83
- // resolve(`tsc process exited with code ${code}`);
84
- // // reject(`tsc process exited with code ${code}`);
85
- // } else {
86
- // resolve({});
87
- // }
88
- });
89
- });
90
- };
91
- export class ITProject {
92
- constructor(configs) {
93
- this.nodeDone = false;
94
- this.webDone = false;
95
- this.onNodeDone = () => {
96
- this.nodeDone = true;
97
- this.onDone();
98
- };
99
- this.onWebDone = () => {
100
- this.webDone = true;
101
- this.onDone();
102
- };
103
- this.onDone = () => {
104
- // console.log(this.nodeDone && this.webDone && this.mode === "PROD");
105
- if (this.nodeDone && this.webDone && this.mode === "PROD") {
106
- console.log("Testeranto-EsBuild is all done. Goodbye!");
107
- process.exit();
108
- }
109
- else {
110
- if (this.mode === "PROD") {
111
- console.log("waiting for tests to finish");
112
- console.log(JSON.stringify({
113
- nodeDone: this.nodeDone,
114
- webDone: this.webDone,
115
- mode: this.mode,
116
- }, null, 2));
117
- }
118
- else {
119
- console.log("waiting for tests to change");
120
- }
121
- console.log("press 'q' to quit");
122
- }
123
- };
124
- this.config = configs;
125
- this.mode = this.config.devMode ? "DEV" : "PROD";
126
- process.stdin.on("keypress", (str, key) => {
127
- if (key.name === "q") {
128
- console.log("Testeranto-EsBuild is shutting down...");
129
- this.mode = "PROD";
130
- this.onDone();
131
- }
132
- });
133
- fs.writeFileSync(`${this.config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, this.config), { buildDir: process.cwd() + "/" + this.config.outdir }), null, 2));
134
- compile();
135
- Promise.resolve(Promise.all([...this.getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
136
- const sourceFileSplit = sourceFilePath.split("/");
137
- const sourceDir = sourceFileSplit.slice(0, -1);
138
- const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
139
- const sourceFileNameMinusJs = sourceFileName
140
- .split(".")
141
- .slice(0, -1)
142
- .join(".");
143
- const htmlFilePath = path.normalize(`${process.cwd()}/${this.config.outdir}/web/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
144
- const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
145
- return fs.promises
146
- .mkdir(path.dirname(htmlFilePath), { recursive: true })
147
- .then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
148
- })));
149
- const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
150
- glob(`./${this.config.outdir}/chunk-*.mjs`, {
151
- ignore: "node_modules/**",
152
- }).then((chunks) => {
153
- chunks.forEach((chunk) => {
154
- fs.unlinkSync(chunk);
155
- });
156
- });
157
- Promise.all([
158
- esbuild
159
- .context(esbuildNodeConfiger(this.config, nodeEntryPoints))
160
- .then(async (nodeContext) => {
161
- if (this.config.devMode) {
162
- await nodeContext.watch().then((v) => {
163
- this.onNodeDone();
164
- });
165
- }
166
- else {
167
- nodeContext.rebuild().then((v) => {
168
- this.onNodeDone();
169
- });
170
- }
171
- return nodeContext;
172
- }),
173
- esbuild
174
- .context(esbuildWebConfiger(this.config, webEntryPoints))
175
- .then(async (webContext) => {
176
- if (this.config.devMode) {
177
- await webContext.watch().then((v) => {
178
- this.onWebDone();
179
- });
180
- }
181
- else {
182
- webContext.rebuild().then((v) => {
183
- this.onWebDone();
184
- });
185
- }
186
- return webContext;
187
- }),
188
- ]);
189
- }
190
- getSecondaryEndpointsPoints(runtime) {
191
- const meta = (ts, st) => {
192
- ts.forEach((t) => {
193
- if (t[1] === runtime) {
194
- st.add(t[0]);
195
- }
196
- if (Array.isArray(t[3])) {
197
- meta(t[3], st);
198
- }
199
- });
200
- return st;
201
- };
202
- return Array.from(meta(this.config.tests, new Set()));
203
- }
204
- }
205
- const getRunnables = (tests, payload = [new Set(), new Set()]) => {
206
- return tests.reduce((pt, cv, cndx, cry) => {
207
- if (cv[1] === "node") {
208
- pt[0].add(cv[0]);
209
- }
210
- else if (cv[1] === "web") {
211
- pt[1].add(cv[0]);
212
- }
213
- if (cv[3].length) {
214
- getRunnables(cv[3], payload);
215
- }
216
- return pt;
217
- }, payload);
218
- };
@@ -1,108 +0,0 @@
1
- import readline from "readline";
2
- import fs from "fs";
3
- import watch from "recursive-watch";
4
- import { PM_Main } from "./PM/main.js";
5
- import { destinationOfRuntime } from "./utils.js";
6
- readline.emitKeypressEvents(process.stdin);
7
- if (process.stdin.isTTY)
8
- process.stdin.setRawMode(true);
9
- export default async (partialConfig) => {
10
- const config = Object.assign(Object.assign({}, partialConfig), { buildDir: process.cwd() + "/" + partialConfig.outdir });
11
- fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2));
12
- const pm = new PM_Main(config);
13
- await pm.startPuppeteer({
14
- // timeout: 1,
15
- waitForInitialPage: false,
16
- executablePath:
17
- // process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
18
- "/opt/homebrew/bin/chromium",
19
- headless: false,
20
- dumpio: true,
21
- // timeout: 0,
22
- devtools: true,
23
- args: [
24
- "--auto-open-devtools-for-tabs",
25
- `--remote-debugging-port=3234`,
26
- // "--disable-features=IsolateOrigins,site-per-process",
27
- "--disable-site-isolation-trials",
28
- "--allow-insecure-localhost",
29
- "--allow-file-access-from-files",
30
- "--allow-running-insecure-content",
31
- "--disable-dev-shm-usage",
32
- "--disable-extensions",
33
- "--disable-gpu",
34
- "--disable-setuid-sandbox",
35
- "--disable-site-isolation-trials",
36
- "--disable-web-security",
37
- "--no-first-run",
38
- "--no-sandbox",
39
- "--no-startup-window",
40
- // "--no-zygote",
41
- "--reduce-security-for-testing",
42
- "--remote-allow-origins=*",
43
- "--unsafely-treat-insecure-origin-as-secure=*",
44
- // "--disable-features=IsolateOrigins",
45
- // "--remote-allow-origins=ws://localhost:3234",
46
- // "--single-process",
47
- // "--unsafely-treat-insecure-origin-as-secure",
48
- // "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
49
- // "--disk-cache-dir=/dev/null",
50
- // "--disk-cache-size=1",
51
- // "--start-maximized",
52
- ],
53
- }, ".");
54
- console.log("\n Puppeteer is running. Press 'q' to shutdown softly. Press 'x' to shutdown forcefully.\n");
55
- process.stdin.on("keypress", (str, key) => {
56
- if (key.name === "q") {
57
- pm.shutDown();
58
- // process.exit();
59
- }
60
- if (key.name === "x") {
61
- // pm.shutDown();
62
- process.exit(-1);
63
- }
64
- });
65
- config.tests.forEach(([test, runtime, tr, sidecars]) => {
66
- if (runtime === "node") {
67
- pm.launchNode(test, destinationOfRuntime(test, "node", config));
68
- }
69
- else if (runtime === "web") {
70
- pm.launchWeb(test, destinationOfRuntime(test, "web", config), sidecars);
71
- }
72
- else {
73
- console.error("runtime makes no sense", runtime);
74
- }
75
- });
76
- if (config.devMode) {
77
- console.log("ready and watching for changes...", config.buildDir);
78
- watch(config.buildDir, (eventType, changedFile) => {
79
- if (changedFile) {
80
- config.tests.forEach(([test, runtime, tr, sidecars]) => {
81
- if (eventType === "change" || eventType === "rename") {
82
- if (changedFile ===
83
- test
84
- .replace("./", "node/")
85
- .split(".")
86
- .slice(0, -1)
87
- .concat("mjs")
88
- .join(".")) {
89
- pm.launchNode(test, destinationOfRuntime(test, "node", config));
90
- }
91
- if (changedFile ===
92
- test
93
- .replace("./", "web/")
94
- .split(".")
95
- .slice(0, -1)
96
- .concat("mjs")
97
- .join(".")) {
98
- pm.launchWeb(test, destinationOfRuntime(test, "web", config), sidecars);
99
- }
100
- }
101
- });
102
- }
103
- });
104
- }
105
- else {
106
- pm.shutDown();
107
- }
108
- };
@@ -1,11 +0,0 @@
1
- import process from "process";
2
- import { ITProject } from "./Project";
3
- if (!process.argv[2]) {
4
- console.log("You didn't pass a config file");
5
- process.exit(-1);
6
- }
7
- else {
8
- import(process.cwd() + "/" + process.argv[2]).then((module) => {
9
- new ITProject(module.default);
10
- });
11
- }
@@ -1,12 +0,0 @@
1
- export default (config) => {
2
- return {
3
- bundle: true,
4
- entryPoints: [config.features],
5
- minify: config.minify === true,
6
- outbase: config.outbase,
7
- write: true,
8
- outfile: `${config.outdir}/features.test.js`,
9
- // external: ["graphology"],
10
- format: "esm",
11
- };
12
- };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- // import { BuildOptions } from "esbuild";
3
- // import { IBaseConfig } from "../lib/types";
4
- // export default (config: IBaseConfig): BuildOptions => {
5
- // return {
6
- // bundle: true,
7
- // entryPoints: ["./node_modules/testeranto/dist/module/report.js"],
8
- // minify: config.minify === true,
9
- // outbase: config.outbase,
10
- // write: true,
11
- // outfile: `${config.outdir}/report.js`,
12
- // external: ["tests.json", "features.test.js"],
13
- // };
14
- // };
@@ -1,11 +0,0 @@
1
- export default (config) => {
2
- return {
3
- bundle: true,
4
- entryPoints: [config.features],
5
- minify: config.minify === true,
6
- outbase: config.outbase,
7
- write: true,
8
- outfile: `${config.outdir}/tests.test.js`,
9
- // external: ["graphology"]
10
- };
11
- };
@@ -1,11 +0,0 @@
1
- import Puppeteer from "./Puppeteer.js";
2
- import process from "process";
3
- if (!process.argv[2]) {
4
- console.log("You didn't pass a config file");
5
- process.exit(-1);
6
- }
7
- else {
8
- import(process.cwd() + "/" + process.argv[2]).then((module) => {
9
- Puppeteer(module.default);
10
- });
11
- }