Skip to content

shellicar/build-version

Repository files navigation

@shellicar/build-version

npm package build status

Build plugin that calculates and exposes version information through a virtual module import.

  • ⚡️ Supports Vite, Webpack, Rspack, Vue CLI, Rollup, esbuild and more, powered by unplugin.

Installation & Quick Start

npm i --save @shellicar/build-version
pnpm add @shellicar/build-version
// vite.config.ts
import VersionPlugin from '@shellicar/build-version/vite'

export default defineConfig({
  plugins: [
    VersionPlugin({})
  ]
})
// main.ts
import version from '@shellicar/build-version/version'

@shellicar TypeScript Ecosystem

Core Libraries

Reference Architectures

Build Tools

Framework Adapters

Logging & Monitoring

Usage

Importing Version Information

interface VersionInfo {
  buildDate: string;
  branch: string;
  sha: string;
  shortSha: string;
  commitDate: string;
  version: string;
}
import version from '@shellicar/build-version/version'

console.log(version)

Version Calculators

Git Calculator

Uses pure git commands to calculate version numbers following mainline versioning:

  • On main branch: increment patch version for each commit after a tag
  • On feature branches: use base version with branch name and commit count suffix
  • On PR branches: use PR number in version suffix

Example versions:

  • Tagged commit on main: 1.2.3
  • Commits after tag on main: 1.2.4, 1.2.5
  • Feature branch: 1.2.3-feature-name.2
  • PR branch: 1.2.3-PullRequest0123.2

GitVersion Calculator

Uses the GitVersion CLI to calculate versions. Requires GitVersion to be installed.

Custom Calculator

Provide your own version calculation function:

VersionPlugin({
  versionCalculator: () => '1.0.0-custom'
})

Options

See types.ts for detailed options documentation.

Credits

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •