From 88e60ea026526f6f782925d550111d305e5749f6 Mon Sep 17 00:00:00 2001 From: carl-chen Date: Mon, 6 Jul 2026 18:24:00 +0800 Subject: [PATCH] fix(scripts): make `vp pm` work inside `vp run` scripts `vp pm` is only implemented by the full Vite+ CLI binary, not by the local `node_modules/.bin/vp` JS wrapper (which only covers core commands like dev/build/run/exec/install). `vp run` prepends `node_modules/.bin` to PATH, so any `vp pm ...` in the pack/publish scripts resolved to the local wrapper and failed with `error: Command 'pm' not found`. Add scripts/run-pm.mjs that forwards to `vp pm` via the `VP_CLI_BIN` env var (exposed by `vp run`, pointing at the full CLI binary), with a `vp` fallback for use outside `vp run`. Switch all pack/publish scripts to use it. --- package.json | 14 +++++++------- scripts/run-pm.mjs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 scripts/run-pm.mjs diff --git a/package.json b/package.json index 67a9f0e..fc7c05e 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,13 @@ "build:docs": "vp run --filter @antdv-next/docs build", "build:x": "vp run --filter @antdv-next/x build", "build:token": "vp run --filter @antdv-next/x build:token", - "pack:packages": "vp pm pack -r --filter \"./packages/*\" --filter \"!./packages/docs\"", - "publish:packages": "vp pm publish -r --filter \"./packages/*\" --filter \"!./packages/docs\" --access public --no-git-checks", - "publish:x": "vp run --filter @antdv-next/x build && vp pm publish --filter @antdv-next/x --access public --no-git-checks", - "publish:x-markdown": "vp run --filter @antdv-next/x-markdown build && vp pm publish --filter @antdv-next/x-markdown --access public --no-git-checks", - "publish:x-sdk": "vp run --filter @antdv-next/x-sdk build && vp pm publish --filter @antdv-next/x-sdk --access public --no-git-checks", - "publish:x-skill": "vp run --filter @antdv-next/x-skill build && vp pm publish --filter @antdv-next/x-skill --access public --no-git-checks", - "publish:x-card": "vp run --filter @antdv-next/x-card build && vp pm publish --filter @antdv-next/x-card --access public --no-git-checks", + "pack:packages": "node scripts/run-pm.mjs pack -r --filter \"./packages/*\" --filter \"!./packages/docs\"", + "publish:packages": "node scripts/run-pm.mjs publish -r --filter \"./packages/*\" --filter \"!./packages/docs\" --access public --no-git-checks", + "publish:x": "vp run --filter @antdv-next/x build && node scripts/run-pm.mjs publish --filter @antdv-next/x --access public --no-git-checks", + "publish:x-markdown": "vp run --filter @antdv-next/x-markdown build && node scripts/run-pm.mjs publish --filter @antdv-next/x-markdown --access public --no-git-checks", + "publish:x-sdk": "vp run --filter @antdv-next/x-sdk build && node scripts/run-pm.mjs publish --filter @antdv-next/x-sdk --access public --no-git-checks", + "publish:x-skill": "vp run --filter @antdv-next/x-skill build && node scripts/run-pm.mjs publish --filter @antdv-next/x-skill --access public --no-git-checks", + "publish:x-card": "vp run --filter @antdv-next/x-card build && node scripts/run-pm.mjs publish --filter @antdv-next/x-card --access public --no-git-checks", "bump:x": "vp exec bumpp packages/x/package.json --tag \"@antdv-next/x@\"", "bump:x-markdown": "vp exec bumpp packages/x-markdown/package.json --tag \"@antdv-next/x-markdown@\"", "bump:x-sdk": "vp exec bumpp packages/x-sdk/package.json --tag \"@antdv-next/x-sdk@\"", diff --git a/scripts/run-pm.mjs b/scripts/run-pm.mjs new file mode 100644 index 0000000..0cc981e --- /dev/null +++ b/scripts/run-pm.mjs @@ -0,0 +1,34 @@ +// Forward all arguments to `vp pm` (the Vite+ package-manager forwarder). +// +// Why this script exists: +// `vp pm` is only implemented by the full Vite+ CLI binary, not by the local +// `node_modules/.bin/vp` JS wrapper (which only covers core commands like +// dev/build/run/exec/install/...). When a package.json script is executed via +// `vp run