dsh-plugin-diagnose 0.0.0-stage → 0.2.9
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/LICENSE +21 -0
- package/README.md +13 -2
- package/bin/dsh-plugin-diagnose.mjs +91 -0
- package/package.json +37 -4
- package/src/index.mjs +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-plugin-e2e contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-diagnose
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
诊断「DSH 插件装了但没生效」。**版本感知**:先报 DSH 版本,再做文件级检查(跨版本稳定),可选接官方 `--dump-config` 补充。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
dsh-plugin-diagnose --profile-dir <profileDir> [--plugin <pkgName>] [--dsh <dsh-cli>] [--dump]
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- `--profile-dir`:某个 profile 目录(如 `~/.dsh/profiles/desktop`)。
|
|
10
|
+
- `--plugin`:只查某个插件包;不给则查该 profile 的全部 dependencies。
|
|
11
|
+
- `--dsh`:给 dsh CLI 以探测版本(并可 `--dump`)。
|
|
12
|
+
- `--dump`:额外跑官方 `--dump-config`,抓 patch 警告(desktop profile 被官方拒绝时自动降级为仅文件级检查)。
|
|
13
|
+
|
|
14
|
+
检查:依赖是否声明 / `node_modules` 是否安装(悬空链接)/ 插件 `package.json` / `dsh.bundle` / `cordis.patch.yml` 是否存在 / `client.js` 产物是否存在。结论 `✓ 健康` 或 `✗ N 个问题`;有问题退出码 1。
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// dsh-plugin-diagnose:诊断"插件装了但没生效"。文件级检查(跨版本稳定)+ 版本探测 + 官方 dump 补充。
|
|
3
|
+
import { basename, join } from 'node:path'
|
|
4
|
+
import { readFileSync } from 'node:fs'
|
|
5
|
+
import { runFileChecks, detectVersion, runDsh, extractWarnings } from '../src/index.mjs'
|
|
6
|
+
|
|
7
|
+
const USAGE =
|
|
8
|
+
'用法: dsh-plugin-diagnose [--profile-dir <profile目录>] [--plugin <包名>] [--dsh <cli>] [--dump]'
|
|
9
|
+
const args = process.argv.slice(2)
|
|
10
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
11
|
+
console.log(USAGE)
|
|
12
|
+
process.exit(0)
|
|
13
|
+
}
|
|
14
|
+
const known = new Set(['--profile-dir', '--plugin', '--dsh', '--dump', '--help', '-h'])
|
|
15
|
+
const bad = args.find((a) => a.startsWith('-') && !known.has(a))
|
|
16
|
+
if (bad) {
|
|
17
|
+
console.error('未知参数: ' + bad + '\n' + USAGE)
|
|
18
|
+
process.exit(2)
|
|
19
|
+
}
|
|
20
|
+
const readOpt = (n, d) => {
|
|
21
|
+
const i = args.indexOf('--' + n)
|
|
22
|
+
if (i < 0) return d
|
|
23
|
+
const v = args[i + 1]
|
|
24
|
+
if (v === undefined || v.startsWith('-')) {
|
|
25
|
+
console.error('--' + n + ' 缺值\n' + USAGE)
|
|
26
|
+
process.exit(2)
|
|
27
|
+
}
|
|
28
|
+
return v
|
|
29
|
+
}
|
|
30
|
+
const profileDir = readOpt('profile-dir', process.cwd())
|
|
31
|
+
const plugin = readOpt('plugin', null)
|
|
32
|
+
const dsh = readOpt('dsh', null)
|
|
33
|
+
const doDump = args.includes('--dump')
|
|
34
|
+
|
|
35
|
+
// 拒绝多余/未知位置参数(只允许选项)。
|
|
36
|
+
const valueFlags = new Set(['--profile-dir', '--plugin', '--dsh'])
|
|
37
|
+
const positionals = args.filter((a, i) => !a.startsWith('-') && !valueFlags.has(args[i - 1]))
|
|
38
|
+
if (positionals.length) {
|
|
39
|
+
console.error('多余/未知位置参数: ' + positionals.join(' ') + '\n' + USAGE)
|
|
40
|
+
process.exit(2)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 前置校验:必须是有 `dsh.profile` 标识的 profile 目录,避免对普通 Node 项目假报"健康"。
|
|
44
|
+
let profPkg = null
|
|
45
|
+
try {
|
|
46
|
+
profPkg = JSON.parse(readFileSync(join(profileDir, 'package.json'), 'utf8'))
|
|
47
|
+
} catch {
|
|
48
|
+
profPkg = null
|
|
49
|
+
}
|
|
50
|
+
if (!profPkg) {
|
|
51
|
+
console.error('这不是 profile 目录(无 package.json): ' + profileDir)
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
if (!profPkg.dsh || !profPkg.dsh.profile) {
|
|
55
|
+
console.error('这不是 profile 目录(package.json 缺 dsh.profile 标识): ' + profileDir)
|
|
56
|
+
process.exit(1)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log('doctor: profile=' + profileDir + (plugin ? ' plugin=' + plugin : ''))
|
|
60
|
+
if (dsh) {
|
|
61
|
+
const v = detectVersion(dsh)
|
|
62
|
+
console.log('doctor: DSH version=' + (v.version || '(未知)') + (v.ok ? '' : ' ⚠ 版本探测失败'))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const r = runFileChecks(profileDir, { plugin })
|
|
66
|
+
for (const c of r.checks) {
|
|
67
|
+
const mark = c.status === 'ok' ? '✓' : c.status === 'warn' ? '⚠' : '✗'
|
|
68
|
+
console.log(' ' + mark + ' ' + c.name + (c.detail ? ' ' + c.detail : '') + (c.fix ? ' → ' + c.fix : ''))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (doDump) {
|
|
72
|
+
console.log('\n[官方 --dump-config 补充]')
|
|
73
|
+
if (!dsh) {
|
|
74
|
+
console.log(' ⚠ 未提供 --dsh,跳过 dump')
|
|
75
|
+
} else {
|
|
76
|
+
const pname = basename(profileDir)
|
|
77
|
+
const res = runDsh(dsh, ['--profile', pname, '--dump-config'])
|
|
78
|
+
const hasOut = (res.stdout || '').trim().length > 0
|
|
79
|
+
if (res.status !== 0 && !hasOut) {
|
|
80
|
+
const first = String(res.stderr || res.stdout || '').split('\n').filter(Boolean)[0] || 'unknown'
|
|
81
|
+
console.log(' ⚠ --dump-config 不可用(' + first.trim() + ')→ 仅文件级检查')
|
|
82
|
+
} else {
|
|
83
|
+
const warns = extractWarnings(res)
|
|
84
|
+
if (warns.length) warns.forEach((w) => console.log(' ⚠ dump: ' + w))
|
|
85
|
+
else console.log(' ✓ dump 无 patch 警告')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log('\n=== 结论: ' + (r.issues.length ? '✗ ' + r.issues.length + ' 个问题' : '✓ 健康') + (r.notes.length ? ' ⚠ ' + r.notes.length : '') + ' ===')
|
|
91
|
+
process.exit(r.issues.length ? 1 : 0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-diagnose",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.9",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"description": "Diagnose 'DSH plugin installed but not taking effect': version-aware profile/plugin checks (deps, link, dsh.bundle, patch, client.js) plus official --dump-config warnings. Built on dsh-plugin-compat.",
|
|
8
|
+
"bin": {
|
|
9
|
+
"dsh-plugin-diagnose": "bin/dsh-plugin-diagnose.mjs"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"dsh-plugin-compat": "^0.2.9"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/metal-huang/dsh-devtools.git",
|
|
20
|
+
"directory": "packages/dsh-plugin-diagnose"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin/",
|
|
24
|
+
"src/",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"registry": "https://registry.npmjs.org/"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"dsh": ">=0.2.2-rc.5",
|
|
33
|
+
"node": ">=22.15.0"
|
|
34
|
+
},
|
|
35
|
+
"dshTestedOn": [
|
|
36
|
+
"0.2.2-rc.5",
|
|
37
|
+
"0.2.3-alpha.2"
|
|
38
|
+
]
|
|
39
|
+
}
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runFileChecks, detectVersion, runDsh, extractWarnings } from 'dsh-plugin-compat'
|