testeranto 0.200.0 → 0.200.1

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testeranto",
3
3
  "description": "the AI powered BDD test framework for typescript projects",
4
- "version": "0.200.0",
4
+ "version": "0.200.1",
5
5
  "engines": {
6
6
  "node": "18.18.0"
7
7
  },
@@ -1,227 +0,0 @@
1
- import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
-
3
- // src/ReportServerLib.ts
4
- import staticServer from "node-static";
5
- import http from "http";
6
- import path from "path";
7
- import fs from "fs";
8
- var fileServer = new staticServer.Server("./", {
9
- cache: false,
10
- headers: {
11
- "Cache-Control": "no-cache, no-store, must-revalidate",
12
- Pragma: "no-cache",
13
- Expires: "0"
14
- }
15
- });
16
- var server = http.createServer((req, res) => {
17
- let responded = false;
18
- const safeResponse = (handler) => {
19
- if (responded)
20
- return;
21
- responded = true;
22
- try {
23
- handler();
24
- } catch (err) {
25
- console.error("Error handling request:", err);
26
- if (!res.headersSent) {
27
- res.writeHead(500);
28
- }
29
- res.end("Internal Server Error");
30
- }
31
- };
32
- req.on("error", (err) => {
33
- console.error("Request error:", err);
34
- safeResponse(() => {
35
- if (!res.headersSent) {
36
- res.writeHead(400);
37
- }
38
- res.end("Bad Request");
39
- });
40
- });
41
- req.on("end", () => {
42
- safeResponse(() => {
43
- const filePath = path.join(process.cwd(), req.url || "");
44
- fs.stat(filePath, (err, stats) => {
45
- if (err || !stats.isFile()) {
46
- fs.stat(filePath, (dirErr, dirStats) => {
47
- if (!dirErr && dirStats.isDirectory()) {
48
- fs.readdir(filePath, (readErr, files) => {
49
- if (readErr) {
50
- res.writeHead(500);
51
- return res.end("Error reading directory");
52
- }
53
- res.writeHead(200, { "Content-Type": "text/html" });
54
- res.write(`
55
- <html>
56
- <head>
57
- <title>Directory Listing: ${req.url}</title>
58
- <style>
59
- body { font-family: sans-serif; margin: 2rem; }
60
- h1 { color: #333; }
61
- ul { list-style: none; padding: 0; }
62
- li { padding: 0.5rem; }
63
- li a { color: #0366d6; text-decoration: none; }
64
- li a:hover { text-decoration: underline; }
65
- </style>
66
- </head>
67
- <body>
68
- <h1>Directory: ${req.url}</h1>
69
- <ul>
70
- ${files.map(
71
- (file) => `
72
- <li>
73
- <a href="${path.join(req.url || "", file)}">
74
- ${file}${file.endsWith("/") ? "/" : ""}
75
- </a>
76
- </li>
77
- `
78
- ).join("")}
79
- </ul>
80
- </body>
81
- </html>
82
- `);
83
- res.end();
84
- });
85
- } else {
86
- if (!res.headersSent) {
87
- res.writeHead(404, { "Content-Type": "text/plain" });
88
- res.end("File not found");
89
- }
90
- }
91
- });
92
- return;
93
- }
94
- const serve = () => {
95
- fileServer.serve(req, res, (err2) => {
96
- if (err2 && !res.headersSent) {
97
- res.writeHead(err2.status || 500);
98
- res.end(err2.message);
99
- }
100
- });
101
- };
102
- if (!res.headersSent) {
103
- serve();
104
- }
105
- });
106
- });
107
- });
108
- req.resume();
109
- });
110
- server.on("error", (err) => {
111
- console.error("Server error:", err);
112
- });
113
- process.on("uncaughtException", (err) => {
114
- console.error("Uncaught exception:", err);
115
- });
116
- var start = (port2) => {
117
- if (port2) {
118
- server.listen(port2, () => {
119
- console.log(`Server running on http://localhost:${port2}`);
120
- console.log("Serving files from:", process.cwd());
121
- });
122
- } else {
123
- console.log("you need to specify a port");
124
- }
125
- };
126
- var ReportServerOfPort = (port2) => start(port2);
127
-
128
- // design-editor/server.ts
129
- import { WebSocketServer } from "ws";
130
- import fs2 from "fs";
131
- import path2 from "path";
132
- var projects = /* @__PURE__ */ new Map();
133
- function startDesignEditorServer(wssPort2, httpPort) {
134
- const wss = new WebSocketServer({ port: wssPort2 });
135
- wss.on("connection", (ws, req) => {
136
- const url = new URL(req.url || "", `http://${req.headers.host}`);
137
- const projectId = url.searchParams.get("project") || "default";
138
- if (!projects.has(projectId)) {
139
- projects.set(projectId, {
140
- connections: /* @__PURE__ */ new Set(),
141
- design: loadDesign(projectId)
142
- });
143
- }
144
- const project = projects.get(projectId);
145
- project.connections.add(ws);
146
- ws.send(
147
- JSON.stringify({
148
- type: "design_update",
149
- data: project.design
150
- })
151
- );
152
- broadcastCollaborators(projectId);
153
- ws.on("message", (message) => {
154
- const data = JSON.parse(message);
155
- if (data.type === "design_update") {
156
- project.design = data.data;
157
- saveDesign(projectId, data.data);
158
- broadcastToProject(projectId, message.toString());
159
- }
160
- });
161
- ws.on("close", (code, reason) => {
162
- project.connections.delete(ws);
163
- if (project.connections.size === 0) {
164
- projects.delete(projectId);
165
- } else {
166
- broadcastCollaborators(projectId);
167
- }
168
- });
169
- });
170
- console.log(`Design editor WebSocket server running on port ${wssPort2}`);
171
- }
172
- function broadcastToProject(projectId, message) {
173
- const project = projects.get(projectId);
174
- if (project) {
175
- project.connections.forEach((client) => {
176
- if (client.readyState === client.OPEN) {
177
- client.send(message);
178
- }
179
- });
180
- }
181
- }
182
- function broadcastCollaborators(projectId) {
183
- const project = projects.get(projectId);
184
- if (project) {
185
- const collaborators = Array.from(project.connections).map((_, i) => ({
186
- id: `user-${i}`,
187
- name: `Collaborator ${i + 1}`
188
- }));
189
- broadcastToProject(
190
- projectId,
191
- JSON.stringify({
192
- type: "collaborators_update",
193
- data: collaborators
194
- })
195
- );
196
- }
197
- }
198
- function loadDesign(projectId) {
199
- const designsDir = path2.join(process.cwd(), "designs");
200
- const filePath = path2.join(designsDir, `${projectId}.json`);
201
- try {
202
- const data = fs2.readFileSync(filePath, "utf-8");
203
- return JSON.parse(data);
204
- } catch {
205
- return {
206
- version: "1.0",
207
- background: "#ffffff",
208
- objects: []
209
- };
210
- }
211
- }
212
- function saveDesign(projectId, design) {
213
- const designsDir = path2.join(process.cwd(), "designs");
214
- if (!fs2.existsSync(designsDir)) {
215
- fs2.mkdirSync(designsDir, { recursive: true });
216
- }
217
- const filePath = path2.join(designsDir, `${projectId}.json`);
218
- fs2.writeFileSync(filePath, JSON.stringify(design, null, 2));
219
- }
220
-
221
- // src/ReportServer.ts
222
- var port = process.argv[2] || 3e3;
223
- var wssPort = Number(port) + 1;
224
- ReportServerOfPort(port);
225
- startDesignEditorServer(wssPort);
226
- console.log(`Report server running on http://localhost:${port}`);
227
- console.log(`Design editor WebSocket running on ws://localhost:${wssPort}`);
@@ -1,22 +0,0 @@
1
- import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
-
3
- // src/mothership/index.ts
4
- import express from "express";
5
- var app = express();
6
- app.get("/", (req, res) => {
7
- res.send("Hello World!");
8
- });
9
- app.get("/claim", (req, res) => {
10
- const { resource } = req.query;
11
- console.log(`Resource claimed: ${resource}`);
12
- res.status(200).json({ status: "claimed", resource });
13
- });
14
- var mothership_default = (port) => {
15
- app.listen(port, () => {
16
- console.log(`Example app listening on port ${port}`);
17
- });
18
- return app;
19
- };
20
- export {
21
- mothership_default as default
22
- };