-
Notifications
You must be signed in to change notification settings - Fork 99
feat(cli): add tab completions #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
π¦ Bundle Size Comparisonπ nuxi
β‘οΈ nuxt-cli
β‘οΈ create-nuxt
|
commit: |
CodSpeed Performance ReportMerging #1082 will not alter performanceComparing Summary
|
b48598c
to
2e68892
Compare
3fab8fe
to
911f4b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking very, very exciting!
npx nuxi <Tab> | ||
npm exec nuxi <Tab> | ||
pnpm nuxi <Tab> | ||
yarn nuxi <Tab> | ||
bun nuxi <Tab> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer advise running nuxi
as a cli but nuxt
directly, for example pnpm nuxt dev
within a nuxt project. @nuxt/cli
is the package most nuxt users have installed, and it works with both the nuxi
and nuxt
binaries. nuxi
is a legacy all-dependencied-inlined version for portability, but we've chosen to use a lighter version without inlined dependencies for smaller installed size, greater security (and to dedupe deps).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, Thanks for the details! I'll handle it!
import type { ArgsDef, CommandDef } from 'citty' | ||
import tab from '@bomb.sh/tab/citty' | ||
|
||
export async function initCompletions<T extends ArgsDef = ArgsDef>(command: CommandDef<T>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we split these up into two sets of completions?
create-nuxt
will only need the the init
completions (yet won't have init
as a subcommand).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sure. I'll do it!
complete('node-server', 'Node.js server') | ||
complete('static', 'Static hosting') | ||
complete('cloudflare-pages', 'Cloudflare Pages') | ||
complete('vercel', 'Vercel') | ||
complete('netlify', 'Netlify') | ||
complete('aws-lambda', 'AWS Lambda') | ||
complete('azure', 'Azure') | ||
complete('firebase', 'Firebase') | ||
complete('deno-deploy', 'Deno Deploy') | ||
complete('bun', 'Bun runtime') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a very long list of possible providers here:
I wonder if it's possible to use nitropack at build time to get this list rather than hard code any of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.. are there any approaches you prefer? I thought of fetching from the url (https://nitro.build/deploy) and extracting the names of the providers, but the CLI preset names don't always match the provider names directly. for example, the docs page says βCloudflareβ but the actual valid presets are: "cloudflare-pages" and "cloudflare-workers" (not just cloudflare)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if there is a json or a file where we can get the full internal preset keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can import from nitropack directly
complete('v3', 'Nuxt 3 template') | ||
complete('v4', 'Nuxt 4 template') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our first-party templates are available at https://github.com/nuxt/starter/tree/templates/templates.
again, do you think maybe we could grab data from these at build-time?
π Linked issue
β Type of change
π Description
This PR introduces tab completion functionality for the nuxt cli, improving developer experience by allowing shell(zsh, powershell, fish, bash) autocompletion for commands, options, values, and flags. With this PR, users can navigate available commands, options and values more efficiently and faster with speeding up workflow.
A small video of how this works:
nuxi.mp4
A small documentation of how CLIs can integrate tab ( in this case, I'm using the citty adapter )