Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"devDependencies": {
"@azure/functions": "^3.5.1",
"@azure/static-web-apps-cli": "^2.0.7",
"@bomb.sh/tab": "^0.0.9",
"@cloudflare/workers-types": "^4.20251008.0",
"@deno/types": "^0.0.1",
"@netlify/edge-functions": "^2.18.2",
Expand Down
23 changes: 23 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 148 additions & 0 deletions src/cli/completions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import type { ArgsDef, CommandDef } from "citty";
import tab from "@bomb.sh/tab/citty";

export async function initCompletions<T extends ArgsDef = ArgsDef>(
command: CommandDef<T>
) {
const completion = await tab(command);

const devCommand = completion.commands.get("dev");
if (devCommand) {
const portOption = devCommand.options.get("port");
if (portOption) {
portOption.handler = (complete) => {
complete("3000", "Default development port");
complete("3001", "Alternative port");
complete("8080", "Common alternative port");
complete("4000", "Another common port");
};
}

const hostOption = devCommand.options.get("host");
if (hostOption) {
hostOption.handler = (complete) => {
complete("localhost", "Local development");
complete("0.0.0.0", "Listen on all interfaces");
complete("127.0.0.1", "Loopback address");
};
}

const dirOption = devCommand.options.get("dir");
if (dirOption) {
dirOption.handler = (complete) => {
complete(".", "Current directory");
};
}
}

const buildCommand = completion.commands.get("build");
if (buildCommand) {
const presetOption = buildCommand.options.get("preset");
if (presetOption) {
presetOption.handler = (complete) => {
complete("node-server", "Node.js server");
complete("node-middleware", "Node.js middleware");
complete("node-cluster", "Node.js cluster mode");

// Static presets
complete("static", "Static hosting");
complete("github-pages", "GitHub Pages");
complete("gitlab-pages", "GitLab Pages");

complete("cloudflare-pages", "Cloudflare Pages");
complete("cloudflare-pages-static", "Cloudflare Pages (static)");
complete("cloudflare-module", "Cloudflare Workers (module)");
complete("cloudflare-durable", "Cloudflare Durable Objects");
complete("vercel", "Vercel");
complete("vercel-static", "Vercel (static)");
complete("netlify", "Netlify");
complete("netlify-edge", "Netlify Edge Functions");
complete("netlify-static", "Netlify (static)");

complete("aws-lambda", "AWS Lambda");
complete("aws-amplify", "AWS Amplify");

complete("azure-swa", "Azure Static Web Apps");

complete("firebase-app-hosting", "Firebase App Hosting");
complete("deno-deploy", "Deno Deploy");
complete("deno-server", "Deno Server");
complete("bun", "Bun runtime");
complete("digital-ocean", "DigitalOcean");
complete("heroku", "Heroku");
complete("render-com", "Render.com");
complete("zeabur", "Zeabur");
complete("zeabur-static", "Zeabur (static)");
complete("zerops", "Zerops");
complete("zerops-static", "Zerops (static)");
complete("koyeb", "Koyeb");
complete("platform-sh", "Platform.sh");
complete("flight-control", "FlightControl");
complete("cleavr", "Cleavr");
complete("stormkit", "Stormkit");
complete("genezio", "Genezio");
complete("alwaysdata", "AlwaysData");

complete("iis-handler", "IIS Handler");
complete("iis-node", "IIS Node");
complete("winterjs", "WinterJS");
complete("standard", "Standard runtime");
};
}

const minifyOption = buildCommand.options.get("minify");
if (minifyOption) {
minifyOption.handler = (complete) => {
complete("true", "Enable minification");
complete("false", "Disable minification");
};
}

const dirOption = buildCommand.options.get("dir");
if (dirOption) {
dirOption.handler = (complete) => {
complete(".", "Current directory");
};
}
}

const prepareCommand = completion.commands.get("prepare");
if (prepareCommand) {
const dirOption = prepareCommand.options.get("dir");
if (dirOption) {
dirOption.handler = (complete) => {
complete(".", "Current directory");
};
}
}

const taskListCommand = completion.commands.get("task list");
if (taskListCommand) {
const dirOption = taskListCommand.options.get("dir");
if (dirOption) {
dirOption.handler = (complete: (value: string, description: string) => void) => {
complete(".", "Current directory");
};
}
}

const taskRunCommand = completion.commands.get("task run");
if (taskRunCommand) {
const dirOption = taskRunCommand.options.get("dir");
if (dirOption) {
dirOption.handler = (complete: (value: string, description: string) => void) => {
complete(".", "Current directory");
};
}

const payloadOption = taskRunCommand.options.get("payload");
if (payloadOption) {
payloadOption.handler = (complete: (value: string, description: string) => void) => {
complete("{}", "");
};
}
}

return completion;
}

10 changes: 8 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import { defineCommand, runMain } from "citty";
import { defineCommand, runMain as _runMain } from "citty";
import { version as nitroVersion } from "nitro/meta";
import { initCompletions } from "./completions";

const main = defineCommand({
meta: {
Expand All @@ -16,4 +17,9 @@ const main = defineCommand({
},
});

runMain(main);
async function runMain() {
await initCompletions(main);
return _runMain(main);
}

runMain();