refactor: js output

This commit is contained in:
Tiara Rodney 2026-03-15 05:11:59 +01:00
parent 1aa28c2a34
commit c6704c3a04
No known key found for this signature in database
GPG key ID: 5CD8EC1D46106723
96 changed files with 3816 additions and 147 deletions

View file

@ -0,0 +1,43 @@
import { CLICommand } from "../cli/CLICommand.js";
import { parseTodoFile, writeTodoFile } from "../file.js";
import { getCurrentBranch, commitFileWithBody } from "../git.js";
import { validateStatusTransition } from "../issue.js";
export class DoneCommand extends CLICommand {
name = "done <id>";
help = "Mark an issue as done";
description = "Set issue to done (must be on issue branch)";
addArguments(yargs) {
return yargs
.positional("id", { type: "number", demandOption: true })
.option("summary", {
type: "string",
demandOption: true,
description: "High-level summary of what was delivered",
});
}
async execute(args) {
const todo = await parseTodoFile();
const issue = todo.issues.find(i => i.id === args.id);
if (!issue) {
console.error(`Issue #${args.id} not found`);
return 1;
}
// Must be on the correct issue branch
const expectedBranch = `${issue.type}/${issue.id}`;
const branch = getCurrentBranch();
if (branch !== expectedBranch) {
console.error(`Must be on ${expectedBranch} to mark issue as done (currently on ${branch})`);
return 1;
}
const err = validateStatusTransition(issue.status, "done");
if (err) {
console.error(err);
return 1;
}
issue.status = "done";
writeTodoFile(todo);
commitFileWithBody("TODO", `todo(${issue.id}): done`, args.summary);
console.log(`Issue #${issue.id} is now done`);
return 0;
}
}