refactor: js output
This commit is contained in:
parent
1aa28c2a34
commit
c6704c3a04
96 changed files with 3816 additions and 147 deletions
|
|
@ -1,53 +0,0 @@
|
|||
import type { Argv, ArgumentsCamelCase } from "yargs"
|
||||
import { CLICommand } from "../cli/CLICommand"
|
||||
import { parseTodoFile, writeTodoFile } from "../file"
|
||||
import { getCurrentBranch, commitFileWithBody } from "../git"
|
||||
import { validateStatusTransition } from "../issue"
|
||||
|
||||
export class HoldCommand extends CLICommand {
|
||||
readonly name = "hold <id>"
|
||||
readonly help = "Put an issue on hold"
|
||||
readonly description = "Set issue to hold (must be on issue branch)"
|
||||
|
||||
addArguments(yargs: Argv): Argv {
|
||||
return yargs
|
||||
.positional("id", { type: "number", demandOption: true })
|
||||
.option("reason", {
|
||||
type: "string",
|
||||
demandOption: true,
|
||||
description: "Reason for holding",
|
||||
})
|
||||
}
|
||||
|
||||
async execute(args: ArgumentsCamelCase): Promise<number> {
|
||||
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
|
||||
}
|
||||
|
||||
const expectedBranch = `${issue.type}/${issue.id}`
|
||||
const branch = getCurrentBranch()
|
||||
if (branch !== expectedBranch) {
|
||||
console.error(`Must be on ${expectedBranch} to hold issue (currently on ${branch})`)
|
||||
return 1
|
||||
}
|
||||
|
||||
const err = validateStatusTransition(issue.status, "hold")
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return 1
|
||||
}
|
||||
|
||||
issue.status = "hold"
|
||||
writeTodoFile(todo)
|
||||
commitFileWithBody(
|
||||
"TODO",
|
||||
`todo(${issue.id}): hold`,
|
||||
args.reason as string
|
||||
)
|
||||
console.log(`Issue #${issue.id} is now on hold`)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue