local-cmd-runner 1.0.0 → 1.0.2
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/README.md +44 -0
- package/package.json +2 -2
- package/server.js +8 -8
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Local Cmd Runner
|
|
2
|
+
|
|
3
|
+
💻 **Local Cmd Runner** 是一个将终端命令行能力搬进网页的可视化工具。当你运行它后,它会自动唤起系统浏览器并提供一个极具现代审美(支持暗黑风全景视效)的本地版的网页控制台。完美兼容 Windows (cmd) 以及 Linux/Mac (shell)。
|
|
4
|
+
|
|
5
|
+
## 特性 (Features)
|
|
6
|
+
|
|
7
|
+
- 🚀 **开箱即用**: 一键启动,无需复杂环境配置,自动启服并唤开系统默认浏览器。
|
|
8
|
+
- 🎨 **精美极客 UI**: 告别枯燥的黑白框,专为极客重构的半透明模糊面板。
|
|
9
|
+
- 📌 **记录置顶显示**: 最新的命令运行结果永远在顶部首位出现,告别辛苦下拉滚动条的折磨。
|
|
10
|
+
- ⚡ **毫秒级实时响应**: 跨越底层调用 WebSockets 结合 Node 原生的 `child_process.spawn`,完美实时透传你的耗时命令输出,不会有断层。
|
|
11
|
+
- 🛠️ **一键式预设**: 已原生预置类似 `openclaw` 快捷操作面板,点一点即可快速触发高频任务(例如启动、部署等)。
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 怎么使唤 (Usage)
|
|
16
|
+
|
|
17
|
+
直接跳到你要跑命令的任意项目目录下,用下面的方式拉起工具。
|
|
18
|
+
|
|
19
|
+
### 方式一:不安装直接云端拉起(推荐)
|
|
20
|
+
|
|
21
|
+
不需要任何前置的手动安装,只需使用 `npx`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx local-cmd-runner
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 方式二:全局安装到系统
|
|
28
|
+
|
|
29
|
+
如果觉得工具很趁手想随时用:
|
|
30
|
+
|
|
31
|
+
1. 先全局安装:
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g local-cmd-runner
|
|
34
|
+
```
|
|
35
|
+
2. 随后在任何目录下都能敲这个注册好的命令:
|
|
36
|
+
```bash
|
|
37
|
+
local-cmd
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 协议 (License)
|
|
43
|
+
|
|
44
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "local-cmd-runner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Run local shell commands from a web page",
|
|
5
5
|
"homepage": "https://github.com/codewoow/local_cmd#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
"socket.io": "^4.7.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {}
|
|
28
|
-
}
|
|
28
|
+
}
|
package/server.js
CHANGED
|
@@ -9,36 +9,36 @@ const app = express();
|
|
|
9
9
|
const httpServer = createServer(app);
|
|
10
10
|
const io = new Server(httpServer);
|
|
11
11
|
|
|
12
|
-
const PORT = process.env.PORT ||
|
|
12
|
+
const PORT = process.env.PORT || 3500;
|
|
13
13
|
|
|
14
14
|
app.use(express.static(path.join(__dirname, 'public')));
|
|
15
15
|
|
|
16
16
|
io.on('connection', (socket) => {
|
|
17
17
|
console.log('Client connected');
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
socket.on('run_command', (payload) => {
|
|
20
20
|
// If the old app.js sends a string, handle it. Otherwise handle the new object format.
|
|
21
21
|
const cmd = typeof payload === 'string' ? payload : payload.cmd;
|
|
22
22
|
const runId = typeof payload === 'string' ? cmd : payload.runId;
|
|
23
23
|
console.log(`Running command: ${cmd}`);
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
// execute the command inside the native OS shell
|
|
26
26
|
const child = spawn(cmd, [], { shell: true });
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
socket.emit('cmd_start', { id: cmd, runId: runId });
|
|
29
29
|
|
|
30
30
|
child.stdout.on('data', (data) => {
|
|
31
31
|
socket.emit('cmd_output', { type: 'stdout', data: data.toString(), id: cmd, runId: runId });
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
child.stderr.on('data', (data) => {
|
|
35
35
|
socket.emit('cmd_output', { type: 'stderr', data: data.toString(), id: cmd, runId: runId });
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
child.on('close', (code) => {
|
|
39
39
|
socket.emit('cmd_close', { code, id: cmd, runId: runId });
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
child.on('error', (err) => {
|
|
43
43
|
socket.emit('cmd_error', { error: err.toString(), id: cmd, runId: runId });
|
|
44
44
|
});
|
|
@@ -48,7 +48,7 @@ io.on('connection', (socket) => {
|
|
|
48
48
|
httpServer.listen(PORT, () => {
|
|
49
49
|
const url = `http://localhost:${PORT}`;
|
|
50
50
|
console.log(`Server is running at ${url}`);
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
// Use platform-specific command to open the browser
|
|
53
53
|
const startCmd = os.platform() === 'win32' ? 'start' : (os.platform() === 'darwin' ? 'open' : 'xdg-open');
|
|
54
54
|
spawn(startCmd, [url], { shell: true });
|