Files
cypress/scripts/get-next-version.js
Zach Bloomquist 42dfb8abb1 docs: add info around next version, testing other projects (#19157)
Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
Co-authored-by: Emily Rohrbough  <emilyrohrbough@users.noreply.github.com>
Co-authored-by: Tyler Biethman <tbiethman@users.noreply.github.com>
2021-12-02 15:35:51 +00:00

49 lines
1.2 KiB
JavaScript

/* eslint-disable no-console */
// See ../guides/next-version.md for documentation.
const semver = require('semver')
const Bluebird = require('bluebird')
const bumpCb = require('conventional-recommended-bump')
const currentVersion = require('../package.json').version
const bump = Bluebird.promisify(bumpCb)
const paths = ['packages', 'cli']
let nextVersion
const getNextVersionForPath = async (path) => {
// allow the semantic next version to be overridden by environment
if (process.env.NEXT_VERSION) {
return process.env.NEXT_VERSION
}
const { releaseType } = await bump({ preset: 'angular', path })
return semver.inc(currentVersion, releaseType || 'patch')
}
Bluebird.mapSeries(paths, async (path) => {
const pathNextVersion = await getNextVersionForPath(path)
if (!nextVersion || semver.gt(pathNextVersion, nextVersion)) {
nextVersion = pathNextVersion
}
})
.then(() => {
if (!nextVersion) {
throw new Error('Unable to determine next version.')
}
if (process.argv.includes('--npm')) {
const cmd = `npm --no-git-tag-version version ${nextVersion}`
console.log(`Running '${cmd}'...`)
return require('child_process').execSync(cmd)
}
console.log(nextVersion)
})