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
package/src/testeranto.ts CHANGED
@@ -6,14 +6,16 @@ import fs from "fs";
6
6
  import readline from "readline";
7
7
 
8
8
  import { ITestconfig, IRunTime, IBuiltConfig } from "./lib";
9
- import { IProject } from "./Types";
9
+ import { IProject, ITestTypes } from "./Types";
10
10
 
11
11
  import { AppHtml } from "./utils/buildTemplates";
12
12
 
13
13
  import { PM_Main } from "./app/backend/main";
14
14
  import { PitonoBuild } from "./PM/pitonoBuild";
15
15
  import { getRunnables } from "./app/backend/utils";
16
+ import path from "path";
16
17
  const { GolingvuBuild } = await import("./PM/golingvuBuild");
18
+ import webHtmlFrame from "./web.html";
17
19
 
18
20
  // if (!process.env.GITHUB_CLIENT_ID) {
19
21
  // console.error(`env var "GITHUB_CLIENT_ID" needs to be set!`);
@@ -110,20 +112,20 @@ import(configFilePath).then(async (module) => {
110
112
  );
111
113
  });
112
114
 
113
- // const getSecondaryEndpointsPoints = (runtime?: IRunTime): string[] => {
114
- // const meta = (ts: ITestTypes[], st: Set<string>): Set<string> => {
115
- // ts.forEach((t) => {
116
- // if (t[1] === runtime) {
117
- // st.add(t[0]);
118
- // }
119
- // if (Array.isArray(t[3])) {
120
- // meta(t[3], st);
121
- // }
122
- // });
123
- // return st;
124
- // };
125
- // return Array.from(meta(config.tests, new Set()));
126
- // };
115
+ const getSecondaryEndpointsPoints = (runtime?: IRunTime): string[] => {
116
+ const meta = (ts: ITestTypes[], st: Set<string>): Set<string> => {
117
+ ts.forEach((t) => {
118
+ if (t[1] === runtime) {
119
+ st.add(t[0]);
120
+ }
121
+ if (Array.isArray(t[3])) {
122
+ meta(t[3], st);
123
+ }
124
+ });
125
+ return st;
126
+ };
127
+ return Array.from(meta(config.tests, new Set()));
128
+ };
127
129
 
128
130
  // Also handle pitono endpoints for HTML generation if needed
129
131
  // [...getSecondaryEndpointsPoints("python")].forEach(async (sourceFilePath) => {
