Core version bumping functionality providing multiple operation modes including interactive prompts, explicit version specification, and full configuration control with git integration.
Main function for performing version bumps with multiple overloads for different use cases.
/**
* Prompts the user for a version number and updates package.json and other files
* @returns Promise resolving to version bump results
*/
function versionBump(): Promise<VersionBumpResults>;
/**
* Bumps the version using a specific release type or version number
* @param release - Version string (e.g., "1.2.3") or release type (e.g., "patch", "major")
* @returns Promise resolving to version bump results
*/
function versionBump(release: string): Promise<VersionBumpResults>;
/**
* Bumps the version with full configuration options
* @param options - Complete configuration object for the version bump operation
* @returns Promise resolving to version bump results
*/
function versionBump(options: VersionBumpOptions): Promise<VersionBumpResults>;Usage Examples:
import { versionBump } from "bumpp";
// Interactive prompting
const result = await versionBump();
// Explicit patch bump
const result = await versionBump("patch");
// Major version bump
const result = await versionBump("major");
// Specific version
const result = await versionBump("2.1.0");
// With full configuration
const result = await versionBump({
release: "minor",
commit: "chore: bump version to %s",
tag: "v%s",
push: true,
files: ["package.json", "src/version.ts", "README.md"]
});Returns operation information without performing the actual version bump, useful for dry-runs and validation.
/**
* Analyzes version bump operation without executing it
* @param arg - Version string or options object
* @returns Promise resolving to operation details
*/
function versionBumpInfo(arg: VersionBumpOptions | string = {}): Promise<Operation>;Usage Examples:
import { versionBumpInfo } from "bumpp";
// Check what a patch bump would do
const operation = await versionBumpInfo("patch");
console.log(`Would bump from ${operation.state.currentVersion} to ${operation.state.newVersion}`);
// Dry run with options
const operation = await versionBumpInfo({
release: "minor",
files: ["package.json", "version.json"]
});The Operation class manages version bump state and configuration throughout the process.
class Operation {
options: NormalizedOptions;
readonly state: Readonly<OperationState>;
readonly results: VersionBumpResults;
static start(input: VersionBumpOptions): Promise<Operation>;
update(newState: Partial<OperationState>): Operation;
}
interface OperationState {
release: ReleaseType | undefined;
currentVersionSource: string;
currentVersion: string;
newVersion: string;
commitMessage: string;
tagName: string;
updatedFiles: string[];
skippedFiles: string[];
}Supports all standard semantic versioning release types plus extended types for conventional commits and next releases.
Standard Release Types:
"major" - Breaking changes (1.0.0 → 2.0.0)"minor" - New features (1.0.0 → 1.1.0)"patch" - Bug fixes (1.0.0 → 1.0.1)Prerelease Types:
"premajor" - Prerelease major (1.0.0 → 2.0.0-0)"preminor" - Prerelease minor (1.0.0 → 1.1.0-0)"prepatch" - Prerelease patch (1.0.0 → 1.0.1-0)"prerelease" - Next prerelease (1.0.0-0 → 1.0.0-1)Extended Types:
"next" - Smart prerelease bumping"conventional" - Version based on conventional commitsDirect version specification bypasses release type logic and sets the exact version.
// Direct version specification
await versionBump("3.2.1");
await versionBump("1.0.0-beta.5");
await versionBump("2.0.0-rc.1");By default, bumpp updates these files when found:
package.json - NPM package manifestpackage-lock.json - NPM lockfilepackages/**/package.json - Monorepo package manifests (when recursive mode is used)jsr.json - JSR package manifestjsr.jsonc - JSR package manifest with commentsdeno.json - Deno configurationdeno.jsonc - Deno configuration with commentsSpecify additional files to update with the version number:
await versionBump({
release: "patch",
files: [
"package.json",
"src/version.ts", // Custom version file
"README.md", // Documentation
"docker-compose.yml", // Docker configuration
"chart/Chart.yaml" // Helm chart
]
});bumpp intelligently handles different file types:
Automatic git commit creation with customizable messages:
await versionBump({
release: "patch",
commit: true, // Default: "release v{version}"
commit: "chore: bump to %s", // Custom format with placeholder
commit: "Version bump to 1.2.3", // Explicit message
});Git tag creation with flexible formatting:
await versionBump({
release: "minor",
tag: true, // Default: "v{version}"
tag: "release-%s", // Custom format
tag: "v1.2.0", // Explicit tag name
});Sign commits and tags with configured GPG/SSH keys:
await versionBump({
release: "patch",
commit: true,
tag: true,
sign: true // Signs both commit and tag
});Automatic pushing of commits and tags to remote repository:
await versionBump({
release: "patch",
commit: true,
tag: true,
push: true // Pushes commit and tag
});Enable recursive version bumping across multiple packages in a monorepo:
await versionBump({
release: "patch",
recursive: true // Finds and updates all package.json files
});When recursive: true, bumpp:
package.json files in subdirectoriesfiles option is not explicitly set.gitignore patterns when searching for packagesExecute custom commands or functions before committing:
// String command
await versionBump({
release: "patch",
execute: "npm run build && npm test"
});
// Function execution
await versionBump({
release: "patch",
execute: async (operation) => {
console.log(`Building version ${operation.state.newVersion}`);
await runBuild();
await runTests();
}
});Automatic execution of NPM lifecycle scripts:
preversion - Runs before version changeversion - Runs after version change, before commitpostversion - Runs after commit and tag creationawait versionBump({
release: "patch",
ignoreScripts: false // Default: run lifecycle scripts
});Monitor version bump progress with custom callbacks:
await versionBump({
release: "patch",
progress: (progress) => {
switch (progress.event) {
case "file updated":
console.log(`Updated ${progress.updatedFiles.slice(-1)[0]}`);
break;
case "git commit":
console.log("Created git commit");
break;
case "git tag":
console.log("Created git tag");
break;
case "git push":
console.log("Pushed to remote");
break;
}
}
});Available progress events:
"file updated" - A file was successfully updated"file skipped" - A file was skipped (no changes needed)"git commit" - Git commit was created"git tag" - Git tag was created"git push" - Changes were pushed to remote"npm script" - NPM lifecycle script was executedbumpp handles various error conditions:
noGitCheck: truetry {
const result = await versionBump("patch");
console.log(`Successfully bumped to ${result.newVersion}`);
} catch (error) {
console.error("Version bump failed:", error.message);
// Operation is atomic - no partial updates on failure
}