Skip to content

feat(create-vite): use @clack/prompts#19445

Merged
sapphi-red merged 8 commits intomainfrom
create-vite-clack
Feb 25, 2025
Merged

feat(create-vite): use @clack/prompts#19445
sapphi-red merged 8 commits intomainfrom
create-vite-clack

Conversation

@bluwy
Copy link
Copy Markdown
Member

@bluwy bluwy commented Feb 17, 2025

Description

Here's a video of me testing out the CLI:

clack-record.mp4

NOTE: I cmd+c during executing the react-router cli as it was taking a bit long. But it was working when testing manually.


I also fixed the --overwrite flag support as the overwrite option is now a 3-option select rather than a boolean. (feature added in #15808). I also replaced minimist with mri.

dist/index.mjs size:

  • before: 60.4kB
  • after: 53.0kB

Other improvements:

Since @clack/prompts is more imperative, we could also add additional step messages like using xxx template (if --template is passed), or files in xxx removed (if --overwrite is passed), etc. But I've kept the prompts as close to as before for now.

@bluwy
Copy link
Copy Markdown
Member Author

bluwy commented Feb 17, 2025

Looks like it's failing on windows CI as there's an error happening for non-tty terminals. There's an upstream issue for this: bombshell-dev/clack#192

I guess it's kinda a blocker now that some windows user wouldn't be able to run create-vite anymore 😦

Error message
SystemError [ERR_TTY_INIT_FAILED]: TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)
    at new WriteStream (node:tty:97:11)
    at file:///D:/a/vite/vite/packages/create-vite/dist/index.mjs:9:1564
    at new Promise (<anonymous>)
    at re.prompt (file:///D:/a/vite/vite/packages/create-vite/dist/index.mjs:9:1346)
    at DD (file:///D:/a/vite/vite/packages/create-vite/dist/index.mjs:22:7)
    at ve (file:///D:/a/vite/vite/packages/create-vite/dist/index.mjs:53:2908)
    at file:///D:/a/vite/vite/packages/create-vite/dist/index.mjs:60:1439
    at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) {
  code: 'ERR_TTY_INIT_FAILED',
  info: {
    errno: -4083,
    code: 'EBADF',
    message: 'bad file descriptor',
    syscall: 'uv_tty_init'
  },
  errno: [Getter/Setter: -4083],
  syscall: [Getter/Setter: 'uv_tty_init']
}

Particularly it's erroring on this line

@sapphi-red
Copy link
Copy Markdown
Member

Nice ✨

I pushed a patch that fixes the error on Windows (it reproduced on my machine). I'll make a PR upstream later on.
To explain briefly, since the patch is impossible to read, I replaced new WriteStream(0); with isatty(0) ? new WriteStream(0) : fs.createWriteStream(null, { fd: 0 }).

I'm not sure if this fixes the Git bash case as that one didn't reproduce on my machine. It worked with powershell / cmd / git bash for me.

@sapphi-red sapphi-red added the feat: create-vite create-vite package label Feb 17, 2025
@patak-cat
Copy link
Copy Markdown
Member

I think this looks great! Awesome that all the options are visible again.

@patak-cat patak-cat added this to the 6.2 milestone Feb 17, 2025
@bluwy
Copy link
Copy Markdown
Member Author

bluwy commented Feb 17, 2025

Thanks for fixing it on windows! I wouldn't be able to figure it out myself.

@sapphi-red sapphi-red modified the milestones: 6.2, 6.3 Feb 25, 2025
@sapphi-red sapphi-red removed this from the 6.3 milestone Feb 25, 2025
@sapphi-red sapphi-red merged commit 5dae6c1 into main Feb 25, 2025
15 checks passed
@sapphi-red sapphi-red deleted the create-vite-clack branch February 25, 2025 04:59
@davidpfarrell
Copy link
Copy Markdown

I also fixed the --overwrite flag support as the overwrite option is now a 3-option select rather than a boolean. (feature added in #15808).

How EXACTLY did this PR fix the --overwrite flag support? It WAS 3 options and after this MR its a boolean that triggers yes i.e. remove all files :(

So now there is no way to trigger 'ignore' from the command line.

moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: create-vite create-vite package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants