testeranto 0.100.0 → 0.111.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 (226) hide show
  1. package/README.md +1 -0
  2. package/bundle.js +80 -30
  3. package/package.json +40 -32
  4. package/src/Footer.tsx +4 -0
  5. package/src/Init.ts +48 -0
  6. package/src/Node.ts +23 -17
  7. package/src/PM/index.ts +1 -1
  8. package/src/PM/main.ts +524 -156
  9. package/src/PM/node.ts +2 -2
  10. package/src/PM/web.ts +1 -1
  11. package/src/ReportClient.tsx +163 -0
  12. package/src/ReportServer.ts +21 -0
  13. package/src/SubPackages/react/component/node.ts +68 -24
  14. package/src/SubPackages/react/component/web.ts +68 -25
  15. package/src/SubPackages/react/jsx/index.ts +39 -18
  16. package/src/SubPackages/react/jsx/node.ts +12 -10
  17. package/src/SubPackages/react/jsx/web.ts +27 -14
  18. package/src/SubPackages/react-dom/component/node.ts +42 -50
  19. package/src/SubPackages/react-dom/component/web.ts +28 -10
  20. package/src/SubPackages/react-dom/jsx/node.ts +54 -56
  21. package/src/SubPackages/react-dom/jsx/web.ts +55 -42
  22. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +23 -7
  23. package/src/SubPackages/react-test-renderer/component/index.ts +38 -5
  24. package/src/SubPackages/react-test-renderer/component/node.ts +24 -5
  25. package/src/SubPackages/react-test-renderer/component/web.ts +22 -5
  26. package/src/SubPackages/react-test-renderer/fc/node.ts +41 -7
  27. package/src/SubPackages/react-test-renderer/fc/web.ts +43 -11
  28. package/src/SubPackages/react-test-renderer/jsx/index.ts +39 -16
  29. package/src/SubPackages/react-test-renderer/jsx/node.ts +8 -6
  30. package/src/SubPackages/react-test-renderer/jsx/web.ts +22 -5
  31. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +39 -6
  32. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +27 -10
  33. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +26 -12
  34. package/src/TestReport.tsx +176 -0
  35. package/src/Types.ts +63 -309
  36. package/src/Web.ts +24 -18
  37. package/src/build.ts +240 -0
  38. package/src/defaultConfig.ts +2 -1
  39. package/src/esbuildConfigs/eslint-formatter-testeranto.ts +5 -0
  40. package/src/esbuildConfigs/featuresPlugin.ts +0 -1
  41. package/src/esbuildConfigs/index.ts +1 -1
  42. package/src/esbuildConfigs/inputFilesPlugin.ts +2 -135
  43. package/src/esbuildConfigs/node.ts +4 -13
  44. package/src/esbuildConfigs/web.ts +3 -19
  45. package/src/init-docs.ts +2 -1
  46. package/src/lib/abstractBase.ts +82 -80
  47. package/src/lib/basebuilder.ts +57 -45
  48. package/src/lib/classBuilder.ts +15 -15
  49. package/src/lib/core.ts +44 -35
  50. package/src/lib/index.ts +47 -98
  51. package/src/lib/readme.md +12 -0
  52. package/src/lib/types.ts +53 -70
  53. package/src/run.ts +31 -0
  54. package/src/style.css +8 -0
  55. package/src/utils.ts +74 -2
  56. package/tsc.log +108 -0
  57. package/Bundle.Dockerfile +0 -52
  58. package/bin/init-docs.js +0 -24
  59. package/dist/common/dist/module/src/Init.js +0 -40
  60. package/dist/common/package.json +0 -3
  61. package/dist/common/src/Init.js +0 -40
  62. package/dist/common/src/Node.js +0 -27
  63. package/dist/common/src/PM/index.js +0 -7
  64. package/dist/common/src/PM/main.js +0 -941
  65. package/dist/common/src/PM/node.js +0 -128
  66. package/dist/common/src/PM/web.js +0 -121
  67. package/dist/common/src/SubPackages/puppeteer.js +0 -21
  68. package/dist/common/src/SubPackages/react/component/node.js +0 -19
  69. package/dist/common/src/SubPackages/react/component/web.js +0 -19
  70. package/dist/common/src/SubPackages/react/jsx/index.js +0 -33
  71. package/dist/common/src/SubPackages/react/jsx/node.js +0 -10
  72. package/dist/common/src/SubPackages/react/jsx/web.js +0 -10
  73. package/dist/common/src/SubPackages/react-dom/component/node.js +0 -101
  74. package/dist/common/src/SubPackages/react-dom/component/web.js +0 -67
  75. package/dist/common/src/SubPackages/react-dom/jsx/index.js +0 -2
  76. package/dist/common/src/SubPackages/react-dom/jsx/node.js +0 -39
  77. package/dist/common/src/SubPackages/react-dom/jsx/web.js +0 -117
  78. package/dist/common/src/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -44
  79. package/dist/common/src/SubPackages/react-test-renderer/component/index.js +0 -2
  80. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +0 -60
  81. package/dist/common/src/SubPackages/react-test-renderer/component/node.js +0 -8
  82. package/dist/common/src/SubPackages/react-test-renderer/component/web.js +0 -8
  83. package/dist/common/src/SubPackages/react-test-renderer/fc/node.js +0 -50
  84. package/dist/common/src/SubPackages/react-test-renderer/fc/web.js +0 -50
  85. package/dist/common/src/SubPackages/react-test-renderer/jsx/index.js +0 -63
  86. package/dist/common/src/SubPackages/react-test-renderer/jsx/node.js +0 -10
  87. package/dist/common/src/SubPackages/react-test-renderer/jsx/web.js +0 -10
  88. package/dist/common/src/SubPackages/react-test-renderer/jsx-promised/index.js +0 -42
  89. package/dist/common/src/SubPackages/react-test-renderer/jsx-promised/node.js +0 -10
  90. package/dist/common/src/SubPackages/react-test-renderer/jsx-promised/web.js +0 -10
  91. package/dist/common/src/Types.js +0 -2
  92. package/dist/common/src/Web.js +0 -49
  93. package/dist/common/src/cli.js +0 -439
  94. package/dist/common/src/cli2.js +0 -144
  95. package/dist/common/src/defaultConfig.js +0 -19
  96. package/dist/common/src/esbuildConfigs/featuresPlugin.js +0 -39
  97. package/dist/common/src/esbuildConfigs/index.js +0 -21
  98. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +0 -99
  99. package/dist/common/src/esbuildConfigs/node.js +0 -45
  100. package/dist/common/src/esbuildConfigs/web.js +0 -61
  101. package/dist/common/src/init-docs.js +0 -43
  102. package/dist/common/src/lib/abstractBase.js +0 -324
  103. package/dist/common/src/lib/basebuilder.js +0 -85
  104. package/dist/common/src/lib/classBuilder.js +0 -42
  105. package/dist/common/src/lib/core.js +0 -101
  106. package/dist/common/src/lib/index.js +0 -22
  107. package/dist/common/src/lib/types.js +0 -3
  108. package/dist/common/src/puppeteerConfiger.js +0 -24
  109. package/dist/common/src/utils.js +0 -16
  110. package/dist/common/src/web.html.js +0 -22
  111. package/dist/common/testeranto.js +0 -15
  112. package/dist/common/tsconfig.common.tsbuildinfo +0 -1
  113. package/dist/module/package.json +0 -3
  114. package/dist/module/src/Init.js +0 -35
  115. package/dist/module/src/Node.js +0 -20
  116. package/dist/module/src/PM/index.js +0 -3
  117. package/dist/module/src/PM/main.js +0 -911
  118. package/dist/module/src/PM/node.js +0 -121
  119. package/dist/module/src/PM/web.js +0 -117
  120. package/dist/module/src/SubPackages/puppeteer.js +0 -16
  121. package/dist/module/src/SubPackages/react/component/node.js +0 -14
  122. package/dist/module/src/SubPackages/react/component/web.js +0 -14
  123. package/dist/module/src/SubPackages/react/jsx/index.js +0 -27
  124. package/dist/module/src/SubPackages/react/jsx/node.js +0 -5
  125. package/dist/module/src/SubPackages/react/jsx/web.js +0 -5
  126. package/dist/module/src/SubPackages/react-dom/component/node.js +0 -93
  127. package/dist/module/src/SubPackages/react-dom/component/web.js +0 -62
  128. package/dist/module/src/SubPackages/react-dom/jsx/index.js +0 -1
  129. package/dist/module/src/SubPackages/react-dom/jsx/node.js +0 -31
  130. package/dist/module/src/SubPackages/react-dom/jsx/web.js +0 -89
  131. package/dist/module/src/SubPackages/react-test-renderer/MemoExoticComponent/node.js +0 -16
  132. package/dist/module/src/SubPackages/react-test-renderer/component/index.js +0 -1
  133. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +0 -31
  134. package/dist/module/src/SubPackages/react-test-renderer/component/node.js +0 -3
  135. package/dist/module/src/SubPackages/react-test-renderer/component/web.js +0 -3
  136. package/dist/module/src/SubPackages/react-test-renderer/fc/node.js +0 -22
  137. package/dist/module/src/SubPackages/react-test-renderer/fc/web.js +0 -22
  138. package/dist/module/src/SubPackages/react-test-renderer/jsx/index.js +0 -34
  139. package/dist/module/src/SubPackages/react-test-renderer/jsx/node.js +0 -5
  140. package/dist/module/src/SubPackages/react-test-renderer/jsx/web.js +0 -5
  141. package/dist/module/src/SubPackages/react-test-renderer/jsx-promised/index.js +0 -16
  142. package/dist/module/src/SubPackages/react-test-renderer/jsx-promised/node.js +0 -5
  143. package/dist/module/src/SubPackages/react-test-renderer/jsx-promised/web.js +0 -5
  144. package/dist/module/src/Types.js +0 -1
  145. package/dist/module/src/Web.js +0 -42
  146. package/dist/module/src/cli.js +0 -411
  147. package/dist/module/src/cli2.js +0 -116
  148. package/dist/module/src/defaultConfig.js +0 -17
  149. package/dist/module/src/esbuildConfigs/featuresPlugin.js +0 -34
  150. package/dist/module/src/esbuildConfigs/index.js +0 -19
  151. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +0 -94
  152. package/dist/module/src/esbuildConfigs/node.js +0 -40
  153. package/dist/module/src/esbuildConfigs/web.js +0 -56
  154. package/dist/module/src/init-docs.js +0 -15
  155. package/dist/module/src/lib/abstractBase.js +0 -316
  156. package/dist/module/src/lib/basebuilder.js +0 -81
  157. package/dist/module/src/lib/classBuilder.js +0 -38
  158. package/dist/module/src/lib/core.js +0 -98
  159. package/dist/module/src/lib/index.js +0 -18
  160. package/dist/module/src/lib/types.js +0 -2
  161. package/dist/module/src/puppeteerConfiger.js +0 -19
  162. package/dist/module/src/utils.js +0 -9
  163. package/dist/module/src/web.html.js +0 -20
  164. package/dist/module/testeranto.js +0 -13
  165. package/dist/module/tsconfig.module.tsbuildinfo +0 -1
  166. package/dist/prebuild/cli.mjs +0 -1491
  167. package/dist/prebuild/cli2.mjs +0 -918
  168. package/dist/prebuild/init-docs.mjs +0 -48
  169. package/dist/types/dist/module/src/Init.d.ts +0 -2
  170. package/dist/types/src/Init.d.ts +0 -2
  171. package/dist/types/src/Node.d.ts +0 -13
  172. package/dist/types/src/PM/index.d.ts +0 -34
  173. package/dist/types/src/PM/main.d.ts +0 -56
  174. package/dist/types/src/PM/node.d.ts +0 -42
  175. package/dist/types/src/PM/web.d.ts +0 -40
  176. package/dist/types/src/SubPackages/puppeteer.d.ts +0 -6
  177. package/dist/types/src/SubPackages/react/component/node.d.ts +0 -7
  178. package/dist/types/src/SubPackages/react/component/web.d.ts +0 -7
  179. package/dist/types/src/SubPackages/react/jsx/index.d.ts +0 -12
  180. package/dist/types/src/SubPackages/react/jsx/node.d.ts +0 -4
  181. package/dist/types/src/SubPackages/react/jsx/web.d.ts +0 -4
  182. package/dist/types/src/SubPackages/react-dom/component/node.d.ts +0 -12
  183. package/dist/types/src/SubPackages/react-dom/component/web.d.ts +0 -11
  184. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +0 -7
  185. package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +0 -6
  186. package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +0 -5
  187. package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -5
  188. package/dist/types/src/SubPackages/react-test-renderer/component/index.d.ts +0 -13
  189. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +0 -9
  190. package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +0 -8
  191. package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +0 -3
  192. package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +0 -8
  193. package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +0 -8
  194. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +0 -17
  195. package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +0 -9
  196. package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +0 -8
  197. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +0 -16
  198. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
  199. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
  200. package/dist/types/src/Types.d.ts +0 -90
  201. package/dist/types/src/Web.d.ts +0 -10
  202. package/dist/types/src/cli.d.ts +0 -1
  203. package/dist/types/src/cli2.d.ts +0 -1
  204. package/dist/types/src/defaultConfig.d.ts +0 -3
  205. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +0 -5
  206. package/dist/types/src/esbuildConfigs/index.d.ts +0 -4
  207. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +0 -7
  208. package/dist/types/src/esbuildConfigs/node.d.ts +0 -4
  209. package/dist/types/src/esbuildConfigs/web.d.ts +0 -4
  210. package/dist/types/src/init-docs.d.ts +0 -1
  211. package/dist/types/src/lib/abstractBase.d.ts +0 -110
  212. package/dist/types/src/lib/basebuilder.d.ts +0 -27
  213. package/dist/types/src/lib/classBuilder.d.ts +0 -7
  214. package/dist/types/src/lib/core.d.ts +0 -8
  215. package/dist/types/src/lib/index.d.ts +0 -60
  216. package/dist/types/src/lib/types.d.ts +0 -40
  217. package/dist/types/src/puppeteerConfiger.d.ts +0 -4
  218. package/dist/types/src/utils.d.ts +0 -2
  219. package/dist/types/src/web.html.d.ts +0 -2
  220. package/dist/types/testeranto.d.ts +0 -16
  221. package/dist/types/tsconfig.types.tsbuildinfo +0 -1
  222. package/docker-compose.yml +0 -37
  223. package/src/SubPackages/puppeteer.ts +0 -51
  224. package/src/cli.ts +0 -535
  225. package/src/cli2.ts +0 -157
  226. package/testeranto.ts +0 -13
