Skip to content

fix(installer): 修复 PowerShell 远程入口 BOM 解析与 pnpm 版本校验 - #47

Merged
Menghuan1918 merged 1 commit into
omdsh-dev:mainfrom
Cora093:codex/fix-install-ps1-entry
Aug 24, 2026
Merged

fix(installer): 修复 PowerShell 远程入口 BOM 解析与 pnpm 版本校验#47
Menghuan1918 merged 1 commit into
omdsh-dev:mainfrom
Cora093:codex/fix-install-ps1-entry

Conversation

@Cora093

@Cora093 Cora093 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

问题

Windows PowerShell 安装入口存在两类问题:

  1. scripts/install.ps1 为兼容 Windows PowerShell 5.1 的 -File 模式带有 UTF-8 BOM,但 README 和脚本注释中的远程执行命令直接把下载结果交给 iexScriptBlock.Create。BOM 会被解析成 # 命令,并导致 param(...) 不再位于脚本起点,出现命令报错或 -Version-DryRun 等参数失效。
  2. README 声明需要 pnpm >= 10,但脚本此前只检查 pnpm 是否存在。使用 pnpm 8 时,会在安装阶段才出现 ERR_PNPM_ADDING_TO_ROOT,且脚本已经开始处理 profile 配置。

修复

  • PowerShell 远程入口统一调整为:
    1. 使用 irm 下载脚本文本;
    2. 调用 .TrimStart([char]0xFEFF) 移除 BOM;
    3. 通过 ScriptBlock.Create 执行。
  • 保留脚本的 UTF-8 BOM,继续兼容 Windows PowerShell 5.1 的 -File 入口。
  • 默认安装与指定版本示例均可独立复制执行。
  • 在版本解析、profile 写入和安装前检查 pnpm --version
    • 未安装、版本读取失败或无法解析时给出明确错误;
    • 主版本低于 10 时提示升级并以退出码 1 结束。
  • 同步更新中英文 README。
  • 新增 PowerShell 安装入口回归测试。

验证

  • pnpm vitest run tests/install-powershell.spec.ts:7/7 通过
    • UTF-8 BOM 保留
    • Windows PowerShell 5.1 -File 执行
    • Windows PowerShell 5.1 内存执行及参数绑定
    • 安装了 pwsh 时额外验证 pwsh 内存执行
    • pnpm 8 在修改 profile 前被拒绝
    • 文档入口均执行 BOM 清理
    • 指定版本示例保持自包含
  • pnpm typecheck:通过
  • git diff --check:通过
  • 原问题 Windows 机器实测:
    • 正确识别 dsh-better-sidebar@0.11.0
    • -DryRun 正常执行
    • 退出码为 0

关联

Related to #44

@Cora093
Cora093 marked this pull request as ready for review August 14, 2026 10:21
@HuanLinOTO HuanLinOTO added bug Something isn't working P2 中:一般功能/优化 area/build Build, packaging, market manifest, CI, deps labels Aug 23, 2026
@Menghuan1918
Menghuan1918 merged commit ddd3bed into omdsh-dev:main Aug 24, 2026
1 check passed
Menghuan1918 added a commit that referenced this pull request Aug 24, 2026
- README / README_EN: add v0.16.0 changelog (free windows #354, model-driven
  sidebar opens #353, Markdown inline HTML + TOC #360, 19-language overlays
  #339, multi-repo git + linked worktrees #326/#285, browser loopback
  allowlist, Vue + 28 legacy languages #202, preview refresh trio #215/#228,
  local Markdown images #292, ego-browser catalog #340; fixes: market/cordis
  #338, ctx.get() reads #357, workspace boundary #345, panel-host layering
  #330/#278, layout-push hardening #310/#130/#180, width sharing #36, terminal
  cleanup #130, fs-search noise dirs #342, mermaid #341, Nerd Font #190,
  UTF-8 HTML #193, trust-fence #182, reveal-in-explorer #94, PowerShell #47,
  GET probe fallback #69, unrun devDep #336) and move v0.15.2 into history
- feature tour: free windows + Markdown inline HTML/TOC (EN), feature list
- plugin ecosystem: add ego-browser (24 tab plugins), install pin ^0.16.0
Menghuan1918 added a commit that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build, packaging, market manifest, CI, deps bug Something isn't working P2 中:一般功能/优化

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants