monorepotime 1.0.0 → 1.0.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/dist/index.js CHANGED
@@ -1,106 +1,1092 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ app: () => app,
35
+ default: () => index_default,
36
+ httpServer: () => httpServer,
37
+ io: () => io
38
+ });
39
+ module.exports = __toCommonJS(index_exports);
40
+ var import_express11 = __toESM(require("express"));
41
+ var import_cors = __toESM(require("cors"));
42
+ var import_path9 = __toESM(require("path"));
43
+
44
+ // ../../packages/api/index.ts
45
+ var apiRoute = {
46
+ /** Scan a workspace
47
+ * get request returns workspace: WorkspaceInfo[]
48
+ */
49
+ scanWorkspace: "scanworkspace",
50
+ /** Run a command in the interactive terminal
51
+ * request body: { workspace: WorkspaceInfo; runas: 'dev' | 'start'; }
52
+ */
53
+ runCmdDev: "runcmddev",
54
+ /** Stop a process
55
+ * request body: { workspace: WorkspaceInfo }
56
+ */
57
+ stopProcess: "stopprocess",
58
+ /** List all workspaces in the workspace directory
59
+ * It is a get request
60
+ * returns: [{ label: string, path: string }]
61
+ */
62
+ listWorkspacesDir: "listworkspacedirs",
63
+ /** Create a new workspace
64
+ * request body: { workspace: WorkspaceInfo }
65
+ */
66
+ newWorkspace: "newworkspace",
67
+ /** Run a command in the interactive terminal
68
+ * request body: { path: string, cmd: string }
69
+ */
70
+ interactvTerminal: "interactvterminal",
71
+ /** Hide or show a file or folder in your IDE (VS Code and variant)
72
+ * it a get request, return true / false
73
+ */
74
+ hideShowFileFolder: "hideshowfilefolder",
75
+ /** Update a workspace
76
+ * request body: { workspace: WorkspaceInfo }
77
+ */
78
+ updateWorkspace: "updateworkspace",
79
+ /** Get the root path of the project
80
+ * It is a get request
81
+ * returns: { path: string }
82
+ */
83
+ getRootPath: "getrootpath",
84
+ /** Scaffold a new repo
85
+ * get request returns { success: boolean }
86
+ */
87
+ scaffoldRepo: "scaffoldrepo",
88
+ /** Check if a turbo repo exists in the rootdir
89
+ * get return { exists: boolean }
90
+ */
91
+ turborepoExist: "turborepoexist"
92
+ };
93
+ var api_default = apiRoute;
94
+
95
+ // ../../packages/config/index.ts
96
+ var config = {
97
+ apiPort: 3e3
98
+ };
99
+ var config_default = config;
100
+
101
+ // src/index.ts
102
+ var import_open = __toESM(require("open"));
103
+ var import_http = require("http");
104
+ var import_socket = require("socket.io");
105
+
106
+ // src/routes/scanworkspace.ts
107
+ var import_fs_extra = __toESM(require("fs-extra"));
108
+ var import_path = __toESM(require("path"));
109
+ var import_fast_glob = __toESM(require("fast-glob"));
110
+ var import_express = require("express");
111
+ var START_DIR = process.cwd();
112
+ function findMonorepoRoot(startDir) {
113
+ let dir = startDir;
114
+ while (dir !== import_path.default.dirname(dir)) {
115
+ const pkgPath = import_path.default.join(dir, "package.json");
116
+ if (import_fs_extra.default.existsSync(pkgPath)) {
117
+ try {
118
+ const pkg = import_fs_extra.default.readJsonSync(pkgPath);
119
+ if (pkg.workspaces) {
120
+ return dir;
121
+ }
122
+ } catch (e) {
123
+ }
124
+ }
125
+ dir = import_path.default.dirname(dir);
126
+ }
127
+ return startDir;
128
+ }
129
+ var ROOT = findMonorepoRoot(START_DIR);
130
+ var route = (0, import_express.Router)();
131
+ var IGNORE = [
132
+ "**/node_modules/**",
133
+ "**/.git/**",
134
+ "**/.turbo/**",
135
+ "**/.next/**",
136
+ "**/.vercel/**",
137
+ "**/.cache/**",
138
+ "**/dist/**",
139
+ "**/build/**",
140
+ "**/out/**",
141
+ "**/coverage/**"
142
+ ];
143
+ async function readJSON(file) {
144
+ try {
145
+ return await import_fs_extra.default.readJSON(file);
146
+ } catch {
147
+ return null;
148
+ }
149
+ }
150
+ async function isRunnableProject(dir) {
151
+ const pkgPath = import_path.default.join(dir, "package.json");
152
+ if (!await import_fs_extra.default.pathExists(pkgPath)) return false;
153
+ const pkg = await readJSON(pkgPath);
154
+ if (!(pkg == null ? void 0 : pkg.scripts)) return false;
155
+ if (pkg.scripts.dev != "object" || pkg.scripts.start != "object") {
156
+ return true;
157
+ }
158
+ return false;
159
+ }
160
+ async function resolveWorkspaceDirs(workspaces) {
161
+ return (0, import_fast_glob.default)(workspaces.map((w) => w.replace(/\/$/, "") + "/"), {
162
+ cwd: ROOT,
163
+ onlyDirectories: true,
164
+ absolute: true,
165
+ ignore: IGNORE
166
+ });
167
+ }
168
+ async function scanWorkspaces(rootPkg) {
169
+ var _a;
170
+ let patterns = [];
171
+ if (Array.isArray(rootPkg.workspaces)) {
172
+ patterns = rootPkg.workspaces;
173
+ } else if ((_a = rootPkg.workspaces) == null ? void 0 : _a.packages) {
174
+ patterns = rootPkg.workspaces.packages;
175
+ }
176
+ if (!patterns.length) return [];
177
+ const dirs = await resolveWorkspaceDirs(patterns);
178
+ const results = /* @__PURE__ */ new Set();
179
+ for (const dir of dirs) {
180
+ if (await isRunnableProject(dir)) {
181
+ results.add(import_path.default.resolve(dir));
182
+ }
183
+ }
184
+ return [...results];
185
+ }
186
+ async function scanRecursively() {
187
+ const pkgFiles = await (0, import_fast_glob.default)("**/package.json", {
188
+ cwd: ROOT,
189
+ absolute: true,
190
+ ignore: IGNORE
191
+ });
192
+ const results = /* @__PURE__ */ new Set();
193
+ for (const pkgFile of pkgFiles) {
194
+ const dir = import_path.default.dirname(pkgFile);
195
+ if (await isRunnableProject(dir)) {
196
+ results.add(import_path.default.resolve(dir));
197
+ }
198
+ }
199
+ return [...results];
200
+ }
201
+ route.get("/", async (req, res) => {
202
+ res.header("Access-Control-Allow-Origin", "*");
203
+ try {
204
+ const rootPkgPath = import_path.default.join(ROOT, "package.json");
205
+ const rootPkg = await readJSON(rootPkgPath);
206
+ let projects = [];
207
+ if (rootPkg == null ? void 0 : rootPkg.workspaces) {
208
+ projects = await scanWorkspaces(rootPkg);
209
+ } else {
210
+ projects = await scanRecursively();
211
+ }
212
+ const projectInfos = (await Promise.all(projects.map(async (p) => {
213
+ const pkgPath = import_path.default.join(p, "package.json");
214
+ const pkg = await readJSON(pkgPath);
215
+ if (!pkg) return null;
216
+ return {
217
+ name: pkg.name || import_path.default.basename(p),
218
+ path: p,
219
+ fontawesomeIcon: pkg.fontawesomeIcon != "object" ? pkg.fontawesomeIcon : null,
220
+ description: pkg.description != "object" ? pkg.description : null,
221
+ devCommand: pkg.scripts.dev != "object" ? pkg.scripts.dev : null,
222
+ startCommand: pkg.scripts.start != "object" ? pkg.scripts.start : null,
223
+ stopCommand: pkg.scripts.stop != "object" ? pkg.scripts.stop : null,
224
+ buildCommand: pkg.scripts.build != "object" ? pkg.scripts.build : null,
225
+ cleanCommand: pkg.scripts.clean != "object" ? pkg.scripts.clean : null,
226
+ lintCommand: pkg.scripts.lint != "object" ? pkg.scripts.lint : null,
227
+ testCommand: pkg.scripts.test != "object" ? pkg.scripts.test : null
228
+ };
229
+ }))).filter(Boolean);
230
+ res.json({
231
+ root: ROOT,
232
+ count: projectInfos.length,
233
+ workspace: projectInfos
234
+ });
235
+ } catch (err) {
236
+ res.status(500).json({ error: err.message });
237
+ }
18
238
  });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
