@shellicar/build-version 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +79 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @shellicar/build-version
2
+
3
+ Build plugin that calculates and exposes version information through a virtual module import.
4
+
5
+ - ⚡️ Supports Vite, Webpack, Rspack, Vue CLI, Rollup, esbuild and more, powered by [unplugin](https://github.com/unjs/unplugin).
6
+
7
+ ## Usage
8
+
9
+ ```sh
10
+ pnpm add -D @shellicar/build-version
11
+ ```
12
+
13
+ ### With Vite
14
+
15
+ ```ts
16
+ import VersionPlugin from '@shellicar/build-version/vite'
17
+
18
+ export default defineConfig({
19
+ plugins: [
20
+ VersionPlugin({
21
+ versionCalculator: 'git'
22
+ })
23
+ ]
24
+ })
25
+ ```
26
+
27
+ ### Importing Version Information
28
+
29
+ ```ts
30
+ interface VersionInfo {
31
+ buildDate: string;
32
+ branch: string;
33
+ sha: string;
34
+ shortSha: string;
35
+ commitDate: string;
36
+ version: string;
37
+ }
38
+ ```
39
+
40
+ ```ts
41
+ import version from '@shellicar/build-version/version'
42
+
43
+ console.log(version)
44
+ ```
45
+
46
+ ### Version Calculators
47
+
48
+ #### Git Calculator
49
+ Uses pure git commands to calculate version numbers following mainline versioning:
50
+ - On main branch: increment patch version for each commit after a tag
51
+ - On feature branches: use base version with branch name and commit count suffix
52
+ - On PR branches: use PR number in version suffix
53
+
54
+ Example versions:
55
+ - Tagged commit on main: `1.2.3`
56
+ - Commits after tag on main: `1.2.4`, `1.2.5`
57
+ - Feature branch: `1.2.3-feature-name.2`
58
+ - PR branch: `1.2.3-PullRequest0123.2`
59
+
60
+ #### GitVersion Calculator
61
+ Uses the GitVersion CLI to calculate versions. Requires GitVersion to be installed.
62
+
63
+ #### Custom Calculator
64
+ Provide your own version calculation function:
65
+
66
+ ```ts
67
+ VersionPlugin({
68
+ versionCalculator: () => '1.0.0-custom'
69
+ })
70
+ ```
71
+
72
+ ## Options
73
+
74
+ See [types.ts](./packages/build-version/src/core/types.ts) for detailed options documentation.
75
+
76
+ ## Credits
77
+
78
+ - [unplugin](https://github.com/unjs/unplugin)
79
+ - [GitVersion](https://gitversion.net)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shellicar/build-version",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/shellicar/build-version#readme",