Version Management
This project maintains version numbers in both deno.json
and package.json
. To ensure these stay synchronized, we use automated tools and git hooks.
Quick Start
Setup Git Hooks (One-time)
./scripts/setup-git-hooks.sh
This installs a pre-commit hook that prevents commits when versions are out of sync.
Version Commands
Increment Version
Use Deno tasks to update versions in both files:
# Increment patch version (0.3.22 → 0.3.23)
deno task version:patch
# Increment minor version (0.3.22 → 0.4.0)
deno task version:minor
# Increment major version (0.3.22 → 1.0.0)
deno task version:major
# Set specific version
deno task version:set 1.2.3
Check Version Sync
# Check if versions match
deno task version:check
How It Works
Version Sync Script
The scripts/sync-version.ts
script:
- Reads version from both
deno.json
andpackage.json
- Updates both files atomically when changing versions
- Validates semantic version format
- Provides clear error messages
Git Pre-commit Hook
The .githooks/pre-commit
hook:
- Runs automatically before each commit
- Checks if versions in both files match
- Prevents commits if versions differ
- Checks both working directory and staged files
- Can be bypassed with
git commit --no-verify
if needed
Workflow Example
Start a new feature:
git checkout -b feature/awesome-feature
Make changes and update version:
# After implementing feature deno task version:minor
Commit changes:
git add . git commit -m "feat: add awesome feature" # Pre-commit hook validates version sync automatically
Troubleshooting
Version Mismatch Error
If you see:
❌ Version mismatch detected!
package.json: 0.3.22
deno.json: 0.3.23
Fix it by running one of the version commands above.
Disable Git Hooks Temporarily
# For a single commit
git commit --no-verify
# To disable hooks completely
git config --unset core.hooksPath
# To re-enable hooks
./scripts/setup-git-hooks.sh
Manual Version Edit
If you manually edit version numbers, ensure you update both files:
- Edit
package.json
version field - Edit
deno.json
version field - Commit both files together
Best Practices
- Always use version tasks instead of manual edits
- Update version when:
- Adding new features (minor)
- Making breaking changes (major)
- Fixing bugs (patch)
- Include version bump in feature commits when appropriate
- Tag releases after version updates:
git tag v0.3.23 git push origin v0.3.23