#!/usr/bin/env node /** * Set Version Script * * Sets the version in package.json and regenerates docker-compose files * with the specified version tag. */ const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); // Parse command line arguments const args = process.argv.slice(2); const version = args[0]; if (!version) { console.error('āŒ Error: Version argument required'); console.error('Usage: node scripts/set-version.js '); console.error('Example: node scripts/set-version.js 0.1.0'); process.exit(1); } // Validate version format const versionRegex = /^\d+\.\d+\.\d+$/; if (!versionRegex.test(version)) { console.error(`āŒ Error: Invalid version format "${version}"`); console.error('Version must be in format: MAJOR.MINOR.PATCH (e.g., 0.1.0)'); process.exit(1); } // Paths const packageJsonPath = path.join(__dirname, '..', 'package.json'); // Update package.json version function updatePackageJson(newVersion) { const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); packageJson.version = newVersion; fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n'); console.log(`āœ“ Updated package.json to version ${newVersion}`); } // Main function function main() { console.log(`šŸ”„ Setting version to ${version}\n`); // Update package.json updatePackageJson(version); console.log(`\nāœ… Version set to ${version}`); console.log(`\nNext steps:`); console.log(` 1. Review changes: git diff`); console.log(` 2. Commit changes: git commit -am "chore: set version to ${version}"`); console.log(` 3. Create tag: git tag -a v${version} -m "Release v${version}"`); console.log(` 4. Generate docker-compose files: npm run docker:compose:generate`); console.log(` 5. Build and push Docker images: npm run docker:build:push`); } // Run main function main();