239
+ var scanworkspace_default = route;
240
+
241
+ // src/routes/runcmddev.ts
242
+ var import_child_process = require("child_process");
243
+ var import_chalk = __toESM(require("chalk"));
244
+ var activeProcesses = /* @__PURE__ */ new Map();
245
+ var sockets = /* @__PURE__ */ new Map();
246
+ function runCmdDevSocket(io2) {
247
+ io2.on("connection", (socket) => {
248
+ socket.on("run", (data) => {
249
+ sockets.set(data.workspace.name, socket);
250
+ try {
251
+ handleOnRun(socket, data);
252
+ } catch (error) {
253
+ socket.emit("error", {
254
+ message: error
255
+ });
256
+ }
257
+ });
258
+ });
259
+ }
260
+ async function handleOnRun(socket, data) {
261
+ const { workspace, runas } = data;
262
+ if (activeProcesses.has(workspace.name))
263
+ return socket.emit("log", "Attached to already running process...");
264
+ const commandToRun = runas === "dev" ? workspace.devCommand : workspace.startCommand;
265
+ if (!commandToRun) throw new Error("No command to run");
266
+ const baseCMD = commandToRun.split(" ")[0];
267
+ const args = commandToRun.split(" ").slice(1);
268
+ socket.emit("log", import_chalk.default.green(`${data.workspace.path}: ${commandToRun}`));
269
+ const child = (0, import_child_process.spawn)(baseCMD, args, {
270
+ cwd: workspace.path,
271
+ env: {
272
+ ...process.env,
273
+ TERM: "dumb",
274
+ FORCE_COLOR: "1"
275
+ },
276
+ stdio: ["ignore", "pipe", "pipe"],
277
+ shell: true,
278
+ detached: process.platform !== "win32"
279
+ });
280
+ activeProcesses.set(workspace.name, child);
281
+ child.on("error", (error) => {
282
+ socket.emit("error", error.message);
283
+ });
284
+ child.stdout.on("data", (data2) => {
285
+ socket.emit("log", data2.toString());
286
+ });
287
+ child.stderr.on("data", (data2) => {
288
+ socket.emit("error", data2.toString());
289
+ });
290
+ child.on("exit", (code) => {
291
+ socket.emit("exit", `Process exited with code ${code}`);
292
+ });
293
+ }
294
+
295
+ // src/routes/stopcmd.ts
296
+ var import_express2 = require("express");
297
+ var import_child_process2 = require("child_process");
298
+ var import_util = require("util");
299
+ var import_chalk2 = __toESM(require("chalk"));
300
+ var router = (0, import_express2.Router)();
301
+ router.post("/", async (req, res) => {
302
+ res.header("Access-Control-Allow-Origin", "*");
303
+ try {
304
+ const body = req.body;
305
+ const workspace = body.workspace;
306
+ if (!workspace) {
307
+ return res.status(400).json({ error: "No workspace provided" });
308
+ }
309
+ const currentSocket = sockets.get(workspace.name);
310
+ const currentProcess = activeProcesses.get(workspace.name);
311
+ if (currentProcess) {
312
+ currentSocket == null ? void 0 : currentSocket.emit("log", import_chalk2.default.yellow("Stopping active process..."));
313
+ if (currentProcess.pid) {
314
+ if (process.platform !== "win32") {
315
+ await cleanupProcessPorts(currentProcess.pid, currentSocket);
316
+ }
317
+ }
318
+ await new Promise((resolve) => {
319
+ let resolved = false;
320
+ const safeResolve = () => {
321
+ if (!resolved) {
322
+ resolved = true;
323
+ resolve();
324
+ }
25
325
  };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
326
+ const timer = setTimeout(() => {
327
+ console.log(`Process stop timed out for ${workspace.name}`);
328
+ safeResolve();
329
+ }, 5e3);
330
+ currentProcess.once("exit", () => {
331
+ clearTimeout(timer);
332
+ safeResolve();
333
+ });
334
+ if (currentProcess.pid) {
335
+ try {
336
+ if (process.platform !== "win32") {
337
+ process.kill(-currentProcess.pid, "SIGINT");
338
+ } else {
339
+ currentProcess.kill();
340
+ }
341
+ } catch (error) {
342
+ if (error.code === "ESRCH") {
343
+ clearTimeout(timer);
344
+ safeResolve();
345
+ } else {
346
+ console.error(`Failed to kill process: ${error.message}`);
347
+ }
348
+ }
349
+ } else {
350
+ safeResolve();
351
+ }
352
+ });
353
+ activeProcesses.delete(workspace.name);
354
+ } else {
355
+ currentSocket == null ? void 0 : currentSocket.emit("log", import_chalk2.default.yellow("No active process found to stop."));
356
+ }
357
+ const commandToRun = workspace.stopCommand;
358
+ if (commandToRun) {
359
+ currentSocket == null ? void 0 : currentSocket.emit("log", import_chalk2.default.green(`Running stop command: ${commandToRun}`));
360
+ const baseCMD = commandToRun.split(" ")[0];
361
+ const args = commandToRun.split(" ").slice(1);
362
+ const child = (0, import_child_process2.spawn)(baseCMD, args, {
363
+ cwd: workspace.path,
364
+ env: {
365
+ ...process.env,
366
+ TERM: "dumb",
367
+ FORCE_COLOR: "1"
368
+ },
369
+ stdio: ["ignore", "pipe", "pipe"],
370
+ shell: true,
371
+ detached: process.platform !== "win32"
372
+ });
373
+ child.stdout.on("data", (data) => {
374
+ currentSocket == null ? void 0 : currentSocket.emit("log", data.toString());
375
+ });
376
+ child.stderr.on("data", (data) => {
377
+ currentSocket == null ? void 0 : currentSocket.emit("error", data.toString());
378
+ });
379
+ child.on("close", (code) => {
380
+ currentSocket == null ? void 0 : currentSocket.emit("log", import_chalk2.default.green(`Stop command finished with code ${code}`));
381
+ currentSocket == null ? void 0 : currentSocket.emit("exit", "Process stopped");
382
+ });
383
+ } else {
384
+ currentSocket == null ? void 0 : currentSocket.emit("log", "Process stopped (no stop command defined).");
385
+ currentSocket == null ? void 0 : currentSocket.emit("exit", "Process stopped");
386
+ }
387
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
388
+ res.end();
389
+ } catch (e) {
390
+ console.error("Error in stopcmd:", e);
391
+ res.status(500).json({ error: e.message });
392
+ }
393
+ });
394
+ var stopcmd_default = router;
395
+ var execAsync = (0, import_util.promisify)(import_child_process2.exec);
396
+ async function getProcessTreePids(rootPid) {
397
+ var _a;
398
+ try {
399
+ const { stdout } = await execAsync("ps -e -o pid,ppid --no-headers");
400
+ const pids = /* @__PURE__ */ new Set();
401
+ pids.add(rootPid);
402
+ const tree = /* @__PURE__ */ new Map();
403
+ const lines = stdout.trim().split("\n");
404
+ for (const line of lines) {
405
+ const parts = line.trim().split(/\s+/);
406
+ if (parts.length >= 2) {
407
+ const pid = parseInt(parts[0], 10);
408
+ const ppid = parseInt(parts[1], 10);
409
+ if (!tree.has(ppid)) tree.set(ppid, []);
410
+ (_a = tree.get(ppid)) == null ? void 0 : _a.push(pid);
411
+ }
412
+ }
413
+ const queue = [rootPid];
414
+ while (queue.length > 0) {
415
+ const current = queue.shift();
416
+ const children = tree.get(current);
417
+ if (children) {
418
+ for (const child of children) {
419
+ pids.add(child);
420
+ queue.push(child);
421
+ }
422
+ }
423
+ }
424
+ return Array.from(pids);
425
+ } catch (e) {
426
+ console.error("Error building process tree:", e);
427
+ return [rootPid];
428
+ }
429
+ }
430
+ async function cleanupProcessPorts(rootPid, socket) {
431
+ var _a;
432
+ try {
433
+ const pids = await getProcessTreePids(rootPid);
434
+ const { stdout } = await execAsync("lsof -P -n -iTCP -sTCP:LISTEN -F pn");
435
+ const lines = stdout.trim().split("\n");
436
+ let currentPid = -1;
437
+ const pidPorts = /* @__PURE__ */ new Map();
438
+ for (const line of lines) {
439
+ const type = line[0];
440
+ const content = line.substring(1);
441
+ if (type === "p") {
442
+ currentPid = parseInt(content, 10);
443
+ } else if (type === "n" && currentPid !== -1) {
444
+ const match = content.match(/:(\d+)$/);
445
+ if (match) {
446
+ const port2 = match[1];
447
+ if (!pidPorts.has(currentPid)) pidPorts.set(currentPid, []);
448
+ (_a = pidPorts.get(currentPid)) == null ? void 0 : _a.push(port2);
449
+ }
450
+ }
451
+ }
452
+ for (const pid of pids) {
453
+ if (pidPorts.has(pid)) {
454
+ const ports = pidPorts.get(pid);
455
+ if (ports) {
456
+ for (const port2 of ports) {
457
+ socket == null ? void 0 : socket.emit("log", import_chalk2.default.yellow(`Detected active port ${port2} on PID ${pid}. Killing port...`));
458
+ try {
459
+ await execAsync(`npx -y kill-port ${port2}`);
460
+ } catch (err) {
461
+ socket == null ? void 0 : socket.emit("log", import_chalk2.default.red(`Failed to kill port ${port2}: ${err.message}`));
462
+ }
463
+ }
464
+ }
465
+ }
466
+ }
467
+ } catch (e) {
468
+ }
469
+ }
470
+
471
+ // src/routes/listworkspacedirs.ts
472
+ var import_express3 = require("express");
473
+ var import_fs_extra2 = __toESM(require("fs-extra"));
474
+ var import_path2 = __toESM(require("path"));
475
+ var router2 = (0, import_express3.Router)();
476
+ var START_DIR2 = process.cwd();
477
+ var findRoot = async (dir) => {
478
+ const pkgPath = import_path2.default.join(dir, "package.json");
479
+ if (await import_fs_extra2.default.pathExists(pkgPath)) {
480
+ try {
481
+ const pkg = await import_fs_extra2.default.readJSON(pkgPath);
482
+ if (pkg.workspaces) {
483
+ return dir;
484
+ }
485
+ } catch {
486
+ }
487
+ }
488
+ const parent = import_path2.default.dirname(dir);
489
+ if (parent === dir) return START_DIR2;
490
+ return findRoot(parent);
491
+ };
492
+ router2.get("/", async (req, res) => {
493
+ res.header("Access-Control-Allow-Origin", "*");
494
+ try {
495
+ const rootPath = await findRoot(START_DIR2);
496
+ const pkgPath = import_path2.default.join(rootPath, "package.json");
497
+ let workspaceDirs = [];
498
+ let foundWorkspaces = false;
499
+ if (await import_fs_extra2.default.pathExists(pkgPath)) {
500
+ const pkg = await import_fs_extra2.default.readJSON(pkgPath);
501
+ let globs = [];
502
+ if (pkg.workspaces) {
503
+ if (Array.isArray(pkg.workspaces)) {
504
+ globs = pkg.workspaces;
505
+ } else if (pkg.workspaces.packages && Array.isArray(pkg.workspaces.packages)) {
506
+ globs = pkg.workspaces.packages;
507
+ }
508
+ }
509
+ if (globs.length > 0) {
510
+ foundWorkspaces = true;
511
+ const uniqueDirs = /* @__PURE__ */ new Set();
512
+ for (const pattern of globs) {
513
+ const parts = pattern.split("/");
514
+ if (parts.length > 0) {
515
+ const topLevel = parts[0];
516
+ if (topLevel && topLevel !== "*") {
517
+ uniqueDirs.add(topLevel);
518
+ }
519
+ }
520
+ }
521
+ for (const dirName of uniqueDirs) {
522
+ const fullPath = import_path2.default.join(rootPath, dirName);
523
+ if (await import_fs_extra2.default.pathExists(fullPath)) {
524
+ workspaceDirs.push({
525
+ label: dirName,
526
+ path: fullPath
527
+ });
528
+ }
529
+ }
530
+ }
531
+ }
532
+ if (!foundWorkspaces) {
533
+ const items = await import_fs_extra2.default.readdir(rootPath, { withFileTypes: true });
534
+ workspaceDirs = items.filter((item) => item.isDirectory()).filter((item) => {
535
+ const name = item.name;
536
+ if (name === "node_modules") return false;
537
+ if (name.startsWith(".")) return false;
538
+ if (name.startsWith("_")) return false;
539
+ return true;
540
+ }).map((item) => ({
541
+ label: item.name,
542
+ path: import_path2.default.join(rootPath, item.name)
543
+ }));
544
+ }
545
+ return res.json(workspaceDirs);
546
+ } catch (e) {
547
+ console.error("Error listing workspaces:", e);
548
+ res.status(500).json({ error: e.message });
549
+ }
550
+ });
551
+ var listworkspacedirs_default = router2;
552
+
553
+ // src/routes/newworkspace.ts
554
+ var import_express4 = require("express");
555
+ var import_fs_extra3 = __toESM(require("fs-extra"));
556
+ var import_path3 = __toESM(require("path"));
557
+ var router3 = (0, import_express4.Router)();
558
+ router3.post("/", async (req, res) => {
559
+ res.header("Access-Control-Allow-Origin", "*");
560
+ try {
561
+ const reqBody = req.body;
562
+ const targetPath = reqBody.path;
563
+ if (!targetPath) {
564
+ return res.status(400).json({ error: "Path is required" });
565
+ }
566
+ await import_fs_extra3.default.ensureDir(targetPath);
567
+ const packageJson = {
568
+ name: reqBody.name || import_path3.default.basename(targetPath),
569
+ version: "1.0.0",
570
+ description: reqBody.description || "",
571
+ fontawesomeIcon: reqBody.fontawesomeIcon || "",
572
+ scripts: {
573
+ dev: reqBody.devCommand || "",
574
+ start: reqBody.startCommand || void 0,
575
+ stop: reqBody.stopCommand || void 0,
576
+ build: reqBody.buildCommand || void 0,
577
+ clean: reqBody.cleanCommand || void 0,
578
+ lint: reqBody.lintCommand || void 0,
579
+ test: reqBody.testCommand || void 0
580
+ }
34
581
  };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
582
+ Object.keys(packageJson.scripts).forEach(
583
+ (key) => packageJson.scripts[key] === void 0 && delete packageJson.scripts[key]
584
+ );
585
+ await import_fs_extra3.default.writeJSON(import_path3.default.join(targetPath, "package.json"), packageJson, { spaces: 2 });
586
+ res.json({ message: "Workspace created successfully", path: targetPath });
587
+ } catch (e) {
588
+ console.error("Error creating workspace:", e);
589
+ res.status(500).json({ error: e.message });
590
+ }
591
+ });
592
+ var newworkspace_default = router3;
593
+
594
+ // src/routes/interactiveTerminal.ts
595
+ var import_express5 = require("express");
596
+ var import_child_process3 = require("child_process");
597
+ var router4 = (0, import_express5.Router)();
598
+ router4.get("/", async (req, res) => {
599
+ res.send("Interactive Terminal Route");
600
+ });
601
+ var interactiveTerminal_default = router4;
602
+ var activeTerminals = /* @__PURE__ */ new Map();
603
+ function interactiveTerminalSocket(io2) {
604
+ io2.on("connection", (socket) => {
605
+ socket.on("terminal:start", (data) => {
606
+ var _a, _b, _c, _d;
607
+ const { path: path10, command } = data;
608
+ if (activeTerminals.has(socket.id)) {
609
+ const oldChild = activeTerminals.get(socket.id);
610
+ if (oldChild) {
611
+ oldChild.removeAllListeners();
612
+ (_a = oldChild.stdout) == null ? void 0 : _a.removeAllListeners();
613
+ (_b = oldChild.stderr) == null ? void 0 : _b.removeAllListeners();
614
+ oldChild.kill();
615
+ activeTerminals.delete(socket.id);
616
+ socket.emit("terminal:log", "\r\n\x1B[33m[System] Previous command terminated.\x1B[0m\r\n");
617
+ }
618
+ }
619
+ try {
620
+ const env = { ...process.env };
621
+ delete env.CI;
622
+ env.TERM = "xterm-256color";
623
+ env.FORCE_COLOR = "1";
624
+ env.PROMPT_COMMAND = 'export PS1="\\[\\033[34m\\][PATH] \\[\\033[32m\\]\\w\\[\\033[0m\\]\\n$ ";';
625
+ let child;
626
+ if (process.platform === "win32") {
627
+ socket.emit("terminal:log", "\x1B[33m[System] Windows detected. Running in compatible mode (limited interactivity).\x1B[0m\r\n");
628
+ const baseCMD = command.split(" ")[0];
629
+ const args = command.split(" ").slice(1);
630
+ child = (0, import_child_process3.spawn)(baseCMD, args, {
631
+ cwd: path10,
632
+ env,
633
+ shell: true,
634
+ stdio: ["pipe", "pipe", "pipe"]
635
+ });
636
+ } else {
637
+ env.CMD = command;
638
+ const pythonScript = `
639
+ import pty, sys, os
640
+
641
+ try:
642
+ cmd = os.environ.get('CMD')
643
+ if not cmd:
644
+ sys.exit(1)
645
+
646
+ # pty.spawn(argv) executes argv and connects stdin/stdout to pty
647
+ status = pty.spawn(['/bin/bash', '-c', 'stty cols 80 rows 24; ' + cmd])
648
+
649
+ if os.WIFEXITED(status):
650
+ sys.exit(os.WEXITSTATUS(status))
651
+ else:
652
+ sys.exit(1)
653
+ except ImportError:
654
+ sys.exit(127) # Return special code if pty module missing (unlikely on unix)
655
+ except Exception as e:
656
+ sys.exit(1)
657
+ `;
658
+ child = (0, import_child_process3.spawn)("python3", ["-u", "-c", pythonScript], {
659
+ cwd: path10,
660
+ env,
661
+ stdio: ["pipe", "pipe", "pipe"]
662
+ });
663
+ }
664
+ activeTerminals.set(socket.id, child);
665
+ (_c = child.stdout) == null ? void 0 : _c.on("data", (chunk) => {
666
+ socket.emit("terminal:log", chunk.toString());
667
+ });
668
+ (_d = child.stderr) == null ? void 0 : _d.on("data", (chunk) => {
669
+ socket.emit("terminal:log", chunk.toString());
670
+ });
671
+ child.on("error", (err) => {
672
+ if (err.code === "ENOENT" && process.platform !== "win32") {
673
+ socket.emit("terminal:error", "\r\n\x1B[31mError: Python3 is required for interactive mode on Linux/Mac but was not found.\x1B[0m");
674
+ } else {
675
+ socket.emit("terminal:error", `Failed to start command: ${err.message}`);
676
+ }
677
+ cleanup(socket.id);
678
+ });
679
+ child.on("exit", (code) => {
680
+ if (code === 127 && process.platform !== "win32") {
681
+ socket.emit("terminal:error", "\r\n\x1B[31mError: Python PTY module issue.\x1B[0m");
682
+ } else if (code !== 0) {
683
+ socket.emit("terminal:error", `\r
684
+ Process exited with code ${code}`);
685
+ } else {
686
+ }
687
+ socket.emit("terminal:exit", code);
688
+ cleanup(socket.id);
689
+ });
690
+ } catch (error) {
691
+ socket.emit("terminal:error", `Error handling command: ${error.message}`);
692
+ cleanup(socket.id);
693
+ }
694
+ });
695
+ socket.on("terminal:input", (input) => {
696
+ const child = activeTerminals.get(socket.id);
697
+ if (child && child.stdin) {
698
+ child.stdin.write(input);
699
+ }
700
+ });
701
+ socket.on("disconnect", () => {
702
+ var _a, _b;
703
+ const child = activeTerminals.get(socket.id);
704
+ if (child) {
705
+ child.removeAllListeners();
706
+ (_a = child.stdout) == null ? void 0 : _a.removeAllListeners();
707
+ (_b = child.stderr) == null ? void 0 : _b.removeAllListeners();
708
+ child.kill();
709
+ activeTerminals.delete(socket.id);
710
+ }
711
+ });
712
+ function cleanup(socketId) {
713
+ activeTerminals.delete(socketId);
714
+ }
715
+ });
716
+ }
717
+
718
+ // src/routes/updateworkspace.ts
719
+ var import_express6 = require("express");
720
+ var import_fs_extra4 = __toESM(require("fs-extra"));
721
+ var import_path4 = __toESM(require("path"));
722
+ var router5 = (0, import_express6.Router)();
723
+ router5.post("/", async (req, res) => {
724
+ res.header("Access-Control-Allow-Origin", "*");
725
+ try {
726
+ const workspace = req.body;
727
+ if (!workspace || !workspace.path) {
728
+ res.status(400).send({ error: "Invalid workspace data" });
729
+ return;
730
+ }
731
+ const packageJsonPath = import_path4.default.join(workspace.path, "package.json");
732
+ if (!import_fs_extra4.default.existsSync(packageJsonPath)) {
733
+ res.status(404).send({ error: "package.json not found in workspace path" });
734
+ return;
735
+ }
736
+ const packageJson = await import_fs_extra4.default.readJson(packageJsonPath);
737
+ if (workspace.name) packageJson.name = workspace.name;
738
+ if (workspace.description != "object") packageJson.description = workspace.description;
739
+ if (workspace.devCommand != "object") packageJson.scripts.dev = workspace.devCommand;
740
+ if (workspace.startCommand != "object") packageJson.scripts.start = workspace.startCommand;
741
+ if (workspace.buildCommand != "object") packageJson.scripts.build = workspace.buildCommand;
742
+ if (workspace.testCommand != "object") packageJson.scripts.test = workspace.testCommand;
743
+ if (workspace.lintCommand != "object") packageJson.scripts.lint = workspace.lintCommand;
744
+ if (workspace.stopCommand != "object") packageJson.scripts.stop = workspace.stopCommand;
745
+ if (workspace.cleanCommand != "object") packageJson.scripts.clean = workspace.cleanCommand;
746
+ await import_fs_extra4.default.writeJson(packageJsonPath, packageJson, { spaces: 2 });
747
+ res.send({ success: true, message: "Workspace updated successfully" });
748
+ } catch (error) {
749
+ console.error("Update workspace error:", error);
750
+ res.status(500).send({ error: error.message });
751
+ }
752
+ });
753
+ var updateworkspace_default = router5;
754
+
755
+ // src/routes/vscodeHideShow.ts
756
+ var import_express7 = require("express");
757
+ var import_fs_extra5 = __toESM(require("fs-extra"));
758
+ var import_path5 = __toESM(require("path"));
759
+ var router6 = (0, import_express7.Router)();
760
+ var EXCLUDE_PATTERNS = {
761
+ "**/node_modules": true,
762
+ "**/.git": true,
763
+ "**/.gitignore": true,
764
+ "**/.turbo": true,
765
+ "**/dist": true,
766
+ "**/_tool": true,
767
+ "**/package-lock.json": true,
768
+ "**/Dockerfile": true,
769
+ "**/docker-compose.yml": true,
770
+ "**/.dockerignore": true,
771
+ "**/turbo.json": true,
772
+ "**/nodemon.json": true,
773
+ "**/temp.md": true,
774
+ "**/*postcss*": true,
775
+ "**/*tailwind*": true,
776
+ "**/*tsconfig*": true,
777
+ "**/*eslint*": true,
778
+ "**/*prettier*": true,
779
+ "**/*vite*": true,
780
+ "_temp": true,
781
+ ".gitignore": true,
782
+ ".vscode": true,
783
+ "package.json": true,
784
+ "README.md": true,
785
+ ".github": true,
786
+ ".buildkite": true,
787
+ ".circleci": true,
788
+ ".gitlab-ci.yml": true,
789
+ ".travis.yml": true,
790
+ "out": true
791
+ };
792
+ var EXCLUDE_PATTERNS_DEFAULT = {
793
+ "**/.git": true,
794
+ ".vscode": true,
795
+ ".turbo": true
38
796
  };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.httpServer = exports.io = exports.app = void 0;