package/src/build.ts ADDED
@@ -0,0 +1,240 @@
1
+ import fs, { watch } from "fs";
2
+ import path from "path";
3
+ import readline from "readline";
4
+ import { glob } from "glob";
5
+ import esbuild from "esbuild";
6
+
7
+ import esbuildNodeConfiger from "./esbuildConfigs/node.js";
8
+ import esbuildWebConfiger from "./esbuildConfigs/web.js";
9
+ import webHtmlFrame from "./web.html.js";
10
+ import {
11
+ ITestTypes,
12
+ IRunnables,
13
+ IBaseConfig,
14
+ IRunTime,
15
+ IBuiltConfig,
16
+ } from "./lib/index.js";
17
+
18
+ readline.emitKeypressEvents(process.stdin);
19
+ if (process.stdin.isTTY) process.stdin.setRawMode(true);
20
+
21
+ const getRunnables = (
22
+ tests: ITestTypes[],
23
+ payload = {
24
+ nodeEntryPoints: {},
25
+ webEntryPoints: {},
26
+ }
27
+ ): IRunnables => {
28
+ return tests.reduce((pt, cv, cndx, cry) => {
29
+ if (cv[1] === "node") {
30
+ pt.nodeEntryPoints[cv[0]] = path.resolve(
31
+ `./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
32
+ );
33
+ } else if (cv[1] === "web") {
34
+ pt.webEntryPoints[cv[0]] = path.resolve(
35
+ `./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
36
+ );
37
+ }
38
+
39
+ if (cv[3].length) {
40
+ getRunnables(cv[3], payload);
41
+ }
42
+
43
+ return pt;
44
+ }, payload as IRunnables);
45
+ };
46
+
47
+ import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
48
+ const rawConfig: IBaseConfig = module.default;
49
+
50
+ const getSecondaryEndpointsPoints = (runtime?: IRunTime): string[] => {
51
+ const meta = (ts: ITestTypes[], st: Set<string>): Set<string> => {
52
+ ts.forEach((t) => {
53
+ if (t[1] === runtime) {
54
+ st.add(t[0]);
55
+ }
56
+ if (Array.isArray(t[3])) {
57
+ meta(t[3], st);
58
+ }
59
+ });
60
+ return st;
61
+ };
62
+ return Array.from(meta(config.tests, new Set()));
63
+ };
64
+
65
+ const config: IBuiltConfig = {
66
+ ...rawConfig,
67
+ buildDir: process.cwd() + "/" + rawConfig.outdir,
68
+ };
69
+
70
+ let nodeDone: boolean = false;
71
+ let webDone: boolean = false;
72
+ let mode = config.devMode ? "DEV" : "PROD";
73
+ let status: "build" | "built" = "build";
74
+ // let pm: PM_Main | undefined = new PM_Main(config);
75
+ // const fileHashes = {};
76
+ const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
77
+
78
+ const onNodeDone = () => {
79
+ nodeDone = true;
80
+ onDone();
81
+ };
82
+
83
+ const onWebDone = () => {
84
+ webDone = true;
85
+ onDone();
86
+ };
87
+
88
+ const onDone = async () => {
89
+ if (nodeDone && webDone) {
90
+ status = "built";
91
+ }
92
+ if (nodeDone && webDone && status === "built") {
93
+ // Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
94
+ // console.log("watching", outputFile);
95
+ // try {
96
+ // watch(outputFile, async (filename) => {
97
+ // const hash = await fileHash(outputFile);
98
+ // if (fileHashes[k] !== hash) {
99
+ // fileHashes[k] = hash;
100
+ // console.log(`< ${filename} `);
101
+ // pm.launchNode(k, outputFile);
102
+ // }
103
+ // });
104
+ // } catch (e) {
105
+ // console.error(e);
106
+ // }
107
+ // });
108
+ // Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
109
+ // console.log("watching", outputFile);
110
+ // watch(outputFile, async (filename) => {
111
+ // const hash = await fileHash(outputFile);
112
+ // console.log(`< ${filename} ${hash}`);
113
+ // if (fileHashes[k] !== hash) {
114
+ // fileHashes[k] = hash;
115
+ // pm.launchWeb(k, outputFile);
116
+ // }
117
+ // });
118
+ // });
119
+ }
120
+
121
+ if (nodeDone && webDone && mode === "PROD") {
122
+ console.log("Testeranto-EsBuild is all done. Goodbye!");
123
+ process.exit();
124
+ } else {
125
+ if (mode === "PROD") {
126
+ console.log("waiting for tests to finish");
127
+ console.log(
128
+ JSON.stringify(
129
+ {
130
+ nodeDone: nodeDone,
131
+ webDone: webDone,
132
+ mode: mode,
133
+ },
134
+ null,
135
+ 2
136
+ )
137
+ );
138
+ } else {
139
+ console.log("waiting for tests to change");
140
+ }
141
+
142
+ if (config.devMode) {
143
+ console.log("ready and watching for changes...");
144
+ } else {
145
+ // pm.shutDown();
146
+ }
147
+ ////////////////////////////////////////////////////////////////////////////////
148
+ }
149
+ };
150
+
151
+ console.log(
152
+ `Press 'q' to shutdown gracefully. Press 'x' to shutdown forcefully.`
153
+ );
154
+ process.stdin.on("keypress", (str, key) => {
155
+ if (key.name === "q") {
156
+ console.log("Testeranto-Build is shutting down...");
157
+ mode = "PROD";
158
+ onDone();
159
+ }
160
+ if (key.name === "x") {
161
+ console.log("Testeranto-Build is shutting down forcefully...");
162
+ process.exit(-1);
163
+ }
164
+ });
165
+
166
+ fs.writeFileSync(
167
+ `${config.outdir}/testeranto.json`,
168
+ JSON.stringify(config, null, 2)
169
+ );
170
+
171
+ Promise.resolve(
172
+ Promise.all(
173
+ [...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
174
+ const sourceFileSplit = sourceFilePath.split("/");
175
+ const sourceDir = sourceFileSplit.slice(0, -1);
176
+ const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
177
+ const sourceFileNameMinusJs = sourceFileName
178
+ .split(".")
179
+ .slice(0, -1)
180
+ .join(".");
181
+
182
+ const htmlFilePath = path.normalize(
183
+ `${process.cwd()}/${config.outdir}/web/${sourceDir.join(
184
+ "/"
185
+ )}/${sourceFileNameMinusJs}.html`
186
+ );
187
+ const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
188
+
189
+ return fs.promises
190
+ .mkdir(path.dirname(htmlFilePath), { recursive: true })
191
+ .then((x) =>
192
+ fs.writeFileSync(
193
+ htmlFilePath,
194
+ webHtmlFrame(jsfilePath, htmlFilePath)
195
+ )
196
+ );
197
+ })
198
+ )
199
+ );
200
+
201
+ glob(`./${config.outdir}/chunk-*.mjs`, {
202
+ ignore: "node_modules/**",
203
+ }).then((chunks) => {
204
+ chunks.forEach((chunk) => {
205
+ fs.unlinkSync(chunk);
206
+ });
207
+ });
208
+
209
+ await Promise.all([
210
+ esbuild
211
+ .context(esbuildNodeConfiger(config, Object.keys(nodeEntryPoints)))
212
+ .then(async (nodeContext) => {
213
+ if (config.devMode) {
214
+ await nodeContext.watch().then((v) => {
215
+ onNodeDone();
216
+ });
217
+ } else {
218
+ nodeContext.rebuild().then((v) => {
219
+ onNodeDone();
220
+ });
221
+ }
222
+
223
+ return nodeContext;
224
+ }),
225
+ esbuild
226
+ .context(esbuildWebConfiger(config, Object.keys(webEntryPoints)))
227
+ .then(async (webContext) => {
228
+ if (config.devMode) {
229
+ await webContext.watch().then((v) => {
230
+ onWebDone();
231
+ });
232
+ } else {
233
+ webContext.rebuild().then((v) => {
234
+ onWebDone();
235
+ });
236
+ }
237
+ return webContext;
238
+ }),
239
+ ]);
240
+ });
@@ -1,6 +1,7 @@
1
- import { IBaseConfig } from "testeranto/src/lib/types.js";
1
+ import { IBaseConfig } from "./lib";
2
2
 
