import childProcess from 'node:child_process' import fs from 'node:fs/promises' import { argv } from 'node:process' const packageName = argv[2] if (!packageName) { throw new Error('No package name specified') } const commitHash = childProcess .execSync('git rev-parse HEAD') .toString() .trim() .slice(0, 7) const file = JSON.parse( await fs.readFile(`packages/${packageName}/package.json`, 'utf-8') ) file.version = `${file.version.split('-')[0]}-next.${commitHash}` await fs.writeFile( `packages/${packageName}/package.json`, JSON.stringify(file, null, 2) ) console.log( `Bumped ${packageName} to ${file.version.split('-')[0]}-next.${commitHash}` )