Skip to content

fix(cli): gracefully handle missing vp fmt during config initialization#789

Merged
fengmk2 merged 4 commits intomainfrom
fix-e2e
Mar 12, 2026
Merged

fix(cli): gracefully handle missing vp fmt during config initialization#789
fengmk2 merged 4 commits intomainfrom
fix-e2e

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 12, 2026

The vpFmt function now gracefully handles cases where vp fmt is not available or fails to execute. Instead of throwing an error when formatting fails, it now shows a warning message and continues execution. Additionally, the entire formatting operation is wrapped in a try-catch block to handle cases where vp fmt is not yet installed (such as during migration processes), allowing the operation to proceed without formatting rather than failing completely.

@fengmk2 fengmk2 self-assigned this Mar 12, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 12, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 added the test: e2e Auto run e2e tests label Mar 12, 2026 — with Graphite App
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 12, 2026

Deploy Preview for viteplus-staging canceled.

Name Link
🔨 Latest commit ea94e9d
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-staging/deploys/69b24b4071662e0008b673d6

@fengmk2 fengmk2 changed the title fix(migration): skip applyToolInitConfigToViteConfig during prettier migration subprocess fix(cli): gracefully handle missing vp fmt during config initialization Mar 12, 2026
@fengmk2 fengmk2 marked this pull request as ready for review March 12, 2026 03:48
Comment thread packages/cli/src/init-config.ts
fengmk2 added 4 commits March 12, 2026 13:12
…migration subprocess

When `vp migrate` runs `vp fmt --migrate=prettier` as a subprocess,
the subprocess's bin.ts was calling applyToolInitConfigToViteConfig
which tries to create vite.config.ts, merge config, and format it
with oxfmt. This fails because vite-plus isn't installed yet in the
target project, so oxfmt can't load the config.

The migrator already handles vite.config.ts creation and config
merging via its own mergeViteConfigFiles + injectFmtDefaults, making
the subprocess call redundant.

Pass __VITE_PLUS_SKIP_INIT_CONFIG env var from the migrator to skip
the redundant applyToolInitConfigToViteConfig in the subprocess.
…navailable

During `vp migrate`, the subprocess `vp fmt --migrate=prettier` calls
applyToolInitConfigToViteConfig which runs vpFmt to format vite.config.ts.
This fails in E2E tests where vite-plus isn't installed yet, causing
oxfmt to be unable to load the config.

Instead of skipping applyToolInitConfigToViteConfig entirely (which
changed config update counts and property ordering), make vpFmt
best-effort: catch errors and warn instead of throwing. This preserves
the existing behavior while preventing the crash.

Removes the __VITE_PLUS_SKIP_INIT_CONFIG env var approach from the
previous commit in favor of this simpler fix.
Instead of throwing on formatting failure, warn and continue. The
caller in bin.ts already handles exceptions from resolveFmt gracefully.
Instead of throwing on formatting failure, warn and continue while
preserving stdout/stderr output for diagnostics.
@fengmk2 fengmk2 merged commit a8d5040 into main Mar 12, 2026
22 of 23 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 12, 2026

Merge activity

@fengmk2 fengmk2 deleted the fix-e2e branch March 12, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants