43 lines
1.2 KiB
JavaScript
Executable file
43 lines
1.2 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
'use strict'
|
|
|
|
const fs = require('fs-extra')
|
|
const path = require('path')
|
|
const { bumpVersion } = require('yarn-version-bump/src/bump-version')
|
|
const { processJsonFile } = require('yarn-version-bump/src/util/json')
|
|
const Workspace = require('yarn-version-bump/src/workspace')
|
|
const rootPkg = require('../package.json')
|
|
|
|
|
|
async function workspacePackages () {
|
|
return Object.keys((await new Workspace('.').workspaceSnapshot).packages)
|
|
}
|
|
|
|
async function bumpAllPackages (newVersion) {
|
|
processJsonFile('package.json', pkg => {
|
|
pkg.version = newVersion
|
|
return pkg
|
|
})
|
|
for (const pkgname of await workspacePackages()) {
|
|
console.log(`bumping ${pkgname} to ${newVersion}`)
|
|
await bumpVersion(pkgname, newVersion, '.')
|
|
}
|
|
}
|
|
|
|
async function updateReadme (newVersion) {
|
|
return fs.readFile('README.adoc', 'utf8')
|
|
.then(str => str.replace(/^:version: \d.*$/m, `:version: ${newVersion}`))
|
|
.then(str => fs.writeFile('README.adoc', str))
|
|
}
|
|
|
|
const newVersion = process.argv[2] || rootPkg.version
|
|
|
|
process.chdir(path.resolve(__dirname, '..'))
|
|
|
|
Promise.all([
|
|
bumpAllPackages(newVersion),
|
|
updateReadme(newVersion),
|
|
]).catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|