@lancewu602/mihomo-dash 0.6.2 → 0.6.3

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.2",
3
+ "version": "0.6.3",
4
4
  "description": "mihomo 管理工具:CLI + 守护进程 + Web 面板",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -5,6 +5,14 @@
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.6.3] - 2026-10-31
9
+
10
+ ### 工程
11
+
12
+ - 服务定义带版本与文档地址:`Description` 里写 `mihomo-dash <版本>`,
13
+ 并加 `Documentation=https://github.com/lancewu602/mihomo-dash`——
14
+ `systemctl status` 的标题行与 `Docs:` 行直接显示;面板启动日志与内核日志也带上版本号
15
+
8
16
  ## [0.6.2] - 2026-10-31
9
17
 
10
18
  ### 修复
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mihomo-dash-server",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "mihomo-dash 后端源码(作为 mihomo-dash 的一部分发布,不单独发包)",
@@ -255,6 +255,6 @@ export async function startServer(opts) {
255
255
  server.on('error', reject);
256
256
  });
257
257
 
258
- console.log(`mihomo-dash 面板已启动: http://${opts.host}:${opts.port}`);
258
+ console.log(`mihomo-dash ${PKG_VERSION} 面板已启动: http://${opts.host}:${opts.port}`);
259
259
  console.log(`内核接口: ${getController().url} 配置目录: ${detectMihomoDir()}`);
260
260
  }
@@ -19,8 +19,12 @@ import {
19
19
  detectMihomoDir,
20
20
  ensureCliDir,
21
21
  } from '../shared/paths.js';
22
+ import { createRequire } from 'node:module';
22
23
  import { readTailLines, rotateLogFile } from '../shared/log-file.js';
23
24
 
25
+ const require = createRequire(import.meta.url);
26
+ const { version: PKG_VERSION } = require('../../../package.json');
27
+
24
28
  /** pid 活着没(不发信号判断,避免误杀) */
25
29
  export function isAlive(pid) {
26
30
  const n = Number(pid);
@@ -223,7 +227,14 @@ export async function kernelStart(opts = {}) {
223
227
  if (!isAlive(child.pid)) break;
224
228
  const ready = await probeKernel(600);
225
229
  if (ready) {
226
- if (opts.foreground) return waitChildExit(child);
230
+ // 前台 = 系统服务管理器拉起的路径,输出进 kernel.log:面板的「内核日志」与
231
+ // `systemctl status` 的日志尾都能看到「面板版本 + 内核版本」
232
+ if (opts.foreground) {
233
+ console.log(
234
+ `mihomo-dash ${PKG_VERSION} 内核已启动: ${ready.url}(pid ${child.pid},v${ready.version})`,
235
+ );
236
+ return waitChildExit(child);
237
+ }
227
238
  console.log(`内核已启动: ${ready.url}(pid ${child.pid},v${ready.version})`);
228
239
  return { ok: true, pid: child.pid };
229
240
  }
@@ -28,6 +28,7 @@
28
28
  import fs from 'node:fs';
29
29
  import os from 'node:os';
30
30
  import path from 'node:path';
31
+ import { createRequire } from 'node:module';
31
32
  import { fileURLToPath } from 'node:url';
32
33
  import { defaultRun } from './exec.js';
33
34
  import { CLI_DIR, DEFAULT_HOST, DEFAULT_PORT } from './paths.js';
@@ -41,19 +42,27 @@ export const SERVICE_ENTRIES = {
41
42
  /** 面板 / 内核两个 agent 共用的 bundle 标识:只是给「登录项」UI 认领用的,不是真的 app bundle */
42
43
  export const BUNDLE_ID = 'com.mihomo-dash';
43
44
 
45
+ /** 单元 / plist 里指回仓库的地址:`systemctl status` 的 `Docs:` 行就是它 */
46
+ export const DOCS_URL = 'https://github.com/lancewu602/mihomo-dash';
47
+
48
+ const require = createRequire(import.meta.url);
49
+ const { version: PKG_VERSION } = require('../../../package.json');
50
+
44
51
  /** 两个受监管的 job:面板与面板自有内核 */
45
52
  const JOBS = {
46
53
  panel: {
47
54
  label: 'com.mihomo-dash.panel',
48
55
  unit: 'mihomo-dash-panel.service',
49
- description: 'mihomo-dash 面板(Web UI + REST 转发)',
56
+ // 版本进 Description:`systemctl status` / `launchctl print` 的第一行就是它,
57
+ // 升级后跑一次 `service install` 即可刷新(定义本来就随安装重写)
58
+ description: `mihomo-dash ${PKG_VERSION} 面板(Web UI + REST 转发)`,
50
59
  args: (opts) => ['--port', String(opts.port), '--host', opts.host],
51
60
  log: (cliDir) => path.join(cliDir, 'daemon.log'),
52
61
  },
53
62
  kernel: {
54
63
  label: 'com.mihomo-dash.kernel',
55
64
  unit: 'mihomo-dash-kernel.service',
56
- description: 'mihomo-dash 自有内核(用配置目录里的 config.yaml)',
65
+ description: `mihomo-dash ${PKG_VERSION} 自有内核(用配置目录里的 config.yaml)`,
57
66
  args: () => [],
58
67
  log: (cliDir) => path.join(cliDir, 'kernel.log'),
59
68
  },
@@ -147,6 +156,8 @@ export function renderUnit(job, opts) {
147
156
  # 作用域:${scope === 'system' ? 'system(/etc/systemd/system,以 root 运行,开机即起)' : 'user(~/.config/systemd/user,登录后启动 or linger)'}
148
157
  [Unit]
149
158
  Description=${def.description}
159
+ # systemctl status 的 Docs: 行就是它;没有这条时那行是空的
160
+ Documentation=${DOCS_URL}
150
161
  After=network-online.target
151
162
 
152
163
  [Service]
@@ -107,7 +107,10 @@ test('plist:路径里的 XML 特殊字符会被转义', () => {
107
107
  test('systemd 单元:ExecStart 固定 argv、Restart=no、日志 append', () => {
108
108
  const unit = renderUnit('panel', OPTS());
109
109
  assert.match(unit, /^# 由 `mihomo-dash service install` 生成/m);
110
- assert.match(unit, /Description=mihomo-dash 面板/);
110
+ // 版本进 Description:`systemctl status` 第一行就能看到装的是哪一版
111
+ assert.match(unit, /Description=mihomo-dash \d+\.\d+\.\d+ 面板/);
112
+ // `systemctl status` 的 `Docs:` 行来自 Documentation=
113
+ assert.match(unit, /^Documentation=https:\/\/github\.com\/lancewu602\/mihomo-dash$/m);
111
114
  assert.match(
112
115
  unit,
113
116
  /ExecStart=\/usr\/local\/bin\/node \/opt\/mihomo-dash\/server\/src\/index\.js --port 8981 --host 127\.0\.0\.1/,