Add hybrid versioning scripts, version shown in app footer
This commit is contained in:
@@ -8,6 +8,55 @@
|
||||
- **Recharts 3.3.0** for data visualization
|
||||
- **Vite 5** as build tool
|
||||
|
||||
## Version Management
|
||||
|
||||
The project uses a **hybrid versioning approach**:
|
||||
- **Semver** (e.g., `0.2.1`) in `package.json` for npm ecosystem compatibility
|
||||
- **Git hash** (e.g., `+a3f2b9c`) automatically appended at build time
|
||||
- **Displayed version** in UI footer: `0.2.1+a3f2b9c` (or `0.2.1+a3f2b9c-dirty` if uncommitted changes)
|
||||
|
||||
### Version Scripts
|
||||
|
||||
```sh
|
||||
# Bump version manually (updates package.json)
|
||||
npm run version:patch # 0.2.1 → 0.2.2 (bug fixes)
|
||||
npm run version:minor # 0.2.1 → 0.3.0 (new features)
|
||||
npm run version:major # 0.2.1 → 1.0.0 (breaking changes)
|
||||
|
||||
# Generate version.json with git info (runs automatically on build)
|
||||
npm run prebuild
|
||||
|
||||
# Build for production (automatically generates version)
|
||||
npm run build
|
||||
```
|
||||
|
||||
### How It Works
|
||||
|
||||
1. **Manual semver bump**: Run `npm run version:patch|minor|major` when you want to increment the version
|
||||
2. **Automatic git info**: On build, `scripts/generate-version.js` creates `src/version.json` with:
|
||||
- `version`: Semver + git hash (e.g., `0.2.1+a3f2b9c`)
|
||||
- `semver`: Just the semver (e.g., `0.2.1`)
|
||||
- `commit`: Git commit hash (e.g., `a3f2b9c`)
|
||||
- `branch`: Current git branch
|
||||
- `buildDate`: ISO timestamp
|
||||
- `gitDate`: Commit date
|
||||
3. **Fallback handling**: If `version.json` is missing (fresh clone before first build), `src/constants/defaults.ts` generates a fallback version from `package.json`
|
||||
|
||||
### Version Display
|
||||
|
||||
The version is displayed in the UI footer (bottom right) next to the GitHub repository link. The format is:
|
||||
- `0.2.1+a3f2b9c` (clean working directory)
|
||||
- `0.2.1+a3f2b9c-dirty` (uncommitted changes present)
|
||||
- `0.2.1-dev` (fallback when version.json is missing)
|
||||
|
||||
### Files
|
||||
|
||||
- `scripts/generate-version.js` - Generates version.json from git + package.json
|
||||
- `scripts/bump-version.js` - Manually bumps semver in package.json
|
||||
- `src/version.json` - Auto-generated, ignored by git
|
||||
- `src/version.json.template` - Fallback template (committed to repo)
|
||||
- `src/constants/defaults.ts` - Exports `APP_VERSION` and `BUILD_INFO`
|
||||
|
||||
## Initial Setup (Fresh Clone)
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user