3
3
  const config: IBaseConfig = {
4
+ src: "src",
4
5
  outdir: "docs",
5
6
  tests: [],
6
7
  debugger: true,
@@ -0,0 +1,5 @@
1
+ import { LintResult } from "eslint/lib/linter";
2
+
3
+ export default function (results: LintResult[]) {
4
+ return JSON.stringify(results, null, 2);
5
+ }
@@ -1,4 +1,3 @@
1
- import fs from "fs";
2
1
  import path from "path";
3
2
 
4
3
  export default {
@@ -1,6 +1,6 @@
1
1
  import { BuildOptions } from "esbuild";
2
2
 
3
- import { IBaseConfig } from "../lib/types";
3
+ import { IBaseConfig } from "../lib";
4
4
 
5
5
  export default (config: IBaseConfig): BuildOptions => {
6
6
  return {
@@ -1,7 +1,5 @@
1
1
  import fs from "fs";
2
- import path from "path";
3
- import type { ImportKind, Metafile, Plugin } from "esbuild";
4
- import { spawn } from "child_process";
2
+ import type { Plugin } from "esbuild";
5
3
 
6
4
  const otherInputs: Record<string, Set<string>> = {};
7
5
 
@@ -12,21 +10,6 @@ const register = (entrypoint: string, sources: string[]): void => {
12
10
  sources.forEach((s) => otherInputs[entrypoint].add(s));
13
11
  };
14
12
 
15
- function tree(meta: Metafile, key: string) {
16
- const outputKey = Object.keys(meta.outputs).find((k) => {
17
- return meta.outputs[k].entryPoint === key;
18
- });
19
-
20
- if (!outputKey) {
21
- console.error("No outputkey found");
22
- process.exit(-1);
23
- }
24
-
25
- return Object.keys(meta.outputs[outputKey].inputs).filter((k) =>
26
- k.startsWith("src")
27
- );
28
- }
29
-
30
13
  export default (
31
14
  platform: "web" | "node",
32
15
  entryPoints: Set<string> | string[]
@@ -41,127 +24,11 @@ export default (
41
24
  name: "metafileWriter",
42
25
  setup(build) {
43
26
  build.onEnd((result) => {
27
+ // console.log("build.onEnd", entryPoints);
44
28
  fs.writeFileSync(
45
29
  `docs/${platform}/metafile.json`,
46
30
  JSON.stringify(result, null, 2)
47
31
  );
48
-
49
- if (result.errors.length === 0) {
50
- entryPoints.forEach((entryPoint) => {
51
- const filePath = path.join(
52
- "./docs/",
53
- platform,
54
- entryPoint.split(".").slice(0, -1).join("."),
55
- `inputFiles.json`
56
- );
57
- const dirName = path.dirname(filePath);
58
-
59
- if (!fs.existsSync(dirName)) {
60
- fs.mkdirSync(dirName, { recursive: true });
61
- }
62
-
63
- const promptPath = path.join(
64
- "./docs/",
65
- platform,
66
- entryPoint.split(".").slice(0, -1).join("."),
67
- `prompt.txt`
68
- );
69
- const testPaths = path.join(
70
- "./docs/",
71
- platform,
72
- entryPoint.split(".").slice(0, -1).join("."),
73
- `tests.json`
74
- );
75
- const featuresPath = path.join(
76
- "./docs/",
77
- platform,
78
- entryPoint.split(".").slice(0, -1).join("."),
79
- `featurePrompt.txt`
80
- );
81
-
82
- const stderrPath = path.join(
83
- "./docs/",
84
- platform,
85
- entryPoint.split(".").slice(0, -1).join("."),
86
- `stderr.log`
87
- );
88
- const stdoutPath = path.join(
89
- "./docs/",
90
- platform,
91
- entryPoint.split(".").slice(0, -1).join("."),
92
- `stdout.log`
93
- );
94
-
95
- if (result.metafile) {
96
- const addableFiles = tree(
97
- result.metafile,
98
- entryPoint.split("/").slice(1).join("/")
99
- )
100
- .map((y) => {
101
- if (otherInputs[y]) {
102
- return Array.from(otherInputs[y]);
103
- }
104
- return y;
105
- })
106
- .flat();
107
-
108
- const typeErrorFiles = addableFiles.map(
109
- (t) => `docs/types/${t}.type_errors.txt`
110
- );
111
-
112
- const lintPath = path.join(
113
- "./docs/",
114
- platform,
115
- entryPoint.split(".").slice(0, -1).join("."),
116
- `lint_errors.txt`
117
- );
118
- fs.writeFileSync(
119
- promptPath,
120
- `
121
- ${addableFiles
122
- .map((x) => {
123
- return `/add ${x}`;
124
- })
125
- .join("\n")}
126
-
127
- ${typeErrorFiles
128
- .map((x) => {
129
- return `/read ${x}`;
130
- })
131
- .join("\n")}
132
-
133
- /read ${lintPath}
134
- /read ${testPaths}
135
- /read ${stdoutPath}
136
- /read ${stderrPath}
137
-
138
- /load ${featuresPath}
139
-
140
- /code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files [${typeErrorFiles.join(
141
- ", "
142
- )}]. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPath}"
143
- `
144
- );
145
-
146
- const logContent: string[] = [];
147
- const tsc = spawn("eslint", addableFiles);
148
-
149
- tsc.stdout.on("data", (data) => {
150
- const lines = data.toString().split("\n");
151
- logContent.push(...lines);
152
- });
153
-
154
- tsc.stderr.on("data", (data) => {
155
- console.error(`stderr: ${data}`);
156
- process.exit(-1);
157
- });
158
-
159
- tsc.on("close", (code) => {
160
- fs.writeFileSync(lintPath, logContent.join("\n"));
161
- });
162
- }
163
- });
164
- }
165
32
  });
166
33
  },
167
34
  },
@@ -1,6 +1,6 @@
1
1
  import { BuildOptions } from "esbuild";
2
2
 
3
- import { IBaseConfig } from "../lib/types";
3
+ import { IBaseConfig } from "../lib/index.js";
4
4
 
5
5
  import baseEsBuildConfig from "./index.js";
6
6
  import inputFilesPlugin from "./inputFilesPlugin.js";
@@ -36,24 +36,13 @@ export default (
36
36
  },
37
37
  platform: "node",
38
38
 
39
- external: [
40
- // "testeranto.json",
41
- // "features.test.js",
42
- "react",
43
- // "events",
44
- // "ganache"
45
- ...config.externals,
46
- ],
39
+ external: ["react", ...config.externals],
47
40
 
48
41
  entryPoints: [...entryPoints],
49
42
  plugins: [
50
43
  featuresPlugin,
51
44
 
52
- ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
53
-
54
45
  inputFilesPluginFactory,
55
- // inputFilesPlugin("node", entryPoints),
56
-
57
46
  {
58
47
  name: "rebuild-notify",
59
48
  setup(build) {
@@ -69,6 +58,8 @@ export default (
69
58
  });
70
59
  },
71
60
  },
61
+
62
+ ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
72
63
  ],
73
64
  };
74
65
  };
@@ -1,9 +1,7 @@
1
1
  import { BuildOptions } from "esbuild";
2
2
  import path from "path";
3
3
 
4
- import pkg from "esbuild-plugin-markdown";
5
-
6
- import { IBaseConfig } from "../lib/types.js";
4
+ import { IBaseConfig } from "../lib/index.js";
7
5
 
8
6
  import baseEsBuildConfig from "./index.js";
9
7
  import inputFilesPlugin from "./inputFilesPlugin.js";
@@ -21,13 +19,6 @@ export default (
21
19
  return {
22
20
  ...baseEsBuildConfig(config),
23
21
 
24
- // inject: ["./node_modules/testeranto/dist/cjs-shim.js"],
25
- // banner: {
26
- // js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
27
- // },
28
-
29
- // splitting: true,
30
-
31
22
  outdir: config.outdir + "/web",
32
23
 
33
24
  alias: {
@@ -37,11 +28,6 @@ export default (
37
28
  metafile: true,
38
29
 
39
30
  external: [
40
- // "testeranto.json",
41
- // "features.test.ts",
42
- // "url",
43
- // "react",
44
-
45
31
  "path",
46
32
  "fs",
47
33
  "stream",
@@ -56,7 +42,6 @@ export default (
56
42
  "zlib",
57
43
  "crypto",
58
44
  "https",
59
-
60
45
  "util",
61
46
  "process",
62
47
  "dns",
@@ -68,9 +53,6 @@ export default (
68
53
 
69
54
  plugins: [
70
55
  featuresPlugin,
71
-
72
- // markdownPlugin({}),
73
- ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
74
56
  inputFilesPluginFactory,
75
57
  {
76
58
  name: "rebuild-notify",
@@ -87,6 +69,8 @@ export default (
87
69
  });
88
70
  },
89
71
  },
72
+
73
+ ...(config.nodePlugins.map((p) => p(register, entryPoints)) || []),
90
74
  ],
91
75
  };
92
76
  };
package/src/init-docs.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import fs from "fs";
2
- import Init from "../dist/module/src/Init";
2
+ import Init from "./Init";
3
+
3
4
  console.log("Initializing a testeranto project");
4
5
 
5
6
  if (!process.argv[2]) {