testeranto 0.205.0 → 0.206.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 (48) hide show
  1. package/Dockerfile.mothership +14 -4
  2. package/Dockerfile.node +5 -3
  3. package/bundle.js +5 -4
  4. package/dist/common/src/app/backend/PM_0.js +3 -0
  5. package/dist/common/src/app/backend/PM_1_WithProcesses.js +2 -0
  6. package/dist/common/src/app/backend/PM_2_WithTCP.js +2 -0
  7. package/dist/common/src/app/backend/PM_WithHelpo.js +1 -0
  8. package/dist/common/src/app/backend/main.js +27 -26
  9. package/dist/common/src/app/frontend/useFs.js +2 -1
  10. package/dist/common/src/mothership/mothership.js +197 -0
  11. package/dist/common/src/testeranto.js +31 -42
  12. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  13. package/dist/module/src/app/backend/PM_0.js +3 -0
  14. package/dist/module/src/app/backend/PM_1_WithProcesses.js +2 -0
  15. package/dist/module/src/app/backend/PM_2_WithTCP.js +2 -0
  16. package/dist/module/src/app/backend/PM_WithHelpo.js +1 -0
  17. package/dist/module/src/app/backend/main.js +27 -26
  18. package/dist/module/src/app/frontend/useFs.js +2 -1
  19. package/dist/module/src/mothership/mothership.js +196 -0
  20. package/dist/module/src/testeranto.js +31 -42
  21. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  22. package/dist/prebuild/App.css +68 -12
  23. package/dist/prebuild/App.js +8 -91
  24. package/dist/prebuild/mothership.mjs +4 -0
  25. package/dist/types/src/app/backend/PM_1_WithProcesses.d.ts +0 -1
  26. package/dist/types/src/app/backend/PM_WithBuild.d.ts +0 -1
  27. package/dist/types/src/app/backend/main.d.ts +1 -0
  28. package/dist/types/src/app/frontend/useFs.d.ts +1 -1
  29. package/dist/types/src/mothership/mothership.d.ts +1 -0
  30. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  31. package/docker-compose.yml +54 -54
  32. package/package.json +8 -3
  33. package/src/app/backend/PM_0.ts +3 -0
  34. package/src/app/backend/PM_1_WithProcesses.ts +4 -2
  35. package/src/app/backend/PM_2_WithTCP.ts +3 -0
  36. package/src/app/backend/PM_WithBuild.ts +0 -2
  37. package/src/app/backend/PM_WithHelpo.ts +1 -1
  38. package/src/app/backend/main.ts +26 -8
  39. package/src/app/frontend/useFs.ts +2 -1
  40. package/src/mothership/mothership.ts +218 -0
  41. package/src/testeranto.ts +47 -45
  42. package/dist/common/src/mothership/index.js +0 -183
  43. package/dist/module/src/mothership/index.js +0 -178
  44. package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +0 -22
  45. package/dist/prebuild/init-docs.mjs +0 -43
  46. package/dist/prebuild/testeranto.mjs +0 -5352
  47. package/dist/types/src/mothership/index.d.ts +0 -2
  48. package/src/mothership/index.ts +0 -216
@@ -10,7 +10,10 @@ const recorders = {};
10
10
  const screenshots = {};
11
11
  export class PM_0 {
12
12
  constructor(configs, projectName, mode) {
13
+ console.log("mark6", configs);
14
+ console.log("mark7", this.configs);
13
15
  this.configs = configs;
16
+ console.log("mark8", this.configs);
14
17
  this.mode = mode;
15
18
  this.projectName = projectName;
16
19
  }
@@ -136,6 +136,8 @@ export class PM_1_WithProcesses extends PM_0 {
136
136
  }
137
137
  }
138
138
  };
