@surenkid/acli-hub 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/.env.example +3 -0
- package/README.md +8 -1
- package/package.json +1 -1
- package/server/index.js +10 -2
- package/server/services/session-manager.js +3 -2
package/.env.example
CHANGED
|
@@ -14,3 +14,6 @@ UPLOAD_MAX_MB=500
|
|
|
14
14
|
# When set, all pages/API/terminal/WebSocket access requires a 7-day
|
|
15
15
|
# login session (cookie).
|
|
16
16
|
AUTH_PASSWORD=
|
|
17
|
+
|
|
18
|
+
# Config locations (cwd is never read): ~/.config/acli-hub/.env for the installed CLI
|
|
19
|
+
# ($XDG_CONFIG_HOME respected); the repo root .env when running from source.
|
package/README.md
CHANGED
|
@@ -79,7 +79,14 @@ npm run dev
|
|
|
79
79
|
|
|
80
80
|
## ⚙️ 配置项
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
配置从固定位置读取,**与启动目录无关**(避免与所在项目的 `.env` 冲突):
|
|
83
|
+
|
|
84
|
+
1. `~/.config/acli-hub/.env` — npm 安装(`npx`/全局)使用的配置,尊重 `$XDG_CONFIG_HOME`(模板参考包内 `.env.example`)
|
|
85
|
+
2. 源码运行(`npm run dev`)时为仓库根目录的 `.env`
|
|
86
|
+
|
|
87
|
+
进程环境变量优先级最高。注意:启动目录同时决定新建终端会话的起始目录,建议固定一个目录启动。
|
|
88
|
+
|
|
89
|
+
配置项:
|
|
83
90
|
|
|
84
91
|
| 变量 | 说明 | 默认值 |
|
|
85
92
|
| ----------------------- | ------------------------------------------ | --------- |
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('
|
|
3
|
-
const express = require('express');
|
|
2
|
+
const os = require('os');
|
|
4
3
|
const path = require('path');
|
|
4
|
+
// Config is read from fixed locations, never the working directory (which
|
|
5
|
+
// would collide with whatever project the user happens to be in):
|
|
6
|
+
// 1. <package root>/.env — the source checkout during development
|
|
7
|
+
// 2. ~/.config/acli-hub/.env ($XDG_CONFIG_HOME) — the installed CLI's config
|
|
8
|
+
// dotenv never overrides variables that are already set, so real env vars
|
|
9
|
+
// always win.
|
|
10
|
+
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
|
|
11
|
+
require('dotenv').config({ path: path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'acli-hub', '.env') });
|
|
12
|
+
const express = require('express');
|
|
5
13
|
const http = require('http');
|
|
6
14
|
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
7
15
|
const SessionManager = require('./services/session-manager');
|
|
@@ -305,7 +305,8 @@ class SessionManager extends EventEmitter {
|
|
|
305
305
|
async restore() {
|
|
306
306
|
let output;
|
|
307
307
|
try {
|
|
308
|
-
|
|
308
|
+
// stderr silenced: tmux prints "no server running" whenever the first session does not exist yet
|
|
309
|
+
output = execSync(`tmux list-sessions -F '#{session_name}\t#{@hub-managed}\t#{@hub-alias}\t#{@hub-root}'`, { stdio: ['ignore', 'pipe', 'ignore'], env: SPAWN_ENV }).toString();
|
|
309
310
|
} catch (_) {
|
|
310
311
|
return []; // no tmux server running or no sessions at all
|
|
311
312
|
}
|
|
@@ -373,7 +374,7 @@ class SessionManager extends EventEmitter {
|
|
|
373
374
|
try {
|
|
374
375
|
output = execSync(
|
|
375
376
|
`tmux list-panes -a -F '#{session_name}\t#{window_active}\t#{pane_active}\t#{pane_current_command}\t#{pane_title}'`,
|
|
376
|
-
{ env: SPAWN_ENV }
|
|
377
|
+
{ stdio: ['ignore', 'pipe', 'ignore'], env: SPAWN_ENV }
|
|
377
378
|
).toString();
|
|
378
379
|
} catch (_) {
|
|
379
380
|
return; // no tmux server running
|