Skip to content

fix(create-vinext-app): pnpm output loses ansi colors when installing dependencies - #2867

Open
NriotHrreion wants to merge 1 commit into
cloudflare:mainfrom
NriotHrreion:fix/issue-2863-scaffolding-cli-ansi-colors
Open

fix(create-vinext-app): pnpm output loses ansi colors when installing dependencies#2867
NriotHrreion wants to merge 1 commit into
cloudflare:mainfrom
NriotHrreion:fix/issue-2863-scaffolding-cli-ansi-colors

Conversation

@NriotHrreion

Copy link
Copy Markdown
Contributor

Closes #2863

Overview

Dependency installation during vinext init should behave like running the package manager directly in the terminal, including preserving pnpm’s interactive output and ANSI colors.

This PR restores that terminal-native experience while retaining reliable detection of pnpm dependencies awaiting build-script approval. It also ensures unrelated installation failures remain visible instead of being misclassified as approval-related errors.

What changed

The root cause of this issue is the hard-coded pipe at packages/vinext/src/init.ts:472, which is to get the raw output of pnpm install and resolve the ignored builds. However, it just broke the terminal-native experience and made pnpm lost its color.

Fortunately, pnpm has a builtin command to list all ignore builds: pnpm ignored-builds. This PR runs pnpm ignored-builds, gets its output and resolve the list.

In this way, the default exec() function doesn't need to pass pipe to stdio and doesn't need to collect exec output:

  const child = spawn(cmd, {
    cwd: opts.cwd,
    shell: true,
-   stdio: ["inherit", "pipe", "pipe"],
+   stdio: opts.stdio,
  });
- let output = "";
- child.stdout.on("data", (chunk: Buffer) => {
-   const text = chunk.toString();
-   output += text;
-   process.stdout.write(text);
- });
- child.stderr.on("data", (chunk: Buffer) => {
-   const text = chunk.toString();
-   output += text;
-   process.stderr.write(text);
- });
- child.on("error", (error) => reject(Object.assign(error, { output })));
+ child.on("error", reject);
  child.on("close", (status) => {
-   if (status === 0) resolve(output);
+   if (status === 0) resolve();
    else {
      reject(
        Object.assign(new Error(`Command failed with exit code ${status}: ${cmd}`), {
          status,
-         output,
        }),
      );
    }
  });

Testing

  • pnpm test tests/init-command-exec.test.ts tests/init.test.ts

…ls dependencies (cloudflare#2863)

No longer detect ignored builds from `pnpm install` output.
Instead, parse ignored builds by running `pnpm ignore-builds`.
@pkg-pr-new

pkg-pr-new Bot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2867
npm i https://pkg.pr.new/create-vinext-app@2867
npm i https://pkg.pr.new/@vinext/types@2867
npm i https://pkg.pr.new/vinext@2867

commit: b1c70cd

@github-actions

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared b1c70cd against base 056cd02 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 134.7 KB 134.7 KB ⚫ +0.0%
Client entry size (gzip) vinext 122.2 KB 122.2 KB ⚫ +0.0%
Dev server cold start vinext 2.88 s 2.90 s ⚫ +0.7%
Production build time vinext 3.04 s 3.03 s ⚫ -0.2%
RSC entry closure size (gzip) vinext 114.3 KB 114.2 KB ⚫ -0.0%
Server bundle size (gzip) vinext 191.9 KB 191.9 KB ⚫ -0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm output loses colors when create-vinext-app initializing the project

1 participant