41
- const express_1 = __importDefault(require("express"));
42
- const cors_1 = __importDefault(require("cors"));
43
- const path_1 = __importDefault(require("path"));
44
- const apiroute_1 = __importDefault(require("apiroute"));
45
- const config_1 = __importDefault(require("config"));
46
- const open_1 = __importDefault(require("open"));
47
- const http_1 = require("http");
48
- const socket_io_1 = require("socket.io");
49
- //routers
50
- const scanworkspace_1 = __importDefault(require("./routes/scanworkspace"));
51
- const runcmddev_1 = __importDefault(require("./routes/runcmddev"));
52
- const stopcmd_1 = __importDefault(require("./routes/stopcmd"));
53
- const listworkspacedirs_1 = __importDefault(require("./routes/listworkspacedirs"));
54
- const newworkspace_1 = __importDefault(require("./routes/newworkspace"));
55
- const interactiveTerminal_1 = __importStar(require("./routes/interactiveTerminal"));
56
- const updateworkspace_1 = __importDefault(require("./routes/updateworkspace"));
57
- const vscodeHideShow_1 = __importDefault(require("./routes/vscodeHideShow"));
58
- const rootPath_1 = __importDefault(require("./routes/rootPath"));
59
- const scafoldrepo_1 = __importDefault(require("./routes/scafoldrepo"));
60
- const turborepoexist_1 = __importDefault(require("./routes/turborepoexist"));
61
- const app = (0, express_1.default)();
62
- exports.app = app;
63
- const port = config_1.default.apiPort;
64
- app.use((0, cors_1.default)({
65
- origin: true,
66
- credentials: true,
797
+ var START_DIR3 = process.cwd();
798
+ function findMonorepoRoot2(startDir) {
799
+ let dir = startDir;
800
+ while (dir !== import_path5.default.dirname(dir)) {
801
+ const pkgPath = import_path5.default.join(dir, "package.json");
802
+ if (import_fs_extra5.default.existsSync(pkgPath)) {
803
+ try {
804
+ const pkg = import_fs_extra5.default.readJsonSync(pkgPath);
805
+ if (pkg.workspaces) {
806
+ return dir;
807
+ }
808
+ } catch (e) {
809
+ }
810
+ }
811
+ if (import_fs_extra5.default.existsSync(import_path5.default.join(dir, ".vscode"))) {
812
+ return dir;
813
+ }
814
+ dir = import_path5.default.dirname(dir);
815
+ }
816
+ return startDir;
817
+ }
818
+ var ROOT2 = findMonorepoRoot2(START_DIR3);
819
+ var getSettingsPath = () => {
820
+ return import_path5.default.join(ROOT2, ".vscode/settings.json");
821
+ };
822
+ var ensureSettingsFile = async () => {
823
+ const settingsPath = getSettingsPath();
824
+ const dir = import_path5.default.dirname(settingsPath);
825
+ await import_fs_extra5.default.ensureDir(dir);
826
+ if (!await import_fs_extra5.default.pathExists(settingsPath)) {
827
+ await import_fs_extra5.default.writeJson(settingsPath, { "files.exclude": {} }, { spaces: 4 });
828
+ }
829
+ };
830
+ router6.post("/", async (req, res) => {
831
+ try {
832
+ const { hide, pathInclude } = req.body;
833
+ await ensureSettingsFile();
834
+ const settingsPath = getSettingsPath();
835
+ const settings = await import_fs_extra5.default.readJson(settingsPath);
836
+ const newExcludes = { ...EXCLUDE_PATTERNS_DEFAULT };
837
+ if (hide) {
838
+ Object.assign(newExcludes, EXCLUDE_PATTERNS);
839
+ if (Array.isArray(pathInclude)) {
840
+ pathInclude.forEach((p) => {
841
+ const relativePath = import_path5.default.relative(ROOT2, p);
842
+ if (relativePath && !relativePath.startsWith("..") && !import_path5.default.isAbsolute(relativePath)) {
843
+ newExcludes[relativePath] = true;
844
+ }
845
+ });
846
+ }
847
+ }
848
+ settings["files.exclude"] = newExcludes;
849
+ await import_fs_extra5.default.writeJson(settingsPath, settings, { spaces: 4 });
850
+ res.json({ success: true, isHidden: hide });
851
+ } catch (error) {
852
+ console.error("Error updating VSCode settings:", error);
853
+ res.status(500).json({ error: "Failed to update VSCode settings" });
854
+ }
855
+ });
856
+ var vscodeHideShow_default = router6;
857
+
858
+ // src/routes/rootPath.ts
859
+ var import_fs_extra6 = __toESM(require("fs-extra"));
860
+ var import_path6 = __toESM(require("path"));
861
+ var import_express8 = require("express");
862
+ var START_DIR4 = process.cwd();
863
+ function findMonorepoRoot3(startDir) {
864
+ let dir = startDir;
865
+ while (dir !== import_path6.default.dirname(dir)) {
866
+ const pkgPath = import_path6.default.join(dir, "package.json");
867
+ if (import_fs_extra6.default.existsSync(pkgPath)) {
868
+ try {
869
+ const pkg = import_fs_extra6.default.readJsonSync(pkgPath);
870
+ if (pkg.workspaces) {
871
+ return dir;
872
+ }
873
+ } catch (e) {
874
+ }
875
+ }
876
+ dir = import_path6.default.dirname(dir);
877
+ }
878
+ return startDir;
879
+ }
880
+ var ROOT3 = findMonorepoRoot3(START_DIR4);
881
+ var route2 = (0, import_express8.Router)();
882
+ route2.get("/", async (req, res) => {
883
+ res.json({ path: ROOT3 });
884
+ });
885
+ var rootPath_default = route2;
886
+
887
+ // src/routes/scafoldrepo.ts
888
+ var import_express9 = require("express");
889
+ var import_fs_extra7 = __toESM(require("fs-extra"));
890
+ var import_path7 = __toESM(require("path"));
891
+ var import_child_process4 = require("child_process");
892
+ var router7 = (0, import_express9.Router)();
893
+ router7.get("/", async (req, res) => {
894
+ var _a;
895
+ try {
896
+ const packageJsonPath = import_path7.default.join(ROOT3, "package.json");
897
+ const turboJsonPath = import_path7.default.join(ROOT3, "turbo.json");
898
+ if (!import_fs_extra7.default.existsSync(packageJsonPath)) {
899
+ res.status(400).json({ error: "package.json not found in root" });
900
+ return;
901
+ }
902
+ const pkg = import_fs_extra7.default.readJsonSync(packageJsonPath);
903
+ let pkgChanged = false;
904
+ if (!pkg.workspaces) {
905
+ pkg.workspaces = ["apps/*", "packages/*"];
906
+ pkgChanged = true;
907
+ }
908
+ if (pkgChanged) {
909
+ import_fs_extra7.default.writeJsonSync(packageJsonPath, pkg, { spaces: 2 });
910
+ }
911
+ await import_fs_extra7.default.ensureDir(import_path7.default.join(ROOT3, "apps"));
912
+ await import_fs_extra7.default.ensureDir(import_path7.default.join(ROOT3, "packages"));
913
+ const monorepoTimePath = import_path7.default.join(ROOT3, "monorepotime.json");
914
+ if (!import_fs_extra7.default.existsSync(monorepoTimePath)) {
915
+ const defaultMonorepoTime = [
916
+ {
917
+ "category": "Internal CRUD Test",
918
+ "devurl": "http://localhost:3200",
919
+ "produrl": "http://superhost:3200",
920
+ "items": [
921
+ {
922
+ "label": "Ping the Tool Server",
923
+ "route": "/pingme",
924
+ "methods": "GET",
925
+ "description": "Ping the tool server to check if it is running.",
926
+ "sampleInput": "{}",
927
+ "suggested": [],
928
+ "expectedOutcome": '# You should see the word "pong" as a message \n\n{\n "message": "pong"\n}',
929
+ "availableFor": "public"
930
+ },
931
+ {
932
+ "label": "Check Post",
933
+ "route": "/pingpost",
934
+ "methods": "POST",
935
+ "description": "Send a POST request to check if it sending correctly",
936
+ "sampleInput": '{\n "data": "test",\n "message": "test"\n}',
937
+ "suggested": [
938
+ {
939
+ "name": "Customer Data",
940
+ "urlparams": "",
941
+ "content": '{\n "name": "Demo Customer",\n "email": "CusRaRa@customer.com",\n "phone1": "123456789",\n "phone2": "987654321",\n "city": "randomw1",\n "state": "ultra state",\n "zip": "12345",\n "country": "mega country",\n "icon": "test icon",\n "gender": "female",\n "delivery_notes": "Make sure that it is packed correctly"\n}'
942
+ }
943
+ ],
944
+ "expectedOutcome": "# Note \nYou should see the mirror of your inputs",
945
+ "availableFor": "public"
946
+ },
947
+ {
948
+ "label": "Check Stream",
949
+ "route": "/pingstream",
950
+ "methods": "STREAM",
951
+ "description": "Send a stream request to check if it sending correctly",
952
+ "sampleInput": "{ }",
953
+ "suggested": [
954
+ {
955
+ "name": "I Wandered Lonely as a Cloud",
956
+ "urlparams": "?poem=I%20Wandered%20Lonely%20as%20a%20Cloud",
957
+ "content": "{}"
958
+ },
959
+ {
960
+ "name": "The Sun Has Long Been Set",
961
+ "urlparams": "?poem=The%20Sun%20Has%20Long%20Been%20Set",
962
+ "content": "{}"
963
+ }
964
+ ],
965
+ "expectedOutcome": "# Note \nYou should see the stream of words",
966
+ "availableFor": "public"
967
+ }
968
+ ]
969
+ }
970
+ ];
971
+ import_fs_extra7.default.writeJsonSync(monorepoTimePath, defaultMonorepoTime, { spaces: 4 });
972
+ }
973
+ if (!import_fs_extra7.default.existsSync(turboJsonPath) || !((_a = pkg.devDependencies) == null ? void 0 : _a.turbo)) {
974
+ if (!import_fs_extra7.default.existsSync(turboJsonPath)) {
975
+ const defaultTurbo = {
976
+ "$schema": "https://turbo.build/schema.json",
977
+ "pipeline": {
978
+ "build": {
979
+ "outputs": ["dist/**", ".next/**"]
980
+ },
981
+ "lint": {}
982
+ }
983
+ };
984
+ import_fs_extra7.default.writeJsonSync(turboJsonPath, defaultTurbo, { spaces: 2 });
985
+ }
986
+ const hasTurbo = pkg.devDependencies && pkg.devDependencies.turbo;
987
+ if (!hasTurbo) {
988
+ await runCommand("npm install turbo -D", ROOT3);
989
+ } else {
990
+ await runCommand("npm install", ROOT3);
991
+ }
992
+ } else {
993
+ if (pkgChanged) {
994
+ await runCommand("npm install", ROOT3);
995
+ }
996
+ }
997
+ res.json({ success: true, message: "Scaffolding complete" });
998
+ } catch (error) {
999
+ console.error("Scaffolding error:", error);
1000
+ res.status(500).json({
1001
+ error: "Failed to scaffold",
1002
+ details: error instanceof Error ? error.message : String(error)
1003
+ });
1004
+ }
1005
+ });
1006
+ function runCommand(cmd, cwd) {
1007
+ console.log(`Running: ${cmd} in ${cwd}`);
1008
+ return new Promise((resolve, reject) => {
1009
+ (0, import_child_process4.exec)(cmd, { cwd }, (error, stdout, stderr) => {
1010
+ if (error) {
1011
+ console.error("Exec error:", stderr);
1012
+ reject(error);
1013
+ } else {
1014
+ console.log(stdout);
1015
+ resolve();
1016
+ }
1017
+ });
1018
+ });
1019
+ }
1020
+ var scafoldrepo_default = router7;
1021
+
1022
+ // src/routes/turborepoexist.ts
1023
+ var import_express10 = require("express");
1024
+ var import_fs = __toESM(require("fs"));
1025
+ var import_path8 = __toESM(require("path"));
1026
+ var router8 = (0, import_express10.Router)();
1027
+ router8.get("/", async (req, res) => {
1028
+ try {
1029
+ let isExist = true;
1030
+ const turboJsonPath = import_path8.default.join(ROOT3, "turbo.json");
1031
+ const turboExists = import_fs.default.existsSync(turboJsonPath);
1032
+ if (!turboExists) {
1033
+ isExist = false;
1034
+ }
1035
+ const monorepoJsonPath = import_path8.default.join(ROOT3, "monorepotime.json");
1036
+ const monorepoExists = import_fs.default.existsSync(monorepoJsonPath);
1037
+ if (!monorepoExists) {
1038
+ isExist = false;
1039
+ }
1040
+ res.json({ exists: isExist });
1041
+ } catch (error) {
1042
+ console.error("Error checking turbo.json:", error);
1043
+ res.status(500).json({ error: "Internal server error", exists: false });
1044
+ }
1045
+ });
1046
+ var turborepoexist_default = router8;
1047
+
1048
+ // src/index.ts
1049
+ var app = (0, import_express11.default)();
1050
+ var port = config_default.apiPort;
1051
+ app.use((0, import_cors.default)({
1052
+ origin: true,
1053
+ credentials: true
67
1054
  }));
68
- app.use(express_1.default.static('public'));
69
- app.use(express_1.default.json());
70
- // Serve frontend static files
71
- //routes=======================================================================
72
- app.use("/" + apiroute_1.default.scanWorkspace, scanworkspace_1.default);
73
- app.use("/" + apiroute_1.default.stopProcess, stopcmd_1.default);
74
- app.use("/" + apiroute_1.default.listWorkspacesDir, listworkspacedirs_1.default);
75
- app.use("/" + apiroute_1.default.newWorkspace, newworkspace_1.default);
76
- app.use("/" + apiroute_1.default.interactvTerminal, interactiveTerminal_1.default);
77
- app.use("/" + apiroute_1.default.updateWorkspace, updateworkspace_1.default);
78
- app.use("/" + apiroute_1.default.hideShowFileFolder, vscodeHideShow_1.default);
79
- app.use("/" + apiroute_1.default.getRootPath, rootPath_1.default);
80
- app.use("/" + apiroute_1.default.scaffoldRepo, scafoldrepo_1.default);
81
- app.use("/" + apiroute_1.default.turborepoExist, turborepoexist_1.default);
82
- // Serve frontend static files==================================================
83
- const frontendPath = path_1.default.join(__dirname, '../public');
84
- app.use(express_1.default.static(frontendPath));
85
- app.get('*', (req, res) => {
86
- res.sendFile(path_1.default.join(frontendPath, 'index.html'));
1055
+ app.use(import_express11.default.static("public"));
1056
+ app.use(import_express11.default.json());
1057
+ app.use("/" + api_default.scanWorkspace, scanworkspace_default);
1058
+ app.use("/" + api_default.stopProcess, stopcmd_default);
1059
+ app.use("/" + api_default.listWorkspacesDir, listworkspacedirs_default);
1060
+ app.use("/" + api_default.newWorkspace, newworkspace_default);
1061
+ app.use("/" + api_default.interactvTerminal, interactiveTerminal_default);
1062
+ app.use("/" + api_default.updateWorkspace, updateworkspace_default);
1063
+ app.use("/" + api_default.hideShowFileFolder, vscodeHideShow_default);
1064
+ app.use("/" + api_default.getRootPath, rootPath_default);
1065
+ app.use("/" + api_default.scaffoldRepo, scafoldrepo_default);
1066
+ app.use("/" + api_default.turborepoExist, turborepoexist_default);
1067
+ var frontendPath = import_path9.default.join(__dirname, "../public");
1068
+ app.use(import_express11.default.static(frontendPath));
1069
+ app.get("*", (req, res) => {
1070
+ res.sendFile(import_path9.default.join(frontendPath, "index.html"));
87
1071
  });
88
- // Socket.IO Setup ============================================================
89
- const httpServer = (0, http_1.createServer)(app);
90
- exports.httpServer = httpServer;
91
- const io = new socket_io_1.Server(httpServer, {
92
- cors: {
93
- origin: "*",
94
- methods: ["GET", "POST"],
95
- },
96
- transports: ['websocket', 'polling']
1072
+ var httpServer = (0, import_http.createServer)(app);
1073
+ var io = new import_socket.Server(httpServer, {
1074
+ cors: {
1075
+ origin: "*",
1076
+ methods: ["GET", "POST"]
1077
+ },
1078
+ transports: ["websocket", "polling"]
97
1079
  });
98
- exports.io = io;
99
- (0, runcmddev_1.default)(io);
100
- (0, interactiveTerminal_1.interactiveTerminalSocket)(io);
101
- //=============================================================================
1080
+ runCmdDevSocket(io);
1081
+ interactiveTerminalSocket(io);
102
1082
  httpServer.listen(port, () => {
103
- console.log(`Server running at http://localhost:${port}`);
104
- (0, open_1.default)(`http://localhost:${port}`);
1083
+ console.log(`Server running at http://localhost:${port}`);
1084
+ (0, import_open.default)(`http://localhost:${port}`);
1085
+ });
1086
+ var index_default = app;
1087
+ // Annotate the CommonJS export names for ESM import in node:
1088
+ 0 && (module.exports = {
1089
+ app,
1090
+ httpServer,
1091
+ io
105
1092
  });
106
- exports.default = app;