@@ -131,36 +133,36 @@ import(configFilePath).then(async (module) => {
131
133
  // console.log(`Pitono test found: ${sourceFilePath}`);
132
134
  // });
133
135
 
134
- // Promise.resolve(
135
- // Promise.all(
136
- // [...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
137
- // const sourceFileSplit = sourceFilePath.split("/");
138
- // const sourceDir = sourceFileSplit.slice(0, -1);
139
- // const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
140
- // const sourceFileNameMinusJs = sourceFileName
141
- // .split(".")
142
- // .slice(0, -1)
143
- // .join(".");
144
-
145
- // const htmlFilePath = path.normalize(
146
- // `${process.cwd()}/testeranto/bundles/web/${testName}/${sourceDir.join(
147
- // "/"
148
- // )}/${sourceFileNameMinusJs}.html`
149
- // );
150
- // const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
151
- // const cssFilePath = `./${sourceFileNameMinusJs}.css`;
152
-
153
- // return fs.promises
154
- // .mkdir(path.dirname(htmlFilePath), { recursive: true })
155
- // .then((x) =>
156
- // fs.writeFileSync(
157
- // htmlFilePath,
158
- // webHtmlFrame(jsfilePath, htmlFilePath, cssFilePath)
159
- // )
160
- // );
161
- // })
162
- // )
163
- // );
136
+ Promise.resolve(
137
+ Promise.all(
138
+ [...getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
139
+ const sourceFileSplit = sourceFilePath.split("/");
140
+ const sourceDir = sourceFileSplit.slice(0, -1);
141
+ const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
142
+ const sourceFileNameMinusJs = sourceFileName
143
+ .split(".")
144
+ .slice(0, -1)
145
+ .join(".");
146
+
147
+ const htmlFilePath = path.normalize(
148
+ `${process.cwd()}/testeranto/bundles/web/${testName}/${sourceDir.join(
149
+ "/"
150
+ )}/${sourceFileNameMinusJs}.html`
151
+ );
152
+ const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
153
+ const cssFilePath = `./${sourceFileNameMinusJs}.css`;
154
+
155
+ return fs.promises
156
+ .mkdir(path.dirname(htmlFilePath), { recursive: true })
157
+ .then((x) =>
158
+ fs.writeFileSync(
159
+ htmlFilePath,
160
+ webHtmlFrame(jsfilePath, htmlFilePath, cssFilePath)
161
+ )
162
+ );
163
+ })
164
+ )
165
+ );
164
166
 
165
167
  const {
166
168
  nodeEntryPoints,
@@ -1,183 +0,0 @@
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 express_1 = __importDefault(require("express"));
7
- const dockerode_1 = __importDefault(require("dockerode"));
8
- const app = (0, express_1.default)();
9
- app.use(express_1.default.json());
10
- const docker = new dockerode_1.default();
11
- // Track running services
12
- const runningServices = new Map();
13
- // Service to build file mapping
14
- const serviceBuildFiles = {
15
- 'node-build': 'src/builders/node.ts',
16
- 'web-build': 'src/builders/web.ts',
17
- 'golang-build': 'src/builders/golang.ts',
18
- 'python-build': 'src/builders/python.ts'
19
- };
20
- // Automatically start build services on mothership startup
21
- async function initializeServices() {
22
- console.log('Initializing build services...');
23
- for (const serviceName of Object.keys(serviceBuildFiles)) {
24
- try {
25
- // Get all containers
26
- const containers = await docker.listContainers({ all: true });
27
- // Find the container for the requested service
28
- const containerInfo = containers.find(container => container.Names.some(name => name.includes(serviceName)));
29
- if (containerInfo) {
30
- const container = docker.getContainer(containerInfo.Id);
31
- // Start the container if it's not running
32
- if (containerInfo.State !== 'running') {
33
- console.log(`Starting ${serviceName}...`);
34
- await container.start();
35
- }
36
- else {
37
- console.log(`${serviceName} is already running`);
38
- }
39
- runningServices.set(serviceName, containerInfo.Id);
40
- }
41
- else {
42
- console.warn(`Container for ${serviceName} not found`);
43
- }
44
- }
45
- catch (error) {
46
- console.error(`Error initializing ${serviceName}:`, error);
47
- }
48
- }
49
- console.log('Build services initialization complete');
50
- }
51
- // Initialize services when mothership starts
52
- initializeServices();
53
- app.get("/", (req, res) => {
54
- res.send("Mothership is running");
55
- });
56
- // Start a specific service
57
- app.post("/services/:serviceName/start", async (req, res) => {
58
- const { serviceName } = req.params;
59
- try {
60
- // Get all containers
61
- const containers = await docker.listContainers({ all: true });
62
- // Find the container for the requested service
63
- const containerInfo = containers.find(container => container.Names.some(name => name.includes(serviceName)));
64
- if (!containerInfo) {
65
- return res.status(404).json({ error: `Service ${serviceName} not found` });
66
- }
67
- const container = docker.getContainer(containerInfo.Id);
68
- // Start the container if it's not running
69
- if (containerInfo.State !== 'running') {
70
- await container.start();
71
- }
72
- runningServices.set(serviceName, containerInfo.Id);
73
- res.status(200).json({
74
- status: 'started',
75
- service: serviceName,
76
- containerId: containerInfo.Id
77
- });
78
- }
79
- catch (error) {
80
- console.error(`Error starting service ${serviceName}:`, error);
81
- res.status(500).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.status(404).json({ error: `Service ${serviceName} is not running` });
91
- }
92
- const container = docker.getContainer(containerId);
93
- await container.stop();
94
- runningServices.delete(serviceName);
95
- res.status(200).json({
96
- status: 'stopped',
97
- service: serviceName
98
- });
99
- }
100
- catch (error) {
101
- console.error(`Error stopping service ${serviceName}:`, error);
102
- res.status(500).json({ error: `Failed to stop service: ${error.message}` });
103
- }
104
- });
105
- // Get status of all services
106
- app.get("/services", async (req, res) => {
107
- try {
108
- const containers = await docker.listContainers({ all: true });
109
- const services = containers
110
- .filter(container => container.Names.some(name => name.match(/_(node-build|web-build|golang-build|python-build|mothership)_/)))
111
- .map(container => ({
112
- name: container.Names[0].replace('/', ''),
113
- id: container.Id,
114
- status: container.State,
115
- image: container.Image
116
- }));
117
- res.status(200).json({ services });
118
- }
119
- catch (error) {
120
- console.error("Error listing services:", error);
121
- res.status(500).json({ error: `Failed to list services: ${error.message}` });
122
- }
123
- });
124
- // Trigger a build in a specific service
125
- app.post("/build/:serviceName", async (req, res) => {
126
- const { serviceName } = req.params;
127
- try {
128
- const containerId = runningServices.get(serviceName);
129
- if (!containerId) {
130
- return res.status(404).json({ error: `Service ${serviceName} is not running` });
131
- }
132
- const container = docker.getContainer(containerId);
133
- // Execute the build command in the container
134
- const buildFile = serviceBuildFiles[serviceName];
135
- if (!buildFile) {
136
- return res.status(400).json({ error: `No build file configured for ${serviceName}` });
137
- }
138
- // Run the TypeScript build file using ts-node
139
- const exec = await container.exec({
140
- Cmd: ['npx', 'ts-node', '--transpile-only', buildFile],
141
- AttachStdout: true,
142
- AttachStderr: true
143
- });
144
- // Start the exec instance
145
- const stream = await exec.start({ hijack: true, stdin: false });
146
- // Collect output
147
- let output = '';
148
- stream.on('data', (chunk) => {
149
- output += chunk.toString();
150
- });
151
- stream.on('end', () => {
152
- res.status(200).json({
153
- status: 'build completed',
154
- service: serviceName,
155
- output: output
156
- });
157
- });
158
- stream.on('error', (error) => {
159
- console.error(`Stream error for ${serviceName}:`, error);
160
- res.status(500).json({ error: `Build stream error: ${error.message}` });
161
- });
162
- }
163
- catch (error) {
164
- console.error(`Error triggering build for ${serviceName}:`, error);
165
- res.status(500).json({ error: `Failed to trigger build: ${error.message}` });
166
- }
167
- });
168
- // Get build file for each service
169
- app.get("/build-files", (req, res) => {
170
- res.status(200).json(serviceBuildFiles);
171
- });
172
- // Claim resource endpoint
173
- app.get("/claim", (req, res) => {
174
- const { resource } = req.query;
175
- console.log(`Resource claimed: ${resource}`);
176
- res.status(200).json({ status: 'claimed', resource });
177
- });
178
- exports.default = (port) => {
179
- app.listen(port, () => {
180
- console.log(`Mothership listening on port ${port}`);
181
- });
182
- return app;
183
- };
@@ -1,178 +0,0 @@
1
- import express from "express";
2
- import Docker from "dockerode";
3
- const app = express();
4
- app.use(express.json());
5
- const docker = new Docker();
6
- // Track running services
7
- const runningServices = new Map();
8
- // Service to build file mapping
9
- const serviceBuildFiles = {
10
- 'node-build': 'src/builders/node.ts',
11
- 'web-build': 'src/builders/web.ts',
12
- 'golang-build': 'src/builders/golang.ts',
13
- 'python-build': 'src/builders/python.ts'
14
- };
15
- // Automatically start build services on mothership startup
16
- async function initializeServices() {
17
- console.log('Initializing build services...');
18
- for (const serviceName of Object.keys(serviceBuildFiles)) {
19
- try {
20
- // Get all containers
21
- const containers = await docker.listContainers({ all: true });
22
- // Find the container for the requested service
23
- const containerInfo = containers.find(container => container.Names.some(name => name.includes(serviceName)));
24
- if (containerInfo) {
25
- const container = docker.getContainer(containerInfo.Id);
26
- // Start the container if it's not running
27
- if (containerInfo.State !== 'running') {
28
- console.log(`Starting ${serviceName}...`);
29
- await container.start();
30
- }
31
- else {
32
- console.log(`${serviceName} is already running`);
33
- }
34
- runningServices.set(serviceName, containerInfo.Id);
35
- }
36
- else {
37
- console.warn(`Container for ${serviceName} not found`);
38
- }
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 => container.Names.some(name => name.includes(serviceName)));
59
- if (!containerInfo) {
60
- return res.status(404).json({ error: `Service ${serviceName} not found` });
61
- }
62
- const container = docker.getContainer(containerInfo.Id);
63
- // Start the container if it's not running
64
- if (containerInfo.State !== 'running') {
65
- await container.start();
66
- }
67
- runningServices.set(serviceName, containerInfo.Id);
68
- res.status(200).json({
69
- status: 'started',
70
- service: serviceName,
71
- containerId: containerInfo.Id
72
- });
73
- }
74
- catch (error) {
75
- console.error(`Error starting service ${serviceName}:`, error);
76
- res.status(500).json({ error: `Failed to start service: ${error.message}` });
77
- }
78
- });
79
- // Stop a specific service
80
- app.post("/services/:serviceName/stop", async (req, res) => {
81
- const { serviceName } = req.params;
82
- try {
83
- const containerId = runningServices.get(serviceName);
84
- if (!containerId) {
85
- return res.status(404).json({ error: `Service ${serviceName} is not running` });
86
- }
87
- const container = docker.getContainer(containerId);
88
- await container.stop();
89
- runningServices.delete(serviceName);
90
- res.status(200).json({
91
- status: 'stopped',
92
- service: serviceName
93
- });
94
- }
95
- catch (error) {
96
- console.error(`Error stopping service ${serviceName}:`, error);
97
- res.status(500).json({ error: `Failed to stop service: ${error.message}` });
98
- }
99
- });
100
- // Get status of all services
101
- app.get("/services", async (req, res) => {
102
- try {
103
- const containers = await docker.listContainers({ all: true });
104
- const services = containers
105
- .filter(container => container.Names.some(name => name.match(/_(node-build|web-build|golang-build|python-build|mothership)_/)))
106
- .map(container => ({
107
- name: container.Names[0].replace('/', ''),
108
- id: container.Id,
109
- status: container.State,
110
- image: container.Image
111
- }));
112
- res.status(200).json({ services });
113
- }
114
- catch (error) {
115
- console.error("Error listing services:", error);
116
- res.status(500).json({ error: `Failed to list services: ${error.message}` });
117
- }
118
- });
119
- // Trigger a build in a specific service
120
- app.post("/build/:serviceName", async (req, res) => {
121
- const { serviceName } = req.params;
122
- try {
123
- const containerId = runningServices.get(serviceName);
124
- if (!containerId) {
125
- return res.status(404).json({ error: `Service ${serviceName} is not running` });
126
- }
127
- const container = docker.getContainer(containerId);
128
- // Execute the build command in the container
129
- const buildFile = serviceBuildFiles[serviceName];
130
- if (!buildFile) {
131
- return res.status(400).json({ error: `No build file configured for ${serviceName}` });
132
- }
133
- // Run the TypeScript build file using ts-node
134
- const exec = await container.exec({
135
- Cmd: ['npx', 'ts-node', '--transpile-only', buildFile],
136
- AttachStdout: true,
137
- AttachStderr: true
138
- });
139
- // Start the exec instance
140
- const stream = await exec.start({ hijack: true, stdin: false });
141
- // Collect output
142
- let output = '';
143
- stream.on('data', (chunk) => {
144
- output += chunk.toString();
145
- });
146
- stream.on('end', () => {
147
- res.status(200).json({
148
- status: 'build completed',
149
- service: serviceName,
150
- output: output
151
- });
152
- });
153
- stream.on('error', (error) => {
154
- console.error(`Stream error for ${serviceName}:`, error);
155
- res.status(500).json({ error: `Build stream error: ${error.message}` });
156
- });
157
- }
158
- catch (error) {
159
- console.error(`Error triggering build for ${serviceName}:`, error);
160
- res.status(500).json({ error: `Failed to trigger build: ${error.message}` });
161
- }
162
- });
163
- // Get build file for each service
164
- app.get("/build-files", (req, res) => {
165
- res.status(200).json(serviceBuildFiles);
166
- });
167
- // Claim resource endpoint
168
- app.get("/claim", (req, res) => {
169
- const { resource } = req.query;
170
- console.log(`Resource claimed: ${resource}`);
171
- res.status(200).json({ status: 'claimed', resource });
172
- });
173
- export default (port) => {
174
- app.listen(port, () => {
175
- console.log(`Mothership listening on port ${port}`);
176
- });
177
- return app;
178
- };
@@ -1,22 +0,0 @@
1
- import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
-
3
- // src/esbuildConfigs/eslint-formatter-testeranto.ts
4
- function eslint_formatter_testeranto_default(results) {
5
- return results.filter((r) => r.messages.length).map((r) => {
6
- const path = r.filePath.replace(process.cwd() + "/", "");
7
- return [
8
- path,
9
- ...r.messages.map(
10
- (m) => [
11
- `${m.line}:${m.column} ${m.message} (${m.ruleId || ""})`,
12
- ...m.suggestions?.map(
13
- (s) => `- ${s.message}${s.fix ? " (fix)" : ""}`
14
- ) || []
15
- ].join("\n")
16
- )
17
- ].join("\n");
18
- }).join("\n\n");
19
- }
20
- export {
21
- eslint_formatter_testeranto_default as default
22
- };
@@ -1,43 +0,0 @@
1
- import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
-
3
- // src/Init.ts
4
- import fs from "fs";
5
- var Init_default = async () => {
6
- [
7
- `testeranto/`,
8
- `testeranto/bundles/`,
9
- `testeranto/bundles/node`,
10
- `testeranto/bundles/web`,
11
- `testeranto/bundles/pure`,
12
- `testeranto/bundles/golang`,
13
- `testeranto/bundles/python`,
14
- `testeranto/reports/`,
15
- `testeranto/features/`,
16
- // `testeranto/externalTests/`,
17
- `testeranto/metafiles/`,
18
- `testeranto/metafiles/node`,
19
- `testeranto/metafiles/web`,
20
- `testeranto/metafiles/pure`,
21
- `testeranto/metafiles/golang`,
22
- `testeranto/metafiles/python`
23
- ].forEach((f) => {
24
- try {
25
- fs.mkdirSync(`${process.cwd()}/${f}`);
26
- } catch (e) {
27
- console.error(e);
28
- }
29
- });
30
- fs.copyFileSync(
31
- `node_modules/testeranto/dist/prebuild/App.js`,
32
- `testeranto/App.js`
33
- );
34
- fs.copyFileSync(
35
- `node_modules/testeranto/dist/prebuild/App.css`,
36
- `testeranto/App.css`
37
- );
38
- };
39
-
40
- // src/init-docs.ts
41
- console.log("Initializing a testeranto project");
42
- Init_default();
43
- console.log("testeranto project initialized");