Skip to content

feat: support self-update via pi-web update - #445

Open
Jyleaves wants to merge 6 commits into
agegr:mainfrom
Jyleaves:feat/pi-web-update
Open

feat: support self-update via pi-web update#445
Jyleaves wants to merge 6 commits into
agegr:mainfrom
Jyleaves:feat/pi-web-update

Conversation

@Jyleaves

@Jyleaves Jyleaves commented Aug 9, 2026

Copy link
Copy Markdown

中文

本 PR 重新提交 #441,并已修复全部评审意见:pnpm 改用 pnpm add -g;仅当第一个位置参数为 update 时才触发;版本检查按检测到的包管理器分发。

新增 pi-web update 命令:检查新版本并自动更新 pi-web,无需手动执行 npm install -g @agegr/pi-web

  • 按安装路径检测包管理器(npm / pnpm / yarn / bun),用对应命令更新:npm install -gpnpm add -gyarn global addbun add -g
  • 版本检查使用同一包管理器(npm view / pnpm view / yarn info / bun pm view),与更新共用同一套 registry / 代理 / 超时配置
  • 无法识别安装方式、检查失败或更新失败时,输出手动命令提示
  • 版本比较沿用 lib/app-update.ts 的稳定版语义(预发布版本不触发更新)
  • 新增 13 个单元测试(含直接执行入口的 CLI 测试),纳入 npm test;并端到端验证了 npm / pnpm / yarn / bun 四种安装方式的更新流程
  • README(英文 / 中文)补充更新说明

English

This PR resubmits #441 with the review feedback addressed: pnpm add -g for pnpm, dispatch only when the first positional argument is update, and per-package-manager version checks.

Adds a pi-web update command that checks for a newer release and updates pi-web without running npm install -g @agegr/pi-web manually.

  • Detects the package manager from the installation path (npm / pnpm / yarn / bun) and updates with the matching command: npm install -g, pnpm add -g, yarn global add, bun add -g
  • Checks the latest version with the same package manager (npm view / pnpm view / yarn info / bun pm view) so the check shares the registry, proxy, and timeout configuration of the update
  • Prints a manual fallback command when the install method is unknown, the check fails, or the update fails
  • Reuses the stable-only version semantics of lib/app-update.ts (prereleases never trigger an update)
  • Adds 13 unit tests (including entry-point CLI tests), wired into npm test; the update flow was end-to-end tested for npm, pnpm, yarn, and bun installs
  • Documents the command in the English and Chinese READMEs

- use pnpm add -g for pnpm global installs
- dispatch update only when it is the first positional argument
- check the latest version with the detected package manager instead of npm
- scan for the first semver line in yarn/bun output (yarn appends
  "Done in ..." noise that the last-line parser mistook for the version)
- import getCommandPositionals in the entry script
- add entry-point tests that execute bin/pi-web.js directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant