@titanpl/cli 26.16.8 → 26.17.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/cli",
3
- "version": "26.16.8",
3
+ "version": "26.17.0",
4
4
  "description": "The unified CLI for Titan Planet. Use it to create, manage, build, and deploy high-performance backend projects.",
5
5
  "keywords": [
6
6
  "titanpl",
@@ -19,12 +19,12 @@
19
19
  "titan": "./index.js"
20
20
  },
21
21
  "optionalDependencies": {
22
- "@titanpl/engine-win32-x64": "26.16.8",
23
- "@titanpl/engine-linux-x64": "26.16.8",
24
- "@titanpl/engine-darwin-arm64": "26.16.8"
22
+ "@titanpl/engine-win32-x64": "26.17.0",
23
+ "@titanpl/engine-linux-x64": "26.17.0",
24
+ "@titanpl/engine-darwin-arm64": "26.17.0"
25
25
  },
26
26
  "dependencies": {
27
- "@titanpl/packet": "26.16.8",
27
+ "@titanpl/packet": "26.17.0",
28
28
  "prompts": "^2.4.2",
29
29
  "commander": "^11.0.0",
30
30
  "chalk": "^4.1.2"
@@ -1,7 +1,7 @@
1
+ import { dev } from "@titanpl/packet";
1
2
  import { startEngine } from "../engine.js";
2
3
 
3
4
  export async function devCommand() {
4
- // The Titan Engine now handles all compilation, watch, and routing natively.
5
- // There is no need for JS-based watchers or Node.js process managers.
5
+ await dev(process.cwd());
6
6
  startEngine(true);
7
7
  }
package/src/engine.js CHANGED
@@ -58,7 +58,7 @@ export function startEngine(watchMode = false) {
58
58
  console.log(`šŸš€ Starting Titan Engine...`);
59
59
 
60
60
  const engineProcess = spawn(binaryPath, args, {
61
- stdio: 'inherit',
61
+ stdio: ['inherit', 'pipe', 'pipe'],
62
62
  env: {
63
63
  ...process.env,
64
64
  TITAN_ENV: watchMode ? 'development' : 'production',
@@ -66,9 +66,54 @@ export function startEngine(watchMode = false) {
66
66
  }
67
67
  });
68
68
 
69
+ let stderrBuffer = "";
70
+
71
+ engineProcess.stdout.pipe(process.stdout);
72
+ engineProcess.stderr.on('data', (data) => {
73
+ const chunk = data.toString();
74
+ stderrBuffer += chunk;
75
+ process.stderr.write(data);
76
+ });
77
+
69
78
  engineProcess.on('close', (code) => {
70
- if (code !== 0 && code !== null && !engineProcess._isKilling) {
71
- console.error(`\nāŒ [Titan Engine died with exit code ${code}]`);
79
+ if (code !== 0 && code !== null) {
80
+ // Check for port binding errors
81
+ const isPortError = stderrBuffer.includes("Address already in use") ||
82
+ stderrBuffer.includes("address in use") ||
83
+ stderrBuffer.includes("os error 10048") || // Windows
84
+ stderrBuffer.includes("EADDRINUSE") ||
85
+ stderrBuffer.includes("AddrInUse");
86
+
87
+ if (isPortError) {
88
+ // Try to read intended port
89
+ let port = 5100;
90
+ try {
91
+ const routesPath = path.join(process.cwd(), "dist", "routes.json");
92
+ if (fs.existsSync(routesPath)) {
93
+ const routesConfig = JSON.parse(fs.readFileSync(routesPath, "utf8"));
94
+ if (routesConfig && routesConfig.__config && routesConfig.__config.port) {
95
+ port = routesConfig.__config.port;
96
+ }
97
+ }
98
+ } catch (e) { }
99
+
100
+ const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
101
+ const yellow = (t) => `\x1b[33m${t}\x1b[0m`;
102
+ const red = (t) => `\x1b[31m${t}\x1b[0m`;
103
+
104
+ console.log("");
105
+ console.log(red("ā£ Your application cannot enter this orbit"));
106
+ console.log(red(`↳ Another application is already bound to port ${port}.`));
107
+ console.log("");
108
+
109
+ console.log(yellow("Recommended Actions:"));
110
+ console.log(yellow(" 1.") + " Release the occupied orbit (stop the other service).");
111
+ console.log(yellow(" 2.") + " Assign your application to a new orbit in " + cyan("app/app.js"));
112
+ console.log(yellow(" Example: ") + cyan(`t.start(${port + 1}, "Titan Running!")`));
113
+ console.log("");
114
+ } else {
115
+ console.error(`\nāŒ [Titan Engine died with exit code ${code}]`);
116
+ }
72
117
  }
73
118
  });
74
119