From 9b7d98fa98238c9a6930b0a66b4832123185f68e Mon Sep 17 00:00:00 2001 From: yyh Date: Wed, 8 Apr 2026 18:27:50 +0800 Subject: [PATCH] fix(ci): provision pnpm for i18n workflows --- .github/actions/setup-web/action.yml | 16 ++++++++++++++++ .github/workflows/translate-i18n-claude.yml | 16 ++++++++-------- .vite-hooks/pre-commit | 8 ++++---- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/actions/setup-web/action.yml b/.github/actions/setup-web/action.yml index 673155bcf7..c2aa1dcd62 100644 --- a/.github/actions/setup-web/action.yml +++ b/.github/actions/setup-web/action.yml @@ -9,3 +9,19 @@ runs: node-version-file: .nvmrc cache: true run-install: true + - name: Setup pnpm + shell: bash + run: | + PACKAGE_MANAGER=$(node -p "require('./package.json').packageManager || ''") + case "$PACKAGE_MANAGER" in + pnpm@*) + corepack enable + corepack prepare "$PACKAGE_MANAGER" --activate + ;; + *) + echo "Expected root packageManager to declare pnpm, got: ${PACKAGE_MANAGER:-}" >&2 + exit 1 + ;; + esac + + echo "$(dirname "$(command -v pnpm)")" >> "$GITHUB_PATH" diff --git a/.github/workflows/translate-i18n-claude.yml b/.github/workflows/translate-i18n-claude.yml index e001f4d677..bbed276345 100644 --- a/.github/workflows/translate-i18n-claude.yml +++ b/.github/workflows/translate-i18n-claude.yml @@ -188,7 +188,7 @@ jobs: Tool rules: - Use Read for repository files. - Use Edit for JSON updates. - - Use Bash only for `vp`. + - Use Bash only for `pnpm`. - Do not use Bash for `git`, `gh`, or branch management. Required execution plan: @@ -210,7 +210,7 @@ jobs: - Read the current English JSON file for any file that still exists so wording, placeholders, and surrounding terminology stay accurate. - If `Structured change set available` is `false`, treat this as a scoped full sync and use the current English files plus scoped checks as the source of truth. 4. Run a scoped pre-check before editing: - - `vp run dify-web#i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }}` + - `pnpm --dir ${{ github.workspace }}/web run i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }}` - Use this command as the source of truth for missing and extra keys inside the current scope. 5. Apply translations. - For every target language and scoped file: @@ -218,19 +218,19 @@ jobs: - If the locale file does not exist yet, create it with `Write` and then continue with `Edit` as needed. - ADD missing keys. - UPDATE stale translations when the English value changed. - - DELETE removed keys. Prefer `vp run dify-web#i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }} --auto-remove` for extra keys so deletions stay in scope. + - DELETE removed keys. Prefer `pnpm --dir ${{ github.workspace }}/web run i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }} --auto-remove` for extra keys so deletions stay in scope. - Preserve placeholders exactly: `{{variable}}`, `${variable}`, HTML tags, component tags, and variable names. - Match the existing terminology and register used by each locale. - Prefer one Edit per file when stable, but prioritize correctness over batching. 6. Verify only the edited files. - - Run `vp run dify-web#lint:fix --quiet -- ` - - Run `vp run dify-web#i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }}` + - Run `pnpm --dir ${{ github.workspace }}/web lint:fix --quiet -- ` + - Run `pnpm --dir ${{ github.workspace }}/web run i18n:check ${{ steps.context.outputs.FILE_ARGS }} ${{ steps.context.outputs.LANG_ARGS }}` - If verification fails, fix the remaining problems before continuing. 7. Stop after the scoped locale files are updated and verification passes. - Do not create branches, commits, or pull requests. claude_args: | --max-turns 120 - --allowedTools "Read,Write,Edit,Bash(vp *),Bash(vp:*),Glob,Grep" + --allowedTools "Read,Write,Edit,Bash(pnpm *),Bash(pnpm:*),Glob,Grep" - name: Prepare branch metadata id: pr_meta @@ -321,8 +321,8 @@ jobs: '', '## Verification', '', - `- \`vp run dify-web#i18n:check --file ${process.env.FILES_IN_SCOPE} --lang ${process.env.TARGET_LANGS}\``, - `- \`vp run dify-web#lint:fix --quiet -- \``, + `- \`pnpm --dir web run i18n:check --file ${process.env.FILES_IN_SCOPE} --lang ${process.env.TARGET_LANGS}\``, + `- \`pnpm --dir web lint:fix --quiet -- \``, '', '## Notes', '', diff --git a/.vite-hooks/pre-commit b/.vite-hooks/pre-commit index d11dda0d31..db5c504606 100755 --- a/.vite-hooks/pre-commit +++ b/.vite-hooks/pre-commit @@ -81,8 +81,8 @@ if $web_modified; then if $web_ts_modified; then echo "Running TypeScript type-check:tsgo" - if ! vp run dify-web#type-check:tsgo; then - echo "Type check failed. Please run 'vp run dify-web#type-check:tsgo' to fix the errors." + if ! pnpm run type-check:tsgo; then + echo "Type check failed. Please run 'pnpm run type-check:tsgo' to fix the errors." exit 1 fi else @@ -90,8 +90,8 @@ if $web_modified; then fi echo "Running knip" - if ! vp run dify-web#knip; then - echo "Knip check failed. Please run 'vp run dify-web#knip' to fix the errors." + if ! pnpm run knip; then + echo "Knip check failed. Please run 'pnpm run knip' to fix the errors." exit 1 fi