139
+ console.log("mark5", configs);
140
+ console.log("mark1", this.configs);
139
141
  this.configs.tests.forEach(([t, rt, tr, sidecars]) => {
140
142
  this.ensureSummaryEntry(t);
141
143
  sidecars.forEach(([sidecarName]) => {
@@ -11,6 +11,8 @@ import { PM_1_WithProcesses } from "./PM_1_WithProcesses.js";
11
11
  export class PM_2_WithTCP extends PM_1_WithProcesses {
12
12
  constructor(configs, name, mode) {
13
13
  super(configs, name, mode);
14
+ console.log("mark2", this.configs);
15
+ console.log("mark3", configs);
14
16
  this.httpServer = http.createServer(this.handleHttpRequest.bind(this));
15
17
  this.wss = new WebSocketServer({ server: this.httpServer });
16
18
  this.wss.on("connection", (ws) => {
@@ -6,6 +6,7 @@ import { spawnSync } from "node:child_process";
6
6
  // @ts-ignore: node-pty is a CommonJS module
7
7
  import fs from "fs";
8
8
  import path from "path";
9
+ // import { PM_1 } from "./PM_1_WithProcesses.js";
9
10
  import { PM_WithGit } from "./PM_WithGit.js";
10
11
  export class PM_WithHelpo extends PM_WithGit {
11
12
  constructor(configs, name, mode) {
@@ -18,8 +18,8 @@ import { PM_WithHelpo } from "./PM_WithHelpo.js";
18
18
  const files = {};
19
19
  const screenshots = {};
20
20
  export class PM_Main extends PM_WithHelpo {
21
- constructor() {
22
- super(...arguments);
21
+ constructor(configs, name, mode) {
22
+ super(configs, name, mode);
23
23
  this.launchPure = async (src, dest) => {
24
24
  console.log(ansiC.green(ansiC.inverse(`pure < ${src}`)));
25
25
  const processId = `pure-${src}-${Date.now()}`;
@@ -223,6 +223,7 @@ export class PM_Main extends PM_WithHelpo {
223
223
  const command = `web test: ${src}`;
224
224
  // Create the promise
225
225
  const webPromise = (async () => {
226
+ var _a, _b;
226
227
  this.bddTestIsRunning(src);
227
228
  const reportDest = `testeranto/reports/${this.projectName}/${src
228
229
  .split(".")
@@ -240,12 +241,16 @@ export class PM_Main extends PM_WithHelpo {
240
241
  });
241
242
  const d = `${dest}?cacheBust=${Date.now()}`;
242
243
  const logs = createLogStreams(reportDest, "web");
244
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("testing123");
245
+ (_b = logs.info) === null || _b === void 0 ? void 0 : _b.write("wtf");
243
246
  return new Promise((resolve, reject) => {
244
247
  this.browser
245
248
  .newPage()
246
249
  .then((page) => {
250
+ // page.on("")
247
251
  page.on("console", (log) => {
248
252
  var _a, _b, _c, _d;
253
+ console.log("mark9", log);
249
254
  const msg = `${log.text()}\n`;
250
255
  switch (log.type()) {
251
256
  case "info":
@@ -265,6 +270,8 @@ export class PM_Main extends PM_WithHelpo {
265
270
  }
266
271
  });
267
272
  page.on("close", () => {
273
+ var _a;
274
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("close 1");
268
275
  logs.writeExitCode(0);
269
276
  logs.closeAll();
270
277
  });
@@ -287,6 +294,8 @@ export class PM_Main extends PM_WithHelpo {
287
294
  })
288
295
  .then(async (page) => {
289
296
  const close = () => {
297
+ var _a;
298
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("close2");
290
299
  if (!files[src]) {
291
300
  files[src] = new Set();
292
301
  }
@@ -297,21 +306,31 @@ export class PM_Main extends PM_WithHelpo {
297
306
  });
298
307
  };
299
308
  page.on("pageerror", (err) => {
300
- logs.writeExitCode(-1, err);
301
- console.log(ansiColors.red(`web ! ${src} failed to execute No "tests.json" file was generated. Check ${reportDest}/error.log for more info`));
302
- this.bddTestIsNowDone(src, -1);
303
- close();
309
+ var _a;
310
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("pageerror");
311
+ // logs.writeExitCode(-1, err);
312
+ // console.log(
313
+ // ansiColors.red(
314
+ // `web ! ${src} failed to execute No "tests.json" file was generated. Check ${reportDest}/error.log for more info`
315
+ // )
316
+ // );
317
+ // this.bddTestIsNowDone(src, -1);
318
+ // close();
304
319
  reject(err);
305
320
  });
306
321
  await page.goto(`file://${`${destFolder}.html`}`, {});
307
322
  await page
308
323
  .evaluate(webEvaluator(d, webArgz))
309
324
  .then(async ({ fails, failed, features }) => {
325
+ var _a;
326
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("\n idk1");
310
327
  statusMessagePretty(fails, src, "web");
311
328
  this.bddTestIsNowDone(src, fails);
312
329
  resolve();
313
330
  })
314
331
  .catch((e) => {
332
+ var _a;
333
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("\n idk2");
315
334
  console.log(ansiC.red(ansiC.inverse(e.stack)));
316
335
  console.log(ansiC.red(ansiC.inverse(`web ! ${src} failed to execute. No "tests.json" file was generated. Check logs for more info`)));
317
336
  // Create a minimal tests.json even on failure
@@ -328,6 +347,8 @@ export class PM_Main extends PM_WithHelpo {
328
347
  reject(e);
329
348
  })
330
349
  .finally(async () => {
350
+ var _a;
351
+ (_a = logs.info) === null || _a === void 0 ? void 0 : _a.write("\n idk3");
331
352
  // Generate prompt files for Web tests
332
353
  await this.generatePromptFiles(reportDest, src);
333
354
  close();
@@ -516,26 +537,6 @@ export class PM_Main extends PM_WithHelpo {
516
537
  })();
517
538
  this.addPromiseProcess(processId, golangPromise, command, "bdd-test", src, "golang");
518
539
  };
519
- // private getGolangSourceFiles(src: string): string[] {
520
- // // Get all .go files in the same directory as the test
521
- // const testDir = path.dirname(src);
522
- // const files: string[] = [];
523
- // try {
524
- // const dirContents = fs.readdirSync(testDir);
525
- // dirContents.forEach((file) => {
526
- // if (file.endsWith(".go")) {
527
- // files.push(path.join(testDir, file));
528
- // }
529
- // });
530
- // } catch (error) {
531
- // console.error(`Error reading directory ${testDir}:`, error);
532
- // }
533
- // // Always include the main test file
534
- // if (!files.includes(src)) {
535
- // files.push(src);
536
- // }
537
- // return files;
538
- // }
539
540
  }
540
541
  async startBuildProcesses() {
541
542
  const { nodeEntryPoints, webEntryPoints, pureEntryPoints } = getRunnables(this.configs.tests, this.projectName);
@@ -7,5 +7,6 @@ export const useFs = () => {
7
7
  if (!context) {
8
8
  throw new Error("useFileService must be used within a FileServiceProvider");
9
9
  }
10
- return context;
10
+ // Return as an array to make it iterable
11
+ return [context];
11
12
  };
@@ -0,0 +1,196 @@
1
+ // import Docker from "dockerode";
2
+ console.log("hello mothership");
3
+ export {};
4
+ // const app = express();
5
+ // app.use(express.json());
6
+ // // const docker = new Docker();
7
+ // // Track running services
8
+ // const runningServices = new Map();
9
+ // // Service to build file mapping
10
+ // const serviceBuildFiles = {
11
+ // "node-build": "src/builders/node.ts",
12
+ // "web-build": "src/builders/web.ts",
13
+ // "golang-build": "src/builders/golang.ts",
14
+ // "python-build": "src/builders/python.ts",
15
+ // };
16
+ // // Automatically start build services on mothership startup
17
+ // async function initializeServices() {
18
+ // console.log("Initializing build services...");
19
+ // for (const serviceName of Object.keys(serviceBuildFiles)) {
20
+ // try {
21
+ // // Get all containers
22
+ // // const containers = await docker.listContainers({ all: true });
23
+ // // Find the container for the requested service
24
+ // // const containerInfo = containers.find((container) =>
25
+ // // container.Names.some((name) => name.includes(serviceName))
26
+ // // );
27
+ // // if (containerInfo) {
28
+ // // // const container = docker.getContainer(containerInfo.Id);
29
+ // // // Start the container if it's not running
30
+ // // if (containerInfo.State !== "running") {
31
+ // // console.log(`Starting ${serviceName}...`);
32
+ // // await container.start();
33
+ // // } else {
34
+ // // console.log(`${serviceName} is already running`);
35
+ // // }
36
+ // // runningServices.set(serviceName, containerInfo.Id);
37
+ // // } else {
38
+ // // console.warn(`Container for ${serviceName} not found`);
39
+ // // }
40
+ // } catch (error) {
41
+ // console.error(`Error initializing ${serviceName}:`, error);
42
+ // }
43
+ // }
44
+ // console.log("Build services initialization complete");
45
+ // }
46
+ // // Initialize services when mothership starts
47
+ // initializeServices();
48
+ // app.get("/", (req, res) => {
49
+ // res.send("Mothership is running");
50
+ // });
51
+ // // Start a specific service
52
+ // app.post("/services/:serviceName/start", async (req, res) => {
53
+ // const { serviceName } = req.params;
54
+ // try {
55
+ // // // Get all containers
56
+ // // const containers = await docker.listContainers({ all: true });
57
+ // // // Find the container for the requested service
58
+ // // const containerInfo = containers.find((container) =>
59
+ // // container.Names.some((name) => name.includes(serviceName))
60
+ // // );
61
+ // // if (!containerInfo) {
62
+ // // return res
63
+ // // .status(404)
64
+ // // .json({ error: `Service ${serviceName} not found` });
65
+ // // }
66
+ // // const container = docker.getContainer(containerInfo.Id);
67
+ // // // Start the container if it's not running
68
+ // // if (containerInfo.State !== "running") {
69
+ // // await container.start();
70
+ // // }
71
+ // // runningServices.set(serviceName, containerInfo.Id);
72
+ // // res.status(200).json({
73
+ // // status: "started",
74
+ // // service: serviceName,
75
+ // // containerId: containerInfo.Id,
76
+ // // });
77
+ // } catch (error) {
78
+ // console.error(`Error starting service ${serviceName}:`, error);
79
+ // res
80
+ // .status(500)
81
+ // .json({ error: `Failed to start service: ${error.message}` });
82
+ // }
83
+ // });
84
+ // // Stop a specific service
85
+ // app.post("/services/:serviceName/stop", async (req, res) => {
86
+ // const { serviceName } = req.params;
87
+ // try {
88
+ // // const containerId = runningServices.get(serviceName);
89
+ // // if (!containerId) {
90
+ // // return res
91
+ // // .status(404)
92
+ // // .json({ error: `Service ${serviceName} is not running` });
93
+ // // }
94
+ // // const container = docker.getContainer(containerId);
95
+ // // await container.stop();
96
+ // // runningServices.delete(serviceName);
97
+ // res.status(200).json({
98
+ // status: "stopped",
99
+ // service: serviceName,
100
+ // });
101
+ // } catch (error) {
102
+ // console.error(`Error stopping service ${serviceName}:`, error);
103
+ // res.status(500).json({ error: `Failed to stop service: ${error.message}` });
104
+ // }
105
+ // });
106
+ // // Get status of all services
107
+ // app.get("/services", async (req, res) => {
108
+ // try {
109
+ // // const containers = await docker.listContainers({ all: true });
110
+ // // const services = containers
111
+ // // .filter((container) =>
112
+ // // container.Names.some((name) =>
113
+ // // name.match(
114
+ // // /_(node-build|web-build|golang-build|python-build|mothership)_/
115
+ // // )
116
+ // // )
117
+ // // )
118
+ // // .map((container) => ({
119
+ // // name: container.Names[0].replace("/", ""),
120
+ // // id: container.Id,
121
+ // // status: container.State,
122
+ // // image: container.Image,
123
+ // // }));
124
+ // // res.status(200).json({ services });
125
+ // } catch (error) {
126
+ // console.error("Error listing services:", error);
127
+ // res
128
+ // .status(500)
129
+ // .json({ error: `Failed to list services: ${error.message}` });
130
+ // }
131
+ // });
132
+ // // Trigger a build in a specific service
133
+ // app.post("/build/:serviceName", async (req, res) => {
134
+ // // const { serviceName } = req.params;
135
+ // // try {
136
+ // // const containerId = runningServices.get(serviceName);
137
+ // // if (!containerId) {
138
+ // // return res
139
+ // // .status(404)
140
+ // // .json({ error: `Service ${serviceName} is not running` });
141
+ // // }
142
+ // // // const container = docker.getContainer(containerId);
143
+ // // // Execute the build command in the container
144
+ // // const buildFile = serviceBuildFiles[serviceName];
145
+ // // if (!buildFile) {
146
+ // // return res
147
+ // // .status(400)
148
+ // // .json({ error: `No build file configured for ${serviceName}` });
149
+ // // }
150
+ // // // Run the TypeScript build file using ts-node
151
+ // // const exec = await container.exec({
152
+ // // Cmd: ["npx", "ts-node", "--transpile-only", buildFile],
153
+ // // AttachStdout: true,
154
+ // // AttachStderr: true,
155
+ // // });
156
+ // // // Start the exec instance
157
+ // // const stream = await exec.start({ hijack: true, stdin: false });
158
+ // // // Collect output
159
+ // // let output = "";
160
+ // // stream.on("data", (chunk: Buffer) => {
161
+ // // output += chunk.toString();
162
+ // // });
163
+ // // stream.on("end", () => {
164
+ // // res.status(200).json({
165
+ // // status: "build completed",
166
+ // // service: serviceName,
167
+ // // output: output,
168
+ // // });
169
+ // // });
170
+ // // stream.on("error", (error) => {
171
+ // // console.error(`Stream error for ${serviceName}:`, error);
172
+ // // res.status(500).json({ error: `Build stream error: ${error.message}` });
173
+ // // });
174
+ // // } catch (error) {
175
+ // // console.error(`Error triggering build for ${serviceName}:`, error);
176
+ // // res
177
+ // // .status(500)
178
+ // // .json({ error: `Failed to trigger build: ${error.message}` });
179
+ // // }
180
+ // });
181
+ // // Get build file for each service
182
+ // app.get("/build-files", (req, res) => {
183
+ // res.status(200).json(serviceBuildFiles);
184
+ // });
185
+ // // Claim resource endpoint
186
+ // app.get("/claim", (req, res) => {
187
+ // const { resource } = req.query;
188
+ // console.log(`Resource claimed: ${resource}`);
189
+ // res.status(200).json({ status: "claimed", resource });
190
+ // });
191
+ // export default (port: number) => {
192
+ // app.listen(port, () => {
193
+ // console.log(`Mothership listening on port ${port}`);
194
+ // });
195
+ // return app;
196
+ // };
@@ -6,7 +6,9 @@ import readline from "readline";
6
6
  import { AppHtml } from "./utils/buildTemplates";
7
7
  import { PitonoBuild } from "./PM/pitonoBuild";
8
8
  import { getRunnables } from "./app/backend/utils";
9
+ import path from "path";
9
10
  const { GolingvuBuild } = await import("./PM/golingvuBuild");
11
+ import webHtmlFrame from "./web.html";
10
12
  // if (!process.env.GITHUB_CLIENT_ID) {
11
13
  // console.error(`env var "GITHUB_CLIENT_ID" needs to be set!`);
12
14
  // process.exit(-1);
@@ -75,53 +77,40 @@ import(configFilePath).then(async (module) => {
75
77
  }
76
78
  fs.writeFileSync(`testeranto/reports/${projectName}/config.json`, JSON.stringify(config, null, 2));
77
79
  });
78
- // const getSecondaryEndpointsPoints = (runtime?: IRunTime): string[] => {
79
- // const meta = (ts: ITestTypes[], st: Set<string>): Set<string> => {
80
- // ts.forEach((t) => {
81
- // if (t[1] === runtime) {
82
- // st.add(t[0]);
83
- // }
84
- // if (Array.isArray(t[3])) {
85
- // meta(t[3], st);
86
- // }
87
- // });
88
- // return st;
89
- // };
90
- // return Array.from(meta(config.tests, new Set()));
91
- // };
80
+ const getSecondaryEndpointsPoints = (runtime) => {
81
+ const meta = (ts, st) => {
82
+ ts.forEach((t) => {
83
+ if (t[1] === runtime) {
84
+ st.add(t[0]);
85
+ }
86
+ if (Array.isArray(t[3])) {
87
+ meta(t[3], st);
88
+ }
89
+ });
90
+ return st;
91
+ };
92
+ return Array.from(meta(config.tests, new Set()));
93
+ };
92
94
  // Also handle pitono endpoints for HTML generation if needed
93
95
  // [...getSecondaryEndpointsPoints("python")].forEach(async (sourceFilePath) => {
94
96
  // // You might want to generate specific files for pitono tests here
95
97
  // console.log(`Pitono test found: ${sourceFilePath}`);
96
98
  // });
97
- // Promise.resolve(
98
- // Promise.all(
99
- // [...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
100
- // const sourceFileSplit = sourceFilePath.split("/");
101
- // const sourceDir = sourceFileSplit.slice(0, -1);
102
- // const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
103
- // const sourceFileNameMinusJs = sourceFileName
104
- // .split(".")
105
- // .slice(0, -1)
106
- // .join(".");
107
- // const htmlFilePath = path.normalize(
108
- // `${process.cwd()}/testeranto/bundles/web/${testName}/${sourceDir.join(
109
- // "/"
110
- // )}/${sourceFileNameMinusJs}.html`
111
- // );
112
- // const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
113
- // const cssFilePath = `./${sourceFileNameMinusJs}.css`;
114
- // return fs.promises
115
- // .mkdir(path.dirname(htmlFilePath), { recursive: true })
116
- // .then((x) =>
117
- // fs.writeFileSync(
118
- // htmlFilePath,
119
- // webHtmlFrame(jsfilePath, htmlFilePath, cssFilePath)
120
- // )
121
- // );
122
- // })
123
- // )
124
- // );
99
+ Promise.resolve(Promise.all([...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
100
+ const sourceFileSplit = sourceFilePath.split("/");
101
+ const sourceDir = sourceFileSplit.slice(0, -1);
102
+ const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
103
+ const sourceFileNameMinusJs = sourceFileName
104
+ .split(".")
105
+ .slice(0, -1)
106
+ .join(".");
107
+ const htmlFilePath = path.normalize(`${process.cwd()}/testeranto/bundles/web/${testName}/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
108
+ const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
109
+ const cssFilePath = `./${sourceFileNameMinusJs}.css`;
110
+ return fs.promises
111
+ .mkdir(path.dirname(htmlFilePath), { recursive: true })
112
+ .then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath, cssFilePath)));
113
+ })));
125
114
  const { nodeEntryPoints, nodeEntryPointSidecars, webEntryPoints, webEntryPointSidecars, pureEntryPoints, pureEntryPointSidecars, pythonEntryPoints, pythonEntryPointSidecars, golangEntryPoints, golangEntryPointSidecars, } = getRunnables(config.tests, testName);
126
115
  // Debug logging to check if entry points are being found
127
116
  console.log("Node entry points:", Object.keys(nodeEntryPoints));