diff --git a/cli/src/config.ts b/cli/src/config.ts index d75a867..e62dc02 100644 --- a/cli/src/config.ts +++ b/cli/src/config.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import type { GitCraftConfig, Plugin } from './plugins' import { ChangelogPlugin } from './plugins/changelog' diff --git a/cli/src/index.ts b/cli/src/index.ts index 5142951..13aa7c9 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -39,15 +39,24 @@ program filterPath: opts.path, }) - const label = result.dryRun ? ' [dry-run]' : '' + let label: string + if (result.published) { + label = ' [published]' + } else if (result.dryRun) { + label = ' [dry-run]' + } else { + label = ' [tag]' + } console.log(`\nGitCraft Release${label}`) console.log(` ${result.previousVersion} → ${result.nextVersion} (${result.bumpType})`) console.log(` Tag: ${result.tag}`) console.log(` Commits: ${result.commitCount}`) - if (result.published) console.log(` Published: ${result.tag} pushed to origin`) - - if (result.dryRun) { - console.log('\nDry run — no plugins ran, no files were written.') + if (result.published) { + console.log(`\nPublished: ${result.tag} pushed to origin`) + } else if (result.nextVersion === result.previousVersion) { + console.log('\nNo version bump needed based on commit messages') + } else if (result.dryRun) { + console.log('\nThis was a dry run — no changes were made') } } catch (err) { console.error(`\nError: ${(err as Error).message}`) diff --git a/cli/src/semver.ts b/cli/src/semver.ts index e082382..7fd7e42 100644 --- a/cli/src/semver.ts +++ b/cli/src/semver.ts @@ -3,6 +3,9 @@ import type { BumpType } from './analyzer' export function bumpVersion(current: string, type: BumpType): string { const next = semver.inc(current, type) - if (!next) throw new Error(`Cannot increment invalid version: "${current}"`) + if (!next) { + throw new Error(`Cannot increment invalid version: "${current}"`) + } + return next } diff --git a/cli/src/tags.ts b/cli/src/tags.ts index 33c8a48..5b9b1e2 100644 --- a/cli/src/tags.ts +++ b/cli/src/tags.ts @@ -1,4 +1,4 @@ -import { execSync } from 'child_process' +import { execSync } from 'node:child_process' import semver from 'semver' export interface TagResolution { @@ -22,7 +22,9 @@ export function resolveLatestTag(prefix: string = 'v'): TagResolution { return makeInitial(prefix) } - if (!rawOutput) return makeInitial(prefix) + if (!rawOutput) { + return makeInitial(prefix) + } const candidates = rawOutput .split('\n') @@ -35,7 +37,9 @@ export function resolveLatestTag(prefix: string = 'v'): TagResolution { }) .filter((e): e is { tag: string; latest: string } => e !== null) - if (candidates.length === 0) return makeInitial(prefix) + if (candidates.length === 0) { + return makeInitial(prefix) + } // Sort descending so index 0 is the highest version candidates.sort((a, b) => semver.rcompare(a.latest, b.latest))