pnpm-upgrade
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesepnpm Upgrade
pnpm 升级
Use these steps to update pnpm and CI pins without blunt search/replace.
按照以下步骤更新pnpm及CI中的版本固定配置,无需粗暴的搜索替换操作。
Steps (run from repo root)
步骤(从仓库根目录执行)
-
Update pnpm locally
- Try ; if pnpm is missing or self-update fails, run
pnpm self-update.corepack prepare pnpm@latest --activate - Capture the resulting version as .
PNPM_VERSION=$(pnpm -v)
- Try
-
Align package.json
- Open and set
package.jsontopackageManager(preserve trailing newline and formatting).pnpm@${PNPM_VERSION}
- Open
-
Find latest pnpm/action-setup tag
- Query GitHub API: .
curl -fsSL https://api.github.com/repos/pnpm/action-setup/releases/latest | jq -r .tag_name - Use /
GITHUB_TOKENif available for higher rate limits.GH_TOKEN - Store as (e.g.,
ACTION_TAG). Abort if missing.v4.2.0
- Query GitHub API:
-
Update workflows carefully (no broad regex)
- Files: everything under that uses
.github/workflows/.pnpm/action-setup - For each file, edit by hand:
- Set .
uses: pnpm/action-setup@${ACTION_TAG} - If a field exists, set it to
with: version:(keep quoting style/indent).${PNPM_VERSION}
- Set
- Do not touch unrelated steps. Avoid multiline sed/perl one-liners.
- Files: everything under
-
Verify
- Run and confirm it matches
pnpm -v.packageManager - to ensure only intended workflow/package.json changes.
git diff
- Run
-
Follow-up
- If runtime code/build/test config was changed (not typical here), run ; otherwise, a light check is enough.
$code-change-verification - Commit with and open a PR (automation may do this).
chore: upgrade pnpm toolchain
- If runtime code/build/test config was changed (not typical here), run
-
本地更新pnpm
- 尝试执行;若pnpm未安装或self-update命令执行失败,运行
pnpm self-update。corepack prepare pnpm@latest --activate - 将最终版本记录为。
PNPM_VERSION=$(pnpm -v)
- 尝试执行
-
同步package.json配置
- 打开,将
package.json字段设置为packageManager(保留末尾换行符和原有格式)。pnpm@${PNPM_VERSION}
- 打开
-
获取pnpm/action-setup的最新标签
- 调用GitHub API:。
curl -fsSL https://api.github.com/repos/pnpm/action-setup/releases/latest | jq -r .tag_name - 若有或
GITHUB_TOKEN,建议使用以提升请求速率限制。GH_TOKEN - 将结果保存为(例如:
ACTION_TAG)。若获取失败则终止操作。v4.2.0
- 调用GitHub API:
-
谨慎更新工作流配置(避免宽泛的正则替换)
- 目标文件:下所有使用
.github/workflows/的文件。pnpm/action-setup - 逐个手动编辑文件:
- 设置。
uses: pnpm/action-setup@${ACTION_TAG} - 若存在字段,将其值设置为
with: version:(保留原有的引号格式和缩进)。${PNPM_VERSION}
- 设置
- 请勿修改无关步骤。避免使用多行sed或perl单行命令。
- 目标文件:
-
验证
- 执行,确认版本与packageManager字段中的值一致。
pnpm -v - 执行,确保仅对工作流配置和package.json进行了预期的修改。
git diff
- 执行
-
后续操作
- 若运行时代码、构建或测试配置被修改(本场景中通常不会发生),执行;否则只需进行简单检查即可。
$code-change-verification - 提交信息使用,并创建PR(自动化流程可能会自动完成此步骤)。
chore: upgrade pnpm toolchain
- 若运行时代码、构建或测试配置被修改(本场景中通常不会发生),执行
Notes
注意事项
- Tools needed: ,
curl,jq,node/pnpm. Install if missing.corepack - Keep edits minimal and readable—prefer explicit file edits over global replacements.
- If GitHub API is rate-limited, retry with a token or bail out rather than guessing the tag.
- 所需工具:、
curl、jq、node/pnpm。若未安装请先安装。corepack - 尽量保持编辑内容简洁易读——优先选择显式的文件编辑而非全局替换。
- 若GitHub API触发速率限制,使用令牌重试或终止操作,请勿猜测标签版本。