Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

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

wants to merge 6 commits into from

Conversation

bluwy
Copy link
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
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
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-dev
Copy link
Member

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

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

bluwy commented Feb 17, 2025

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feat: create-vite create-vite package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants