Skip to content

Commit e3a8706

Browse files
committed
feat: add AI automation support with --dry-run and --yes options
- Add --dry-run option to preview commands without execution - Add --yes option to skip interactive prompts for automation - Add --release-type, --version, and --tag options for programmatic control - Update TypeScript configuration for better Node.js support - Maintain backward compatibility with existing interactive mode - Enable AI agents to safely preview and execute publish workflows
1 parent b10cfe0 commit e3a8706

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

AI_AUTOMATION.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# AI Automation Support
2+
3+
This document describes the AI automation features added to quick-publish.
4+
5+
## New CLI Options
6+
7+
### `--dry-run`
8+
Shows what commands would be executed without actually running them. Perfect for AI agents to understand what will happen before execution.
9+
10+
```bash
11+
# See what would happen with a patch release
12+
quick-publish --dry-run --release-type patch
13+
14+
# Preview a custom version release
15+
quick-publish --dry-run --release-type custom --version 1.2.3 --tag beta
16+
```
17+
18+
### `--yes`
19+
Skips all interactive prompts and uses provided or default values. Enables fully automated execution.
20+
21+
```bash
22+
# Automated patch release
23+
quick-publish --yes --release-type patch
24+
25+
# Automated custom release
26+
quick-publish --yes --release-type custom --version 1.2.3 --tag latest
27+
```
28+
29+
### Version and Tag Options
30+
31+
- `--release-type <type>`: `patch`, `minor`, `major`, `prerelease`, or `custom`
32+
- `--version <version>`: Custom version (required when `--release-type=custom`)
33+
- `--tag <tag>`: NPM tag (`latest`, `next`, `beta`, or custom tag name)
34+
35+
## AI Usage Examples
36+
37+
### 1. Preview Changes (Dry Run)
38+
```bash
39+
# AI can run this to see what would happen
40+
quick-publish --dry-run --release-type patch
41+
```
42+
43+
Output:
44+
```
45+
[DRY RUN] Would select version: 0.7.2, tag: latest
46+
[DRY RUN] Would ask: Continue to publish `0.7.2` with tag `latest`? (auto-yes in automated mode)
47+
48+
[DRY RUN] Publish workflow for version 0.7.2 with tag latest:
49+
[DRY RUN] Would execute: npm version 0.7.2
50+
[DRY RUN] Would execute: /path/to/conventional-changelog -p angular -r 2 -i CHANGELOG.md -s
51+
[DRY RUN] Would execute: npm publish --tag=latest
52+
[DRY RUN] Would execute: git add CHANGELOG.md
53+
[DRY RUN] Would execute: git commit -m chore%3A%20changelog%200.7.2
54+
[DRY RUN] Would execute: git push
55+
[DRY RUN] Would execute: git push origin refs/tags/v0.7.2
56+
57+
[DRY RUN] Publish workflow completed. Use --yes to execute.
58+
```
59+
60+
### 2. Automated Execution
61+
```bash
62+
# AI can run this after confirming with dry-run
63+
quick-publish --yes --release-type patch
64+
```
65+
66+
### 3. Custom Version Release
67+
```bash
68+
# For specific version requirements
69+
quick-publish --yes --release-type custom --version 1.0.0 --tag latest
70+
```
71+
72+
### 4. Beta Release
73+
```bash
74+
# For pre-release versions
75+
quick-publish --yes --release-type prerelease --tag beta
76+
```
77+
78+
## AI Workflow Recommendation
79+
80+
1. **Analysis Phase**: AI runs with `--dry-run` to understand what will happen
81+
2. **Confirmation Phase**: AI presents the planned actions to user
82+
3. **Execution Phase**: AI runs with `--yes` and appropriate parameters
83+
84+
```bash
85+
# Step 1: Analyze
86+
quick-publish --dry-run --release-type patch
87+
88+
# Step 2: Execute (after user confirmation)
89+
quick-publish --yes --release-type patch
90+
```
91+
92+
## Error Handling
93+
94+
- Missing `--version` with `--release-type=custom` will throw an error
95+
- Invalid release types will be rejected
96+
- All validation happens before any commands are executed
97+
98+
## Backward Compatibility
99+
100+
All existing functionality remains unchanged. The new options are additive and don't affect the interactive mode when not specified.

src/cli.ts

100755100644
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ export function bootstrapCli() {
1818
'--push',
1919
'Execute git push & tag push to remote git origin, defaults to `true`',
2020
)
21+
.option(
22+
'--dry-run',
23+
'Show what would be executed without actually running commands',
24+
)
25+
.option(
26+
'--yes',
27+
'Skip all prompts and use default values for automated execution',
28+
)
29+
.option(
30+
'--release-type <type>',
31+
'Release type: patch, minor, major, prerelease, or custom',
32+
)
33+
.option(
34+
'--version <version>',
35+
'Custom version (required when --release-type=custom)',
36+
)
37+
.option(
38+
'--tag <tag>',
39+
'NPM tag: latest, next, beta, or custom tag name',
40+
)
2141
.action(opts => {
2242
publish(opts);
2343
});

src/types.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ export interface IOptions {
2323
* Execute git push & tag push to remote git origin, defaults to `true`
2424
*/
2525
push?: boolean;
26+
/**
27+
* Show what would be executed without actually running commands
28+
*/
29+
dryRun?: boolean;
30+
/**
31+
* Skip all prompts and use default values for automated execution
32+
*/
33+
yes?: boolean;
34+
/**
35+
* Release type: patch, minor, major, prerelease, or custom
36+
*/
37+
releaseType?: ReleaseType | CustomReleaseType;
38+
/**
39+
* Custom version (required when releaseType=custom)
40+
*/
41+
version?: string;
42+
/**
43+
* NPM tag: latest, next, beta, or custom tag name
44+
*/
45+
tag?: string;
2646
}
2747
/**
2848
* Definition of versions candidate.

0 commit comments

Comments
 (0)