From d10268a8fa6a76967ea07ea2473dee32fd953cfb Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 14 Jan 2019 06:16:30 +0000 Subject: [PATCH] chore(package): update xo to version 0.24.0 --- bin/semantic-release.js | 2 +- cli.js | 4 +++- index.js | 2 ++ lib/branches/normalize.js | 2 ++ lib/definitions/errors.js | 7 +++---- lib/definitions/plugins.js | 1 + lib/get-config.js | 1 + lib/get-git-auth-url.js | 2 +- lib/git.js | 1 + lib/plugins/index.js | 2 ++ lib/plugins/normalize.js | 2 ++ lib/plugins/pipeline.js | 2 ++ lib/plugins/utils.js | 3 +++ lib/utils.js | 1 + package.json | 2 +- 15 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bin/semantic-release.js b/bin/semantic-release.js index cbd697e9..407475da 100755 --- a/bin/semantic-release.js +++ b/bin/semantic-release.js @@ -3,7 +3,7 @@ // Bad news: We have to write plain ES5 in this file // Good news: It's the only file of the entire project -/* eslint-disable no-var, promise/prefer-await-to-then, prefer-destructuring */ +/* eslint-disable no-var */ var semver = require('semver'); var execa = require('execa'); diff --git a/cli.js b/cli.js index 39549a28..58c14bc4 100755 --- a/cli.js +++ b/cli.js @@ -1,4 +1,4 @@ -const {argv, env, stderr} = require('process'); +const {argv, env, stderr} = require('process'); // eslint-disable-line node/prefer-global/process const util = require('util'); const hideSensitive = require('./lib/hide-sensitive'); @@ -51,12 +51,14 @@ Usage: // Debug must be enabled before other requires in order to work require('debug').enable('semantic-release:*'); } + await require('.')(opts); return 0; } catch (error) { if (error.name !== 'YError') { stderr.write(hideSensitive(env)(util.inspect(error, {colors: true}))); } + return 1; } }; diff --git a/index.js b/index.js index 9303f01c..30974153 100644 --- a/index.js +++ b/index.js @@ -64,6 +64,7 @@ async function run(context, plugins) { ); return false; } + logger[options.dryRun ? 'warn' : 'success']( `Run automated release from branch ${ciBranch}${options.dryRun ? ' in dry-run mode' : ''}` ); @@ -82,6 +83,7 @@ async function run(context, plugins) { ); return false; } + throw error; } } catch (error) { diff --git a/lib/branches/normalize.js b/lib/branches/normalize.js index 54c1722c..4e3e9b01 100644 --- a/lib/branches/normalize.js +++ b/lib/branches/normalize.js @@ -60,6 +60,7 @@ function release({release}) { if (release.length === 0) { return release; } + const breakpoints = release.length > 2 ? ['minor', 'major'] : ['major']; // The intial bound is the last release from the base branch of `FIRST_RELEASE` (1.0.0) @@ -80,6 +81,7 @@ function release({release}) { // The upper bound is the lowest version between `nextFirstVersion` and the default upper bound bound = lowest(nextFirstVersion, upperBound); } + const diff = bound ? semverDiff(min, bound) : null; return { ...rest, diff --git a/lib/definitions/errors.js b/lib/definitions/errors.js index 4d0b6bcd..6f04eb72 100644 --- a/lib/definitions/errors.js +++ b/lib/definitions/errors.js @@ -1,10 +1,9 @@ -const url = require('url'); const {inspect} = require('util'); const {toLower, isString, trim} = require('lodash'); const pkg = require('../../package.json'); const {RELEASE_TYPE} = require('./constants'); -const homepage = url.format({...url.parse(pkg.homepage), hash: null}); +const [homepage] = pkg.homepage.split('#'); const stringify = obj => (isString(obj) ? obj : inspect(obj, {breakLength: Infinity, depth: 2, maxArrayLength: 5})); const linkify = file => `${homepage}/blob/master/${file}`; const wordsList = words => @@ -211,8 +210,8 @@ The following commit${commits.length > 1 ? 's are' : ' is'} responsible for the ${commits.map(({commit: {short}, subject}) => `- ${subject} (${short})`).join('\n')} ${ - commits.length > 1 ? 'Those commits' : 'This commit' - } should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed from branch \`${name}\` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset). + commits.length > 1 ? 'Those commits' : 'This commit' +} should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed from branch \`${name}\` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset). A valid branch could be ${wordsList(validBranches.map(({name}) => `\`${name}\``))}. diff --git a/lib/definitions/plugins.js b/lib/definitions/plugins.js index 69651eb2..d77c230f 100644 --- a/lib/definitions/plugins.js +++ b/lib/definitions/plugins.js @@ -59,6 +59,7 @@ module.exports = { // Regenerate the release notes context.nextRelease.notes = await generateNotes(context); } + // Call the next prepare plugin with the updated `nextRelease` return context; }, diff --git a/lib/get-config.js b/lib/get-config.js index 3b1864b6..e4812088 100644 --- a/lib/get-config.js +++ b/lib/get-config.js @@ -30,6 +30,7 @@ module.exports = async (context, opts) => { if (options.ci === false) { options.noCi = true; } + const pluginsPath = {}; let extendPaths; ({extends: extendPaths, ...options} = options); diff --git a/lib/get-git-auth-url.js b/lib/get-git-auth-url.js index 6f130bcb..5206db02 100644 --- a/lib/get-git-auth-url.js +++ b/lib/get-git-auth-url.js @@ -1,4 +1,4 @@ -const {parse, format} = require('url'); +const {parse, format} = require('url'); // eslint-disable-line node/no-deprecated-api const {isNil} = require('lodash'); const hostedGitInfo = require('hosted-git-info'); const {verifyAuth} = require('./git'); diff --git a/lib/git.js b/lib/git.js index c5030875..896a5daf 100644 --- a/lib/git.js +++ b/lib/git.js @@ -99,6 +99,7 @@ async function isRefInHistory(ref, branch, findRebasedTags, execaOpts) { ); return (await getBranchCommits(branch, execaOpts)).some(matches(pick(tagCommit, ['message', 'author']))); } + return false; } diff --git a/lib/plugins/index.js b/lib/plugins/index.js index abbc754c..51b080d1 100644 --- a/lib/plugins/index.js +++ b/lib/plugins/index.js @@ -57,10 +57,12 @@ module.exports = (context, pluginsPath) => { plugin ? [plugin[0], Object.assign(plugin[1], options[type])] : plugin ); } + if (!validateStep({required}, options[type])) { errors.push(getError('EPLUGINCONF', {type, required, pluginConf: options[type]})); return pluginsConf; } + pluginOpts = options[type]; } diff --git a/lib/plugins/normalize.js b/lib/plugins/normalize.js index 56af5b68..b35f3370 100644 --- a/lib/plugins/normalize.js +++ b/lib/plugins/normalize.js @@ -40,9 +40,11 @@ module.exports = (context, type, pluginOpt, pluginsPath) => { if (outputValidator && !outputValidator(result)) { throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName}); } + logger.success(`Completed step "${type}" of plugin "${pluginName}"`); return result; } + logger.warn(`Skip step "${type}" of plugin "${pluginName}" in dry-run mode`); } catch (error) { logger.error(`Failed step "${type}" of plugin "${pluginName}"`); diff --git a/lib/plugins/pipeline.js b/lib/plugins/pipeline.js index d36c8608..b12f264e 100644 --- a/lib/plugins/pipeline.js +++ b/lib/plugins/pipeline.js @@ -44,6 +44,7 @@ module.exports = (steps, {settleAll = false, getNextInput = identity, transform throw error; } } + // Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one return getNextInput(lastInput, result); }, @@ -52,5 +53,6 @@ module.exports = (steps, {settleAll = false, getNextInput = identity, transform if (errors.length > 0) { throw new AggregateError(errors); } + return results; }; diff --git a/lib/plugins/utils.js b/lib/plugins/utils.js index 2a213400..e0cf759f 100644 --- a/lib/plugins/utils.js +++ b/lib/plugins/utils.js @@ -12,6 +12,7 @@ const validateSteps = conf => { ) { return true; } + conf = castArray(conf); if (conf.length !== 1) { @@ -39,6 +40,7 @@ function validateStep({required}, conf) { if (required) { return conf.length >= 1 && validateSteps(conf); } + return conf.length === 0 || validateSteps(conf); } @@ -59,6 +61,7 @@ function parseConfig(plugin) { } else { path = plugin; } + return [path, config || {}]; } diff --git a/lib/utils.js b/lib/utils.js index f2ca198c..9497026b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -59,6 +59,7 @@ function getFirstVersion(versions, lowerBranches) { if (lowerVersion[0]) { return versions.sort(semver.compare).find(version => semver.gt(version, lowerVersion[0])); } + return getEarliestVersion(versions); } diff --git a/package.json b/package.json index c0594ae6..65d45f59 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "sinon": "^7.1.1", "stream-buffers": "^3.0.2", "tempy": "^0.2.1", - "xo": "^0.23.0" + "xo": "^0.24.0" }, "engines": { "node": ">=8.3"