@zaofan/dsh-qqbot 1.10.12 → 1.10.14

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/settings-host.js CHANGED
@@ -28,30 +28,54 @@ const NS = 'im-qqbot';
28
28
  * 上溯层级在单包合并时已按包根位置修正); 若该位置没有 cordis.patch.yml(link/symlink 安装时
29
29
  * 本文件被从源码目录加载), 则扫描 ~/.dsh/profiles/* 找装着 @zaofan/dsh-qqbot 的 profile。
30
30
  */
31
- function resolveProfileRoot() {
32
- const byLocation = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
33
- try {
34
- if (existsSync(join(byLocation, 'cordis.patch.yml'))) return byLocation;
35
- } catch { /* 继续扫描 */ }
36
- try {
37
- const base = join(homedir(), '.dsh', 'profiles');
38
- for (const name of readdirSync(base)) {
39
- const prof = resolve(base, name);
40
- try {
41
- if (!statSync(prof).isDirectory()) continue;
42
- } catch { continue; }
43
- try {
44
- if (existsSync(join(prof, 'node_modules', '@zaofan', 'dsh-qqbot'))) return prof;
45
- } catch { /* 走下一判据 */ }
46
- try {
47
- const pkg = JSON.parse(readFileSync(join(prof, 'package.json'), 'utf8'));
48
- const blob = JSON.stringify(pkg.dsh?.profile?.bundles ?? []) + JSON.stringify(pkg.dependencies ?? {});
49
- if (blob.includes('@zaofan/dsh-qqbot')) return prof;
50
- } catch { /* 无 package.json, 跳过 */ }
51
- }
52
- } catch { /* profiles 目录不存在 */ }
53
- return byLocation;
54
- }
31
+ function resolveProfileRoot() {
32
+ // 2026-10-20 修(GitHub issue #14): 生成式安装(dsh-market / DSH Desktop)下,
33
+ // "包根上溯 3 级"得到的是 profiles/.generations/live/<pkg>, 不是 profile 根;
34
+ // 且 Desktop 的 DSH_HOME 在 %APPDATA%dsh-desktopharness, 原兜底写死 ~/.dsh 扫不到。
35
+ // → 显式环境变量 > 代码位置 > .generations 反推 > 多 home 扫描。
36
+ for (const k of ['DSH_PROFILE_DIR', 'DSH_PROFILE_ROOT']) {
37
+ const v = (process.env[k] ?? '').trim();
38
+ if (v) { try { if (existsSync(join(v, 'cordis.patch.yml'))) return v; } catch { /* 下一个 */ } }
39
+ }
40
+ const here = dirname(fileURLToPath(import.meta.url));
41
+ const byLocation = resolve(here, '..', '..', '..');
42
+ try {
43
+ if (existsSync(join(byLocation, 'cordis.patch.yml'))) return byLocation;
44
+ } catch { /* 继续扫描 */ }
45
+ const roots = [];
46
+ try {
47
+ let cur = here;
48
+ for (let n = 0; n < 12; n++) {
49
+ cur = dirname(cur);
50
+ if (basename(cur) === '.generations') { roots.push(dirname(cur)); break; }
51
+ }
52
+ } catch { /* ignore */ }
53
+ const homeEnv = (process.env.DSH_HOME ?? '').trim();
54
+ if (homeEnv) roots.push(join(homeEnv, 'profiles'));
55
+ roots.push(join(homedir(), '.dsh', 'profiles'));
56
+ for (const base of roots) {
57
+ try {
58
+ for (const name of readdirSync(base)) {
59
+ const prof = resolve(base, name);
60
+ try {
61
+ if (!statSync(prof).isDirectory()) continue;
62
+ } catch { continue; }
63
+ try {
64
+ if (existsSync(join(prof, 'cordis.patch.yml'))) return prof;
65
+ } catch { /* 走下一判据 */ }
66
+ try {
67
+ if (existsSync(join(prof, 'node_modules', '@zaofan', 'dsh-qqbot'))) return prof;
68
+ } catch { /* 走下一判据 */ }
69
+ try {
70
+ const pkg = JSON.parse(readFileSync(join(prof, 'package.json'), 'utf8'));
71
+ const blob = JSON.stringify(pkg.dsh?.profile?.bundles ?? []) + JSON.stringify(pkg.dependencies ?? {});
72
+ if (blob.includes('@zaofan/dsh-qqbot')) return prof;
73
+ } catch { /* 无 package.json, 跳过 */ }
74
+ }
75
+ } catch { /* 该 profiles 根不存在 */ }
76
+ }
77
+ return byLocation;
78
+ }
55
79
  const PROFILE_ROOT = resolveProfileRoot();
56
80
  /** cordis.patch.yml = 宿主插件装配文件(账号实例声明处; 改它需重启 dsh 生效) */
57
81
  const PATCH_FILE = join(PROFILE_ROOT, 'cordis.patch.yml');