@pagopa/dx-cli
Version:
A CLI useful to manage DX tools.
23 lines (22 loc) • 943 B
JavaScript
import { getLogger } from "@logtape/logtape";
import { Command } from "commander";
export const makeCodemodCommand = ({ applyCodemodById, listCodemods, }) => new Command("codemod")
.description("Manage and apply migration scripts to the repository")
.addCommand(new Command("list")
.description("List available migration scripts")
.action(async function () {
await listCodemods()
.andTee((codemods) => console.table(codemods, ["id", "description"]))
.orTee((error) => this.error(error.message));
}))
.addCommand(new Command("apply")
.argument("<id>", "The id of the codemod to apply")
.description("Apply migration scripts to the repository")
.action(async function (id) {
const logger = getLogger(["dx-cli", "codemod"]);
await applyCodemodById(id)
.andTee(() => {
logger.info("Codemod applied ✅");
})
.orTee((error) => this.error(error.message));
}));