@lancewu602/mihomo-dash 0.6.1 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancewu602/mihomo-dash",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "mihomo 管理工具:CLI + 守护进程 + Web 面板",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -5,6 +5,13 @@
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.6.2] - 2026-10-31
9
+
10
+ ### 修复
11
+
12
+ - `service uninstall` / `service start` 回显的动作命令按作用域生成:system 作用域下不再印
13
+ `systemctl --user …`(真实执行的 argv 本来就不带 `--user`,只有文案错)
14
+
8
15
  ## [0.6.1] - 2026-10-31
9
16
 
10
17
  ### 修复
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mihomo-dash-server",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "mihomo-dash 后端源码(作为 mihomo-dash 的一部分发布,不单独发包)",
@@ -227,6 +227,8 @@ export function createServiceManager(options = {}) {
227
227
  const scope = platform === 'linux' ? (options.scope ?? (isRoot ? 'system' : 'user')) : 'user';
228
228
  /** systemd 的公共参数:system 作用域不带 `--user` */
229
229
  const systemdArgs = scope === 'system' ? [] : ['--user'];
230
+ /** 回显给人看的 systemctl 前缀,必须与 systemdArgs 一致 */
231
+ const systemctlCmd = ['systemctl', ...systemdArgs].join(' ');
230
232
  /** launchd 的域:GUI 会话固定在 gui/<uid>,只有 SSH 时会话里退到 user/<uid> */
231
233
  const domains = [`gui/${uid}`, `user/${uid}`];
232
234
  const dir = serviceDir({ platform, home, scope, systemDir: options.systemDir });
@@ -433,7 +435,7 @@ export function createServiceManager(options = {}) {
433
435
  const stillLoaded = platform === 'darwin' && !!(await loadedDomain(job));
434
436
  if (platform === 'linux') {
435
437
  const r = await run('systemctl', [...systemdArgs, 'disable', jobOf(job).unit]);
436
- if (r.ok) actions.push(`systemctl --user disable ${jobOf(job).unit}`);
438
+ if (r.ok) actions.push(`${systemctlCmd} disable ${jobOf(job).unit}`);
437
439
  else if (r.stderr && !/not loaded|does not exist|No such file/i.test(r.stderr)) {
438
440
  errors.push(`${job}: ${r.stderr.trim()}`);
439
441
  }
@@ -541,7 +543,7 @@ export function createServiceManager(options = {}) {
541
543
  else errors.push(`${j}: ${r.stderr.trim() || 'launchctl kickstart 失败'}`);
542
544
  } else {
543
545
  const r = await run('systemctl', [...systemdArgs, 'start', jobOf(j).unit]);
544
- if (r.ok) started.push(`systemctl --user start ${jobOf(j).unit}`);
546
+ if (r.ok) started.push(`${systemctlCmd} start ${jobOf(j).unit}`);
545
547
  else errors.push(`${j}: ${r.stderr.trim() || 'systemctl start 失败'}`);
546
548
  }
547
549
  }
@@ -252,6 +252,36 @@ test('Linux 安装/卸载:daemon-reload + enable --now / disable(不 --now
252
252
  assert.ok(!calls.some((c) => c.includes('--now') && c.includes('disable')));
253
253
  });
254
254
 
255
+ test('Linux system 作用域:回显的动作命令不带 --user', async () => {
256
+ const { run, calls } = stubRun();
257
+ // system 作用域默认写 /etc(测试里换成临时目录,别碰本机)
258
+ const systemDir = path.join(tmpDir, 'etc-systemd');
259
+ const svc = createServiceManager({
260
+ run,
261
+ platform: 'linux',
262
+ scope: 'system',
263
+ systemDir,
264
+ home,
265
+ cliDir,
266
+ });
267
+ await svc.install({ port: 8982, host: '0.0.0.0' });
268
+ // 真正执行的命令本来就不带 --user;回显文案以前写死了 --user,照着抄会失败
269
+ assert.ok(calls.some((c) => c.join(' ') === 'systemctl enable --now mihomo-dash-panel.service'));
270
+
271
+ const started = await svc.start();
272
+ assert.deepEqual(started.started, [
273
+ 'systemctl start mihomo-dash-panel.service',
274
+ 'systemctl start mihomo-dash-kernel.service',
275
+ ]);
276
+
277
+ const res = await svc.uninstall();
278
+ assert.deepEqual(res.actions, [
279
+ 'systemctl disable mihomo-dash-panel.service',
280
+ 'systemctl disable mihomo-dash-kernel.service',
281
+ ]);
282
+ assert.deepEqual(res.errors, []);
283
+ });
284
+
255
285
  test('Linux 安装:manualRunning 的 job 只 enable(不 --now),不拉第二个实例', async () => {
256
286
  const { run, calls } = stubRun();
257
287
  const svc = createServiceManager({ run, platform: 'linux', home, cliDir });