-
Notifications
You must be signed in to change notification settings - Fork 17
/
set-version.js
31 lines (27 loc) · 1.05 KB
/
set-version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Set the package version to @daostack/arc version
const fs = require('fs')
const ora = require('ora')
const inquirer = require('inquirer')
async function setVersion () {
const spinner = ora()
const packageJson = require('./package.json')
const arcVersion = packageJson.dependencies['@daostack/arc'] || packageJson.devDependencies['@daostack/arc']
spinner.info(`Current package version is '${packageJson.version}'`)
spinner.info(`@daostack/arc version is '${arcVersion}'`)
const { migrationVersion } = await inquirer.prompt([
{
type: 'input',
name: 'migrationVersion',
message: `What would you like to call this migration version ('${arcVersion}-v???')?`,
validate: x => (x ? true : 'Please choose a version')
}
])
packageJson.version = `${arcVersion}-v${migrationVersion}`
fs.writeFileSync('package.json', JSON.stringify(packageJson, undefined, 2), 'utf-8')
spinner.succeed(`Updated package version to ${packageJson.version}`)
}
if (require.main === module) {
setVersion()
} else {
module.exports = setVersion
}