feat(commit): Add non-interactive --yes (-y) flag to commit command to auto-accept AI recommendations and optionally push with -p
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-06 - 1.20.0 - feat(commit)
|
||||||
|
Add non-interactive --yes (-y) flag to commit command to auto-accept AI recommendations and optionally push with -p
|
||||||
|
|
||||||
|
- Add -y / --yes flag to gitzone commit to auto-accept AI-generated commit recommendations without interactive prompts
|
||||||
|
- Support -yp or -y -p combinations to auto-accept and push to origin; -p / --push remains the separate control for pushing
|
||||||
|
- Implementation creates a smartinteract AnswerBucket programmatically when -y is used and populates commitType, commitScope, commitDescription and pushToOrigin
|
||||||
|
- Preserves existing UI output and interactive flow when -y is not used; fully backward compatible and CI/CD friendly
|
||||||
|
- Updated CLI usage and documentation (readme.hints.md) to document the new flags
|
||||||
|
|
||||||
## 2025-11-05 - 1.19.9 - fix(mod_commit)
|
## 2025-11-05 - 1.19.9 - fix(mod_commit)
|
||||||
Refactor version bumping to a unified implementation for npm and Deno; remove npm-exec based helpers and add file-based version readers/updaters to avoid npm warning pollution
|
Refactor version bumping to a unified implementation for npm and Deno; remove npm-exec based helpers and add file-based version readers/updaters to avoid npm warning pollution
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,21 @@ The commit module's version bumping has been refactored to eliminate npm command
|
|||||||
- Same code path for all project types
|
- Same code path for all project types
|
||||||
- Reuses existing `calculateNewVersion()` function
|
- Reuses existing `calculateNewVersion()` function
|
||||||
|
|
||||||
|
### Auto-Accept Flag for Commits
|
||||||
|
|
||||||
|
The commit module now supports `-y/--yes` flag for non-interactive commits:
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
- `gitzone commit -y` - Auto-accepts AI recommendations without prompts
|
||||||
|
- `gitzone commit -yp` - Auto-accepts and pushes to origin
|
||||||
|
- Separate `-p/--push` flag controls push behavior
|
||||||
|
|
||||||
|
**Implementation:**
|
||||||
|
- Creates AnswerBucket programmatically when `-y` flag detected
|
||||||
|
- Preserves all UI output for transparency
|
||||||
|
- Fully backward compatible with interactive mode
|
||||||
|
- CI/CD friendly for automated workflows
|
||||||
|
|
||||||
## Development Tips
|
## Development Tips
|
||||||
|
|
||||||
- Always check readme.plan.md for ongoing improvement plans
|
- Always check readme.plan.md for ongoing improvement plans
|
||||||
@@ -157,6 +172,27 @@ The commit module's version bumping has been refactored to eliminate npm command
|
|||||||
|
|
||||||
## CLI Usage
|
## CLI Usage
|
||||||
|
|
||||||
|
### Commit Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Interactive commit (default)
|
||||||
|
gitzone commit
|
||||||
|
|
||||||
|
# Auto-accept AI recommendations (no prompts)
|
||||||
|
gitzone commit -y
|
||||||
|
gitzone commit --yes
|
||||||
|
|
||||||
|
# Auto-accept and push to origin
|
||||||
|
gitzone commit -yp
|
||||||
|
gitzone commit -y -p
|
||||||
|
gitzone commit --yes --push
|
||||||
|
|
||||||
|
# Run format before commit
|
||||||
|
gitzone commit --format
|
||||||
|
```
|
||||||
|
|
||||||
|
### Format Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Basic format
|
# Basic format
|
||||||
gitzone format
|
gitzone format
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/cli',
|
name: '@git.zone/cli',
|
||||||
version: '1.19.9',
|
version: '1.20.0',
|
||||||
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,35 +27,63 @@ export const run = async (argvArg: any) => {
|
|||||||
recommendedNextVersionScope: nextCommitObject.recommendedNextVersionScope,
|
recommendedNextVersionScope: nextCommitObject.recommendedNextVersionScope,
|
||||||
recommendedNextVersionMessage: nextCommitObject.recommendedNextVersionMessage,
|
recommendedNextVersionMessage: nextCommitObject.recommendedNextVersionMessage,
|
||||||
});
|
});
|
||||||
const commitInteract = new plugins.smartinteract.SmartInteract();
|
|
||||||
commitInteract.addQuestions([
|
let answerBucket: plugins.smartinteract.AnswerBucket;
|
||||||
{
|
|
||||||
type: 'list',
|
// Check if -y or --yes flag is set to auto-accept recommendations
|
||||||
name: `commitType`,
|
if (argvArg.y || argvArg.yes) {
|
||||||
message: `Choose TYPE of the commit:`,
|
// Auto-mode: create AnswerBucket programmatically
|
||||||
choices: [`fix`, `feat`, `BREAKING CHANGE`],
|
logger.log('info', '✓ Auto-accepting AI recommendations (--yes flag)');
|
||||||
default: nextCommitObject.recommendedNextVersionLevel,
|
|
||||||
},
|
answerBucket = new plugins.smartinteract.AnswerBucket();
|
||||||
{
|
answerBucket.addAnswer({
|
||||||
type: 'input',
|
name: 'commitType',
|
||||||
name: `commitScope`,
|
value: nextCommitObject.recommendedNextVersionLevel,
|
||||||
message: `What is the SCOPE of the commit:`,
|
});
|
||||||
default: nextCommitObject.recommendedNextVersionScope,
|
answerBucket.addAnswer({
|
||||||
},
|
name: 'commitScope',
|
||||||
{
|
value: nextCommitObject.recommendedNextVersionScope,
|
||||||
type: `input`,
|
});
|
||||||
name: `commitDescription`,
|
answerBucket.addAnswer({
|
||||||
message: `What is the DESCRIPTION of the commit?`,
|
name: 'commitDescription',
|
||||||
default: nextCommitObject.recommendedNextVersionMessage,
|
value: nextCommitObject.recommendedNextVersionMessage,
|
||||||
},
|
});
|
||||||
{
|
answerBucket.addAnswer({
|
||||||
type: 'confirm',
|
name: 'pushToOrigin',
|
||||||
name: `pushToOrigin`,
|
value: !!(argvArg.p || argvArg.push), // Only push if -p flag also provided
|
||||||
message: `Do you want to push this version now?`,
|
});
|
||||||
default: true,
|
} else {
|
||||||
},
|
// Interactive mode: prompt user for input
|
||||||
]);
|
const commitInteract = new plugins.smartinteract.SmartInteract();
|
||||||
const answerBucket = await commitInteract.runQueue();
|
commitInteract.addQuestions([
|
||||||
|
{
|
||||||
|
type: 'list',
|
||||||
|
name: `commitType`,
|
||||||
|
message: `Choose TYPE of the commit:`,
|
||||||
|
choices: [`fix`, `feat`, `BREAKING CHANGE`],
|
||||||
|
default: nextCommitObject.recommendedNextVersionLevel,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'input',
|
||||||
|
name: `commitScope`,
|
||||||
|
message: `What is the SCOPE of the commit:`,
|
||||||
|
default: nextCommitObject.recommendedNextVersionScope,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: `input`,
|
||||||
|
name: `commitDescription`,
|
||||||
|
message: `What is the DESCRIPTION of the commit?`,
|
||||||
|
default: nextCommitObject.recommendedNextVersionMessage,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'confirm',
|
||||||
|
name: `pushToOrigin`,
|
||||||
|
message: `Do you want to push this version now?`,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
answerBucket = await commitInteract.runQueue();
|
||||||
|
}
|
||||||
const commitString = createCommitStringFromAnswerBucket(answerBucket);
|
const commitString = createCommitStringFromAnswerBucket(answerBucket);
|
||||||
const commitVersionType = (() => {
|
const commitVersionType = (() => {
|
||||||
switch (answerBucket.getAnswerFor('commitType')) {
|
switch (answerBucket.getAnswerFor('commitType')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user