dsh-session-superagent 0.0.0-stage → 0.8.12
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/CHANGELOG.md +631 -0
- package/LICENSE +21 -0
- package/README.md +98 -3
- package/client.js +1023 -0
- package/cordis.patch.yml +9 -0
- package/lib/body.js +17 -0
- package/lib/index.js +1095 -0
- package/lib/redact.js +34 -0
- package/lib/watch.js +383 -0
- package/package.json +74 -6
- package/scripts/port-official-ui.mjs +40 -0
- package/scripts/preview-orbit.mjs +136 -0
- package/scripts/sync-profile.mjs +76 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// 把插件源码目录同步到 profile 的安装副本。
|
|
2
|
+
//
|
|
3
|
+
// 为什么需要:profile 里是 `file:` 安装 —— pnpm 为**已存在的文件**建了硬链接,
|
|
4
|
+
// 所以改内容会自动生效;但**新增文件不会**自动出现。
|
|
5
|
+
// 真实事故(2026-11-01 23:59 重启):新增的 lib/body.js 没进 profile,
|
|
6
|
+
// 宿主 import './body.js' 失败 → 整个插件不挂载 → 工具和 HTTP 路由全消失,
|
|
7
|
+
// 而客户端 bundle 照常加载,表面看起来"插件还在"。
|
|
8
|
+
//
|
|
9
|
+
// 用法: node scripts/sync-profile.mjs [profile 安装目录]
|
|
10
|
+
import { existsSync, linkSync, mkdirSync, readFileSync, readdirSync, statSync } from 'node:fs'
|
|
11
|
+
import { dirname, join } from 'node:path'
|
|
12
|
+
import { fileURLToPath } from 'node:url'
|
|
13
|
+
|
|
14
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
15
|
+
const DEFAULT_PROFILE = join(
|
|
16
|
+
process.env.DSH_HOME || join(process.env.USERPROFILE || '', '.dsh'),
|
|
17
|
+
'profiles',
|
|
18
|
+
'desktop',
|
|
19
|
+
'node_modules',
|
|
20
|
+
'dsh-session-superagent',
|
|
21
|
+
)
|
|
22
|
+
const DEST = process.argv[2] || DEFAULT_PROFILE
|
|
23
|
+
|
|
24
|
+
/** 运行时要用的文件(不含 docs / test / scripts 这些开发件)。 */
|
|
25
|
+
const TARGETS = [
|
|
26
|
+
'client.js', 'package.json', 'cordis.patch.yml', 'README.md', 'CHANGELOG.md', 'LICENSE',
|
|
27
|
+
'lib/index.js', 'lib/watch.js', 'lib/redact.js', 'lib/body.js',
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
if (!existsSync(DEST)) {
|
|
31
|
+
console.error('找不到 profile 安装目录:' + DEST)
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let linked = 0
|
|
36
|
+
let skipped = 0
|
|
37
|
+
for (const rel of TARGETS) {
|
|
38
|
+
const src = join(ROOT, rel)
|
|
39
|
+
const dst = join(DEST, rel)
|
|
40
|
+
if (!existsSync(src)) continue
|
|
41
|
+
if (existsSync(dst)) {
|
|
42
|
+
const same = statSync(src).ino === statSync(dst).ino
|
|
43
|
+
console.log((same ? 'ok ' : '注意 ') + rel + (same ? '' : '(inode 不同,内容改动不会同步)'))
|
|
44
|
+
skipped += 1
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
mkdirSync(dirname(dst), { recursive: true })
|
|
48
|
+
try {
|
|
49
|
+
linkSync(src, dst)
|
|
50
|
+
linked += 1
|
|
51
|
+
console.log('linked ' + rel)
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.log('link 失败:' + rel + ' — ' + (error && error.message))
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// lib/ 里每个相对 import 都必须能解析到真实文件(这次事故的直接原因)
|
|
58
|
+
const libDir = join(ROOT, 'lib')
|
|
59
|
+
const missing = []
|
|
60
|
+
for (const name of readdirSync(libDir)) {
|
|
61
|
+
if (!name.endsWith('.js')) continue
|
|
62
|
+
const file = join(libDir, name)
|
|
63
|
+
const code = readFileSync(file, 'utf8')
|
|
64
|
+
for (const m of code.matchAll(/from '(\.[^']+)'/g)) {
|
|
65
|
+
if (!existsSync(join(dirname(file), m[1]))) missing.push(name + ' → ' + m[1])
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log('---')
|
|
70
|
+
console.log(`新增链接 ${linked} 个,跳过 ${skipped} 个`)
|
|
71
|
+
console.log(`目标:${DEST}`)
|
|
72
|
+
if (missing.length > 0) {
|
|
73
|
+
console.error('相对 import 解析失败:' + missing.join(', '))
|
|
74
|
+
process.exit(2)
|
|
75
|
+
}
|
|
76
|
+
console.log('相对 import 全部可解析 ✓')
|