/ scripts / bumpVersion.js
bumpVersion.js
 1  const fs = require("fs")
 2  const semver = require("semver")
 3  
 4  const filePath = "../lerna.json"
 5  const versionBump = process.argv[2] || "patch"
 6  
 7  // Read and parse lerna.json file
 8  const fileData = fs.readFileSync(filePath)
 9  const lernaData = JSON.parse(fileData)
10  
11  const currentVersion = lernaData.version
12  
13  const newVersion = semver.inc(currentVersion, versionBump, "alpha")
14  
15  // Update lerna.json file with new version
16  lernaData.version = newVersion
17  const updatedData = JSON.stringify(lernaData, null, 2)
18  fs.writeFileSync(filePath, updatedData)
19  
20  console.log(`Updated version from ${currentVersion} to ${newVersion}`)