Skip to content

feat(init): show a spinner instead of the output of a successful install - #877

Open
morinokami wants to merge 5 commits into
voidzero-dev:mainfrom
morinokami:feat/init-spinner
Open

morinokami wants to merge 5 commits into
voidzero-dev:mainfrom
morinokami:feat/init-spinner

Conversation

@morinokami

Copy link
Copy Markdown
Collaborator

This PR changes what void init shows while it installs dependencies and generates the first migration. Init printed the installer's full output, about 40 lines for a new project. It now shows a spinner with the elapsed time, and prints the output only when the install fails.

This follows #853, #860 and #865. It is the last of these PRs for void init itself; a PR for create-void will follow.

Changes

A spinner instead of the installer's output

Init ran the install with inherited output. The package manager's progress, warnings and dependency list all went to the terminal, and so did the postinstall output of void prepare, whose "✓ Project codegen is ready." read like the end of the command.

Init now runs the install behind a spinner that shows the elapsed time, as vp create does, and removes the spinner when the install ends. The summary reports the result, such as "Installed dependencies in 2.4s". The duration has the format vp create uses ("215ms", "2.4s", "12s").

Generating the first migration works the same way and adds "Generated the initial database migration" to the summary. The spinner, the summary and the error now all call it the initial database migration. They used "initial Drizzle migration" and "starter database migration".

Without a terminal (CI, piped output), each of the two steps prints one line when it starts, like the progress of other commands.

Notices that a package manager prints after a successful install are no longer shown, such as pnpm's "Agent skills awaiting approval" and npm's warning about install scripts.

A failed install prints its output and how to finish

When the install fails, the spinner becomes a "Failed to install dependencies with vp" line. Everything the installer wrote to stdout and stderr follows, in the order it arrived. The error after it is the same as before.

Init also says how to finish by hand, such as "Run vp install, then void db generate to finish setup". Running void init again does not finish a new project whose install failed: init then finds an existing project and does not generate the starter's migration. When generating the migration fails, the line is "Run void db generate to finish setup".

When neither the project nor PATH has a vp, init installs through npx, and the line names that command: "Run npx -p vite-plus@1.7.0 vp install, then …". A bare vp install would not run for that user.

Ctrl+C during the install stops the installer

A spinner reads the keyboard, so the terminal no longer interrupts the installer on Ctrl+C. Init now runs the installer in its own process group and stops that group when init exits. On Windows it stops the installer's process tree. Stopping only the installer's own process is not enough: with vp, a running postinstall script kept running.

Init waits until the stopped processes have ended, so that none of them changes the project after init has exited. It kills one that is still running after 5 seconds, such as a postinstall script that ignores SIGTERM. To see whether they have ended, init reads the process states (/proc on Linux, ps elsewhere). kill(-pgid, 0) cannot tell: an exited child counts until Node collects it, which Node cannot do inside an exit listener.

When init exits while drizzle-kit generates the migration, it also removes what drizzle-kit wrote. A journal entry left without its SQL file would make void db generate report no schema changes.

The terminal's signals do not reach that group either, so while the installer runs, init exits on SIGINT and SIGTERM, which stops the installer the same way.

Init then prints the warning for a run that stopped early. The stopped step comes first, and the line about how to finish comes last. The exit code is 130, as before. The prompt library exits with 0 on Ctrl+C at a spinner, which create-void would take for a finished setup.

Without a terminal, such as on a cancelled CI job, the stopped step is a red ■ line too. The static spinner printed a cancelled step as a yellow warning. Only init cancels a spinner, so the output of other commands does not change.

The Git command uses a relative path

For a project in a new subfolder, the Git (optional) command named the folder by its absolute path, twice. The line was long enough to wrap in most terminals, and a wrapped line cannot be copied as one command. The command now uses the path from the user's shell, as vp create does, and as the cd in the success line already did.

