Skip to content

fix(cli): re-prompt when the project directory already exists - #976

Merged
AbhinRustagi merged 1 commit into
mainfrom
fix/cli-retry-existing-project-name
Aug 13, 2026
Merged

fix(cli): re-prompt when the project directory already exists#976
AbhinRustagi merged 1 commit into
mainfrom
fix/cli-retry-existing-project-name

Conversation

@AbhinRustagi

Copy link
Copy Markdown
Contributor

What

openui create aborted outright when the target directory already existed, so you had to start the whole run again. Worse, it only checked after the template prompt — you answered everything, then got rejected.

Changes

  • Check the name as soon as it's resolved, before any other prompt is shown.
  • Interactive runs report the collision and ask again, defaulting to the next free <name>-<n>. After 5 attempts they abort, as before.
  • Non-interactive runs still fail immediately with TARGET_EXISTS — there's nobody to ask.
  • Moved the logic into lib/target-dir.ts so create-app.ts stays readable.
  • Added cli_target_exists, fired on every collision in both modes. Interactive runs now recover instead of throwing, so the signal that used to reach analytics via cli_create_failed would otherwise have been lost.

Independent of the backend-framework stack (#964#969); both touch create-app.ts, so whichever lands second will need a trivial rebase.

Test Plan

  • Verified locally

tsc, prettier and eslint clean. Built the CLI and ran:

  • taken name, no --template, non-interactive → Error: Directory "taken" already exists., exit 1 — proves the name is now checked before template resolution
  • free name, no --template, non-interactive → Error: Missing required argument --template (control)

Also diffed every telemetry.capture / telemetry.register call site against main: all 27 existing events are preserved, with cli_target_exists and cli_target_name_retried added.

Checklist

  • I considered backwards compatibility

`openui create` aborted when the target directory was taken, so an
interactive run had to be started over. It also only checked after the
template prompt, so you answered everything before being rejected.

- Check the name as soon as it is resolved, before any other prompt.
- Interactive runs report the collision and ask again, defaulting to the
  next free `<name>-<n>`. After 5 attempts they abort as before.
- Non-interactive runs still fail immediately with TARGET_EXISTS, since
  there is nobody to ask.
- Move the logic to `lib/target-dir.ts` to keep `create-app.ts` readable.
- Add `cli_target_exists`, fired on every collision in both modes.
  Interactive runs now recover instead of throwing, so the signal that
  used to reach analytics via `cli_create_failed` would otherwise be lost.
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openui-docs Ready Ready Preview Aug 13, 2026 12:42pm

Request Review

@AbhinRustagi
AbhinRustagi merged commit 4e4974c into main Aug 13, 2026
33 checks passed
@AbhinRustagi
AbhinRustagi deleted the fix/cli-retry-existing-project-name branch August 13, 2026 12:54
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.

2 participants