claude-code-inspector 0.1.4 → 0.1.5
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/bin/cli.js +46 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,13 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
4
5
|
const { createServer } = require('http');
|
|
5
6
|
const next = require('next');
|
|
6
7
|
const { WebSocketServer } = require('ws');
|
|
7
8
|
const { parse } = require('url');
|
|
8
9
|
|
|
9
10
|
// 切换到包的安装目录,确保 Next.js 能正确找到文件
|
|
10
|
-
|
|
11
|
+
const installDir = path.resolve(__dirname, '..');
|
|
12
|
+
process.chdir(installDir);
|
|
13
|
+
|
|
14
|
+
// 临时重命名 tsconfig.json,防止 Next.js 尝试安装 TypeScript 依赖
|
|
15
|
+
// 但创建一个包含路径别名的简化版本,确保模块解析正确
|
|
16
|
+
const tsconfigPath = path.join(installDir, 'tsconfig.json');
|
|
17
|
+
const tsconfigBackupPath = path.join(installDir, 'tsconfig.json.bak');
|
|
18
|
+
let tsconfigMoved = false;
|
|
19
|
+
|
|
20
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
21
|
+
fs.renameSync(tsconfigPath, tsconfigBackupPath);
|
|
22
|
+
tsconfigMoved = true;
|
|
23
|
+
// 创建一个简化的 tsconfig.json,只包含路径别名配置
|
|
24
|
+
const minimalTsconfig = {
|
|
25
|
+
compilerOptions: {
|
|
26
|
+
baseUrl: '.',
|
|
27
|
+
paths: {
|
|
28
|
+
'@/*': ['./*']
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(minimalTsconfig, null, 2));
|
|
33
|
+
|
|
34
|
+
// 进程退出时恢复原始文件
|
|
35
|
+
process.on('exit', () => {
|
|
36
|
+
if (tsconfigMoved && fs.existsSync(tsconfigBackupPath)) {
|
|
37
|
+
fs.renameSync(tsconfigBackupPath, tsconfigPath);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 捕获信号,确保恢复文件
|
|
42
|
+
process.on('SIGINT', () => {
|
|
43
|
+
if (tsconfigMoved && fs.existsSync(tsconfigBackupPath)) {
|
|
44
|
+
fs.renameSync(tsconfigBackupPath, tsconfigPath);
|
|
45
|
+
}
|
|
46
|
+
process.exit();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
process.on('SIGTERM', () => {
|
|
50
|
+
if (tsconfigMoved && fs.existsSync(tsconfigBackupPath)) {
|
|
51
|
+
fs.renameSync(tsconfigBackupPath, tsconfigPath);
|
|
52
|
+
}
|
|
53
|
+
process.exit();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
11
56
|
|
|
12
57
|
const port = parseInt(process.env.PORT || '3000', 10);
|
|
13
58
|
const dev = process.env.NODE_ENV !== 'production';
|