Skip to content

Commit 4d678df

Browse files
Salnikafengmk2
andauthored
fix(cli) use vp fmt instead of bin in create (#972)
`vp create` was formatting newly scaffolded projects by invoking `oxfmt` directly instead of going through vp fmt. I n Yarn PnP projects, that bypassed Vite+'s normal config resolution path, so oxfmt failed to load the generated vite.config.ts The fix changes the formatting step to call `vp fmt --write` instead of executing `oxfmt` directly. ```shell $> vp create --verbose ... Wrote editor config to .vscode/settings.json Wrote editor config to .vscode/extensions.json Rewrote imports in one file synth-tools/vite.config.ts ✔ Merged staged config into synth-tools/vite.config.ts ✔ Git hooks configured ◇ Dependencies installed ◇ Format failed Failed to load configuration file. /Users/USER/workspace/perso/projects/web/synth-tools/vite.config.ts Ensure the file has a valid default export of a JSON-serializable configuration object. You may need to run "vp fmt --write" manually in /Users/User/workspace/perso/projects/web/synth-tools ◇ Scaffolded synth-tools with Vite+ monorepo • Node 24.14.0 yarn 4.12.0 ✓ Dependencies installed in 2.7s → Next: cd synth-tools && vp dev apps/website ``` Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
1 parent 69f551a commit 4d678df

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

packages/cli/src/utils/prompts.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as prompts from '@voidzero-dev/vite-plus-prompts';
22

33
import { downloadPackageManager as downloadPackageManagerBinding } from '../../binding/index.js';
4-
import { fmt as resolveFmt } from '../resolve-fmt.js';
54
import { PackageManager } from '../types/index.js';
65
import { runCommandSilently } from './command.js';
76
import { accent } from './terminal.js';
@@ -109,15 +108,11 @@ export async function runViteFmt(
109108
const startTime = Date.now();
110109
spinner.start(`Formatting code...`);
111110

112-
const { binPath, envs } = await resolveFmt();
113111
const { exitCode, stderr, stdout } = await runCommandSilently({
114-
command: binPath,
115-
args: ['--write', ...(paths ?? [])],
112+
command: process.env.VITE_PLUS_CLI_BIN ?? 'vp',
113+
args: ['fmt', '--write', ...(paths ?? [])],
116114
cwd,
117-
envs: {
118-
...process.env,
119-
...envs,
120-
},
115+
envs: process.env,
121116
});
122117

123118
if (exitCode === 0) {

0 commit comments

Comments
 (0)