This commit is contained in:
2026-09-03 11:28:30 +07:00 Unverified
parent 26c2d0f015
commit 82d0fe3e0d
93 changed files with 19237 additions and 1285 deletions
+21 -12
View File
@@ -1,10 +1,24 @@
import { defineCommand } from "citty";
import {
buildNamespaceGraphs,
fetchNamespaceObjects,
renderNamespaceGraphs,
} from "../lib/graph";
import { getProject } from "../lib/shared";
import { apiRequest, type ApiRequestInit } from "../lib/api";
import { renderNamespaceGraphs, type NamespaceGraph } from "../lib/graph";
import { ctx } from "../lib/context";
export type PsApiRequest = <T>(
path: string,
init?: ApiRequestInit,
) => Promise<T>;
export async function runPs(
project: string,
includeIdle = false,
request: PsApiRequest = apiRequest,
): Promise<string> {
const query = includeIdle ? "?includeIdle=true" : "";
const graphs = await request<NamespaceGraph[]>(
`/workspaces/${encodeURIComponent(project)}/status${query}`,
);
return renderNamespaceGraphs(graphs);
}
export const ps = defineCommand({
meta: {
@@ -20,11 +34,6 @@ export const ps = defineCommand({
},
},
async run({ args: { all } }) {
const objects = await fetchNamespaceObjects(getProject());
console.log(
renderNamespaceGraphs(
buildNamespaceGraphs(objects, { includeIdle: all }),
),
);
console.log(await runPs(ctx().project, all));
},
});