feat: release 2.7.1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { renderUsage } from "citty";
|
||||
import { login, logout, whoami } from "../../command/auth";
|
||||
import { db } from "../../command/db";
|
||||
import { down } from "../../command/down";
|
||||
@@ -6,6 +7,7 @@ import { exec } from "../../command/exec";
|
||||
import { exportCommand } from "../../command/export";
|
||||
import { logs } from "../../command/logs";
|
||||
import { initializeCompletion, main } from "../../command/main";
|
||||
import { maintenance } from "../../command/maintenance";
|
||||
import { ps } from "../../command/ps";
|
||||
import { restart } from "../../command/restart";
|
||||
import { rollback } from "../../command/rollback";
|
||||
@@ -15,7 +17,7 @@ import { stop } from "../../command/stop";
|
||||
import { up } from "../../command/up";
|
||||
|
||||
type Command = {
|
||||
meta?: { name?: string; description?: string };
|
||||
meta?: { name?: string; description?: string; hidden?: boolean };
|
||||
args?: Record<string, Record<string, unknown>>;
|
||||
subCommands?: Record<string, Command>;
|
||||
run?: unknown;
|
||||
@@ -23,21 +25,23 @@ type Command = {
|
||||
|
||||
describe("CLI command definitions", () => {
|
||||
const commands = [
|
||||
["kuber", "Deploy and manage projects on Kubernetes", main],
|
||||
["up", "Create and start deployments", up],
|
||||
["login", "Log in to kuber.astrxl.dev", login],
|
||||
["login", "Log in to the cluster", login],
|
||||
["logout", "Log out of kuber.astrxl.dev", logout],
|
||||
["whoami", "Show the current kuber user", whoami],
|
||||
["start", "Start deployments without rebuilding images", start],
|
||||
["stop", "Scale managed deployments to zero", stop],
|
||||
["restart", "Roll out a restart for managed deployments", restart],
|
||||
["stop", "Stop all deployments", stop],
|
||||
["restart", "Restart deployments", restart],
|
||||
["rollback", "Roll deployments back to the previous release", rollback],
|
||||
["s3", "Inspect managed S3 storage", s3],
|
||||
["maintenance", "Toggle maintenance page on hostnames", maintenance],
|
||||
["s3", "View project object storage settings", s3],
|
||||
["down", "Delete managed resources except ingress and PVCs", down],
|
||||
["ps", "List deployments", ps],
|
||||
["logs", "Show deployment logs", logs],
|
||||
["exec", "Execute a command inside a deployment pod", exec],
|
||||
["export", "Write rendered manifests to a YAML file", exportCommand],
|
||||
["db", "Inspect managed postgres databases", db],
|
||||
["db", "View project databases and credentials", db],
|
||||
] as const;
|
||||
|
||||
test.each(commands)(
|
||||
@@ -45,8 +49,9 @@ describe("CLI command definitions", () => {
|
||||
(name, description, command) => {
|
||||
const definition = command as Command;
|
||||
expect(definition.meta).toMatchObject({ name, description });
|
||||
if (name !== "db" && name !== "s3")
|
||||
if (name !== "kuber" && name !== "db" && name !== "s3")
|
||||
expect(typeof definition.run).toBe("function");
|
||||
if (name === "kuber") expect(definition.run).toBeUndefined();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -79,7 +84,7 @@ describe("CLI command definitions", () => {
|
||||
expect((main as Command).args?.config).toMatchObject({
|
||||
type: "string",
|
||||
});
|
||||
expect((login as Command).args?.persist).toMatchObject({
|
||||
expect((login as Command).args?.session).toMatchObject({
|
||||
type: "boolean",
|
||||
});
|
||||
});
|
||||
@@ -115,4 +120,43 @@ describe("CLI command definitions", () => {
|
||||
Object.keys((await Promise.resolve(main.subCommands)) ?? {}),
|
||||
).toContain("complete");
|
||||
});
|
||||
|
||||
test("hides internal commands only from root help", async () => {
|
||||
const usage = await renderUsage(main);
|
||||
for (const name of [
|
||||
"ci",
|
||||
"whoami",
|
||||
"logout",
|
||||
"operations",
|
||||
"maintenance",
|
||||
"audit",
|
||||
"users",
|
||||
]) {
|
||||
expect(usage).not.toContain(name);
|
||||
expect(usage).not.toContain(`${name}|`);
|
||||
}
|
||||
for (const name of ["add", "login", "up"]) expect(usage).toContain(name);
|
||||
});
|
||||
|
||||
test("does not mutate exported command metadata when loading hidden commands", async () => {
|
||||
await renderUsage(main);
|
||||
const { ci } = await import("../../command/ci");
|
||||
const { whoami, logout } = await import("../../command/auth");
|
||||
const { operations } = await import("../../command/operations");
|
||||
const { maintenance } = await import("../../command/maintenance");
|
||||
const { audit } = await import("../../command/audit");
|
||||
const { users } = await import("../../command/users");
|
||||
for (const command of [
|
||||
ci,
|
||||
whoami,
|
||||
logout,
|
||||
operations,
|
||||
maintenance,
|
||||
audit,
|
||||
users,
|
||||
])
|
||||
expect(
|
||||
(command as Command & { meta?: { hidden?: boolean } }).meta?.hidden,
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user