Files
dmgnr 6c8c8e0c1b feat: implement rollback command for deployments
- Added a new `rollback` command to roll back deployments to their previous release.
- Introduced `findRollbackCandidates` and `rollbackDeployment` functions to handle rollback logic.
- Updated CLI command definitions to include the new `rollback` command with an alias.
- Enhanced deployment conversion to use resolved images for buildable services.
- Introduced a new `graph` module to visualize Kubernetes resources and their relationships.
- Added tests for the new rollback functionality and graph rendering.
- Updated package version to 1.3.0.
2026-08-30 23:47:38 +07:00

53 lines
1.3 KiB
TypeScript

import { defineCommand } from "citty";
import { resolve } from "node:path";
import { YAML } from "bun";
import type { KuberResource } from "../types";
import { sortResources } from "../lib/apply";
import { ctx } from "../lib/context";
import { renderResources } from "../lib/render";
function toDocumentYaml(
resources: Parameters<typeof sortResources>[0],
): string {
return `${sortResources(resources)
.map((resource) => YAML.stringify(resource, null, 2).trimEnd())
.join("\n---\n")}\n`;
}
export const exportCommand = defineCommand({
meta: {
name: "export",
description: "Write rendered manifests to a YAML file",
},
args: {
output: {
type: "string",
alias: "o",
description: "Output YAML file path",
},
},
async run({ args }) {
const {
project,
compose,
cwd,
config,
hookContext: getHookContext,
} = ctx();
const resources = await renderResources(
project,
await compose(),
cwd,
config,
);
await config.postRender?.(
resources as KuberResource[],
await getHookContext(),
);
const outputPath = resolve(cwd, args.output || `${project}.yaml`);
await Bun.write(outputPath, toDocumentYaml(resources));
console.log(outputPath);
},
});