chore: convert bump script to js (#15820)

This commit is contained in:
Shelley Vohr 2018-12-06 11:00:10 -08:00 committed by GitHub
parent 2845267c18
commit 1b8c11121f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 378 additions and 323 deletions

View file

@ -13,8 +13,8 @@ const path = require('path')
const readline = require('readline')
const releaseNotesGenerator = require('./release-notes/index.js')
const { getCurrentBranch } = require('./lib/utils.js')
const versionType = args._[0]
const targetRepo = versionType === 'nightly' ? 'nightlies' : 'electron'
const bumpType = args._[0]
const targetRepo = bumpType === 'nightly' ? 'nightlies' : 'electron'
require('colors')
const pass = '\u2713'.green
@ -23,8 +23,8 @@ const fail = '\u2717'.red
// TODO (future) automatically determine version based on conventional commits
// via conventional-recommended-bump
if (!versionType && !args.notesOnly) {
console.log(`Usage: prepare-release versionType [stable | beta | nightly]` +
if (!bumpType && !args.notesOnly) {
console.log(`Usage: prepare-release [stable | beta | nightly]` +
` (--stable) (--notesOnly) (--automaticRelease) (--branch)`)
process.exit(1)
}
@ -35,13 +35,11 @@ github.authenticate({ type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN })
async function getNewVersion (dryRun) {
if (!dryRun) {
console.log(`Bumping for new "${versionType}" version.`)
}
const bumpScript = path.join(__dirname, 'bump-version.py')
const scriptArgs = [bumpScript, '--bump', versionType]
if (dryRun) {
scriptArgs.push('--dry-run')
console.log(`Bumping for new "${bumpType}" version.`)
}
const bumpScript = path.join(__dirname, 'bump-version.js')
const scriptArgs = ['node', bumpScript, `--bump=${bumpType}`]
if (dryRun) scriptArgs.push('--dry-run')
try {
let bumpVersion = execSync(scriptArgs.join(' '), { encoding: 'UTF-8' })
bumpVersion = bumpVersion.substr(bumpVersion.indexOf(':') + 1).trim()
@ -57,7 +55,7 @@ async function getNewVersion (dryRun) {
}
async function getReleaseNotes (currentBranch) {
if (versionType === 'nightly') {
if (bumpType === 'nightly') {
return 'Nightlies do not get release notes, please compare tags for info'
}
console.log(`Generating release notes for ${currentBranch}.`)