@dsh-workbench/core 0.2.7 → 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.
@@ -15,6 +15,9 @@
15
15
  # 用法:
16
16
  # ./scripts/seed-profile.sh
17
17
  # WORKBENCH_PROFILE=wb2 ./scripts/seed-profile.sh # 建到别的 profile 名下(试装用)
18
+ # ./scripts/seed-profile.sh ensure-selected # 只做"确保选中"这一步:
19
+ # # 把工作台 bundle 补进 dsh.profile.bundles
20
+ # # (setup 在 `dsh plugin add` **之后**调它)
18
21
 
19
22
  set -euo pipefail
20
23
 
@@ -22,6 +25,7 @@ DSH_HOME="${DSH_HOME:-$HOME/.dsh}"
22
25
  PROFILE="${WORKBENCH_PROFILE:-workbench}"
23
26
  SRC_PROFILE="$DSH_HOME/profiles/web"
24
27
  DST_PROFILE="$DSH_HOME/profiles/$PROFILE"
28
+ PKG='@dsh-workbench/core'
25
29
  REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
26
30
  GIT_TOP="$(git -C "$REPO_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
27
31
  ISOLATION="$REPO_DIR/profile/isolation.patch.yml"
@@ -36,6 +40,53 @@ die() {
36
40
  exit 1
37
41
  }
38
42
 
43
+ # ── 确保工作台 bundle 被**选中**(`ensure-selected` 子命令,幂等)──────────────
44
+ #
45
+ # 为什么单独一步、还要排在 `dsh plugin add` **之后**:装包与"选中"在 dsh 那侧是两件事。
46
+ # `dsh plugin add` 的 pnpm 那半把包装进 profile;登记 `dsh.profile.bundles` 是它装完后的
47
+ # 对账,而那条对账**跳过已存在的依赖** —— 所以依赖已经在清单里时(重跑 setup、上次装到
48
+ # 一半),bundle 名单永远缺那一项。症状是静默的:profile 照常组起来、服务照常监听,
49
+ # 只是侧边栏什么也不出现。启动器现在拿"选中"当硬门禁(拒绝启动 + 打印修复命令),
50
+ # 这一步就是那条修复命令的落点。
51
+ #
52
+ # 与 dsh 自己的 `selectBundle(name, true)` 等价:已经在清单里就一个字节都不写;
53
+ # 补之前先确认包真的装着(`dsh plugin add` 落了 dependencies)—— 把没装的包塞进
54
+ # bundles 只会让 profile 组不起来,比"面板不出现"更糟。
55
+ ensure_selected() {
56
+ local manifest="$DST_PROFILE/package.json"
57
+ [ -f "$manifest" ] ||
58
+ die "找不到 $manifest —— 先跑一次 '$REPO_DIR/bin/dsh-workbench setup'。"
59
+
60
+ WB_MANIFEST="$manifest" WB_PKG="$PKG" node -e '
61
+ const fs = require("node:fs");
62
+ const manifestPath = process.env.WB_MANIFEST;
63
+ const pkg = process.env.WB_PKG;
64
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
65
+ const dependencies = manifest.dependencies || {};
66
+ if (!Object.hasOwn(dependencies, pkg)) {
67
+ console.error("seed-profile: dependencies 里没有 " + pkg + " —— dsh plugin add 那一步没成,先重装一遍。");
68
+ process.exit(1);
69
+ }
70
+ const profile = (manifest.dsh || {}).profile || {};
71
+ const bundles = Array.isArray(profile.bundles) ? profile.bundles : [];
72
+ if (bundles.includes(pkg)) {
73
+ console.log("→ 工作台 bundle 已选中: " + pkg);
74
+ process.exit(0);
75
+ }
76
+ manifest.dsh = Object.assign({}, manifest.dsh, {
77
+ profile: Object.assign({}, profile, { bundles: bundles.concat([pkg]) }),
78
+ });
79
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
80
+ console.log("→ 已把工作台 bundle 补进 dsh.profile.bundles: " + pkg);
81
+ ' ||
82
+ die "'$PKG' 没被选中,也没能补上(原因见上一行)。"
83
+ }
84
+
85
+ if [ "${1:-}" = "ensure-selected" ]; then
86
+ ensure_selected
87
+ exit 0
88
+ fi
89
+
39
90
  [ -f "$SRC_PROFILE/package.json" ] ||
40
91
  die "找不到 $SRC_PROFILE —— 请先跑一次 'dsh web',让 web profile 落地。"
41
92
  [ -f "$ISOLATION" ] || die "找不到 $ISOLATION"
@@ -114,7 +165,7 @@ bash "$REPO_DIR/scripts/seed-workshop.sh"
114
165
  if [ -n "$GIT_TOP" ]; then
115
166
  BUNDLE_TARGET="$REPO_DIR"
116
167
  else
117
- BUNDLE_TARGET="@dsh-workbench/core@^$(node -p "require('$REPO_DIR/package.json').version" 2>/dev/null || echo 0)"
168
+ BUNDLE_TARGET="$PKG@^$(node -p "require('$REPO_DIR/package.json').version" 2>/dev/null || echo 0)"
118
169
  fi
119
170
 
120
171
  cat <<EOF