WIP convert CJS to ESM using https://github.com/homer0/cjs2esm
This commit is contained in:
parent
d9605a5e45
commit
ce263c5f4a
@ -1,16 +1,11 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node// Bad news: We have to write plain ES5 in this file
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
// Bad news: We have to write plain ES5 in this file
|
import execa from 'execa';
|
||||||
// Good news: It's the only file of the entire project
|
import findVersions from 'find-versions';
|
||||||
|
import pkg from '../package.json';
|
||||||
|
|
||||||
/* eslint-disable no-var */
|
const MIN_GIT_VERSION = '2.7.1';
|
||||||
|
|
||||||
var semver = require('semver');
|
|
||||||
var execa = require('execa');
|
|
||||||
var findVersions = require('find-versions');
|
|
||||||
var pkg = require('../package.json');
|
|
||||||
|
|
||||||
var MIN_GIT_VERSION = '2.7.1';
|
|
||||||
|
|
||||||
if (!semver.satisfies(process.version, pkg.engines.node)) {
|
if (!semver.satisfies(process.version, pkg.engines.node)) {
|
||||||
console.error(
|
console.error(
|
||||||
@ -23,7 +18,7 @@ See https://github.com/semantic-release/semantic-release/blob/master/docs/suppor
|
|||||||
|
|
||||||
execa('git', ['--version'])
|
execa('git', ['--version'])
|
||||||
.then(({stdout}) => {
|
.then(({stdout}) => {
|
||||||
var gitVersion = findVersions(stdout)[0];
|
const gitVersion = findVersions(stdout)[0];
|
||||||
if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
|
if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
|
||||||
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
|
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
21
cli.js
21
cli.js
@ -1,6 +1,9 @@
|
|||||||
const {argv, env, stderr} = require('process'); // eslint-disable-line node/prefer-global/process
|
import util from 'util';
|
||||||
const util = require('util');
|
import hideSensitive from './lib/hide-sensitive';
|
||||||
const hideSensitive = require('./lib/hide-sensitive');
|
import yargs from 'yargs';
|
||||||
|
import debug from 'debug';
|
||||||
|
|
||||||
|
import run from '.';
|
||||||
|
|
||||||
const stringList = {
|
const stringList = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -11,8 +14,8 @@ const stringList = {
|
|||||||
: values.reduce((values, value) => values.concat(value.split(',').map((value) => value.trim())), []),
|
: values.reduce((values, value) => values.concat(value.split(',').map((value) => value.trim())), []),
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = async () => {
|
export default async () => {
|
||||||
const cli = require('yargs')
|
const cli = yargs
|
||||||
.command('$0', 'Run automated package publishing', (yargs) => {
|
.command('$0', 'Run automated package publishing', (yargs) => {
|
||||||
yargs.demandCommand(0, 0).usage(`Run automated package publishing
|
yargs.demandCommand(0, 0).usage(`Run automated package publishing
|
||||||
|
|
||||||
@ -41,7 +44,7 @@ Usage:
|
|||||||
.exitProcess(false);
|
.exitProcess(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {help, version, ...options} = cli.parse(argv.slice(2));
|
const {help, version, ...options} = cli.parse(process.argv.slice(2));
|
||||||
|
|
||||||
if (Boolean(help) || Boolean(version)) {
|
if (Boolean(help) || Boolean(version)) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -49,14 +52,14 @@ Usage:
|
|||||||
|
|
||||||
if (options.debug) {
|
if (options.debug) {
|
||||||
// Debug must be enabled before other requires in order to work
|
// Debug must be enabled before other requires in order to work
|
||||||
require('debug').enable('semantic-release:*');
|
debug.enable('semantic-release:*');
|
||||||
}
|
}
|
||||||
|
|
||||||
await require('.')(options);
|
await run(options);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name !== 'YError') {
|
if (error.name !== 'YError') {
|
||||||
stderr.write(hideSensitive(env)(util.inspect(error, {colors: true})));
|
process.stderr.write(hideSensitive(process.env)(util.inspect(error, {colors: true})));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
48
index.js
48
index.js
@ -1,25 +1,27 @@
|
|||||||
const {pick} = require('lodash');
|
import {pick} from 'lodash';
|
||||||
const marked = require('marked');
|
import marked from 'marked';
|
||||||
const TerminalRenderer = require('marked-terminal');
|
import TerminalRenderer from 'marked-terminal';
|
||||||
const envCi = require('env-ci');
|
import envCi from 'env-ci';
|
||||||
const hookStd = require('hook-std');
|
import hookStd from 'hook-std';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const pkg = require('./package.json');
|
import pkg from './package.json';
|
||||||
const hideSensitive = require('./lib/hide-sensitive');
|
import hideSensitive from './lib/hide-sensitive';
|
||||||
const getConfig = require('./lib/get-config');
|
import getConfig from './lib/get-config';
|
||||||
const verify = require('./lib/verify');
|
import verify from './lib/verify';
|
||||||
const getNextVersion = require('./lib/get-next-version');
|
import getNextVersion from './lib/get-next-version';
|
||||||
const getCommits = require('./lib/get-commits');
|
import getCommits from './lib/get-commits';
|
||||||
const getLastRelease = require('./lib/get-last-release');
|
import getLastRelease from './lib/get-last-release';
|
||||||
const getReleaseToAdd = require('./lib/get-release-to-add');
|
import getReleaseToAdd from './lib/get-release-to-add';
|
||||||
const {extractErrors, makeTag} = require('./lib/utils');
|
import {extractErrors, makeTag} from './lib/utils';
|
||||||
const getGitAuthUrl = require('./lib/get-git-auth-url');
|
import getGitAuthUrl from './lib/get-git-auth-url';
|
||||||
const getBranches = require('./lib/branches');
|
import getBranches from './lib/branches';
|
||||||
const getLogger = require('./lib/get-logger');
|
import getLogger from './lib/get-logger';
|
||||||
const {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} = require('./lib/git');
|
|
||||||
const getError = require('./lib/get-error');
|
import {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} from './lib/git';
|
||||||
const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants');
|
|
||||||
|
import getError from './lib/get-error';
|
||||||
|
import {COMMIT_NAME, COMMIT_EMAIL} from './lib/definitions/constants';
|
||||||
|
|
||||||
marked.setOptions({renderer: new TerminalRenderer()});
|
marked.setOptions({renderer: new TerminalRenderer()});
|
||||||
|
|
||||||
@ -239,7 +241,7 @@ async function callFail(context, plugins, err) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => {
|
export default async (cliOptions = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => {
|
||||||
const {unhook} = hookStd(
|
const {unhook} = hookStd(
|
||||||
{silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean)},
|
{silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean)},
|
||||||
hideSensitive(env)
|
hideSensitive(env)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const {isString, remove, omit, mapValues, template} = require('lodash');
|
import {isString, remove, omit, mapValues, template} from 'lodash';
|
||||||
const micromatch = require('micromatch');
|
import micromatch from 'micromatch';
|
||||||
const {getBranches} = require('../git');
|
import {getBranches} from '../git.js';
|
||||||
|
|
||||||
module.exports = async (repositoryUrl, {cwd}, branches) => {
|
export default async (repositoryUrl, {cwd}, branches) => {
|
||||||
const gitBranches = await getBranches(repositoryUrl, {cwd});
|
const gitBranches = await getBranches(repositoryUrl, {cwd});
|
||||||
|
|
||||||
return branches.reduce(
|
return branches.reduce(
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
const {template, escapeRegExp} = require('lodash');
|
import {template, escapeRegExp} from 'lodash';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const pReduce = require('p-reduce');
|
import pReduce from 'p-reduce';
|
||||||
const debug = require('debug')('semantic-release:get-tags');
|
import debugFactory from 'debug';
|
||||||
const {getTags, getNote} = require('../../lib/git');
|
const debug = debugFactory('semantic-release:get-tags');
|
||||||
|
import {getTags, getNote} from '../../lib/git.js';
|
||||||
|
|
||||||
module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
|
export default async ({cwd, env, options: {tagFormat}}, branches) => {
|
||||||
// Generate a regex to parse tags formatted with `tagFormat`
|
// Generate a regex to parse tags formatted with `tagFormat`
|
||||||
// by replacing the `version` variable in the template by `(.+)`.
|
// by replacing the `version` variable in the template by `(.+)`.
|
||||||
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
|
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
const {isString, isRegExp} = require('lodash');
|
import {isString, isRegExp} from 'lodash';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const pEachSeries = require('p-each-series');
|
import pEachSeries from 'p-each-series';
|
||||||
const DEFINITIONS = require('../definitions/branches');
|
import DEFINITIONS from '../definitions/branches.js';
|
||||||
const getError = require('../get-error');
|
import getError from '../get-error.js';
|
||||||
const {fetch, fetchNotes, verifyBranchName} = require('../git');
|
import {fetch, fetchNotes, verifyBranchName} from '../git.js';
|
||||||
const expand = require('./expand');
|
import expand from './expand.js';
|
||||||
const getTags = require('./get-tags');
|
import getTags from './get-tags.js';
|
||||||
const normalize = require('./normalize');
|
import normalize from './normalize.js';
|
||||||
|
|
||||||
module.exports = async (repositoryUrl, ciBranch, context) => {
|
export default async (repositoryUrl, ciBranch, context) => {
|
||||||
const {cwd, env} = context;
|
const {cwd, env} = context;
|
||||||
|
|
||||||
const remoteBranches = await expand(
|
const remoteBranches = await expand(
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const {sortBy, isNil} = require('lodash');
|
import {sortBy, isNil} from 'lodash';
|
||||||
const semverDiff = require('semver-diff');
|
import semverDiff from 'semver-diff';
|
||||||
const {FIRST_RELEASE, RELEASE_TYPE} = require('../definitions/constants');
|
import {FIRST_RELEASE, RELEASE_TYPE} from '../definitions/constants.js';
|
||||||
const {
|
|
||||||
|
import {
|
||||||
tagsToVersions,
|
tagsToVersions,
|
||||||
isMajorRange,
|
isMajorRange,
|
||||||
getUpperBound,
|
getUpperBound,
|
||||||
@ -11,7 +12,7 @@ const {
|
|||||||
getLatestVersion,
|
getLatestVersion,
|
||||||
getFirstVersion,
|
getFirstVersion,
|
||||||
getRange,
|
getRange,
|
||||||
} = require('../utils');
|
} from '../utils.js';
|
||||||
|
|
||||||
function maintenance({maintenance, release}) {
|
function maintenance({maintenance, release}) {
|
||||||
return sortBy(
|
return sortBy(
|
||||||
@ -103,4 +104,11 @@ function prerelease({prerelease}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {maintenance, release, prerelease};
|
const exported = {
|
||||||
|
maintenance,
|
||||||
|
release,
|
||||||
|
prerelease,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {maintenance, release, prerelease};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const {isNil, uniqBy} = require('lodash');
|
import {isNil, uniqBy} from 'lodash';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const {isMaintenanceRange} = require('../utils');
|
import {isMaintenanceRange} from '../utils.js';
|
||||||
|
|
||||||
const maintenance = {
|
const maintenance = {
|
||||||
filter: ({name, range}) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
|
filter: ({name, range}) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
|
||||||
@ -20,4 +20,11 @@ const release = {
|
|||||||
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
|
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {maintenance, prerelease, release};
|
const exported = {
|
||||||
|
maintenance,
|
||||||
|
prerelease,
|
||||||
|
release,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {maintenance, prerelease, release};
|
||||||
|
@ -16,7 +16,20 @@ const SECRET_MIN_SIZE = 5;
|
|||||||
|
|
||||||
const GIT_NOTE_REF = 'semantic-release';
|
const GIT_NOTE_REF = 'semantic-release';
|
||||||
|
|
||||||
module.exports = {
|
const exported = {
|
||||||
|
RELEASE_TYPE,
|
||||||
|
FIRST_RELEASE,
|
||||||
|
FIRSTPRERELEASE,
|
||||||
|
COMMIT_NAME,
|
||||||
|
COMMIT_EMAIL,
|
||||||
|
RELEASE_NOTES_SEPARATOR,
|
||||||
|
SECRET_REPLACEMENT,
|
||||||
|
SECRET_MIN_SIZE,
|
||||||
|
GIT_NOTE_REF,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {
|
||||||
RELEASE_TYPE,
|
RELEASE_TYPE,
|
||||||
FIRST_RELEASE,
|
FIRST_RELEASE,
|
||||||
FIRSTPRERELEASE,
|
FIRSTPRERELEASE,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const {inspect} = require('util');
|
import {inspect} from 'util';
|
||||||
const {toLower, isString, trim} = require('lodash');
|
import {toLower, isString, trim} from 'lodash';
|
||||||
const pkg = require('../../package.json');
|
import pkg from '../../package.json';
|
||||||
const {RELEASE_TYPE} = require('./constants');
|
import {RELEASE_TYPE} from './constants.js';
|
||||||
|
|
||||||
const [homepage] = pkg.homepage.split('#');
|
const [homepage] = pkg.homepage.split('#');
|
||||||
const stringify = (object) =>
|
const stringify = (object) =>
|
||||||
@ -10,7 +10,7 @@ const linkify = (file) => `${homepage}/blob/master/${file}`;
|
|||||||
const wordsList = (words) =>
|
const wordsList = (words) =>
|
||||||
`${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
|
`${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
|
||||||
|
|
||||||
module.exports = {
|
const exported = {
|
||||||
ENOGITREPO: ({cwd}) => ({
|
ENOGITREPO: ({cwd}) => ({
|
||||||
message: 'Not running from a git repository.',
|
message: 'Not running from a git repository.',
|
||||||
details: `The \`semantic-release\` command must be executed from a Git repository.
|
details: `The \`semantic-release\` command must be executed from a Git repository.
|
||||||
@ -19,6 +19,7 @@ The current working directory is \`${cwd}\`.
|
|||||||
|
|
||||||
Please verify your CI configuration to make sure the \`semantic-release\` command is executed from the root of the cloned repository.`,
|
Please verify your CI configuration to make sure the \`semantic-release\` command is executed from the root of the cloned repository.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ENOREPOURL: () => ({
|
ENOREPOURL: () => ({
|
||||||
message: 'The `repositoryUrl` option is required.',
|
message: 'The `repositoryUrl` option is required.',
|
||||||
details: `The [repositoryUrl option](${linkify(
|
details: `The [repositoryUrl option](${linkify(
|
||||||
@ -29,6 +30,7 @@ Please make sure to add the \`repositoryUrl\` to the [semantic-release configura
|
|||||||
'docs/usage/configuration.md'
|
'docs/usage/configuration.md'
|
||||||
)}).`,
|
)}).`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EGITNOPERMISSION: ({options: {repositoryUrl}, branch: {name}}) => ({
|
EGITNOPERMISSION: ({options: {repositoryUrl}, branch: {name}}) => ({
|
||||||
message: 'Cannot push to the Git repository.',
|
message: 'Cannot push to the Git repository.',
|
||||||
details: `**semantic-release** cannot push the version tag to the branch \`${name}\` on the remote Git repository with URL \`${repositoryUrl}\`.
|
details: `**semantic-release** cannot push the version tag to the branch \`${name}\` on the remote Git repository with URL \`${repositoryUrl}\`.
|
||||||
@ -40,6 +42,7 @@ This can be caused by:
|
|||||||
'docs/usage/ci-configuration.md#authentication'
|
'docs/usage/ci-configuration.md#authentication'
|
||||||
)})`,
|
)})`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EINVALIDTAGFORMAT: ({options: {tagFormat}}) => ({
|
EINVALIDTAGFORMAT: ({options: {tagFormat}}) => ({
|
||||||
message: 'Invalid `tagFormat` option.',
|
message: 'Invalid `tagFormat` option.',
|
||||||
details: `The [tagFormat](${linkify(
|
details: `The [tagFormat](${linkify(
|
||||||
@ -48,6 +51,7 @@ This can be caused by:
|
|||||||
|
|
||||||
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ETAGNOVERSION: ({options: {tagFormat}}) => ({
|
ETAGNOVERSION: ({options: {tagFormat}}) => ({
|
||||||
message: 'Invalid `tagFormat` option.',
|
message: 'Invalid `tagFormat` option.',
|
||||||
details: `The [tagFormat](${linkify(
|
details: `The [tagFormat](${linkify(
|
||||||
@ -56,6 +60,7 @@ Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`
|
|||||||
|
|
||||||
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EPLUGINCONF: ({type, required, pluginConf}) => ({
|
EPLUGINCONF: ({type, required, pluginConf}) => ({
|
||||||
message: `The \`${type}\` plugin configuration is invalid.`,
|
message: `The \`${type}\` plugin configuration is invalid.`,
|
||||||
details: `The [${type} plugin configuration](${linkify(`docs/usage/plugins.md#${toLower(type)}-plugin`)}) ${
|
details: `The [${type} plugin configuration](${linkify(`docs/usage/plugins.md#${toLower(type)}-plugin`)}) ${
|
||||||
@ -64,6 +69,7 @@ Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`
|
|||||||
|
|
||||||
Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
|
Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EPLUGINSCONF: ({plugin}) => ({
|
EPLUGINSCONF: ({plugin}) => ({
|
||||||
message: 'The `plugins` configuration is invalid.',
|
message: 'The `plugins` configuration is invalid.',
|
||||||
details: `The [plugins](${linkify(
|
details: `The [plugins](${linkify(
|
||||||
@ -72,6 +78,7 @@ Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
|
|||||||
|
|
||||||
The invalid configuration is \`${stringify(plugin)}\`.`,
|
The invalid configuration is \`${stringify(plugin)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EPLUGIN: ({pluginName, type}) => ({
|
EPLUGIN: ({pluginName, type}) => ({
|
||||||
message: `A plugin configured in the step ${type} is not a valid semantic-release plugin.`,
|
message: `A plugin configured in the step ${type} is not a valid semantic-release plugin.`,
|
||||||
details: `A valid \`${type}\` **semantic-release** plugin must be a function or an object with a function in the property \`${type}\`.
|
details: `A valid \`${type}\` **semantic-release** plugin must be a function or an object with a function in the property \`${type}\`.
|
||||||
@ -82,6 +89,7 @@ Please refer to the \`${pluginName}\` and [semantic-release plugins configuratio
|
|||||||
'docs/usage/plugins.md'
|
'docs/usage/plugins.md'
|
||||||
)}) documentation for more details.`,
|
)}) documentation for more details.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EANALYZECOMMITSOUTPUT: ({result, pluginName}) => ({
|
EANALYZECOMMITSOUTPUT: ({result, pluginName}) => ({
|
||||||
message: 'The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.',
|
message: 'The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.',
|
||||||
details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
|
details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
|
||||||
@ -98,6 +106,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|||||||
'docs/developer-guide/plugin.md'
|
'docs/developer-guide/plugin.md'
|
||||||
)})`,
|
)})`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EGENERATENOTESOUTPUT: ({result, pluginName}) => ({
|
EGENERATENOTESOUTPUT: ({result, pluginName}) => ({
|
||||||
message: 'The `generateNotes` plugin returned an invalid value. It must return a `String`.',
|
message: 'The `generateNotes` plugin returned an invalid value. It must return a `String`.',
|
||||||
details: `The \`generateNotes\` plugin must return a \`String\`.
|
details: `The \`generateNotes\` plugin must return a \`String\`.
|
||||||
@ -112,6 +121,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|||||||
'docs/developer-guide/plugin.md'
|
'docs/developer-guide/plugin.md'
|
||||||
)})`,
|
)})`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EPUBLISHOUTPUT: ({result, pluginName}) => ({
|
EPUBLISHOUTPUT: ({result, pluginName}) => ({
|
||||||
message: 'A `publish` plugin returned an invalid value. It must return an `Object`.',
|
message: 'A `publish` plugin returned an invalid value. It must return an `Object`.',
|
||||||
details: `The \`publish\` plugins must return an \`Object\`.
|
details: `The \`publish\` plugins must return an \`Object\`.
|
||||||
@ -126,6 +136,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|||||||
'docs/developer-guide/plugin.md'
|
'docs/developer-guide/plugin.md'
|
||||||
)})`,
|
)})`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EADDCHANNELOUTPUT: ({result, pluginName}) => ({
|
EADDCHANNELOUTPUT: ({result, pluginName}) => ({
|
||||||
message: 'A `addChannel` plugin returned an invalid value. It must return an `Object`.',
|
message: 'A `addChannel` plugin returned an invalid value. It must return an `Object`.',
|
||||||
details: `The \`addChannel\` plugins must return an \`Object\`.
|
details: `The \`addChannel\` plugins must return an \`Object\`.
|
||||||
@ -140,6 +151,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|||||||
'docs/developer-guide/plugin.md'
|
'docs/developer-guide/plugin.md'
|
||||||
)})`,
|
)})`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EINVALIDBRANCH: ({branch}) => ({
|
EINVALIDBRANCH: ({branch}) => ({
|
||||||
message: 'A branch is invalid in the `branches` configuration.',
|
message: 'A branch is invalid in the `branches` configuration.',
|
||||||
details: `Each branch in the [branches configuration](${linkify(
|
details: `Each branch in the [branches configuration](${linkify(
|
||||||
@ -148,6 +160,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|||||||
|
|
||||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EINVALIDBRANCHNAME: ({branch}) => ({
|
EINVALIDBRANCHNAME: ({branch}) => ({
|
||||||
message: 'A branch name is invalid in the `branches` configuration.',
|
message: 'A branch name is invalid in the `branches` configuration.',
|
||||||
details: `Each branch in the [branches configuration](${linkify(
|
details: `Each branch in the [branches configuration](${linkify(
|
||||||
@ -156,6 +169,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|||||||
|
|
||||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EDUPLICATEBRANCHES: ({duplicates}) => ({
|
EDUPLICATEBRANCHES: ({duplicates}) => ({
|
||||||
message: 'The `branches` configuration has duplicate branches.',
|
message: 'The `branches` configuration has duplicate branches.',
|
||||||
details: `Each branch in the [branches configuration](${linkify(
|
details: `Each branch in the [branches configuration](${linkify(
|
||||||
@ -164,6 +178,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|||||||
|
|
||||||
Your configuration contains duplicates for the following branch names: \`${stringify(duplicates)}\`.`,
|
Your configuration contains duplicates for the following branch names: \`${stringify(duplicates)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EMAINTENANCEBRANCH: ({branch}) => ({
|
EMAINTENANCEBRANCH: ({branch}) => ({
|
||||||
message: 'A maintenance branch is invalid in the `branches` configuration.',
|
message: 'A maintenance branch is invalid in the `branches` configuration.',
|
||||||
details: `Each maintenance branch in the [branches configuration](${linkify(
|
details: `Each maintenance branch in the [branches configuration](${linkify(
|
||||||
@ -172,6 +187,7 @@ Your configuration contains duplicates for the following branch names: \`${strin
|
|||||||
|
|
||||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EMAINTENANCEBRANCHES: ({branches}) => ({
|
EMAINTENANCEBRANCHES: ({branches}) => ({
|
||||||
message: 'The maintenance branches are invalid in the `branches` configuration.',
|
message: 'The maintenance branches are invalid in the `branches` configuration.',
|
||||||
details: `Each maintenance branch in the [branches configuration](${linkify(
|
details: `Each maintenance branch in the [branches configuration](${linkify(
|
||||||
@ -180,6 +196,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|||||||
|
|
||||||
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ERELEASEBRANCHES: ({branches}) => ({
|
ERELEASEBRANCHES: ({branches}) => ({
|
||||||
message: 'The release branches are invalid in the `branches` configuration.',
|
message: 'The release branches are invalid in the `branches` configuration.',
|
||||||
details: `A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](${linkify(
|
details: `A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](${linkify(
|
||||||
@ -190,6 +207,7 @@ This may occur if your repository does not have a release branch, such as \`mast
|
|||||||
|
|
||||||
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EPRERELEASEBRANCH: ({branch}) => ({
|
EPRERELEASEBRANCH: ({branch}) => ({
|
||||||
message: 'A pre-release branch configuration is invalid in the `branches` configuration.',
|
message: 'A pre-release branch configuration is invalid in the `branches` configuration.',
|
||||||
details: `Each pre-release branch in the [branches configuration](${linkify(
|
details: `Each pre-release branch in the [branches configuration](${linkify(
|
||||||
@ -198,6 +216,7 @@ Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
|||||||
|
|
||||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EPRERELEASEBRANCHES: ({branches}) => ({
|
EPRERELEASEBRANCHES: ({branches}) => ({
|
||||||
message: 'The pre-release branches are invalid in the `branches` configuration.',
|
message: 'The pre-release branches are invalid in the `branches` configuration.',
|
||||||
details: `Each pre-release branch in the [branches configuration](${linkify(
|
details: `Each pre-release branch in the [branches configuration](${linkify(
|
||||||
@ -206,6 +225,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|||||||
|
|
||||||
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EINVALIDNEXTVERSION: ({nextRelease: {version}, branch: {name, range}, commits, validBranches}) => ({
|
EINVALIDNEXTVERSION: ({nextRelease: {version}, branch: {name, range}, commits, validBranches}) => ({
|
||||||
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
||||||
details: `Based on the releases published on other branches, only versions within the range \`${range}\` can be published from branch \`${name}\`.
|
details: `Based on the releases published on other branches, only versions within the range \`${range}\` can be published from branch \`${name}\`.
|
||||||
@ -221,6 +241,7 @@ A valid branch could be ${wordsList(validBranches.map(({name}) => `\`${name}\``)
|
|||||||
|
|
||||||
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
EINVALIDMAINTENANCEMERGE: ({nextRelease: {channel, gitTag, version}, branch: {mergeRange, name}}) => ({
|
EINVALIDMAINTENANCEMERGE: ({nextRelease: {channel, gitTag, version}, branch: {mergeRange, name}}) => ({
|
||||||
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
||||||
details: `Only releases within the range \`${mergeRange}\` can be merged into the maintenance branch \`${name}\` and published to the \`${channel}\` distribution channel.
|
details: `Only releases within the range \`${mergeRange}\` can be merged into the maintenance branch \`${name}\` and published to the \`${channel}\` distribution channel.
|
||||||
@ -230,3 +251,30 @@ The branch \`${name}\` head should be [reset](https://git-scm.com/docs/git-reset
|
|||||||
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
|
||||||
|
export const {
|
||||||
|
ENOGITREPO,
|
||||||
|
ENOREPOURL,
|
||||||
|
EGITNOPERMISSION,
|
||||||
|
EINVALIDTAGFORMAT,
|
||||||
|
ETAGNOVERSION,
|
||||||
|
EPLUGINCONF,
|
||||||
|
EPLUGINSCONF,
|
||||||
|
EPLUGIN,
|
||||||
|
EANALYZECOMMITSOUTPUT,
|
||||||
|
EGENERATENOTESOUTPUT,
|
||||||
|
EPUBLISHOUTPUT,
|
||||||
|
EADDCHANNELOUTPUT,
|
||||||
|
EINVALIDBRANCH,
|
||||||
|
EINVALIDBRANCHNAME,
|
||||||
|
EDUPLICATEBRANCHES,
|
||||||
|
EMAINTENANCEBRANCH,
|
||||||
|
EMAINTENANCEBRANCHES,
|
||||||
|
ERELEASEBRANCHES,
|
||||||
|
EPRERELEASEBRANCH,
|
||||||
|
EPRERELEASEBRANCHES,
|
||||||
|
EINVALIDNEXTVERSION,
|
||||||
|
EINVALIDMAINTENANCEMERGE,
|
||||||
|
} = exported;
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/* eslint require-atomic-updates: off */
|
import {isString, isPlainObject} from 'lodash';
|
||||||
|
|
||||||
const {isString, isPlainObject} = require('lodash');
|
import {getGitHead} from '../git.js';
|
||||||
const {getGitHead} = require('../git');
|
import hideSensitive from '../hide-sensitive.js';
|
||||||
const hideSensitive = require('../hide-sensitive');
|
import {hideSensitiveValues} from '../utils.js';
|
||||||
const {hideSensitiveValues} = require('../utils');
|
import {RELEASE_TYPE, RELEASE_NOTES_SEPARATOR} from './constants.js';
|
||||||
const {RELEASE_TYPE, RELEASE_NOTES_SEPARATOR} = require('./constants');
|
|
||||||
|
|
||||||
module.exports = {
|
const exported = {
|
||||||
verifyConditions: {
|
verifyConditions: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: true,
|
dryRun: true,
|
||||||
pipelineConfig: () => ({settleAll: true}),
|
pipelineConfig: () => ({settleAll: true}),
|
||||||
},
|
},
|
||||||
|
|
||||||
analyzeCommits: {
|
analyzeCommits: {
|
||||||
default: ['@semantic-release/commit-analyzer'],
|
default: ['@semantic-release/commit-analyzer'],
|
||||||
required: true,
|
required: true,
|
||||||
@ -29,11 +29,13 @@ module.exports = {
|
|||||||
}, -1)
|
}, -1)
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
verifyRelease: {
|
verifyRelease: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: true,
|
dryRun: true,
|
||||||
pipelineConfig: () => ({settleAll: true}),
|
pipelineConfig: () => ({settleAll: true}),
|
||||||
},
|
},
|
||||||
|
|
||||||
generateNotes: {
|
generateNotes: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: true,
|
dryRun: true,
|
||||||
@ -49,6 +51,7 @@ module.exports = {
|
|||||||
}),
|
}),
|
||||||
postprocess: (results, {env}) => hideSensitive(env)(results.filter(Boolean).join(RELEASE_NOTES_SEPARATOR)),
|
postprocess: (results, {env}) => hideSensitive(env)(results.filter(Boolean).join(RELEASE_NOTES_SEPARATOR)),
|
||||||
},
|
},
|
||||||
|
|
||||||
prepare: {
|
prepare: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: false,
|
dryRun: false,
|
||||||
@ -67,6 +70,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
publish: {
|
publish: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: false,
|
dryRun: false,
|
||||||
@ -80,6 +84,7 @@ module.exports = {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
addChannel: {
|
addChannel: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: false,
|
dryRun: false,
|
||||||
@ -93,12 +98,14 @@ module.exports = {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
success: {
|
success: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: false,
|
dryRun: false,
|
||||||
pipelineConfig: () => ({settleAll: true}),
|
pipelineConfig: () => ({settleAll: true}),
|
||||||
preprocess: ({releases, env, ...inputs}) => ({...inputs, env, releases: hideSensitiveValues(env, releases)}),
|
preprocess: ({releases, env, ...inputs}) => ({...inputs, env, releases: hideSensitiveValues(env, releases)}),
|
||||||
},
|
},
|
||||||
|
|
||||||
fail: {
|
fail: {
|
||||||
required: false,
|
required: false,
|
||||||
dryRun: false,
|
dryRun: false,
|
||||||
@ -106,3 +113,17 @@ module.exports = {
|
|||||||
preprocess: ({errors, env, ...inputs}) => ({...inputs, env, errors: hideSensitiveValues(env, errors)}),
|
preprocess: ({errors, env, ...inputs}) => ({...inputs, env, errors: hideSensitiveValues(env, errors)}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
|
||||||
|
export const {
|
||||||
|
verifyConditions,
|
||||||
|
analyzeCommits,
|
||||||
|
verifyRelease,
|
||||||
|
generateNotes,
|
||||||
|
prepare,
|
||||||
|
publish,
|
||||||
|
addChannel,
|
||||||
|
success,
|
||||||
|
fail,
|
||||||
|
} = exported;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const debug = require('debug')('semantic-release:get-commits');
|
import debugFactory from 'debug';
|
||||||
const {getCommits} = require('./git');
|
const debug = debugFactory('semantic-release:get-commits');
|
||||||
|
import {getCommits} from './git.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
|
* Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
|
||||||
@ -8,7 +9,7 @@ const {getCommits} = require('./git');
|
|||||||
*
|
*
|
||||||
* @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
|
* @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
|
||||||
*/
|
*/
|
||||||
module.exports = async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
|
export default async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
|
||||||
if (from) {
|
if (from) {
|
||||||
debug('Use from: %s', from);
|
debug('Use from: %s', from);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
const {castArray, pickBy, isNil, isString, isPlainObject} = require('lodash');
|
import {castArray, pickBy, isNil, isString, isPlainObject} from 'lodash';
|
||||||
const readPkgUp = require('read-pkg-up');
|
import readPkgUp from 'read-pkg-up';
|
||||||
const {cosmiconfig} = require('cosmiconfig');
|
import {cosmiconfig} from 'cosmiconfig';
|
||||||
const resolveFrom = require('resolve-from');
|
import resolveFrom from 'resolve-from';
|
||||||
const debug = require('debug')('semantic-release:config');
|
import debugFactory from 'debug';
|
||||||
const {repoUrl} = require('./git');
|
const debug = debugFactory('semantic-release:config');
|
||||||
const PLUGINS_DEFINITIONS = require('./definitions/plugins');
|
import {repoUrl} from './git.js';
|
||||||
const plugins = require('./plugins');
|
import PLUGINS_DEFINITIONS from './definitions/plugins.js';
|
||||||
const {validatePlugin, parseConfig} = require('./plugins/utils');
|
import plugins from './plugins';
|
||||||
|
import {validatePlugin, parseConfig} from './plugins/utils.js';
|
||||||
|
|
||||||
const CONFIG_NAME = 'release';
|
const CONFIG_NAME = 'release';
|
||||||
|
|
||||||
module.exports = async (context, cliOptions) => {
|
export default async (context, cliOptions) => {
|
||||||
const {cwd, env} = context;
|
const {cwd, env} = context;
|
||||||
const {config, filepath} = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};
|
const {config, filepath} = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const SemanticReleaseError = require('@semantic-release/error');
|
import SemanticReleaseError from '@semantic-release/error';
|
||||||
const ERROR_DEFINITIONS = require('./definitions/errors');
|
import ERROR_DEFINITIONS from './definitions/errors.js';
|
||||||
|
|
||||||
module.exports = (code, ctx = {}) => {
|
export default (code, ctx = {}) => {
|
||||||
const {message, details} = ERROR_DEFINITIONS[code](ctx);
|
const {message, details} = ERROR_DEFINITIONS[code](ctx);
|
||||||
return new SemanticReleaseError(message, code, details);
|
return new SemanticReleaseError(message, code, details);
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
const {parse, format} = require('url'); // eslint-disable-line node/no-deprecated-api
|
import {format} from 'url';
|
||||||
const {isNil} = require('lodash');
|
import {isNil} from 'lodash';
|
||||||
const hostedGitInfo = require('hosted-git-info');
|
import hostedGitInfo from 'hosted-git-info';
|
||||||
const {verifyAuth} = require('./git');
|
import {verifyAuth} from './git.js';
|
||||||
const debug = require('debug')('semantic-release:get-git-auth-url');
|
import debugFactory from 'debug';
|
||||||
|
const debug = debugFactory('semantic-release:get-git-auth-url');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Machinery to format a repository URL with the given credentials
|
* Machinery to format a repository URL with the given credentials
|
||||||
@ -16,7 +17,7 @@ const debug = require('debug')('semantic-release:get-git-auth-url');
|
|||||||
function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
|
function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
|
||||||
const [match, auth, host, basePort, path] =
|
const [match, auth, host, basePort, path] =
|
||||||
/^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
|
/^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
|
||||||
const {port, hostname, ...parsed} = parse(
|
const {port, hostname, ...parsed} = new URL(
|
||||||
match ? `ssh://${auth ? `${auth}@` : ''}${host}${basePort ? `:${basePort}` : ''}/${path}` : repositoryUrl
|
match ? `ssh://${auth ? `${auth}@` : ''}${host}${basePort ? `:${basePort}` : ''}/${path}` : repositoryUrl
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ async function ensureValidAuthUrl({cwd, env, branch}, authUrl) {
|
|||||||
*
|
*
|
||||||
* @return {String} The formatted Git repository URL.
|
* @return {String} The formatted Git repository URL.
|
||||||
*/
|
*/
|
||||||
module.exports = async (context) => {
|
export default async (context) => {
|
||||||
const {cwd, env, branch} = context;
|
const {cwd, env, branch} = context;
|
||||||
const GIT_TOKENS = {
|
const GIT_TOKENS = {
|
||||||
GIT_CREDENTIALS: undefined,
|
GIT_CREDENTIALS: undefined,
|
||||||
@ -75,7 +76,7 @@ module.exports = async (context) => {
|
|||||||
|
|
||||||
let {repositoryUrl} = context.options;
|
let {repositoryUrl} = context.options;
|
||||||
const info = hostedGitInfo.fromUrl(repositoryUrl, {noGitPlus: true});
|
const info = hostedGitInfo.fromUrl(repositoryUrl, {noGitPlus: true});
|
||||||
const {protocol, ...parsed} = parse(repositoryUrl);
|
const {protocol, ...parsed} = new URL(repositoryUrl);
|
||||||
|
|
||||||
if (info && info.getDefaultRepresentation() === 'shortcut') {
|
if (info && info.getDefaultRepresentation() === 'shortcut') {
|
||||||
// Expand shorthand URLs (such as `owner/repo` or `gitlab:owner/repo`)
|
// Expand shorthand URLs (such as `owner/repo` or `gitlab:owner/repo`)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const {isUndefined} = require('lodash');
|
import {isUndefined} from 'lodash';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const {makeTag, isSameChannel} = require('./utils');
|
import {makeTag, isSameChannel} from './utils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last release.
|
* Last release.
|
||||||
@ -26,7 +26,7 @@ const {makeTag, isSameChannel} = require('./utils');
|
|||||||
*
|
*
|
||||||
* @return {LastRelease} The last tagged release or empty object if none is found.
|
* @return {LastRelease} The last tagged release or empty object if none is found.
|
||||||
*/
|
*/
|
||||||
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
|
export default ({branch, options: {tagFormat}}, {before} = {}) => {
|
||||||
const [{version, gitTag, channels} = {}] = branch.tags
|
const [{version, gitTag, channels} = {}] = branch.tags
|
||||||
.filter(
|
.filter(
|
||||||
(tag) =>
|
(tag) =>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const {Signale} = require('signale');
|
import {Signale} from 'signale';
|
||||||
const figures = require('figures');
|
import figures from 'figures';
|
||||||
|
|
||||||
module.exports = ({stdout, stderr}) =>
|
export default ({stdout, stderr}) =>
|
||||||
new Signale({
|
new Signale({
|
||||||
config: {displayTimestamp: true, underlineMessage: false, displayLabel: false},
|
config: {displayTimestamp: true, underlineMessage: false, displayLabel: false},
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const {FIRST_RELEASE, FIRSTPRERELEASE} = require('./definitions/constants');
|
import {FIRST_RELEASE, FIRSTPRERELEASE} from './definitions/constants.js';
|
||||||
const {isSameChannel, getLatestVersion, tagsToVersions, highest} = require('./utils');
|
import {isSameChannel, getLatestVersion, tagsToVersions, highest} from './utils.js';
|
||||||
|
|
||||||
module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
|
export default ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
|
||||||
let version;
|
let version;
|
||||||
if (lastRelease.version) {
|
if (lastRelease.version) {
|
||||||
const {major, minor, patch} = semver.parse(lastRelease.version);
|
const {major, minor, patch} = semver.parse(lastRelease.version);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const {uniqBy, intersection} = require('lodash');
|
import {uniqBy, intersection} from 'lodash';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const semverDiff = require('semver-diff');
|
import semverDiff from 'semver-diff';
|
||||||
const getLastRelease = require('./get-last-release');
|
import getLastRelease from './get-last-release.js';
|
||||||
const {makeTag, getLowerBound} = require('./utils');
|
import {makeTag, getLowerBound} from './utils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
||||||
@ -11,7 +11,7 @@ const {makeTag, getLowerBound} = require('./utils');
|
|||||||
*
|
*
|
||||||
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
||||||
*/
|
*/
|
||||||
module.exports = (context) => {
|
export default (context) => {
|
||||||
const {
|
const {
|
||||||
branch,
|
branch,
|
||||||
branches,
|
branches,
|
||||||
|
36
lib/git.js
36
lib/git.js
@ -1,8 +1,9 @@
|
|||||||
const gitLogParser = require('git-log-parser');
|
import gitLogParser from 'git-log-parser';
|
||||||
const getStream = require('get-stream');
|
import getStream from 'get-stream';
|
||||||
const execa = require('execa');
|
import execa from 'execa';
|
||||||
const debug = require('debug')('semantic-release:git');
|
import debugFactory from 'debug';
|
||||||
const {GIT_NOTE_REF} = require('./definitions/constants');
|
const debug = debugFactory('semantic-release:git');
|
||||||
|
import {GIT_NOTE_REF} from './definitions/constants.js';
|
||||||
|
|
||||||
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
|
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
|
||||||
|
|
||||||
@ -328,7 +329,30 @@ async function addNote(note, ref, execaOptions) {
|
|||||||
await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-f', '-m', JSON.stringify(note), ref], execaOptions);
|
await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-f', '-m', JSON.stringify(note), ref], execaOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
const exported = {
|
||||||
|
getTagHead,
|
||||||
|
getTags,
|
||||||
|
getCommits,
|
||||||
|
getBranches,
|
||||||
|
isRefExists,
|
||||||
|
fetch,
|
||||||
|
fetchNotes,
|
||||||
|
getGitHead,
|
||||||
|
repoUrl,
|
||||||
|
isGitRepo,
|
||||||
|
verifyAuth,
|
||||||
|
tag,
|
||||||
|
push,
|
||||||
|
pushNotes,
|
||||||
|
verifyTagName,
|
||||||
|
isBranchUpToDate,
|
||||||
|
verifyBranchName,
|
||||||
|
getNote,
|
||||||
|
addNote,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {
|
||||||
getTagHead,
|
getTagHead,
|
||||||
getTags,
|
getTags,
|
||||||
getCommits,
|
getCommits,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const {escapeRegExp, size, isString} = require('lodash');
|
import {escapeRegExp, size, isString} from 'lodash';
|
||||||
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('./definitions/constants');
|
import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from './definitions/constants.js';
|
||||||
|
|
||||||
module.exports = (env) => {
|
export default (env) => {
|
||||||
const toReplace = Object.keys(env).filter((envVar) => {
|
const toReplace = Object.keys(env).filter((envVar) => {
|
||||||
// https://github.com/semantic-release/semantic-release/issues/1558
|
// https://github.com/semantic-release/semantic-release/issues/1558
|
||||||
if (envVar === 'GOPRIVATE') {
|
if (envVar === 'GOPRIVATE') {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
const {identity, isPlainObject, omit, castArray, isNil, isString} = require('lodash');
|
import {identity, isPlainObject, omit, castArray, isNil, isString} from 'lodash';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const getError = require('../get-error');
|
import getError from '../get-error.js';
|
||||||
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
|
import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
|
||||||
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('./utils');
|
import {validatePlugin, validateStep, loadPlugin, parseConfig} from './utils.js';
|
||||||
const pipeline = require('./pipeline');
|
import pipeline from './pipeline.js';
|
||||||
const normalize = require('./normalize');
|
import normalize from './normalize.js';
|
||||||
|
|
||||||
module.exports = (context, pluginsPath) => {
|
export default (context, pluginsPath) => {
|
||||||
let {options, logger} = context;
|
let {options, logger} = context;
|
||||||
const errors = [];
|
const errors = [];
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
const {isPlainObject, isFunction, noop, cloneDeep, omit} = require('lodash');
|
import {isPlainObject, isFunction, noop, cloneDeep, omit} from 'lodash';
|
||||||
const debug = require('debug')('semantic-release:plugins');
|
import debugFactory from 'debug';
|
||||||
const getError = require('../get-error');
|
const debug = debugFactory('semantic-release:plugins');
|
||||||
const {extractErrors} = require('../utils');
|
import getError from '../get-error.js';
|
||||||
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
|
import {extractErrors} from '../utils.js';
|
||||||
const {loadPlugin, parseConfig} = require('./utils');
|
import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
|
||||||
|
import {loadPlugin, parseConfig} from './utils.js';
|
||||||
|
|
||||||
module.exports = (context, type, pluginOpt, pluginsPath) => {
|
export default (context, type, pluginOpt, pluginsPath) => {
|
||||||
const {stdout, stderr, options, logger} = context;
|
const {stdout, stderr, options, logger} = context;
|
||||||
if (!pluginOpt) {
|
if (!pluginOpt) {
|
||||||
return noop;
|
return noop;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const {identity} = require('lodash');
|
import {identity} from 'lodash';
|
||||||
const pReduce = require('p-reduce');
|
import pReduce from 'p-reduce';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const {extractErrors} = require('../utils');
|
import {extractErrors} from '../utils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Function that execute a list of function sequencially. If at least one Function ins the pipeline throws an Error or rejects, the pipeline function rejects as well.
|
* A Function that execute a list of function sequencially. If at least one Function ins the pipeline throws an Error or rejects, the pipeline function rejects as well.
|
||||||
@ -25,7 +25,7 @@ const {extractErrors} = require('../utils');
|
|||||||
*
|
*
|
||||||
* @return {Pipeline} A Function that execute the `steps` sequencially
|
* @return {Pipeline} A Function that execute the `steps` sequencially
|
||||||
*/
|
*/
|
||||||
module.exports = (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
|
export default (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
|
||||||
const results = [];
|
const results = [];
|
||||||
const errors = [];
|
const errors = [];
|
||||||
await pReduce(
|
await pReduce(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const {dirname} = require('path');
|
import {dirname} from 'path';
|
||||||
const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = require('lodash');
|
import {isString, isFunction, castArray, isArray, isPlainObject, isNil} from 'lodash';
|
||||||
const resolveFrom = require('resolve-from');
|
import resolveFrom from 'resolve-from';
|
||||||
|
|
||||||
const validateSteps = (conf) => {
|
const validateSteps = (conf) => {
|
||||||
return conf.every((conf) => {
|
return conf.every((conf) => {
|
||||||
@ -65,4 +65,12 @@ function parseConfig(plugin) {
|
|||||||
return [path, config || {}];
|
return [path, config || {}];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {validatePlugin, validateStep, loadPlugin, parseConfig};
|
const exported = {
|
||||||
|
validatePlugin,
|
||||||
|
validateStep,
|
||||||
|
loadPlugin,
|
||||||
|
parseConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {validatePlugin, validateStep, loadPlugin, parseConfig};
|
||||||
|
27
lib/utils.js
27
lib/utils.js
@ -1,6 +1,6 @@
|
|||||||
const {isFunction, union, template} = require('lodash');
|
import {isFunction, union, template} from 'lodash';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const hideSensitive = require('./hide-sensitive');
|
import hideSensitive from './hide-sensitive.js';
|
||||||
|
|
||||||
function extractErrors(err) {
|
function extractErrors(err) {
|
||||||
return err && isFunction(err[Symbol.iterator]) ? [...err] : [err];
|
return err && isFunction(err[Symbol.iterator]) ? [...err] : [err];
|
||||||
@ -82,7 +82,26 @@ function isSameChannel(channel, otherChannel) {
|
|||||||
return channel === otherChannel || (!channel && !otherChannel);
|
return channel === otherChannel || (!channel && !otherChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
const exported = {
|
||||||
|
extractErrors,
|
||||||
|
hideSensitiveValues,
|
||||||
|
tagsToVersions,
|
||||||
|
isMajorRange,
|
||||||
|
isMaintenanceRange,
|
||||||
|
getUpperBound,
|
||||||
|
getLowerBound,
|
||||||
|
highest,
|
||||||
|
lowest,
|
||||||
|
getLatestVersion,
|
||||||
|
getEarliestVersion,
|
||||||
|
getFirstVersion,
|
||||||
|
getRange,
|
||||||
|
makeTag,
|
||||||
|
isSameChannel,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {
|
||||||
extractErrors,
|
extractErrors,
|
||||||
hideSensitiveValues,
|
hideSensitiveValues,
|
||||||
tagsToVersions,
|
tagsToVersions,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const {template, isString, isPlainObject} = require('lodash');
|
import {template, isString, isPlainObject} from 'lodash';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const {isGitRepo, verifyTagName} = require('./git');
|
import {isGitRepo, verifyTagName} from './git.js';
|
||||||
const getError = require('./get-error');
|
import getError from './get-error.js';
|
||||||
|
|
||||||
module.exports = async (context) => {
|
export default async (context) => {
|
||||||
const {
|
const {
|
||||||
cwd,
|
cwd,
|
||||||
env,
|
env,
|
||||||
|
3645
package-lock.json
generated
3645
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "semantic-release",
|
"name": "semantic-release",
|
||||||
|
"type": "module",
|
||||||
"description": "Automated semver compliant package publishing",
|
"description": "Automated semver compliant package publishing",
|
||||||
"version": "0.0.0-development",
|
"version": "0.0.0-development",
|
||||||
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
||||||
@ -51,6 +52,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "3.15.0",
|
"ava": "3.15.0",
|
||||||
|
"cjs2esm": "^2.0.0",
|
||||||
"clear-module": "4.1.1",
|
"clear-module": "4.1.1",
|
||||||
"codecov": "3.8.2",
|
"codecov": "3.8.2",
|
||||||
"delay": "5.0.0",
|
"delay": "5.0.0",
|
||||||
@ -92,7 +94,7 @@
|
|||||||
"version"
|
"version"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"exports": "./index.js",
|
||||||
"nyc": {
|
"nyc": {
|
||||||
"include": [
|
"include": [
|
||||||
"lib/**/*.js",
|
"lib/**/*.js",
|
||||||
@ -129,7 +131,8 @@
|
|||||||
"prettier": true,
|
"prettier": true,
|
||||||
"space": true,
|
"space": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"unicorn/string-content": "off"
|
"unicorn/string-content": "off",
|
||||||
|
"import/extensions": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"renovate": {
|
"renovate": {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {union} = require('lodash');
|
import {union} from 'lodash';
|
||||||
const semver = require('semver');
|
import semver from 'semver';
|
||||||
const proxyquire = require('proxyquire');
|
import proxyquire from 'proxyquire';
|
||||||
|
|
||||||
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
|
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
|
||||||
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
|
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const expand = require('../../lib/branches/expand');
|
import expand from '../../lib/branches/expand.js';
|
||||||
const {gitRepo, gitCommits, gitCheckout, gitPush} = require('../helpers/git-utils');
|
import {gitRepo, gitCommits, gitCheckout, gitPush} from '../helpers/git-utils.js';
|
||||||
|
|
||||||
test('Expand branches defined with globs', async (t) => {
|
test('Expand branches defined with globs', async (t) => {
|
||||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const getTags = require('../../lib/branches/get-tags');
|
import getTags from '../../lib/branches/get-tags.js';
|
||||||
const {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} = require('../helpers/git-utils');
|
import {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} from '../helpers/git-utils.js';
|
||||||
|
|
||||||
test('Get the valid tags', async (t) => {
|
test('Get the valid tags', async (t) => {
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const normalize = require('../../lib/branches/normalize');
|
import normalize from '../../lib/branches/normalize.js';
|
||||||
|
|
||||||
const toTags = (versions) => versions.map((version) => ({version}));
|
const toTags = (versions) => versions.map((version) => ({version}));
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {escapeRegExp} = require('lodash');
|
import {escapeRegExp} from 'lodash';
|
||||||
const proxyquire = require('proxyquire').noPreserveCache();
|
const proxyquire = require('proxyquire').noPreserveCache();
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
|
||||||
|
|
||||||
test.beforeEach((t) => {
|
test.beforeEach((t) => {
|
||||||
t.context.logs = '';
|
t.context.logs = '';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');
|
import {maintenance, prerelease, release} from '../../lib/definitions/branches.js';
|
||||||
|
|
||||||
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
|
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
|
||||||
t.true(maintenance.filter({name: '1.x.x'}));
|
t.true(maintenance.filter({name: '1.x.x'}));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const plugins = require('../../lib/definitions/plugins');
|
import plugins from '../../lib/definitions/plugins.js';
|
||||||
const {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} = require('../../lib/definitions/constants');
|
import {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} from '../../lib/definitions/constants.js';
|
||||||
|
|
||||||
test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', (t) => {
|
test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', (t) => {
|
||||||
t.false(plugins.analyzeCommits.outputValidator('invalid'));
|
t.false(plugins.analyzeCommits.outputValidator('invalid'));
|
||||||
|
2
test/fixtures/index.js
vendored
2
test/fixtures/index.js
vendored
@ -1 +1 @@
|
|||||||
module.exports = () => {};
|
export default () => {};
|
||||||
|
6
test/fixtures/multi-plugin.js
vendored
6
test/fixtures/multi-plugin.js
vendored
@ -1,4 +1,4 @@
|
|||||||
module.exports = {
|
const exported = {
|
||||||
verifyConditions: () => {},
|
verifyConditions: () => {},
|
||||||
getLastRelease: () => {},
|
getLastRelease: () => {},
|
||||||
analyzeCommits: () => {},
|
analyzeCommits: () => {},
|
||||||
@ -6,3 +6,7 @@ module.exports = {
|
|||||||
generateNotes: () => {},
|
generateNotes: () => {},
|
||||||
publish: () => {},
|
publish: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
|
||||||
|
export const {verifyConditions, getLastRelease, analyzeCommits, verifyRelease, generateNotes, publish} = exported;
|
||||||
|
4
test/fixtures/plugin-error-inherited.js
vendored
4
test/fixtures/plugin-error-inherited.js
vendored
@ -1,4 +1,4 @@
|
|||||||
const SemanticReleaseError = require('@semantic-release/error');
|
import SemanticReleaseError from '@semantic-release/error';
|
||||||
|
|
||||||
class InheritedError extends SemanticReleaseError {
|
class InheritedError extends SemanticReleaseError {
|
||||||
constructor(message, code) {
|
constructor(message, code) {
|
||||||
@ -9,6 +9,6 @@ class InheritedError extends SemanticReleaseError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = () => {
|
export default () => {
|
||||||
throw new InheritedError('Inherited error', 'EINHERITED');
|
throw new InheritedError('Inherited error', 'EINHERITED');
|
||||||
};
|
};
|
||||||
|
2
test/fixtures/plugin-error.js
vendored
2
test/fixtures/plugin-error.js
vendored
@ -1,4 +1,4 @@
|
|||||||
module.exports = () => {
|
export default () => {
|
||||||
const error = new Error('a');
|
const error = new Error('a');
|
||||||
error.errorProperty = 'errorProperty';
|
error.errorProperty = 'errorProperty';
|
||||||
throw error;
|
throw error;
|
||||||
|
4
test/fixtures/plugin-errors.js
vendored
4
test/fixtures/plugin-errors.js
vendored
@ -1,5 +1,5 @@
|
|||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
|
|
||||||
module.exports = () => {
|
export default () => {
|
||||||
throw new AggregateError([new Error('a'), new Error('b')]);
|
throw new AggregateError([new Error('a'), new Error('b')]);
|
||||||
};
|
};
|
||||||
|
2
test/fixtures/plugin-identity.js
vendored
2
test/fixtures/plugin-identity.js
vendored
@ -1 +1 @@
|
|||||||
module.exports = (pluginConfig, context) => context;
|
export default (pluginConfig, context) => context;
|
||||||
|
2
test/fixtures/plugin-log-env.js
vendored
2
test/fixtures/plugin-log-env.js
vendored
@ -1,4 +1,4 @@
|
|||||||
module.exports = (pluginConfig, {env, logger}) => {
|
export default (pluginConfig, {env, logger}) => {
|
||||||
console.log(`Console: Exposing token ${env.MY_TOKEN}`);
|
console.log(`Console: Exposing token ${env.MY_TOKEN}`);
|
||||||
logger.log(`Log: Exposing token ${env.MY_TOKEN}`);
|
logger.log(`Log: Exposing token ${env.MY_TOKEN}`);
|
||||||
logger.error(`Error: Console token ${env.MY_TOKEN}`);
|
logger.error(`Error: Console token ${env.MY_TOKEN}`);
|
||||||
|
2
test/fixtures/plugin-noop.js
vendored
2
test/fixtures/plugin-noop.js
vendored
@ -1 +1 @@
|
|||||||
module.exports = () => {};
|
export default () => {};
|
||||||
|
2
test/fixtures/plugin-result-config.js
vendored
2
test/fixtures/plugin-result-config.js
vendored
@ -1 +1 @@
|
|||||||
module.exports = (pluginConfig, context) => ({pluginConfig, context});
|
export default (pluginConfig, context) => ({pluginConfig, context});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const getCommits = require('../lib/get-commits');
|
import getCommits from '../lib/get-commits.js';
|
||||||
const {gitRepo, gitCommits, gitDetachedHead} = require('./helpers/git-utils');
|
import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils.js';
|
||||||
|
|
||||||
test.beforeEach((t) => {
|
test.beforeEach((t) => {
|
||||||
// Stub the logger functions
|
// Stub the logger functions
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
const path = require('path');
|
import path from 'path';
|
||||||
const {format} = require('util');
|
import {format} from 'util';
|
||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {writeFile, outputJson} = require('fs-extra');
|
import {writeFile, outputJson} from 'fs-extra';
|
||||||
const {omit} = require('lodash');
|
import {omit} from 'lodash';
|
||||||
const proxyquire = require('proxyquire');
|
import proxyquire from 'proxyquire';
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const yaml = require('js-yaml');
|
import yaml from 'js-yaml';
|
||||||
const {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} = require('./helpers/git-utils');
|
import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils.js';
|
||||||
|
|
||||||
const DEFAULT_PLUGINS = [
|
const DEFAULT_PLUGINS = [
|
||||||
'@semantic-release/commit-analyzer',
|
'@semantic-release/commit-analyzer',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const getAuthUrl = require('../lib/get-git-auth-url');
|
import getAuthUrl from '../lib/get-git-auth-url.js';
|
||||||
const {gitRepo} = require('./helpers/git-utils');
|
import {gitRepo} from './helpers/git-utils.js';
|
||||||
|
|
||||||
const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0};
|
const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const getLastRelease = require('../lib/get-last-release');
|
import getLastRelease from '../lib/get-last-release.js';
|
||||||
|
|
||||||
test('Get the highest non-prerelease valid tag', (t) => {
|
test('Get the highest non-prerelease valid tag', (t) => {
|
||||||
const result = getLastRelease({
|
const result = getLastRelease({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {spy} = require('sinon');
|
import {spy} from 'sinon';
|
||||||
const getLogger = require('../lib/get-logger');
|
import getLogger from '../lib/get-logger.js';
|
||||||
|
|
||||||
test('Expose "error", "success" and "log" functions', (t) => {
|
test('Expose "error", "success" and "log" functions', (t) => {
|
||||||
const stdout = spy();
|
const stdout = spy();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const getNextVersion = require('../lib/get-next-version');
|
import getNextVersion from '../lib/get-next-version.js';
|
||||||
|
|
||||||
test.beforeEach((t) => {
|
test.beforeEach((t) => {
|
||||||
// Stub the logger functions
|
// Stub the logger functions
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const getReleaseToAdd = require('../lib/get-release-to-add');
|
import getReleaseToAdd from '../lib/get-release-to-add.js';
|
||||||
|
|
||||||
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', (t) => {
|
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', (t) => {
|
||||||
const result = getReleaseToAdd({
|
const result = getReleaseToAdd({
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const tempy = require('tempy');
|
import tempy from 'tempy';
|
||||||
const {
|
|
||||||
|
import {
|
||||||
getTagHead,
|
getTagHead,
|
||||||
isRefExists,
|
isRefExists,
|
||||||
fetch,
|
fetch,
|
||||||
@ -16,8 +17,9 @@ const {
|
|||||||
getNote,
|
getNote,
|
||||||
addNote,
|
addNote,
|
||||||
fetchNotes,
|
fetchNotes,
|
||||||
} = require('../lib/git');
|
} from '../lib/git.js';
|
||||||
const {
|
|
||||||
|
import {
|
||||||
gitRepo,
|
gitRepo,
|
||||||
gitCommits,
|
gitCommits,
|
||||||
gitCheckout,
|
gitCheckout,
|
||||||
@ -34,7 +36,7 @@ const {
|
|||||||
gitGetNote,
|
gitGetNote,
|
||||||
gitFetch,
|
gitFetch,
|
||||||
initGit,
|
initGit,
|
||||||
} = require('./helpers/git-utils');
|
} from './helpers/git-utils.js';
|
||||||
|
|
||||||
test('Get the last commit sha', async (t) => {
|
test('Get the last commit sha', async (t) => {
|
||||||
// Create a git repository, set the current working directory at the root of the repo
|
// Create a git repository, set the current working directory at the root of the repo
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const tempy = require('tempy');
|
import tempy from 'tempy';
|
||||||
const execa = require('execa');
|
import execa from 'execa';
|
||||||
const fileUrl = require('file-url');
|
import fileUrl from 'file-url';
|
||||||
const pEachSeries = require('p-each-series');
|
import pEachSeries from 'p-each-series';
|
||||||
const gitLogParser = require('git-log-parser');
|
import gitLogParser from 'git-log-parser';
|
||||||
const getStream = require('get-stream');
|
import getStream from 'get-stream';
|
||||||
const {GIT_NOTE_REF} = require('../../lib/definitions/constants');
|
import {GIT_NOTE_REF} from '../../lib/definitions/constants.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commit message information.
|
* Commit message information.
|
||||||
@ -323,7 +323,33 @@ async function gitGetNote(ref, execaOptions) {
|
|||||||
return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout;
|
return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
const exported = {
|
||||||
|
initGit,
|
||||||
|
gitRepo,
|
||||||
|
initBareRepo,
|
||||||
|
gitCommits,
|
||||||
|
gitGetCommits,
|
||||||
|
gitCheckout,
|
||||||
|
gitFetch,
|
||||||
|
gitHead,
|
||||||
|
gitTagVersion,
|
||||||
|
gitShallowClone,
|
||||||
|
gitDetachedHead,
|
||||||
|
gitDetachedHeadFromBranch,
|
||||||
|
gitAddConfig,
|
||||||
|
gitTagHead,
|
||||||
|
gitRemoteTagHead,
|
||||||
|
gitCommitTag,
|
||||||
|
gitPush,
|
||||||
|
merge,
|
||||||
|
mergeFf,
|
||||||
|
rebase,
|
||||||
|
gitAddNote,
|
||||||
|
gitGetNote,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {
|
||||||
initGit,
|
initGit,
|
||||||
gitRepo,
|
gitRepo,
|
||||||
initBareRepo,
|
initBareRepo,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const Docker = require('dockerode');
|
import Docker from 'dockerode';
|
||||||
const getStream = require('get-stream');
|
import getStream from 'get-stream';
|
||||||
const pRetry = require('p-retry');
|
import pRetry from 'p-retry';
|
||||||
const {initBareRepo, gitShallowClone} = require('./git-utils');
|
import {initBareRepo, gitShallowClone} from './git-utils.js';
|
||||||
|
|
||||||
const IMAGE = 'pvdlg/docker-gitbox:latest';
|
const IMAGE = 'pvdlg/docker-gitbox:latest';
|
||||||
const SERVER_PORT = 80;
|
const SERVER_PORT = 80;
|
||||||
@ -69,4 +69,12 @@ async function createRepo(name, branch = 'master', description = `Repository ${n
|
|||||||
return {cwd, repositoryUrl, authUrl};
|
return {cwd, repositoryUrl, authUrl};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {start, stop, gitCredential, createRepo};
|
const exported = {
|
||||||
|
start,
|
||||||
|
stop,
|
||||||
|
gitCredential,
|
||||||
|
createRepo,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {start, stop, gitCredential, createRepo};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const Docker = require('dockerode');
|
import Docker from 'dockerode';
|
||||||
const getStream = require('get-stream');
|
import getStream from 'get-stream';
|
||||||
const got = require('got');
|
import got from 'got';
|
||||||
const pRetry = require('p-retry');
|
import pRetry from 'p-retry';
|
||||||
const {mockServerClient} = require('mockserver-client');
|
import {mockServerClient} from 'mockserver-client';
|
||||||
|
|
||||||
const IMAGE = 'jamesdbloom/mockserver:latest';
|
const IMAGE = 'jamesdbloom/mockserver:latest';
|
||||||
const MOCK_SERVER_PORT = 1080;
|
const MOCK_SERVER_PORT = 1080;
|
||||||
@ -100,4 +100,13 @@ function verify(expectation) {
|
|||||||
return client.verify(expectation);
|
return client.verify(expectation);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {start, stop, mock, verify, url};
|
const exported = {
|
||||||
|
start,
|
||||||
|
stop,
|
||||||
|
mock,
|
||||||
|
verify,
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {start, stop, mock, verify, url};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const Docker = require('dockerode');
|
import Docker from 'dockerode';
|
||||||
const getStream = require('get-stream');
|
import getStream from 'get-stream';
|
||||||
const got = require('got');
|
import got from 'got';
|
||||||
const delay = require('delay');
|
import delay from 'delay';
|
||||||
const pRetry = require('p-retry');
|
import pRetry from 'p-retry';
|
||||||
|
|
||||||
const IMAGE = 'semanticrelease/npm-registry-docker:latest';
|
const IMAGE = 'semanticrelease/npm-registry-docker:latest';
|
||||||
const SERVER_PORT = 15986;
|
const SERVER_PORT = 15986;
|
||||||
@ -76,4 +76,12 @@ async function stop() {
|
|||||||
await container.remove();
|
await container.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {start, stop, authEnv, url};
|
const exported = {
|
||||||
|
start,
|
||||||
|
stop,
|
||||||
|
authEnv,
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {start, stop, authEnv, url};
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
const execa = require('execa');
|
import execa from 'execa';
|
||||||
|
|
||||||
async function npmView(packageName, env) {
|
async function npmView(packageName, env) {
|
||||||
return JSON.parse((await execa('npm', ['view', packageName, '--json'], {env})).stdout);
|
return JSON.parse((await execa('npm', ['view', packageName, '--json'], {env})).stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {npmView};
|
const exported = {
|
||||||
|
npmView,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default exported;
|
||||||
|
export {npmView};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {repeat} = require('lodash');
|
import {repeat} from 'lodash';
|
||||||
const hideSensitive = require('../lib/hide-sensitive');
|
import hideSensitive from '../lib/hide-sensitive.js';
|
||||||
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('../lib/definitions/constants');
|
import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from '../lib/definitions/constants.js';
|
||||||
|
|
||||||
test('Replace multiple sensitive environment variable values', (t) => {
|
test('Replace multiple sensitive environment variable values', (t) => {
|
||||||
const env = {SOME_PASSWORD: 'password', SOME_TOKEN: 'secret'};
|
const env = {SOME_PASSWORD: 'password', SOME_TOKEN: 'secret'};
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {escapeRegExp, isString, sortBy, omit} = require('lodash');
|
import {escapeRegExp, isString, sortBy, omit} from 'lodash';
|
||||||
const proxyquire = require('proxyquire');
|
import proxyquire from 'proxyquire';
|
||||||
const {spy, stub} = require('sinon');
|
import {spy, stub} from 'sinon';
|
||||||
const {WritableStreamBuffer} = require('stream-buffers');
|
import {WritableStreamBuffer} from 'stream-buffers';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const SemanticReleaseError = require('@semantic-release/error');
|
import SemanticReleaseError from '@semantic-release/error';
|
||||||
const {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
import {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
|
||||||
const {
|
|
||||||
gitHead: getGitHead,
|
import {
|
||||||
|
gitHead as getGitHead,
|
||||||
gitCheckout,
|
gitCheckout,
|
||||||
gitTagHead,
|
gitTagHead,
|
||||||
gitRepo,
|
gitRepo,
|
||||||
@ -21,7 +22,7 @@ const {
|
|||||||
rebase,
|
rebase,
|
||||||
gitAddNote,
|
gitAddNote,
|
||||||
gitGetNote,
|
gitGetNote,
|
||||||
} = require('./helpers/git-utils');
|
} from './helpers/git-utils.js';
|
||||||
|
|
||||||
const requireNoCache = proxyquire.noPreserveCache();
|
const requireNoCache = proxyquire.noPreserveCache();
|
||||||
const pluginNoop = require.resolve('./fixtures/plugin-noop');
|
const pluginNoop = require.resolve('./fixtures/plugin-noop');
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
const path = require('path');
|
import path from 'path';
|
||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const proxyquire = require('proxyquire');
|
import proxyquire from 'proxyquire';
|
||||||
const {escapeRegExp} = require('lodash');
|
import {escapeRegExp} from 'lodash';
|
||||||
const {writeJson, readJson} = require('fs-extra');
|
import {writeJson, readJson} from 'fs-extra';
|
||||||
const execa = require('execa');
|
import execa from 'execa';
|
||||||
const {WritableStreamBuffer} = require('stream-buffers');
|
import {WritableStreamBuffer} from 'stream-buffers';
|
||||||
const delay = require('delay');
|
import delay from 'delay';
|
||||||
const getAuthUrl = require('../lib/get-git-auth-url');
|
import getAuthUrl from '../lib/get-git-auth-url.js';
|
||||||
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
|
||||||
const {
|
|
||||||
|
import {
|
||||||
gitHead,
|
gitHead,
|
||||||
gitTagHead,
|
gitTagHead,
|
||||||
gitRepo,
|
gitRepo,
|
||||||
@ -18,11 +19,12 @@ const {
|
|||||||
gitCheckout,
|
gitCheckout,
|
||||||
merge,
|
merge,
|
||||||
gitGetNote,
|
gitGetNote,
|
||||||
} = require('./helpers/git-utils');
|
} from './helpers/git-utils.js';
|
||||||
const {npmView} = require('./helpers/npm-utils');
|
|
||||||
const gitbox = require('./helpers/gitbox');
|
import {npmView} from './helpers/npm-utils.js';
|
||||||
const mockServer = require('./helpers/mockserver');
|
import gitbox from './helpers/gitbox.js';
|
||||||
const npmRegistry = require('./helpers/npm-registry');
|
import mockServer from './helpers/mockserver.js';
|
||||||
|
import npmRegistry from './helpers/npm-registry.js';
|
||||||
|
|
||||||
/* eslint camelcase: ["error", {properties: "never"}] */
|
/* eslint camelcase: ["error", {properties: "never"}] */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {noop} = require('lodash');
|
import {noop} from 'lodash';
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const normalize = require('../../lib/plugins/normalize');
|
import normalize from '../../lib/plugins/normalize.js';
|
||||||
|
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const pipeline = require('../../lib/plugins/pipeline');
|
import pipeline from '../../lib/plugins/pipeline.js';
|
||||||
|
|
||||||
test('Execute each function in series passing the same input', async (t) => {
|
test('Execute each function in series passing the same input', async (t) => {
|
||||||
const step1 = stub().resolves(1);
|
const step1 = stub().resolves(1);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const path = require('path');
|
import path from 'path';
|
||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {copy, outputFile} = require('fs-extra');
|
import {copy, outputFile} from 'fs-extra';
|
||||||
const {stub} = require('sinon');
|
import {stub} from 'sinon';
|
||||||
const tempy = require('tempy');
|
import tempy from 'tempy';
|
||||||
const getPlugins = require('../../lib/plugins');
|
import getPlugins from '../../lib/plugins';
|
||||||
|
|
||||||
// Save the current working diretory
|
// Save the current working diretory
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('../../lib/plugins/utils');
|
import {validatePlugin, validateStep, loadPlugin, parseConfig} from '../../lib/plugins/utils.js';
|
||||||
|
|
||||||
test('validatePlugin', (t) => {
|
test('validatePlugin', (t) => {
|
||||||
const path = 'plugin-module';
|
const path = 'plugin-module';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const AggregateError = require('aggregate-error');
|
import AggregateError from 'aggregate-error';
|
||||||
const {
|
|
||||||
|
import {
|
||||||
extractErrors,
|
extractErrors,
|
||||||
tagsToVersions,
|
tagsToVersions,
|
||||||
isMajorRange,
|
isMajorRange,
|
||||||
@ -15,7 +16,7 @@ const {
|
|||||||
getRange,
|
getRange,
|
||||||
makeTag,
|
makeTag,
|
||||||
isSameChannel,
|
isSameChannel,
|
||||||
} = require('../lib/utils');
|
} from '../lib/utils.js';
|
||||||
|
|
||||||
test('extractErrors', (t) => {
|
test('extractErrors', (t) => {
|
||||||
const errors = [new Error('Error 1'), new Error('Error 2')];
|
const errors = [new Error('Error 1'), new Error('Error 2')];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const test = require('ava');
|
import test from 'ava';
|
||||||
const tempy = require('tempy');
|
import tempy from 'tempy';
|
||||||
const verify = require('../lib/verify');
|
import verify from '../lib/verify.js';
|
||||||
const {gitRepo} = require('./helpers/git-utils');
|
import {gitRepo} from './helpers/git-utils.js';
|
||||||
|
|
||||||
test('Throw a AggregateError', async (t) => {
|
test('Throw a AggregateError', async (t) => {
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user