Smaller changes

  • A project in a new subfolder printed "Empty project detected." right after init created the folder. It now prints "Creating a Pages starter in ./my-void-app."
  • The line for a migrated void.json or Wrangler config was a gray ◇ line above the first question. It is now a ✓ line in the summary, and "Commit void.config.ts and void.lock.json" is a → line. The → line names void.lock.json only when the migration wrote it, which it does not for a project that had only void.json.
  • After it removes a dependency, init asks for vp install in a Vite+ project, not pnpm install. vp install is what init runs itself.
  • The note for a starter in a workspace member read "…the new dependencies." followed by a line that started with "then run". A comma now joins the two.

Before / after

Blank lines are omitted, and the install output is shortened.

New project, answering every question:

 ● Empty project detected. Creating a Pages starter.
 ◇ Initialize a git repository?
   Yes
 ◇ Choose a Pages scaffold toolchain:
   Vite+
 ◇ Choose a Pages framework to scaffold:
   React
 ◇ Choose a Pages starter:
   D1 (SQLite)
 ◇ Where should this project deploy?
   Skip deployment setup
-◇ Installing dependencies with vp
-  … (about 40 lines of vp install output)
-◇ Installed dependencies with vp
-◇ Generating initial Drizzle migration
-◇ Generated initial Drizzle migration
 ✓ Created a React Pages starter with D1 (SQLite)
+✓ Installed dependencies in 1.2s
+✓ Generated the initial database migration
 → Git (optional): git add -A && git commit -m "chore: initial commit"
 ✓ Project initialized. Run `vp dev` to start developing.

The same run with its output piped:

 ● Empty project detected. Creating a Pages starter.
 ◇ Installing dependencies with vp
-  … (about 40 lines of vp install output)
-◇ Installed dependencies with vp
-◇ Generating initial Drizzle migration
-◇ Generated initial Drizzle migration
+◇ Generating the initial database migration
 ✓ Created a React Pages starter with D1 (SQLite)
+✓ Installed dependencies in 879ms
+✓ Generated the initial database migration
 → Git (optional): git add -A && git commit -m "chore: initial commit"
 ✓ Project initialized. Run `vp dev` to start developing.

An install that fails (a vp that prints two lines and exits with 1):

 ● Empty project detected. Creating a Pages starter.
-◇ Installing dependencies with vp
+▲ Failed to install dependencies with vp (0s)
 fake vp: install output
 fake vp: install failed
 ▲ Setup did not finish. Done so far:
 ✓ Created a React Pages starter with D1 (SQLite)
+→ Run `vp install`, then `void db generate` to finish setup
 ■ vp install failed with exit code 1

Ctrl+C during the install. Before, the terminal interrupted init and the installer, and init printed nothing more:

 ● Empty project detected. Creating a Pages starter.
-◇ Installing dependencies with vp
-  … (vp install output so far)
+■ Installing dependencies with vp (3s)
+▲ Setup did not finish. Done so far:
+✓ Created a React Pages starter with D1 (SQLite)
+→ Run `vp install`, then `void db generate` to finish setup

A PostgreSQL starter in a new subfolder:

 ◇ This folder is not empty. Where should Void initialize?
   Create a new subfolder
 ◇ New project folder name:
   my-void-app
-● Empty project detected. Creating a Pages starter.
+● Creating a Pages starter in ./my-void-app.
 ◇ Initialize a git repository?
   Yes
-◇ Installing dependencies with vp
-  … (vp install output)
-◇ Installed dependencies with vp
-◇ Generating initial Drizzle migration
-◇ Generated initial Drizzle migration
 ✓ Created a React Pages starter with PostgreSQL in ./my-void-app
+✓ Installed dependencies in 882ms
+✓ Generated the initial database migration
 → Add DATABASE_URL to .env before running `vp dev` (Void uses it for local PostgreSQL development)
-→ Git (optional): git -C /home/me/projects/my-void-app add -A && git -C /home/me/projects/my-void-app commit -m "chore: initial commit"
+→ Git (optional): git -C my-void-app add -A && git -C my-void-app commit -m "chore: initial commit"
 ✓ Project initialized. Run `cd my-void-app && vp dev` to start developing.

