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.
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/core-config
- A library for securely handling sensitive configuration values like connection strings, URLs, and secrets.@shellicar/core-di
- A basic dependency injection library.
@shellicar/reference-foundation
- A comprehensive starter repository. Illustrates individual concepts.@shellicar/reference-enterprise
- A comprehensive starter repository. Can be used as the basis for creating a new Azure application workload.
@shellicar/build-clean
- Build plugin that automatically cleans unused files from output directories.@shellicar/build-version
- Build plugin that calculates and exposes version information through a virtual module import.@shellicar/build-graphql
- Build plugin that loads GraphQL files and makes them available through a virtual module import.
@shellicar/svelte-adapter-azure-functions
- A SvelteKit adapter that builds your app into an Azure Function.
@shellicar/winston-azure-application-insights
- An Azure Application Insights transport for Winston logging library.@shellicar/pino-applicationinsights-transport
- Azure Application Insights transport for pino
interface VersionInfo {
buildDate: string;
branch: string;
sha: string;
shortSha: string;
commitDate: string;
version: string;
}
import version from '@shellicar/build-version/version'
console.log(version)
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
Uses the GitVersion CLI to calculate versions. Requires GitVersion to be installed.
Provide your own version calculation function:
VersionPlugin({
versionCalculator: () => '1.0.0-custom'
})
See types.ts for detailed options documentation.