Files
kuber/index.ts
T
2026-08-28 21:19:50 +07:00

54 lines
1.3 KiB
TypeScript

import { defineCommand, runMain } from "citty";
import { db } from "./command/db";
import { down } from "./command/down";
import { exportCommand } from "./command/export";
import { exec } from "./command/exec";
import { logs } from "./command/logs";
import { ps } from "./command/ps";
import { restart } from "./command/restart";
import { start } from "./command/start";
import { stop } from "./command/stop";
import { up } from "./command/up";
import { provideContext } from "./lib/context";
import z, { ZodError } from "zod";
function formatUnknownError(error: unknown): string {
if (error instanceof ZodError) return z.prettifyError(error);
if (error instanceof Error) {
const stack = error.stack?.split("\n").slice(0, 3).join("\n");
return stack && stack.trim().length > 0 ? stack : error.message;
}
try {
return JSON.stringify(error, null, 2);
} catch {
return String(error);
}
}
const main = defineCommand({
meta: {
name: "kuber",
version: "1.0.0",
description: "Docker Compose -> K8s translation layer",
},
subCommands: {
db,
down,
export: exportCommand,
exec,
logs,
ps,
restart,
start,
stop,
up,
},
});
provideContext(() => runMain(main)).catch((e) => {
console.error(formatUnknownError(e));
process.exitCode = 1;
});