tlc-claude-code 0.7.4 → 0.7.6
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 +1 -1
- package/server/index.js +56 -32
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -47,6 +47,9 @@ function addLog(type, text, level = '') {
|
|
|
47
47
|
logs[type].push(entry);
|
|
48
48
|
if (logs[type].length > 1000) logs[type].shift();
|
|
49
49
|
broadcast(`${type}-log`, { data: text, level });
|
|
50
|
+
// Also log to console for debugging
|
|
51
|
+
const prefix = level === 'error' ? '[ERROR]' : level === 'warn' ? '[WARN]' : '[INFO]';
|
|
52
|
+
console.log(`[${type}] ${prefix} ${text}`);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
// WebSocket connection handling
|
|
@@ -65,7 +68,11 @@ wss.on('connection', (ws) => {
|
|
|
65
68
|
|
|
66
69
|
// Start the user's app
|
|
67
70
|
async function startApp() {
|
|
71
|
+
console.log('[TLC] Starting app detection...');
|
|
72
|
+
console.log('[TLC] Project dir:', PROJECT_DIR);
|
|
73
|
+
|
|
68
74
|
const project = detectProject(PROJECT_DIR);
|
|
75
|
+
console.log('[TLC] Detected project:', project);
|
|
69
76
|
|
|
70
77
|
if (!project) {
|
|
71
78
|
addLog('app', 'Could not detect project type. Create a start command in .tlc.json', 'error');
|
|
@@ -83,28 +90,39 @@ async function startApp() {
|
|
|
83
90
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
appProcess
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
try {
|
|
94
|
+
console.log('[TLC] Spawning:', project.cmd, project.args);
|
|
95
|
+
appProcess = spawn(project.cmd, project.args, {
|
|
96
|
+
cwd: PROJECT_DIR,
|
|
97
|
+
env: { ...process.env, PORT: appPort.toString() },
|
|
98
|
+
shell: true
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
appProcess.stdout.on('data', (data) => {
|
|
102
|
+
const text = data.toString().trim();
|
|
103
|
+
if (text) addLog('app', text);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
appProcess.stderr.on('data', (data) => {
|
|
107
|
+
const text = data.toString().trim();
|
|
108
|
+
if (text) addLog('app', text, 'error');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
appProcess.on('error', (err) => {
|
|
112
|
+
console.error('[TLC] Spawn error:', err);
|
|
113
|
+
addLog('app', `Failed to start: ${err.message}`, 'error');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
appProcess.on('exit', (code) => {
|
|
117
|
+
addLog('app', `App exited with code ${code}`, code === 0 ? 'info' : 'error');
|
|
118
|
+
appProcess = null;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
broadcast('app-start', { port: appPort });
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.error('[TLC] Failed to spawn app:', err);
|
|
124
|
+
addLog('app', `Failed to start app: ${err.message}`, 'error');
|
|
125
|
+
}
|
|
108
126
|
}
|
|
109
127
|
|
|
110
128
|
// Run tests
|
|
@@ -278,20 +296,26 @@ app.post('/api/restart', (req, res) => {
|
|
|
278
296
|
// Proxy to running app
|
|
279
297
|
app.use('/app', createProxyMiddleware({
|
|
280
298
|
target: 'http://localhost:3000', // default fallback
|
|
281
|
-
router: () =>
|
|
299
|
+
router: () => {
|
|
300
|
+
const target = `http://localhost:${appPort}`;
|
|
301
|
+
return target;
|
|
302
|
+
}, // dynamic routing
|
|
282
303
|
changeOrigin: true,
|
|
283
304
|
pathRewrite: { '^/app': '' },
|
|
284
305
|
ws: true,
|
|
285
306
|
onError: (err, req, res) => {
|
|
286
|
-
res.status
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
<
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
307
|
+
// WebSocket upgrades don't have res.status
|
|
308
|
+
if (res && typeof res.status === 'function') {
|
|
309
|
+
res.status(502).send(`
|
|
310
|
+
<html>
|
|
311
|
+
<body style="font-family: system-ui; padding: 40px; background: #1a1a2e; color: #eee;">
|
|
312
|
+
<h2>App not running</h2>
|
|
313
|
+
<p>Waiting for app to start on port ${appPort}...</p>
|
|
314
|
+
<script>setTimeout(() => location.reload(), 2000)</script>
|
|
315
|
+
</body>
|
|
316
|
+
</html>
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
295
319
|
}
|
|
296
320
|
}));
|
|
297
321
|
|