An existing app with void.json and wrangler.jsonc:

-◇ Migrated project configuration to void.config.ts. Commit void.config.ts and void.lock.json.
 ● Existing project detected. Configuring Void.
 ◇ Choose a database setup for this project:
   D1 (SQLite)
 ◇ Create AGENTS.md with Void instructions?
   Yes
 ◇ Scaffold demo code? (migration + API route + frontend fetch)
   No
-◇ Installing dependencies with pnpm
-  … (pnpm install output)
-◇ Installed dependencies with pnpm
 ✓ Configured Void
   + void.config.ts
   + void.lock.json
   + .gitignore
   + AGENTS.md
   ~ tsconfig.json  extends .void/tsconfig.json, added void/env to types
+✓ Migrated project configuration to void.config.ts
+✓ Installed dependencies in 443ms
+→ Commit void.config.ts and void.lock.json
 ✓ Project initialized. Run `vite dev` to start developing.

Testing

  • The unit tests for init answer the installer and drizzle-kit from one mock for spawn and spawnSync. New cases cover the summary lines, a failed install and a failed migration, an exit during the install and during the migration, and the new wording.
  • init-install.test.ts runs real subprocesses and checks that a successful installer's output stays off the terminal and that a failed one's is printed. It also exits init during an install and checks that the installer and the script it started have ended by then.
  • init-subprocess.test.ts stops real process trees: one that ends on SIGTERM, and one with a child that ignores it. It also checks that a process that has exited, but that Node has not collected, does not count as running.
  • By hand on Linux: a new project, a new subfolder, an existing npm app, a migrated config, a failing installer with and without vp on PATH, and an interrupt during vp install, npm install, drizzle-kit, and an installer whose postinstall script ignores SIGTERM (nothing was left running).
  • On macOS, where init reads the process states from ps instead of /proc: the two test files above, and the interrupt cases by hand.
  • Not run on Windows. Its path (taskkill) is covered by the mocked unit test only.

🤖 Generated with Claude Code

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebase.

morinokami and others added 3 commits November 18, 2026 19:18
`void init` printed the installer's full output, about 40 lines for a new
project. It now shows a spinner with the elapsed time while it installs
dependencies and generates the first migration, and reports both in the
closing summary. A failed install prints everything the installer wrote.

- A step that fails or is interrupted prints how to finish by hand. The
  install is named as the user can type it, also without `vp` on PATH.
- Init runs the installer in its own process group. When init exits during
  a step, it stops that group, waits until its processes have ended, kills
  what is still running after 5 seconds, and removes a half-written
  migration. Ctrl+C at the spinner keeps exit code 130.
- The Git command for a new subfolder uses a relative path, as `vp create`
  does.
- A new subfolder prints "Creating a Pages starter in ./<name>." instead of
  "Empty project detected."
- A migrated config is a ✓ line in the summary, with "Commit …" as a → line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
When init got a signal with piped output, as on a cancelled CI job, the
step it stopped was printed as a yellow warning, above the warning for the
unfinished setup. In a terminal the cancelled spinner leaves a red ■ line.

The static spinner printed a cancelled step with `log.warn`. It now uses
`log.error`, which draws the same red ■. Only init cancels a spinner, so
the output of other commands does not change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…stall

- `init-command.ts` read like the init command itself. It runs and stops
  subprocesses, so it is `init-subprocess.ts` now, and its result type is
  `SubprocessResult`.
- `ProjectInstall.typed` is `manualCommand`: "typed" means "with types"
  elsewhere in this code.
- `installProjectDependencies()` took the package manager only to build a
  default for its third argument, and ignored it when the caller passed
  one. It now takes the resolved install alone.
- `runBehindSpinner()` returns how long the command ran, so the install
  does not time it again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@morinokami

Copy link
Copy Markdown
Collaborator Author

@cpojer Rebased and resolved the conflicts. Together with the earlier PRs, this should make void init's output a lot cleaner and easier to follow!

@morinokami
morinokami requested a review from cpojer November 18, 2026 10:39

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants