Files
kuber/command/stop.ts
T
2026-10-07 10:33:21 +00:00

39 lines
993 B
TypeScript

import { defineCommand } from "citty";
import { Listr } from "listr2";
import { apiRequest, type ApiRequestInit } from "../lib/api";
import { ctx } from "../lib/context";
type LifecycleResponse = { deployments: string[] };
export type StopApiRequest = <T>(
path: string,
init?: ApiRequestInit,
) => Promise<T>;
export function runStop(
project: string,
request: StopApiRequest = apiRequest,
): Promise<LifecycleResponse> {
return request<LifecycleResponse>(
`/workspaces/${encodeURIComponent(project)}/lifecycle`,
{ method: "POST", json: { action: "stop" } },
);
}
export const stop = defineCommand({
meta: {
name: "stop",
description: "Stop all deployments",
},
async run() {
await new Listr([
{
title: "Scale deployments",
task: async (_ctx, task) => {
const { deployments } = await runStop(ctx().project);
task.output = `${deployments.length} deployments queued`;
},
},
]).run();
},
});