From cdda0729738740c4b88095a9e884d4ed237889ad Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Sat, 22 Aug 2026 12:06:32 +0800 Subject: [PATCH] docs(readme): make first-run install succeed (pre-write allowBuilds before dsh plugin add) pnpm 11's strict-dep-builds blocks node-pty/protobufjs build scripts and makes the FIRST 'dsh plugin add' exit non-zero (dsh aborts on ERR_PNPM_IGNORED_BUILDS), forcing a second run after approve-builds. The install block now pre-writes allowBuilds (node-pty/protobufjs) and minimumReleaseAgeExclude (dsh-better-sidebar) into the profile's pnpm-workspace.yaml with the same idempotent merge as scripts/install.sh ensure_workspace_settings, so the first add succeeds. Verified in a scratch DSH_HOME: preflight -> add exit 0 (node-pty postinstall ran), rerun unchanged (no duplicate keys), second add exit 0; merge branch tested when allowBuilds already exists. Paste-to-DSH prompt updated to match. --- README.md | 29 ++++++++++++++++++++++++++--- README_EN.md | 30 +++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 63e9663..3676f73 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,31 @@ 支持的 DSH 版本:0.1.0-rc.8 · 0.1.1-rc.1 · 0.1.1-rc.2 ```sh +# pnpm 11 默认拦截构建脚本(node-pty / protobufjs),会让首次 add 失败; +# 先把构建许可预写进 profile 的 pnpm-workspace.yaml(幂等,可反复执行) +node -e ' +const f = require("fs"), p = process.argv[1]; +let t = f.readFileSync(p, "utf8"); +t = t.replace(/^(\s*)(node-pty|protobufjs):.*$/gm, "$1$2: true"); +if (!/^\s*allowBuilds:\s*$/m.test(t)) { + t += "\nallowBuilds:\n node-pty: true\n protobufjs: true\n"; +} else { + for (const k of ["node-pty", "protobufjs"]) { + if (!new RegExp("^\\s*" + k + ":\\s*true\\s*$", "m").test(t)) { + t = t.replace(/^(\s*allowBuilds:\s*)$/m, "$1\n " + k + ": true"); + } + } +} +if (!/^\s*-\s+dsh-better-sidebar\s*$/m.test(t)) { + if (/^\s*minimumReleaseAgeExclude:\s*$/m.test(t)) { + t = t.replace(/^(\s*minimumReleaseAgeExclude:\s*)$/m, "$1\n - dsh-better-sidebar"); + } else { + t += "\nminimumReleaseAgeExclude:\n - dsh-better-sidebar\n"; + } +} +f.writeFileSync(p, t); +' ~/.dsh/profiles/web/pnpm-workspace.yaml dsh plugin --profile web add dsh-better-sidebar@latest -cd ~/.dsh/profiles/web && pnpm approve-builds --all && pnpm rebuild node-pty # 终端功能依赖 node-pty 的预编译二进制:放行构建脚本并确保装好 ``` 装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R)即可看到侧边栏(DSH 对 client 改动热加载,无需重启;仅 host 半更新时需要重启)。 @@ -72,8 +95,8 @@ cd ~/.dsh/profiles/web && pnpm approve-builds --all && pnpm rebuild node-pty # ```text 帮我安装 dsh-better-sidebar 插件(DSH 侧边栏工作台),步骤: -1. 执行 dsh plugin --profile web add dsh-better-sidebar@latest -2. 在 ~/.dsh/profiles/web 下执行 pnpm approve-builds --all && pnpm rebuild node-pty(终端功能需要 node-pty 的预编译二进制) +1. 先用 node 把 node-pty / protobufjs 的构建许可预写进 ~/.dsh/profiles/web/pnpm-workspace.yaml(allowBuilds),保证首次安装不被 pnpm 11 拦截(可参考仓库 scripts/install.sh 的 ensure_workspace_settings) +2. 再执行 dsh plugin --profile web add dsh-better-sidebar@latest 3. 完成后提醒我硬刷新浏览器(Cmd/Ctrl+Shift+R) 遇到报错先查 https://github.com/omdsh-dev/DSH-better-sidebar README 的常见问题表。 ``` diff --git a/README_EN.md b/README_EN.md index 4b6b17a..1d38d99 100644 --- a/README_EN.md +++ b/README_EN.md @@ -62,8 +62,32 @@ Supported DSH versions: 0.1.0-rc.8 · 0.1.1-rc.1 · 0.1.1-rc.2 ```sh +# pnpm 11 blocks build scripts (node-pty / protobufjs) by default, which makes +# the first `dsh plugin add` fail; pre-write the build approvals into the +# profile's pnpm-workspace.yaml (idempotent, safe to re-run) +node -e ' +const f = require("fs"), p = process.argv[1]; +let t = f.readFileSync(p, "utf8"); +t = t.replace(/^(\s*)(node-pty|protobufjs):.*$/gm, "$1$2: true"); +if (!/^\s*allowBuilds:\s*$/m.test(t)) { + t += "\nallowBuilds:\n node-pty: true\n protobufjs: true\n"; +} else { + for (const k of ["node-pty", "protobufjs"]) { + if (!new RegExp("^\\s*" + k + ":\\s*true\\s*$", "m").test(t)) { + t = t.replace(/^(\s*allowBuilds:\s*)$/m, "$1\n " + k + ": true"); + } + } +} +if (!/^\s*-\s+dsh-better-sidebar\s*$/m.test(t)) { + if (/^\s*minimumReleaseAgeExclude:\s*$/m.test(t)) { + t = t.replace(/^(\s*minimumReleaseAgeExclude:\s*)$/m, "$1\n - dsh-better-sidebar"); + } else { + t += "\nminimumReleaseAgeExclude:\n - dsh-better-sidebar\n"; + } +} +f.writeFileSync(p, t); +' ~/.dsh/profiles/web/pnpm-workspace.yaml dsh plugin --profile web add dsh-better-sidebar@latest -cd ~/.dsh/profiles/web && pnpm approve-builds --all && pnpm rebuild node-pty # the terminal needs node-pty's prebuilt binary: allow build scripts and make sure it is installed ``` Then **hard-refresh the browser** (Cmd/Ctrl+Shift+R) to see the sidebar (DSH hot-reloads client changes; only host-half updates need a restart). @@ -72,8 +96,8 @@ Then **hard-refresh the browser** (Cmd/Ctrl+Shift+R) to see the sidebar (DSH hot ```text Install the dsh-better-sidebar plugin (a sidebar workbench for DSH): -1. Run: dsh plugin --profile web add dsh-better-sidebar@latest -2. In ~/.dsh/profiles/web run: pnpm approve-builds --all && pnpm rebuild node-pty (the terminal feature needs node-pty's prebuilt binary) +1. First pre-write build approvals for node-pty / protobufjs into ~/.dsh/profiles/web/pnpm-workspace.yaml (allowBuilds) so the first install is not blocked by pnpm 11 (see ensure_workspace_settings in the repo's scripts/install.sh) +2. Then run: dsh plugin --profile web add dsh-better-sidebar@latest 3. When done, remind me to hard-refresh the browser (Cmd/Ctrl+Shift+R) If anything fails, check the troubleshooting table in the README at https://github.com/omdsh-dev/DSH-better-sidebar ```