Files
pikasTech-unidesk/scripts/src/cicd.ts
T
2026-07-08 19:55:43 +02:00

43 lines
2.4 KiB
TypeScript

// SPEC: PJ2026-01060703 CI/CD branch follower and GH-1548/GH-1560 Gitea PaC migration.
// Responsibility: thin CI/CD top-level route entry; subcommand logic lives in responsibility modules.
import type { UniDeskConfig } from "./config";
import { renderMachine } from "./cicd-render";
import type { RenderedCliResult } from "./output";
import { cicdHelp as branchFollowerHelp, runCicdCommand as runBranchFollowerCommand } from "./cicd-branch-follower";
import { cicdGiteaActionsPocHelp, runGiteaActionsPocCommand } from "./cicd-gitea-actions-poc";
import { cicdNodeStatusHelp, runCicdNodeStatusCommand } from "./cicd-node-status";
export function cicdHelp(): unknown {
return {
command: "cicd status|gitea-actions-poc|branch-follower",
output: "text by default for subcommands; top-level help is json",
nodeStatus: {
primary: "bun scripts/cli.ts cicd status --node NC01",
note: "Use this for node-level CI/CD status. It aggregates all current Pipelines-as-Code consumers for the node, including AgentRun, HWLAB and Web sentinel.",
},
migration: {
issue: "https://github.com/pikasTech/unidesk/issues/1560",
primary: "platform-infra pipelines-as-code",
primaryStatus: "bun scripts/cli.ts platform-infra pipelines-as-code status --target JD01",
primaryHistory: "bun scripts/cli.ts platform-infra pipelines-as-code history --target JD01 --limit 10",
archived: "cicd gitea-actions-poc",
deprecated: "cicd branch-follower",
note: "JD01 CI/CD source/trigger authority is Gitea mirror -> Pipelines-as-Code -> Tekton -> Argo/k8s runtime. Gitea Actions POC and branch-follower are historical or migration-only surfaces.",
},
subcommands: [
cicdNodeStatusHelp(),
cicdGiteaActionsPocHelp(),
branchFollowerHelp(),
],
};
}
export async function runCicdCommand(config: UniDeskConfig | null, args: string[]): Promise<RenderedCliResult> {
const top = args[0];
if (top === undefined || top === "help" || top === "--help" || top === "-h") return renderMachine("cicd", cicdHelp(), "json");
if (top === "status") return await runCicdNodeStatusCommand(config, args);
if (top === "branch-follower") return await runBranchFollowerCommand(config, args);
if (top === "gitea-actions-poc" || top === "gitea-builder-poc") return await runGiteaActionsPocCommand(config, args.slice(1), top);
throw new Error("cicd usage: cicd status --node <NODE> | cicd gitea-actions-poc|branch-follower");
}