The version management system has been updated to support dry-run mode for local builds, preventing accidental commits of auto-generated versions.
Added support for command-line flags:
# For local development (no file changes)
node setVersion.js --dry-run
node setVersion.js --local
# For CI/packaging (writes to disk)
node setVersion.js
# Show help
node setVersion.js --helpKey features:
--dry-run/-d: Calculate versions without writing--local/-l: Alias for --dry-run--help/-h: Show documentation- Clear visual indicators (🔍, ✅, ⏭️) for what's happening
- Prevents package.json modifications in local dev
In package.json:
{
"scripts": {
"version": "node setVersion.js", // CI mode
"version:local": "node setVersion.js --local", // Local mode
"version:check": "node setVersion.js --dry-run" // Check only
}
}New files:
VERSION_MANAGEMENT.md- Comprehensive guide on local vs CI buildsresetVersion.js- Utility to reset versions to base (cleanup script)
Updated files:
HOW_TO_RELEASE.md- Updated to mention --dry-run flagsetVersion.js- Added help documentation and flags
The version in package.json comes from two sources depending on context:
Static placeholder that matches base version from version.json:
// version.json
{
"version": "0.1.0-preview.{height}"
}
// package.json (committed)
{
"version": "0.1.0-preview.0"
}Dynamically calculated by setVersion.js based on git history:
// package.json (after setVersion.js runs)
{
"version": "0.1.0-preview.127"
}The {height} placeholder is replaced with actual commit count.
"Where is this version property coming from?"
Answer:
- In source code: Manually set placeholder version (
0.1.0-preview.0) - During CI build: Calculated by
setVersion.jsusing Nerdbank.GitVersioning - Based on: Git commit count + version.json configuration
"I only want this version to be set during build"
Solution Implemented:
✅ Local builds: Use --dry-run flag (no file modifications)
✅ CI builds: Run without flags (writes versions to disk for packaging)
✅ Source control: Keep placeholder versions only
# Build your code
npm run build
# Check version (without modifying files)
npm run version:check
# Output: 📦 Calculated version: 0.1.0-preview.127
# ⏭️ Skipped updating root package.json (dry-run mode)
# Your git status remains clean!# Already configured in .github/workflows/ci.yml
- name: Build package
run: npm run build
- name: Set version with Nerdbank.GitVersioning
run: node setVersion.js # No --dry-run flag!
- name: Run tests
run: npm test| Benefit | Description |
|---|---|
| 🧹 Clean Git | No version changes in working directory |
| 🔒 No Accidental Commits | Dry-run mode prevents file modifications |
| 📦 CI Packaging | Versions written only during CI for npm pack |
| 🎯 Clear Intent | Explicit flags for different build contexts |
| 📖 Self-Documenting | Built-in help and clear output messages |
- Update
setVersion.jswith dry-run support - Add npm scripts for version commands
- Create
VERSION_MANAGEMENT.mddocumentation - Create
resetVersion.jsutility script - Update
HOW_TO_RELEASE.md - Verify CI workflow uses correct mode
- Reset all package.json to placeholder versions
- Document in README or contributing guide
- Communicate to team about new workflow
Run this to set all packages back to base version:
node resetVersion.jsThis will reset all package.json files to 0.1.0-preview.0 (or whatever's in version.json).
# Should show version without modifying files
npm run version:check
# Verify no changes
git statusgit add setVersion.js
git add resetVersion.js
git add package.json
git add VERSION_MANAGEMENT.md
git add HOW_TO_RELEASE.md
git commit -m "Add dry-run mode for version management
- Add --dry-run and --local flags to setVersion.js
- Add npm scripts: version:local and version:check
- Create VERSION_MANAGEMENT.md documentation
- Create resetVersion.js utility script
- Update HOW_TO_RELEASE.md with new workflow
This prevents package.json version changes during local builds
while maintaining automatic versioning in CI/CD pipeline."Share VERSION_MANAGEMENT.md with the team and highlight:
- Always use
npm run version:checkor--dry-runlocally - Never commit auto-generated versions
- CI handles version writing automatically
# ✅ CORRECT: Local development
npm run version:check
node setVersion.js --dry-run
node setVersion.js --local
# ❌ WRONG: Don't use this locally
node setVersion.js # Will modify files!
# ✅ CORRECT: CI/CD only
node setVersion.js # No flags
# 🛠️ UTILITY: Reset after accidental modification
node resetVersion.jsStatus: ✅ Complete - Ready for Use
Documentation: See VERSION_MANAGEMENT.md for full guide
Date: November 4, 2025