git-release-manager
Version:
A tool to generate release notes from git commit history
53 lines • 3.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCommitCommand = createCommitCommand;
const commander_1 = require("commander");
const configManager_1 = require("../../config/configManager");
const CommitController_1 = require("../../modules/commit/CommitController");
function createCommitCommand(program) {
const commitProgram = program
.command("commit")
.alias("c")
.description("Operations related to git commits");
commitProgram.addCommand(new commander_1.Command()
.command("create")
.alias("c")
.description("Create a new commit with staged changes")
.addOption(new commander_1.Option('--stage <files...>', 'Files to add or "all"/"empty"').default('all'))
.addOption(new commander_1.Option("-m, --message <message>", "Specify the commit message"))
.addOption(new commander_1.Option("-b, --body <lines...>", "Add commit body text"))
.addOption(new commander_1.Option("-t, --type <type>", "Specify commit type (e.g., feat, fix, chore)"))
.addOption(new commander_1.Option("-s, --scope <scope>", "Specify commit scope (e.g., module or component)"))
.addOption(new commander_1.Option("--dry-run", "Show what would be committed without committing"))
.addOption(new commander_1.Option("--no-verify", "Skip pre-commit and commit-msg hooks"))
.addOption(new commander_1.Option("-i, --sign", "Sign the commit with a GPG key"))
.action(async (args, commandOptions) => {
const options = { ...program.opts(), ...commandOptions };
const config = await (0, configManager_1.readConfig)(options === null || options === void 0 ? void 0 : options.config, options.environment);
const controller = new CommitController_1.CommitController();
await controller.handleCreateCommand(options, config);
}));
commitProgram.addCommand(new commander_1.Command()
.command("list")
.alias("l")
.description("List recent commits with options to filter")
.option("-c, --count <number>", "Number of commits to list")
.action(async (args, commandOptions) => {
const options = { ...program.opts(), ...commandOptions };
const config = await (0, configManager_1.readConfig)(options === null || options === void 0 ? void 0 : options.config, options.environment);
const controller = new CommitController_1.CommitController();
await controller.handleListCommand(options, config);
}));
commitProgram.addCommand(new commander_1.Command()
.command("amend")
.alias("a")
.description("Amend the previous commit")
.action(async (args, commandOptions) => {
const options = { ...program.opts(), ...commandOptions };
const config = await (0, configManager_1.readConfig)(options === null || options === void 0 ? void 0 : options.config, options.environment);
const controller = new CommitController_1.CommitController();
await controller.handleAmendCommand(options, config);
}));
return commitProgram;
}
//# sourceMappingURL=command.js.map