diff --git a/.eslintrc.js b/.eslintrc.js index e4b8d27b29..9bcf20c3e2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -81,5 +81,7 @@ module.exports = { spyOnDev: true, spyOnDevAndProd: true, spyOnProd: true, + // TODO: Remove dependency on Promise.race + Promise: true, }, }; diff --git a/scripts/release/build-commands/check-circle-ci-status.js b/scripts/release/build-commands/check-circle-ci-status.js index c2c140d764..406246945f 100644 --- a/scripts/release/build-commands/check-circle-ci-status.js +++ b/scripts/release/build-commands/check-circle-ci-status.js @@ -43,5 +43,8 @@ const check = async ({cwd}) => { }; module.exports = async params => { + if (params.local) { + return; + } return logPromise(check(params), 'Checking CircleCI status'); }; diff --git a/scripts/release/build-commands/update-git.js b/scripts/release/build-commands/update-git.js index 58255a48ca..467916a578 100644 --- a/scripts/release/build-commands/update-git.js +++ b/scripts/release/build-commands/update-git.js @@ -6,15 +6,21 @@ const chalk = require('chalk'); const {exec} = require('child-process-promise'); const {logPromise} = require('../utils'); -const update = async ({cwd}) => { - await exec('git fetch', {cwd}); - await exec('git checkout master', {cwd}); - await exec('git pull', {cwd}); +const update = async ({cwd, branch, local}) => { + if (!local) { + await exec('git fetch', {cwd}); + } + await exec(`git checkout ${branch}`, {cwd}); + if (!local) { + await exec('git pull', {cwd}); + } }; -module.exports = async ({cwd}) => { +module.exports = async params => { return logPromise( - update({cwd}), - `Updating checkout ${chalk.yellow.bold(cwd)}` + update(params), + `Updating checkout ${chalk.yellow.bold( + params.cwd + )} on branch ${chalk.yellow.bold(params.branch)}}` ); }; diff --git a/scripts/release/config.js b/scripts/release/config.js index 367cc2ef89..b6fe43b714 100644 --- a/scripts/release/config.js +++ b/scripts/release/config.js @@ -23,6 +23,25 @@ const paramDefinitions = [ alias: 'v', description: 'Semantic version number', }, + { + name: 'branch', + type: String, + alias: 'b', + description: 'Branch to build from; defaults to [bold]{master}', + defaultValue: 'master', + }, + { + name: 'local', + type: Boolean, + description: "Don't pull changes from the remote branch. Also skips CI.", + }, + { + name: 'tag', + type: String, + description: + 'The npm dist tag; defaults to [bold]{latest} for a stable' + + 'release, [bold]{next} for unstable', + }, ]; module.exports = { diff --git a/scripts/release/publish-commands/check-build-status.js b/scripts/release/publish-commands/check-build-status.js index b64d7e90ab..02ecf20424 100644 --- a/scripts/release/publish-commands/check-build-status.js +++ b/scripts/release/publish-commands/check-build-status.js @@ -7,7 +7,10 @@ const {existsSync} = require('fs'); const {readJson} = require('fs-extra'); const {join} = require('path'); -module.exports = async ({cwd, version}) => { +module.exports = async ({cwd, version, local}) => { + if (local) { + return; + } const packagePath = join( cwd, 'build', diff --git a/scripts/release/publish-commands/publish-to-npm.js b/scripts/release/publish-commands/publish-to-npm.js index 6b34e12a7c..af17c42a40 100644 --- a/scripts/release/publish-commands/publish-to-npm.js +++ b/scripts/release/publish-commands/publish-to-npm.js @@ -8,10 +8,21 @@ const {join} = require('path'); const semver = require('semver'); const {execRead, execUnlessDry, logPromise} = require('../utils'); -const push = async ({cwd, dry, packages, version}) => { +const push = async ({cwd, dry, packages, version, tag}) => { const errors = []; - const isPrerelease = semver.prerelease(version); - const tag = isPrerelease ? 'next' : 'latest'; + let isPrerelease; + if (tag === undefined) { + // No tag was provided. Check the version. + isPrerelease = semver.prerelease(version); + if (isPrerelease) { + tag = 'next'; + } else { + tag = 'latest'; + } + } else { + // Any tag besides `latest` is a prerelease + isPrerelease = tag === 'latest'; + } const publishProject = async project => { try { @@ -76,5 +87,6 @@ const push = async ({cwd, dry, packages, version}) => { }; module.exports = async params => { + console.log(params); return logPromise(push(params), 'Publishing packages to NPM'); }; diff --git a/scripts/release/publish-commands/push-git-remote.js b/scripts/release/publish-commands/push-git-remote.js index c30d035f28..6d487ac546 100644 --- a/scripts/release/publish-commands/push-git-remote.js +++ b/scripts/release/publish-commands/push-git-remote.js @@ -10,5 +10,8 @@ const push = async ({cwd, dry}) => { }; module.exports = async params => { + if (params.local) { + return; + } return logPromise(push(params), 'Pushing to git remote'); };