@@ -20,28 +20,39 @@ export async function handleBump(
2020 cliPart : string ,
2121 cliOptions : Command & {
2222 ai ?: boolean ;
23+ ci ?: boolean ;
2324 dryRun ?: boolean ;
2425 noPackageJson ?: boolean ;
2526 noChangelog ?: boolean ;
2627 noGit ?: boolean ;
28+ output ?: string ;
2729 }
2830) {
2931 const config = loadChimpConfig (
3032 'releaseChimp'
3133 ) as ReleaseChimpConfig ;
3234
33- const part = cliPart || config . bumpType || 'patch' ;
3435 const dryRun = cliOptions . dryRun ?? config . dryRun ?? false ;
36+ const part = cliPart || config . bumpType || 'patch' ;
37+ const inferVersionOnly = cliPart === undefined && ! dryRun ;
38+ const isCI = cliOptions . ci ?? false ;
39+
40+ if ( isCI ) {
41+ console . log (
42+ '🤖 CI mode enabled: Skipping package.json, changelog, and git.'
43+ ) ;
44+ }
45+
3546 const noPackageJson =
3647 cliOptions . noPackageJson ?? config . noPackageJson ?? false ;
3748 const noChangelog =
38- cliOptions . noChangelog ?? config . noChangelog ?? false ;
39- const noGit = cliOptions . noGit ?? config . noGit ?? false ;
49+ isCI || ( cliOptions . noChangelog ?? config . noChangelog ?? false ) ;
50+ const noGit = isCI || ( cliOptions . noGit ?? config . noGit ?? false ) ;
51+ const useAI = cliOptions . ai ?? config . changelog ?. useAI ?? false ;
52+ const outputFormat = cliOptions . output ?? 'text' ;
4053
4154 const validParts = [ 'major' , 'minor' , 'patch' ] as const ;
4255
43- const useAI = cliOptions . ai ?? config . changelog ?. useAI ?? false ;
44-
4556 if ( ! validParts . includes ( part as any ) ) {
4657 console . error (
4758 `❌ Invalid bump type: '${ part } '. Must be one of: ${ validParts . join ( ', ' ) } `
@@ -54,11 +65,17 @@ export async function handleBump(
5465 } ) ;
5566
5667 const rawVersion = extractVersionFromTag ( current ) ;
57- const next = bumpVersion ( rawVersion , part as any ) ;
68+ const next = inferVersionOnly
69+ ? rawVersion
70+ : bumpVersion ( rawVersion , part as any ) ;
5871
5972 console . log ( `🐵 Current version: ${ current } ` ) ;
6073 console . log ( `🍌 Next version: ${ next } ` ) ;
6174
75+ if ( inferVersionOnly ) {
76+ console . log ( `🔄 Inferring version from latest tag` ) ;
77+ }
78+
6279 if ( dryRun ) {
6380 const changelog = noChangelog
6481 ? '_Changelog generation skipped (dry run)._'
@@ -87,7 +104,7 @@ export async function handleBump(
87104 return ;
88105 }
89106
90- // Write package.json version bump unless opted out
107+ // Update package.json version
91108 if ( ! noPackageJson ) {
92109 const packageJsonPath = path . resolve (
93110 process . cwd ( ) ,
@@ -113,7 +130,7 @@ export async function handleBump(
113130 console . log ( '📦 Skipping package.json update' ) ;
114131 }
115132
116- // Generate and write changelog unless opted out
133+ // Generate
117134 if ( ! noChangelog ) {
118135 const changelog = await generateSemanticChangelog ( {
119136 from : isGitRef ? current : undefined ,
@@ -140,4 +157,10 @@ export async function handleBump(
140157 } else {
141158 console . log ( '🚀 Skipping git commit, tag, and push' ) ;
142159 }
160+
161+ if ( outputFormat === 'json' ) {
162+ console . log ( JSON . stringify ( { next } , null , 2 ) ) ;
163+ } else {
164+ console . log ( next ) ;
165+ }
143166}
0 commit comments