Compare commits

...

5 Commits

Author SHA1 Message Date
Gregor Martynus
e72d201afe wip esm adapt lodash 2021-07-30 13:57:35 -07:00
Gregor Martynus
ab7a428102 WIP esm - adapt sinon 2021-07-30 13:57:35 -07:00
Gregor Martynus
ce263c5f4a WIP convert CJS to ESM using https://github.com/homer0/cjs2esm 2021-07-30 13:57:35 -07:00
Matt Travi
d9605a5e45
docs(node-version): updated documentation to reference the new minimum 2021-07-30 15:47:49 -05:00
Matt Travi
e1c00e2531
feat(node-version): raised the minimum required version to v14.17
for #2055

BREAKING CHANGE: the minimum required version of node is now v14.17
2021-07-30 15:18:22 -05:00
78 changed files with 4523 additions and 667 deletions

View File

@ -17,9 +17,8 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: node-version:
- 10.18.0 - 14.17
- 12 - 16
- 14
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -97,7 +97,7 @@ In order to use **semantic-release** you need:
- To host your code in a [Git repository](https://git-scm.com) - To host your code in a [Git repository](https://git-scm.com)
- Use a Continuous Integration service that allows you to [securely set up credentials](docs/usage/ci-configuration.md#authentication) - Use a Continuous Integration service that allows you to [securely set up credentials](docs/usage/ci-configuration.md#authentication)
- Git CLI version [2.7.1 or higher](docs/support/FAQ.md#why-does-semantic-release-require-git-version--271) installed in your Continuous Integration environment - Git CLI version [2.7.1 or higher](docs/support/FAQ.md#why-does-semantic-release-require-git-version--271) installed in your Continuous Integration environment
- [Node.js](https://nodejs.org) version [10.18 or higher](docs/support/FAQ.md#why-does-semantic-release-require-node-version--1018) installed in your Continuous Integration environment - [Node.js](https://nodejs.org) version [14.17 or higher](docs/support/FAQ.md#why-does-semantic-release-require-node-version--1417) installed in your Continuous Integration environment
## Documentation ## Documentation

View File

@ -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
View File

@ -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;

View File

@ -39,7 +39,7 @@ workflows:
parameters: parameters:
version: version:
- 16.1.0 - 16.1.0
- 14.7.0 - 14.17.0
- release: - release:
requires: requires:
- node/test - node/test
@ -52,7 +52,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
```json ```json
{ {
"devDependencies": { "devDependencies": {
"semantic-release": "^15.0.0" "semantic-release": "^18.0.0"
} }
} }
``` ```

View File

@ -10,11 +10,12 @@ In this example a publish type [`NPM_TOKEN`](https://docs.npmjs.com/creating-and
[GitHub Actions](https://github.com/features/actions) support [Workflows](https://help.github.com/en/articles/configuring-workflows), allowing to run tests on multiple Node versions and publish a release only when all test pass. [GitHub Actions](https://github.com/features/actions) support [Workflows](https://help.github.com/en/articles/configuring-workflows), allowing to run tests on multiple Node versions and publish a release only when all test pass.
**Note**: The publish pipeline must run on [Node version >= 10.18](../support/FAQ.md#why-does-semantic-release-require-node-version--1018). **Note**: The publish pipeline must run on [Node version >= 14.17](../support/FAQ.md#why-does-semantic-release-require-node-version--1417).
### `.github/workflows/release.yml` configuration for Node projects ### `.github/workflows/release.yml` configuration for Node projects
The following is a minimal configuration for [`semantic-release`](https://github.com/semantic-release/semantic-release) with a build running on Node 12 when a new commit is pushed to a `master` branch. See [Configuring a Workflow](https://help.github.com/en/articles/configuring-a-workflow) for additional configuration options. The following is a minimal configuration for [`semantic-release`](https://github.com/semantic-release/semantic-release) with a build running on Node 14.17 when a new commit is pushed to a `master` branch.
See [Configuring a Workflow](https://help.github.com/en/articles/configuring-a-workflow) for additional configuration options.
```yaml ```yaml
name: Release name: Release
@ -34,7 +35,7 @@ jobs:
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12 node-version: '14.17'
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Release - name: Release

View File

@ -10,7 +10,7 @@ The [Authentication](../usage/ci-configuration.md#authentication) environment va
GitLab CI supports [Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html) allowing to test on multiple Node versions and publishing a release only when all test pass. GitLab CI supports [Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html) allowing to test on multiple Node versions and publishing a release only when all test pass.
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018). **Note**: The publish pipeline must run a [Node >= 14.17 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1417).
### `.gitlab-ci.yml` configuration for Node projects ### `.gitlab-ci.yml` configuration for Node projects
@ -54,7 +54,7 @@ This example is a minimal configuration for **semantic-release** with a build ru
```yaml ```yaml
# The release pipeline will run only on the master branch a commit is triggered # The release pipeline will run only on the master branch a commit is triggered
stages: stages:
- release - release

View File

@ -10,16 +10,16 @@ Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with
### `Jenkinsfile (Declarative Pipeline)` configuration for a Node.js job ### `Jenkinsfile (Declarative Pipeline)` configuration for a Node.js job
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018). **Note**: The publish pipeline must run a [Node >= 14.17 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1417).
This example is a minimal configuration for **semantic-release** with a build running Node 10.18. See [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options. This example is a minimal configuration for **semantic-release** with a build running Node 14.17. See [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options.
The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation. The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation.
```yaml ```yaml
// The release stage in the pipeline will run only if the test stage in the pipeline is successful // The release stage in the pipeline will run only if the test stage in the pipeline is successful
pipeline { pipeline {
agent any agent any
environment { environment {
GH_TOKEN = credentials('some-id') GH_TOKEN = credentials('some-id')
} }
@ -35,14 +35,14 @@ pipeline {
} }
stage('Release') { stage('Release') {
tools { tools {
nodejs "node 10.18" nodejs "node 14.17"
} }
steps { steps {
sh ''' sh '''
# Run optional required steps before releasing # Run optional required steps before releasing
npx semantic-release npx semantic-release
''' '''
} }
} }
} }
} }
@ -55,7 +55,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
```json ```json
{ {
"devDependencies": { "devDependencies": {
"semantic-release": "^15.0.0" "semantic-release": "^18.0.0"
} }
} }
``` ```

View File

@ -10,7 +10,7 @@ Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with
### `.travis.yml` configuration for multiple Node.js jobs ### `.travis.yml` configuration for multiple Node.js jobs
This example is a minimal configuration for **semantic-release** with a build running Node 6 and 8. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options. This example is a minimal configuration for **semantic-release** with a build running Node 14 and 16. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded). This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
@ -24,8 +24,8 @@ It's recommended to run the `semantic-release` command in the [Travis `deploy` s
language: node_js language: node_js
node_js: node_js:
- 8 - 14
- 6 - 16
jobs: jobs:
include: include:
@ -48,7 +48,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
```json ```json
{ {
"devDependencies": { "devDependencies": {
"semantic-release": "^15.0.0" "semantic-release": "^18.0.0"
} }
} }
``` ```

View File

@ -38,44 +38,14 @@ If using npm hook scripts is not possible, and alternative solution is to [`@sem
Yes with the [dry-run options](../usage/configuration.md#dryrun) which prints to the console the next version to be published and the release notes. Yes with the [dry-run options](../usage/configuration.md#dryrun) which prints to the console the next version to be published and the release notes.
## Can I use semantic-release with Yarn?
If you are using a [local](../usage/installation.md#local-installation) **semantic-release** installation and run multiple CI jobs with different versions, the `yarn install` command will fail on jobs running with Node < 8 as **semantic-release** requires [Node >= 10.18](#why-does-semantic-release-require-node-version--1018) and specifies it in its `package.json`s [`engines`](https://docs.npmjs.com/files/package.json#engines) key.
The recommended solution is to use the [Yarn](https://yarnpkg.com) [--ignore-engines](https://yarnpkg.com/en/docs/cli/install#toc-yarn-install-ignore-engines) option to install the project dependencies on the CI environment, so Yarn will ignore the **semantic-release**'s `engines` key:
```bash
$ yarn install --ignore-engines
```
**Note**: Several CI services use Yarn by default if your repository contains a `yarn.lock` file. So you should override the install step to specify `yarn install --ignore-engines`.
Alternatively you can use a [global](../usage/installation.md#global-installation) **semantic-release** installation and make sure to install and run the `semantic-release` command only in a CI jobs running with Node >= 10.18.
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can switch to Node 8 before installing and running the `semantic-release` command:
```bash
$ nvm install 8 && yarn global add semantic-release && semantic-release
```
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
As `semantic-release` is recommended to be executed with [`npx`](https://www.npmjs.com/package/npx) an alternative is required for usage with Yarn. Even though it is possible to install npx with Yarn, it's not recommended. Yarn and npx would be using different cache locations.
For [local installation](../usage/installation.md#local-installation) replace
`npx semantic-release` with `yarn run semantic-release`.
For [global installation](../usage/installation.md#global-installation) replace
`npx semantic-release` with `yarn global add semantic-release && semantic-release`.
## Can I use semantic-release to publish non-JavaScript packages? ## Can I use semantic-release to publish non-JavaScript packages?
Yes, **semantic-release** is a Node CLI application but it can be used to publish any type of packages. Yes, **semantic-release** is a Node CLI application, but it can be used to publish any type of packages.
To publish a non-Node package (without a `package.json`) you would need to: To publish a non-Node package (without a `package.json`) you would need to:
- Use a [global](../usage/installation.md#global-installation) **semantic-release** installation - Use a [global](../usage/installation.md#global-installation) **semantic-release** installation
- Set **semantic-release** [options](../usage/configuration.md#options) via [CLI arguments or rc file](../usage/configuration.md#configuration) - Set **semantic-release** [options](../usage/configuration.md#options) via [CLI arguments or rc file](../usage/configuration.md#configuration)
- Make sure your CI job executing the `semantic-release` command has access to [Node >= 10.18](#why-does-semantic-release-require-node-version--1018) to execute the `semantic-release` command - Make sure your CI job executing the `semantic-release` command has access to [Node >= 14.17](#why-does-semantic-release-require-node-version--1417) to execute the `semantic-release` command
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments. See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
@ -234,9 +204,9 @@ See [“Introduction to SemVer” - Irina Gebauer](https://blog.greenkeeper.io/i
In addition the [verify conditions step](../../README.md#release-steps) verifies that all necessary conditions for proceeding with a release are met, and a new release will be performed [only if all your tests pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded). In addition the [verify conditions step](../../README.md#release-steps) verifies that all necessary conditions for proceeding with a release are met, and a new release will be performed [only if all your tests pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
## Why does semantic-release require Node version >= 10.18? ## Why does semantic-release require Node version >= 14.17?
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which **requires Node version 10.18 or higher**. **semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which **requires Node version 14.17 or higher**.
See [Node version requirement](./node-version.md#node-version-requirement) for more details and solutions. See [Node version requirement](./node-version.md#node-version-requirement) for more details and solutions.

View File

@ -1,6 +1,6 @@
# Node Support Policy # Node Support Policy
We only support [Long-Term Support](https://github.com/nodejs/Release) versions of Node starting with [Node 8.9.0 (LTS)](https://nodejs.org/en/blog/release/v8.9.0). We only support [Long-Term Support](https://github.com/nodejs/Release) versions of Node starting with [Node 14.17.0 (LTS)](https://nodejs.org/en/blog/release/v14.17.0).
We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment. We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.

View File

@ -1,16 +1,17 @@
# Node version requirement # Node version requirement
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which requires **requires Node version 10 or higher**. **semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which requires **requires Node version 14.17 or higher**.
**semantic-release** is meant to be used in a CI environment as a development support tool, not as a production dependency. Therefore the only constraint is to run the `semantic-release` in a CI environment providing Node 8 or higher. **semantic-release** is meant to be used in a CI environment as a development support tool, not as a production dependency. Therefore the only constraint is to run the `semantic-release` in a CI environment providing Node 14.17 or higher.
See our [Node Support Policy](node-support-policy.md) for our long-term promise regarding Node version support. See our [Node Support Policy](node-support-policy.md) for our long-term promise regarding Node version support.
## Recommended solution ## Recommended solution
### Run at least one CI job with Node >= 10.18 ### Run at least one CI job with Node >= 14.17
The recommended approach is to run the `semantic-release` command from a CI job running on Node 10.18 or higher. This can either be a job used by your project to test on Node >= 10.18 or a dedicated job for the release steps. The recommended approach is to run the `semantic-release` command from a CI job running on Node 14.17 or higher.
This can either be a job used by your project to test on Node >= 14.17 or a dedicated job for the release steps.
See [CI configuration](../usage/ci-configuration.md) and [CI configuration recipes](../recipes/README.md#ci-configurations) for more details. See [CI configuration](../usage/ci-configuration.md) and [CI configuration recipes](../recipes/README.md#ci-configurations) for more details.
@ -18,18 +19,19 @@ See [CI configuration](../usage/ci-configuration.md) and [CI configuration recip
### Use `npx` ### Use `npx`
`npx` is included with npm >= 5.2 and can be used to download the latest [Node 8 package published on npm](https://www.npmjs.com/package/node). Use it to execute the `semantic-release` command. `npx` is included with npm >= 5.2 and can be used to download the latest [Node 14 package published on npm](https://www.npmjs.com/package/node).
Use it to execute the `semantic-release` command.
```bash ```bash
$ npx -p node@8 -c "npx semantic-release" $ npx -p node@14 -c "npx semantic-release"
``` ```
**Note:**: See [What is npx](./FAQ.md#what-is-npx) for more details. **Note:**: See [What is npx](./FAQ.md#what-is-npx) for more details.
### Use `nvm` ### Use `nvm`
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to Node 8 before running the `semantic-release` command. If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to Node 14.17 before running the `semantic-release` command.
```bash ```bash
$ nvm install 8 && npx semantic-release $ nvm install 14.17 && npx semantic-release
``` ```

View File

@ -24,6 +24,7 @@ For other type of projects we recommend installing **semantic-release** directly
$ npx semantic-release $ npx semantic-release
``` ```
**Note**: For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@15`). This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released. **Note**: For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@18`).
This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released.
**Note**: `npx` is a tool bundled with `npm@>=5.2.0`. It is used to conveniently install the semantic-release binary and to execute it. See [What is npx](../support/FAQ.md#what-is-npx) for more details. **Note**: `npx` is a tool bundled with `npm@>=5.2.0`. It is used to conveniently install the semantic-release binary and to execute it. See [What is npx](../support/FAQ.md#what-is-npx) for more details.

View File

@ -1,25 +1,28 @@
const {pick} = require('lodash'); import lodash from 'lodash'
const marked = require('marked'); const {pick} = lodash
const TerminalRenderer = require('marked-terminal'); import marked from 'marked';
const envCi = require('env-ci'); import TerminalRenderer from 'marked-terminal';
const hookStd = require('hook-std'); import envCi from 'env-ci';
const semver = require('semver'); import hookStd from 'hook-std';
const AggregateError = require('aggregate-error'); import semver from 'semver';
const pkg = require('./package.json'); import AggregateError from 'aggregate-error';
const hideSensitive = require('./lib/hide-sensitive'); import pkg from './package.json';
const getConfig = require('./lib/get-config'); import hideSensitive from './lib/hide-sensitive';
const verify = require('./lib/verify'); import getConfig from './lib/get-config';
const getNextVersion = require('./lib/get-next-version'); import verify from './lib/verify';
const getCommits = require('./lib/get-commits'); import getNextVersion from './lib/get-next-version';
const getLastRelease = require('./lib/get-last-release'); import getCommits from './lib/get-commits';
const getReleaseToAdd = require('./lib/get-release-to-add'); import getLastRelease from './lib/get-last-release';
const {extractErrors, makeTag} = require('./lib/utils'); import getReleaseToAdd from './lib/get-release-to-add';
const getGitAuthUrl = require('./lib/get-git-auth-url'); import {extractErrors, makeTag} from './lib/utils';
const getBranches = require('./lib/branches'); import getGitAuthUrl from './lib/get-git-auth-url';
const getLogger = require('./lib/get-logger'); import getBranches from './lib/branches';
const {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} = require('./lib/git'); import getLogger from './lib/get-logger';
const getError = require('./lib/get-error');
const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants'); import {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} from './lib/git';
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 +242,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)

View File

@ -1,8 +1,9 @@
const {isString, remove, omit, mapValues, template} = require('lodash'); import lodash from 'lodash'
const micromatch = require('micromatch'); const {isString, remove, omit, mapValues, template} = lodash
const {getBranches} = require('../git'); import micromatch from 'micromatch';
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(

View File

@ -1,10 +1,12 @@
const {template, escapeRegExp} = require('lodash'); import lodash from 'lodash'
const semver = require('semver'); const {template, escapeRegExp} = lodash
const pReduce = require('p-reduce'); import semver from 'semver';
const debug = require('debug')('semantic-release:get-tags'); import pReduce from 'p-reduce';
const {getTags, getNote} = require('../../lib/git'); import debugFactory from 'debug';
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,

View File

@ -1,14 +1,15 @@
const {isString, isRegExp} = require('lodash'); import lodash from 'lodash'
const AggregateError = require('aggregate-error'); const {isString, isRegExp} = lodash
const pEachSeries = require('p-each-series'); import AggregateError from 'aggregate-error';
const DEFINITIONS = require('../definitions/branches'); import pEachSeries from 'p-each-series';
const getError = require('../get-error'); import DEFINITIONS from '../definitions/branches.js';
const {fetch, fetchNotes, verifyBranchName} = require('../git'); import getError from '../get-error.js';
const expand = require('./expand'); import {fetch, fetchNotes, verifyBranchName} from '../git.js';
const getTags = require('./get-tags'); import expand from './expand.js';
const normalize = require('./normalize'); import getTags from './get-tags.js';
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(

View File

@ -1,7 +1,9 @@
const {sortBy, isNil} = require('lodash'); import lodash from 'lodash'
const semverDiff = require('semver-diff'); const {sortBy, isNil} = lodash
const {FIRST_RELEASE, RELEASE_TYPE} = require('../definitions/constants'); import semverDiff from 'semver-diff';
const { import {FIRST_RELEASE, RELEASE_TYPE} from '../definitions/constants.js';
import {
tagsToVersions, tagsToVersions,
isMajorRange, isMajorRange,
getUpperBound, getUpperBound,
@ -11,7 +13,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 +105,11 @@ function prerelease({prerelease}) {
}); });
} }
module.exports = {maintenance, release, prerelease}; const exported = {
maintenance,
release,
prerelease,
};
export default exported;
export {maintenance, release, prerelease};

View File

@ -1,6 +1,7 @@
const {isNil, uniqBy} = require('lodash'); import lodash from 'lodash'
const semver = require('semver'); const {isNil, uniqBy} = lodash
const {isMaintenanceRange} = require('../utils'); import semver from 'semver';
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 +21,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};

View File

@ -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,

View File

@ -1,7 +1,8 @@
const {inspect} = require('util'); import {inspect} from 'util';
const {toLower, isString, trim} = require('lodash'); import lodash from 'lodash'
const pkg = require('../../package.json'); const {toLower, isString, trim} = lodash
const {RELEASE_TYPE} = require('./constants'); import pkg from '../../package.json';
import {RELEASE_TYPE} from './constants.js';
const [homepage] = pkg.homepage.split('#'); const [homepage] = pkg.homepage.split('#');
const stringify = (object) => const stringify = (object) =>
@ -10,7 +11,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 +20,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 +31,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 +43,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 +52,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 +61,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 +70,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 +79,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 +90,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 +107,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 +122,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 +137,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 +152,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 +161,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 +170,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 +179,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 +188,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 +197,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 +208,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 +217,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 +226,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 +242,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 +252,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;

View File

@ -1,17 +1,18 @@
/* eslint require-atomic-updates: off */ import lodash from 'lodash'
const {isString, isPlainObject} = 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 +30,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 +52,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 +71,7 @@ module.exports = {
}, },
}), }),
}, },
publish: { publish: {
required: false, required: false,
dryRun: false, dryRun: false,
@ -80,6 +85,7 @@ module.exports = {
}), }),
}), }),
}, },
addChannel: { addChannel: {
required: false, required: false,
dryRun: false, dryRun: false,
@ -93,12 +99,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 +114,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;

View File

@ -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 {

View File

@ -1,16 +1,18 @@
const {castArray, pickBy, isNil, isString, isPlainObject} = require('lodash'); import lodash from 'lodash'
const readPkgUp = require('read-pkg-up'); const {castArray, pickBy, isNil, isString, isPlainObject} = lodash
const {cosmiconfig} = require('cosmiconfig'); import readPkgUp from 'read-pkg-up';
const resolveFrom = require('resolve-from'); import {cosmiconfig} from 'cosmiconfig';
const debug = require('debug')('semantic-release:config'); import resolveFrom from 'resolve-from';
const {repoUrl} = require('./git'); import debugFactory from 'debug';
const PLUGINS_DEFINITIONS = require('./definitions/plugins'); const debug = debugFactory('semantic-release:config');
const plugins = require('./plugins'); import {repoUrl} from './git.js';
const {validatePlugin, parseConfig} = require('./plugins/utils'); import PLUGINS_DEFINITIONS from './definitions/plugins.js';
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)) || {};

View File

@ -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);
}; };

View File

@ -1,8 +1,10 @@
const {parse, format} = require('url'); // eslint-disable-line node/no-deprecated-api import {format} from 'url';
const {isNil} = require('lodash'); import lodash from 'lodash'
const hostedGitInfo = require('hosted-git-info'); const {isNil} = lodash
const {verifyAuth} = require('./git'); import hostedGitInfo from 'hosted-git-info';
const debug = require('debug')('semantic-release:get-git-auth-url'); import {verifyAuth} from './git.js';
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 +18,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 +59,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 +77,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`)

View File

@ -1,6 +1,7 @@
const {isUndefined} = require('lodash'); import lodash from 'lodash'
const semver = require('semver'); const {isUndefined} = lodash
const {makeTag, isSameChannel} = require('./utils'); import semver from 'semver';
import {makeTag, isSameChannel} from './utils.js';
/** /**
* Last release. * Last release.
@ -26,7 +27,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) =>

View File

@ -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,

View File

@ -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);

View File

@ -1,8 +1,9 @@
const {uniqBy, intersection} = require('lodash'); import lodash from 'lodash'
const semver = require('semver'); const {uniqBy, intersection} = lodash
const semverDiff = require('semver-diff'); import semver from 'semver';
const getLastRelease = require('./get-last-release'); import semverDiff from 'semver-diff';
const {makeTag, getLowerBound} = require('./utils'); import getLastRelease from './get-last-release.js';
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 +12,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,

View File

@ -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,

View File

@ -1,7 +1,8 @@
const {escapeRegExp, size, isString} = require('lodash'); import lodash from 'lodash'
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('./definitions/constants'); const {escapeRegExp, size, isString} = lodash
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') {

View File

@ -1,12 +1,13 @@
const {identity, isPlainObject, omit, castArray, isNil, isString} = require('lodash'); import lodash from 'lodash'
const AggregateError = require('aggregate-error'); const {identity, isPlainObject, omit, castArray, isNil, isString} = lodash
const getError = require('../get-error'); import AggregateError from 'aggregate-error';
const PLUGINS_DEFINITIONS = require('../definitions/plugins'); import getError from '../get-error.js';
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('./utils'); import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
const pipeline = require('./pipeline'); import {validatePlugin, validateStep, loadPlugin, parseConfig} from './utils.js';
const normalize = require('./normalize'); import pipeline from './pipeline.js';
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 = [];

View File

@ -1,11 +1,13 @@
const {isPlainObject, isFunction, noop, cloneDeep, omit} = require('lodash'); import lodash from 'lodash'
const debug = require('debug')('semantic-release:plugins'); const {isPlainObject, isFunction, noop, cloneDeep, omit} = lodash
const getError = require('../get-error'); import debugFactory from 'debug';
const {extractErrors} = require('../utils'); const debug = debugFactory('semantic-release:plugins');
const PLUGINS_DEFINITIONS = require('../definitions/plugins'); import getError from '../get-error.js';
const {loadPlugin, parseConfig} = require('./utils'); import {extractErrors} from '../utils.js';
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;

View File

@ -1,7 +1,8 @@
const {identity} = require('lodash'); import lodash from 'lodash'
const pReduce = require('p-reduce'); const {identity} = lodash
const AggregateError = require('aggregate-error'); import pReduce from 'p-reduce';
const {extractErrors} = require('../utils'); import AggregateError from 'aggregate-error';
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 +26,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(

View File

@ -1,6 +1,7 @@
const {dirname} = require('path'); import {dirname} from 'path';
const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = require('lodash'); import lodash from 'lodash'
const resolveFrom = require('resolve-from'); const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = lodash
import resolveFrom from 'resolve-from';
const validateSteps = (conf) => { const validateSteps = (conf) => {
return conf.every((conf) => { return conf.every((conf) => {
@ -65,4 +66,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};

View File

@ -1,6 +1,7 @@
const {isFunction, union, template} = require('lodash'); import lodash from 'lodash'
const semver = require('semver'); const {isFunction, union, template} = lodash
const hideSensitive = require('./hide-sensitive'); import semver from 'semver';
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 +83,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,

View File

@ -1,9 +1,10 @@
const {template, isString, isPlainObject} = require('lodash'); import lodash from 'lodash'
const AggregateError = require('aggregate-error'); const {template, isString, isPlainObject} = lodash
const {isGitRepo, verifyTagName} = require('./git'); import AggregateError from 'aggregate-error';
const getError = require('./get-error'); import {isGitRepo, verifyTagName} from './git.js';
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

File diff suppressed because it is too large Load Diff

View File

@ -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",
@ -70,7 +72,7 @@
"xo": "0.29.1" "xo": "0.29.1"
}, },
"engines": { "engines": {
"node": ">=10.18" "node": ">=14.17"
}, },
"files": [ "files": [
"bin", "bin",
@ -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": {

View File

@ -1,7 +1,8 @@
const test = require('ava'); import test from 'ava';
const {union} = require('lodash'); import lodash from 'lodash'
const semver = require('semver'); const {union} = lodash
const proxyquire = require('proxyquire'); import semver from 'semver';
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});

View File

@ -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);

View File

@ -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();

View File

@ -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}));

View File

@ -1,16 +1,17 @@
const test = require('ava'); import test from 'ava';
const {escapeRegExp} = require('lodash'); import lodash from 'lodash'
const {escapeRegExp} = lodash
const proxyquire = require('proxyquire').noPreserveCache(); const proxyquire = require('proxyquire').noPreserveCache();
const {stub} = require('sinon'); import sinon 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 = '';
t.context.errors = ''; t.context.errors = '';
t.context.stdout = stub(process.stdout, 'write').callsFake((value) => { t.context.stdout = sinon.stubprocess.stdout, 'write').callsFake((value) => {
t.context.logs += value.toString(); t.context.logs += value.toString();
}); });
t.context.stderr = stub(process.stderr, 'write').callsFake((value) => { t.context.stderr = sinon.stubprocess.stderr, 'write').callsFake((value) => {
t.context.errors += value.toString(); t.context.errors += value.toString();
}); });
}); });
@ -21,7 +22,7 @@ test.afterEach.always((t) => {
}); });
test.serial('Pass options to semantic-release API', async (t) => { test.serial('Pass options to semantic-release API', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = [ const argv = [
'', '',
'', '',
@ -87,7 +88,7 @@ test.serial('Pass options to semantic-release API', async (t) => {
}); });
test.serial('Pass options to semantic-release API with alias arguments', async (t) => { test.serial('Pass options to semantic-release API with alias arguments', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = [ const argv = [
'', '',
'', '',
@ -120,7 +121,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async (
}); });
test.serial('Pass unknown options to semantic-release API', async (t) => { test.serial('Pass unknown options to semantic-release API', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3']; const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -134,7 +135,7 @@ test.serial('Pass unknown options to semantic-release API', async (t) => {
}); });
test.serial('Pass empty Array to semantic-release API for list option set to "false"', async (t) => { test.serial('Pass empty Array to semantic-release API for list option set to "false"', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = ['', '', '--publish', 'false']; const argv = ['', '', '--publish', 'false'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -146,7 +147,7 @@ test.serial('Pass empty Array to semantic-release API for list option set to "fa
}); });
test.serial('Do not set properties in option for which arg is not in command line', async (t) => { test.serial('Do not set properties in option for which arg is not in command line', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = ['', '', '-b', 'master']; const argv = ['', '', '-b', 'master'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -163,7 +164,7 @@ test.serial('Do not set properties in option for which arg is not in command lin
}); });
test.serial('Display help', async (t) => { test.serial('Display help', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = ['', '', '--help']; const argv = ['', '', '--help'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -174,7 +175,7 @@ test.serial('Display help', async (t) => {
}); });
test.serial('Return error exitCode and prints help if called with a command', async (t) => { test.serial('Return error exitCode and prints help if called with a command', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = ['', '', 'pre']; const argv = ['', '', 'pre'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -186,7 +187,7 @@ test.serial('Return error exitCode and prints help if called with a command', as
}); });
test.serial('Return error exitCode if multiple plugin are set for single plugin', async (t) => { test.serial('Return error exitCode if multiple plugin are set for single plugin', async (t) => {
const run = stub().resolves(true); const run = sinon.stub).resolves(true);
const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2']; const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2'];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -198,7 +199,7 @@ test.serial('Return error exitCode if multiple plugin are set for single plugin'
}); });
test.serial('Return error exitCode if semantic-release throw error', async (t) => { test.serial('Return error exitCode if semantic-release throw error', async (t) => {
const run = stub().rejects(new Error('semantic-release error')); const run = sinon.stub).rejects(new Error('semantic-release error'));
const argv = ['', '']; const argv = ['', ''];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
@ -210,7 +211,7 @@ test.serial('Return error exitCode if semantic-release throw error', async (t) =
test.serial('Hide sensitive environment variable values from the logs', async (t) => { test.serial('Hide sensitive environment variable values from the logs', async (t) => {
const env = {MY_TOKEN: 'secret token'}; const env = {MY_TOKEN: 'secret token'};
const run = stub().rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`)); const run = sinon.stub).rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`));
const argv = ['', '']; const argv = ['', ''];
const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}}); const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}});

View File

@ -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'}));

View File

@ -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'));

View File

@ -1 +1 @@
module.exports = () => {}; export default () => {};

View File

@ -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;

View File

@ -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');
}; };

View File

@ -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;

View File

@ -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')]);
}; };

View File

@ -1 +1 @@
module.exports = (pluginConfig, context) => context; export default (pluginConfig, context) => context;

View File

@ -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}`);

View File

@ -1 +1 @@
module.exports = () => {}; export default () => {};

View File

@ -1 +1 @@
module.exports = (pluginConfig, context) => ({pluginConfig, context}); export default (pluginConfig, context) => ({pluginConfig, context});

View File

@ -1,12 +1,12 @@
const test = require('ava'); import test from 'ava';
const {stub} = require('sinon'); import sinon 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
t.context.log = stub(); t.context.log = sinon.stub();
t.context.error = stub(); t.context.error = sinon.stub();
t.context.logger = {log: t.context.log, error: t.context.error}; t.context.logger = {log: t.context.log, error: t.context.error};
}); });

View File

@ -1,12 +1,13 @@
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 lodash from 'lodash'
const proxyquire = require('proxyquire'); const {omit} = lodash
const {stub} = require('sinon'); import proxyquire from 'proxyquire';
const yaml = require('js-yaml'); import sinon from 'sinon';
const {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} = require('./helpers/git-utils'); import yaml from 'js-yaml';
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',
@ -16,7 +17,7 @@ const DEFAULT_PLUGINS = [
]; ];
test.beforeEach((t) => { test.beforeEach((t) => {
t.context.plugins = stub().returns({}); t.context.plugins = sinon.stub).returns({});
t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins}); t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins});
}); });

View File

@ -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};

View File

@ -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({

View File

@ -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();

View File

@ -1,10 +1,10 @@
const test = require('ava'); import test from 'ava';
const {stub} = require('sinon'); import sinon 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
t.context.log = stub(); t.context.log = sinon.stub);
t.context.logger = {log: t.context.log}; t.context.logger = {log: t.context.log};
}); });

View File

@ -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({

View File

@ -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

View File

@ -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,

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -1,7 +1,8 @@
const test = require('ava'); import test from 'ava';
const {repeat} = require('lodash'); import lodash from 'lodash'
const hideSensitive = require('../lib/hide-sensitive'); const {repeat} = lodash
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('../lib/definitions/constants'); import hideSensitive from '../lib/hide-sensitive.js';
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'};

View File

@ -1,13 +1,15 @@
const test = require('ava'); import test from 'ava';
const {escapeRegExp, isString, sortBy, omit} = require('lodash'); import lodash from 'lodash'
const proxyquire = require('proxyquire'); const {escapeRegExp, isString, sortBy, omit} = lodash
const {spy, stub} = require('sinon'); import proxyquire from 'proxyquire';
const {WritableStreamBuffer} = require('stream-buffers'); import sinon from 'sinon';
const AggregateError = require('aggregate-error'); import {WritableStreamBuffer} from 'stream-buffers';
const SemanticReleaseError = require('@semantic-release/error'); import AggregateError from 'aggregate-error';
const {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} = require('../lib/definitions/constants'); import SemanticReleaseError from '@semantic-release/error';
const { import {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
gitHead: getGitHead,
import {
gitHead as getGitHead,
gitCheckout, gitCheckout,
gitTagHead, gitTagHead,
gitRepo, gitRepo,
@ -21,17 +23,17 @@ 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');
test.beforeEach((t) => { test.beforeEach((t) => {
// Stub the logger functions // Stub the logger functions
t.context.log = spy(); t.context.log = sinon.spy();
t.context.error = spy(); t.context.error = sinon.spy();
t.context.success = spy(); t.context.success = sinon.spy();
t.context.warn = spy(); t.context.warn = sinon.spy();
t.context.logger = { t.context.logger = {
log: t.context.log, log: t.context.log,
error: t.context.error, error: t.context.error,
@ -73,19 +75,19 @@ test('Plugins are called with expected values', async (t) => {
const notes1 = 'Release notes 1'; const notes1 = 'Release notes 1';
const notes2 = 'Release notes 2'; const notes2 = 'Release notes 2';
const notes3 = 'Release notes 3'; const notes3 = 'Release notes 3';
const verifyConditions1 = stub().resolves(); const verifyConditions1 = sinon.stub().resolves();
const verifyConditions2 = stub().resolves(); const verifyConditions2 = sinon.stub().resolves();
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes1 = stub().resolves(notes1); const generateNotes1 = sinon.stub().resolves(notes1);
const generateNotes2 = stub().resolves(notes2); const generateNotes2 = sinon.stub().resolves(notes2);
const generateNotes3 = stub().resolves(notes3); const generateNotes3 = sinon.stub().resolves(notes3);
const release1 = {name: 'Release 1', url: 'https://release1.com'}; const release1 = {name: 'Release 1', url: 'https://release1.com'};
const release2 = {name: 'Release 2', url: 'https://release2.com'}; const release2 = {name: 'Release 2', url: 'https://release2.com'};
const addChannel = stub().resolves(release1); const addChannel = sinon.stub().resolves(release1);
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(release2); const publish = sinon.stub().resolves(release2);
const success = stub().resolves(); const success = sinon.stub().resolves();
const env = {}; const env = {};
const config = { const config = {
branches: [{name: 'master'}, {name: 'next'}], branches: [{name: 'master'}, {name: 'next'}],
@ -408,15 +410,15 @@ test('Use custom tag format', async (t) => {
const config = {branches: 'master', repositoryUrl, globalOpt: 'global', tagFormat: `test-\${version}`}; const config = {branches: 'master', repositoryUrl, globalOpt: 'global', tagFormat: `test-\${version}`};
const options = { const options = {
...config, ...config,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
analyzeCommits: stub().resolves(nextRelease.type), analyzeCommits: sinon.stub().resolves(nextRelease.type),
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(notes), generateNotes: sinon.stub().resolves(notes),
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -458,24 +460,24 @@ test('Use new gitHead, and recreate release notes if a prepare plugin create a c
}; };
const notes = 'Release notes'; const notes = 'Release notes';
const generateNotes = stub().resolves(notes); const generateNotes = sinon.stub().resolves(notes);
const prepare1 = stub().callsFake(async () => { const prepare1 = sinon.stub().callsFake(async () => {
commits = (await gitCommits(['Third'], {cwd})).concat(commits); commits = (await gitCommits(['Third'], {cwd})).concat(commits);
}); });
const prepare2 = stub().resolves(); const prepare2 = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const options = { const options = {
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
analyzeCommits: stub().resolves(nextRelease.type), analyzeCommits: sinon.stub().resolves(nextRelease.type),
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes, generateNotes,
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: [prepare1, prepare2], prepare: [prepare1, prepare2],
publish, publish,
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -527,12 +529,12 @@ test('Make a new release when a commit is forward-ported to an upper branch', as
await merge('1.0.x', {cwd}); await merge('1.0.x', {cwd});
await gitPush('origin', 'master', {cwd}); await gitPush('origin', 'master', {cwd});
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const addChannel = stub().resolves(); const addChannel = sinon.stub().resolves();
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const config = {branches: [{name: '1.0.x'}, {name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; const config = {branches: [{name: '1.0.x'}, {name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
const options = { const options = {
@ -570,14 +572,14 @@ test('Publish a pre-release version', async (t) => {
const config = {branches: ['master', {name: 'beta', prerelease: true}], repositoryUrl}; const config = {branches: ['master', {name: 'beta', prerelease: true}], repositoryUrl};
const options = { const options = {
...config, ...config,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(''), generateNotes: sinon.stub().resolves(''),
addChannel: false, addChannel: false,
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -620,17 +622,17 @@ test('Publish releases from different branch on the same channel', async (t) =>
branches: ['master', {name: 'next', channel: false}, {name: 'next-major', channel: false}], branches: ['master', {name: 'next', channel: false}, {name: 'next-major', channel: false}],
repositoryUrl, repositoryUrl,
}; };
const addChannel = stub().resolves({}); const addChannel = sinon.stub().resolves({});
const options = { const options = {
...config, ...config,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(''), generateNotes: sinon.stub().resolves(''),
addChannel, addChannel,
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
let semanticRelease = requireNoCache('..', { let semanticRelease = requireNoCache('..', {
@ -683,14 +685,14 @@ test('Publish pre-releases the same channel as regular releases', async (t) => {
}; };
const options = { const options = {
...config, ...config,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(''), generateNotes: sinon.stub().resolves(''),
addChannel: false, addChannel: false,
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -733,14 +735,14 @@ test('Do not add pre-releases to a different channel', async (t) => {
await merge('beta', {cwd}); await merge('beta', {cwd});
await gitPush('origin', 'master', {cwd}); await gitPush('origin', 'master', {cwd});
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves('Release notes'); const generateNotes = sinon.stub().resolves('Release notes');
const release1 = {name: 'Release 1', url: 'https://release1.com'}; const release1 = {name: 'Release 1', url: 'https://release1.com'};
const addChannel = stub().resolves(release1); const addChannel = sinon.stub().resolves(release1);
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const config = { const config = {
branches: [{name: 'master'}, {name: 'beta', prerelease: 'beta'}], branches: [{name: 'master'}, {name: 'beta', prerelease: 'beta'}],
@ -791,15 +793,15 @@ async function addChannelMacro(t, mergeFunction) {
await gitPush('origin', 'master', {cwd}); await gitPush('origin', 'master', {cwd});
const notes = 'Release notes'; const notes = 'Release notes';
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves(notes); const generateNotes = sinon.stub().resolves(notes);
const release1 = {name: 'Release 1', url: 'https://release1.com'}; const release1 = {name: 'Release 1', url: 'https://release1.com'};
const addChannel1 = stub().resolves(release1); const addChannel1 = sinon.stub().resolves(release1);
const addChannel2 = stub().resolves(); const addChannel2 = sinon.stub().resolves();
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const config = { const config = {
branches: [ branches: [
@ -870,14 +872,14 @@ test('Call all "success" plugins even if one errors out', async (t) => {
channel: null, channel: null,
}; };
const notes = 'Release notes'; const notes = 'Release notes';
const verifyConditions1 = stub().resolves(); const verifyConditions1 = sinon.stub().resolves();
const verifyConditions2 = stub().resolves(); const verifyConditions2 = sinon.stub().resolves();
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const generateNotes = stub().resolves(notes); const generateNotes = sinon.stub().resolves(notes);
const release = {name: 'Release', url: 'https://release.com'}; const release = {name: 'Release', url: 'https://release.com'};
const publish = stub().resolves(release); const publish = sinon.stub().resolves(release);
const success1 = stub().rejects(); const success1 = sinon.stub().rejects();
const success2 = stub().resolves(); const success2 = sinon.stub().resolves();
const config = { const config = {
branches: [{name: 'master'}], branches: [{name: 'master'}],
repositoryUrl, repositoryUrl,
@ -889,8 +891,8 @@ test('Call all "success" plugins even if one errors out', async (t) => {
verifyConditions: [verifyConditions1, verifyConditions2], verifyConditions: [verifyConditions1, verifyConditions2],
analyzeCommits, analyzeCommits,
generateNotes, generateNotes,
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish, publish,
success: [success1, success2], success: [success1, success2],
}; };
@ -926,12 +928,12 @@ test('Log all "verifyConditions" errors', async (t) => {
const error1 = new Error('error 1'); const error1 = new Error('error 1');
const error2 = new SemanticReleaseError('error 2', 'ERR2'); const error2 = new SemanticReleaseError('error 2', 'ERR2');
const error3 = new SemanticReleaseError('error 3', 'ERR3'); const error3 = new SemanticReleaseError('error 3', 'ERR3');
const fail = stub().resolves(); const fail = sinon.stub().resolves();
const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
const options = { const options = {
...config, ...config,
plugins: false, plugins: false,
verifyConditions: [stub().rejects(new AggregateError([error1, error2])), stub().rejects(error3)], verifyConditions: [sinon.stub().rejects(new AggregateError([error1, error2])), sinon.stub().rejects(error3)],
fail, fail,
}; };
@ -970,13 +972,13 @@ test('Log all "verifyRelease" errors', async (t) => {
const error1 = new SemanticReleaseError('error 1', 'ERR1'); const error1 = new SemanticReleaseError('error 1', 'ERR1');
const error2 = new SemanticReleaseError('error 2', 'ERR2'); const error2 = new SemanticReleaseError('error 2', 'ERR2');
const fail = stub().resolves(); const fail = sinon.stub().resolves();
const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
const options = { const options = {
...config, ...config,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
analyzeCommits: stub().resolves('major'), analyzeCommits: sinon.stub().resolves('major'),
verifyRelease: [stub().rejects(error1), stub().rejects(error2)], verifyRelease: [sinon.stub().rejects(error1), sinon.stub().rejects(error2)],
fail, fail,
}; };
@ -1011,14 +1013,14 @@ test('Dry-run skips addChannel, prepare, publish and success', async (t) => {
await gitCheckout('next', true, {cwd}); await gitCheckout('next', true, {cwd});
await gitPush('origin', 'next', {cwd}); await gitPush('origin', 'next', {cwd});
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const analyzeCommits = stub().resolves('minor'); const analyzeCommits = sinon.stub().resolves('minor');
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves(); const generateNotes = sinon.stub().resolves();
const addChannel = stub().resolves(); const addChannel = sinon.stub().resolves();
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const options = { const options = {
dryRun: true, dryRun: true,
@ -1077,13 +1079,13 @@ test('Dry-run skips fail', async (t) => {
const error1 = new SemanticReleaseError('error 1', 'ERR1'); const error1 = new SemanticReleaseError('error 1', 'ERR1');
const error2 = new SemanticReleaseError('error 2', 'ERR2'); const error2 = new SemanticReleaseError('error 2', 'ERR2');
const fail = stub().resolves(); const fail = sinon.stub().resolves();
const options = { const options = {
dryRun: true, dryRun: true,
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: [stub().rejects(error1), stub().rejects(error2)], verifyConditions: [sinon.stub().rejects(error1), sinon.stub().rejects(error2)],
fail, fail,
}; };
@ -1125,12 +1127,12 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t
}; };
const notes = 'Release notes'; const notes = 'Release notes';
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves(notes); const generateNotes = sinon.stub().resolves(notes);
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const options = { const options = {
dryRun: false, dryRun: false,
@ -1140,11 +1142,11 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t
analyzeCommits, analyzeCommits,
verifyRelease, verifyRelease,
generateNotes, generateNotes,
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish, publish,
success, success,
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1181,8 +1183,8 @@ test('Dry-run does not print changelog if "generateNotes" return "undefined"', a
await gitPush(repositoryUrl, 'master', {cwd}); await gitPush(repositoryUrl, 'master', {cwd});
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead({cwd}), gitTag: 'v2.0.0'}; const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead({cwd}), gitTag: 'v2.0.0'};
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const generateNotes = stub().resolves(); const generateNotes = sinon.stub().resolves();
const options = { const options = {
dryRun: true, dryRun: true,
@ -1234,12 +1236,12 @@ test('Allow local releases with "noCi" option', async (t) => {
}; };
const notes = 'Release notes'; const notes = 'Release notes';
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves(notes); const generateNotes = sinon.stub().resolves(notes);
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const options = { const options = {
noCi: true, noCi: true,
@ -1249,11 +1251,11 @@ test('Allow local releases with "noCi" option', async (t) => {
analyzeCommits, analyzeCommits,
verifyRelease, verifyRelease,
generateNotes, generateNotes,
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish, publish,
success, success,
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1303,27 +1305,27 @@ test('Accept "undefined" value returned by "generateNotes" and "false" by "publi
gitTag: 'v1.2.0', gitTag: 'v1.2.0',
channel: null, channel: null,
}; };
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes1 = stub().resolves(); const generateNotes1 = sinon.stub().resolves();
const notes2 = 'Release notes 2'; const notes2 = 'Release notes 2';
const generateNotes2 = stub().resolves(notes2); const generateNotes2 = sinon.stub().resolves(notes2);
const publish = stub().resolves(false); const publish = sinon.stub().resolves(false);
const addChannel = stub().resolves(false); const addChannel = sinon.stub().resolves(false);
const success = stub().resolves(); const success = sinon.stub().resolves();
const options = { const options = {
branches: ['master', 'next'], branches: ['master', 'next'],
repositoryUrl, repositoryUrl,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
analyzeCommits, analyzeCommits,
verifyRelease, verifyRelease,
generateNotes: [generateNotes1, generateNotes2], generateNotes: [generateNotes1, generateNotes2],
addChannel, addChannel,
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish, publish,
success, success,
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1386,12 +1388,12 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
await gitCommits(['feat: feature on maintenance version 1.x'], {cwd}); await gitCommits(['feat: feature on maintenance version 1.x'], {cwd});
await gitPush('origin', 'master', {cwd}); await gitPush('origin', 'master', {cwd});
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const addChannel = stub().resolves(); const addChannel = sinon.stub().resolves();
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const config = { const config = {
branches: [{name: '1.x'}, {name: 'master'}], branches: [{name: '1.x'}, {name: 'master'}],
@ -1438,12 +1440,12 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
await gitCommits(['feat: new feature on master', 'fix: new fix on master'], {cwd}); await gitCommits(['feat: new feature on master', 'fix: new fix on master'], {cwd});
await gitPush('origin', 'master', {cwd}); await gitPush('origin', 'master', {cwd});
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const addChannel = stub().resolves(); const addChannel = sinon.stub().resolves();
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const config = { const config = {
branches: [{name: 'master'}, {name: 'next'}, {name: 'next-major'}], branches: [{name: 'master'}, {name: 'next'}, {name: 'next-major'}],
@ -1496,15 +1498,15 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma
await gitPush('origin', '1.1.x', {cwd}); await gitPush('origin', '1.1.x', {cwd});
const notes = 'Release notes'; const notes = 'Release notes';
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const analyzeCommits = stub().resolves(); const analyzeCommits = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves(notes); const generateNotes = sinon.stub().resolves(notes);
const addChannel = stub().resolves(); const addChannel = sinon.stub().resolves();
const prepare = stub().resolves(); const prepare = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const success = stub().resolves(); const success = sinon.stub().resolves();
const fail = stub().resolves(); const fail = sinon.stub().resolves();
const config = {branches: [{name: 'master'}, {name: '1.1.x'}], repositoryUrl, tagFormat: `v\${version}`}; const config = {branches: [{name: 'master'}, {name: '1.1.x'}], repositoryUrl, tagFormat: `v\${version}`};
const options = { const options = {
@ -1579,15 +1581,15 @@ test('Returns false if not running from the configured branch', async (t) => {
const options = { const options = {
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
analyzeCommits: stub().resolves(), analyzeCommits: sinon.stub().resolves(),
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(), generateNotes: sinon.stub().resolves(),
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1616,23 +1618,23 @@ test('Returns false if there is no relevant changes', async (t) => {
await gitCommits(['First'], {cwd}); await gitCommits(['First'], {cwd});
await gitPush(repositoryUrl, 'master', {cwd}); await gitPush(repositoryUrl, 'master', {cwd});
const analyzeCommits = stub().resolves(); const analyzeCommits = sinon.stub().resolves();
const verifyRelease = stub().resolves(); const verifyRelease = sinon.stub().resolves();
const generateNotes = stub().resolves(); const generateNotes = sinon.stub().resolves();
const publish = stub().resolves(); const publish = sinon.stub().resolves();
const options = { const options = {
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: [stub().resolves()], verifyConditions: [sinon.stub().resolves()],
analyzeCommits, analyzeCommits,
verifyRelease, verifyRelease,
generateNotes, generateNotes,
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish, publish,
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1676,19 +1678,19 @@ test('Exclude commits with [skip release] or [release skip] from analysis', asyn
{cwd} {cwd}
); );
await gitPush(repositoryUrl, 'master', {cwd}); await gitPush(repositoryUrl, 'master', {cwd});
const analyzeCommits = stub().resolves(); const analyzeCommits = sinon.stub().resolves();
const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'}; const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'};
const options = { const options = {
...config, ...config,
verifyConditions: [stub().resolves(), stub().resolves()], verifyConditions: [sinon.stub().resolves(), sinon.stub().resolves()],
analyzeCommits, analyzeCommits,
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(), generateNotes: sinon.stub().resolves(),
addChannel: stub().resolves(), addChannel: sinon.stub().resolves(),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1716,8 +1718,8 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) =>
const options = { const options = {
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: stub().rejects(pluginError), verifyConditions: sinon.stub().rejects(pluginError),
fail: [stub().rejects(failError1), stub().rejects(failError2)], fail: [sinon.stub().rejects(failError1), sinon.stub().rejects(failError2)],
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
'./lib/get-logger': () => t.context.logger, './lib/get-logger': () => t.context.logger,
@ -1736,12 +1738,12 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) =>
test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => { test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true); const {cwd, repositoryUrl} = await gitRepo(true);
const pluginError = new Error('Plugin error'); const pluginError = new Error('Plugin error');
const fail = stub().resolves(); const fail = sinon.stub().resolves();
const options = { const options = {
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: stub().rejects(pluginError), verifyConditions: sinon.stub().rejects(pluginError),
fail, fail,
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1789,16 +1791,16 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => {
await gitCommits(['Second'], {cwd}); await gitCommits(['Second'], {cwd});
await gitPush(repositoryUrl, 'master', {cwd}); await gitPush(repositoryUrl, 'master', {cwd});
const verifyConditions = stub().resolves(); const verifyConditions = sinon.stub().resolves();
const analyzeCommits = stub().resolves('string'); const analyzeCommits = sinon.stub().resolves('string');
const options = { const options = {
branches: ['master'], branches: ['master'],
repositoryUrl, repositoryUrl,
verifyConditions: [verifyConditions], verifyConditions: [verifyConditions],
analyzeCommits, analyzeCommits,
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1815,19 +1817,19 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => {
test('Hide sensitive information passed to "fail" plugin', async (t) => { test('Hide sensitive information passed to "fail" plugin', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true); const {cwd, repositoryUrl} = await gitRepo(true);
const fail = stub().resolves(); const fail = sinon.stub().resolves();
const env = {MY_TOKEN: 'secret token'}; const env = {MY_TOKEN: 'secret token'};
const options = { const options = {
branch: 'master', branch: 'master',
repositoryUrl, repositoryUrl,
verifyConditions: stub().throws( verifyConditions: sinon.stub().throws(
new SemanticReleaseError( new SemanticReleaseError(
`Message: Exposing token ${env.MY_TOKEN}`, `Message: Exposing token ${env.MY_TOKEN}`,
'ERR', 'ERR',
`Details: Exposing token ${env.MY_TOKEN}` `Details: Exposing token ${env.MY_TOKEN}`
) )
), ),
success: stub().resolves(), success: sinon.stub().resolves(),
fail, fail,
}; };
@ -1858,7 +1860,7 @@ test('Hide sensitive information passed to "success" plugin', async (t) => {
await gitCommits(['feat: new feature'], {cwd}); await gitCommits(['feat: new feature'], {cwd});
await gitPush(repositoryUrl, 'master', {cwd}); await gitPush(repositoryUrl, 'master', {cwd});
const success = stub().resolves(); const success = sinon.stub().resolves();
const env = {MY_TOKEN: 'secret token'}; const env = {MY_TOKEN: 'secret token'};
const options = { const options = {
branch: 'master', branch: 'master',
@ -1866,14 +1868,14 @@ test('Hide sensitive information passed to "success" plugin', async (t) => {
verifyConditions: false, verifyConditions: false,
verifyRelease: false, verifyRelease: false,
prepare: false, prepare: false,
generateNotes: stub().resolves(`Exposing token ${env.MY_TOKEN}`), generateNotes: sinon.stub().resolves(`Exposing token ${env.MY_TOKEN}`),
publish: stub().resolves({ publish: sinon.stub().resolves({
name: `Name: Exposing token ${env.MY_TOKEN}`, name: `Name: Exposing token ${env.MY_TOKEN}`,
url: `URL: Exposing token ${env.MY_TOKEN}`, url: `URL: Exposing token ${env.MY_TOKEN}`,
}), }),
addChannel: false, addChannel: false,
success, success,
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {
@ -1911,19 +1913,19 @@ test('Get all commits including the ones not in the shallow clone', async (t) =>
channel: undefined, channel: undefined,
}; };
const notes = 'Release notes'; const notes = 'Release notes';
const analyzeCommits = stub().resolves(nextRelease.type); const analyzeCommits = sinon.stub().resolves(nextRelease.type);
const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'}; const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'};
const options = { const options = {
...config, ...config,
verifyConditions: stub().resolves(), verifyConditions: sinon.stub().resolves(),
analyzeCommits, analyzeCommits,
verifyRelease: stub().resolves(), verifyRelease: sinon.stub().resolves(),
generateNotes: stub().resolves(notes), generateNotes: sinon.stub().resolves(notes),
prepare: stub().resolves(), prepare: sinon.stub().resolves(),
publish: stub().resolves(), publish: sinon.stub().resolves(),
success: stub().resolves(), success: sinon.stub().resolves(),
fail: stub().resolves(), fail: sinon.stub().resolves(),
}; };
const semanticRelease = requireNoCache('..', { const semanticRelease = requireNoCache('..', {

View File

@ -1,14 +1,16 @@
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 lodash from 'lodash'
const {writeJson, readJson} = require('fs-extra'); const {escapeRegExp} = lodash
const execa = require('execa'); import {writeJson, readJson} from 'fs-extra';
const {WritableStreamBuffer} = require('stream-buffers'); import execa from 'execa';
const delay = require('delay'); import {WritableStreamBuffer} from 'stream-buffers';
const getAuthUrl = require('../lib/get-git-auth-url'); import delay from 'delay';
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants'); import getAuthUrl from '../lib/get-git-auth-url.js';
const { import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
import {
gitHead, gitHead,
gitTagHead, gitTagHead,
gitRepo, gitRepo,
@ -18,11 +20,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"}] */

View File

@ -1,16 +1,17 @@
const test = require('ava'); import test from 'ava';
const {noop} = require('lodash'); import lodash from 'lodash'
const {stub} = require('sinon'); const {noop} = lodash
const normalize = require('../../lib/plugins/normalize'); import sinon from 'sinon';
import normalize from '../../lib/plugins/normalize.js';
const cwd = process.cwd(); const cwd = process.cwd();
test.beforeEach((t) => { test.beforeEach((t) => {
// Stub the logger functions // Stub the logger functions
t.context.log = stub(); t.context.log = sinon.stub);
t.context.error = stub(); t.context.error = sinon.stub);
t.context.success = stub(); t.context.success = sinon.stub);
t.context.stderr = {write: stub()}; t.context.stderr = {write: sinon.stub)};
t.context.logger = { t.context.logger = {
log: t.context.log, log: t.context.log,
error: t.context.error, error: t.context.error,
@ -99,7 +100,7 @@ test('Normalize and load plugin that retuns multiple functions', (t) => {
}); });
test('Wrap "analyzeCommits" plugin in a function that validate the output of the plugin', async (t) => { test('Wrap "analyzeCommits" plugin in a function that validate the output of the plugin', async (t) => {
const analyzeCommits = stub().resolves(2); const analyzeCommits = sinon.stub).resolves(2);
const plugin = normalize( const plugin = normalize(
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
'analyzeCommits', 'analyzeCommits',
@ -117,7 +118,7 @@ test('Wrap "analyzeCommits" plugin in a function that validate the output of the
}); });
test('Wrap "generateNotes" plugin in a function that validate the output of the plugin', async (t) => { test('Wrap "generateNotes" plugin in a function that validate the output of the plugin', async (t) => {
const generateNotes = stub().resolves(2); const generateNotes = sinon.stub).resolves(2);
const plugin = normalize( const plugin = normalize(
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
'generateNotes', 'generateNotes',
@ -135,7 +136,7 @@ test('Wrap "generateNotes" plugin in a function that validate the output of the
}); });
test('Wrap "publish" plugin in a function that validate the output of the plugin', async (t) => { test('Wrap "publish" plugin in a function that validate the output of the plugin', async (t) => {
const publish = stub().resolves(2); const publish = sinon.stub).resolves(2);
const plugin = normalize( const plugin = normalize(
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
'publish', 'publish',
@ -153,7 +154,7 @@ test('Wrap "publish" plugin in a function that validate the output of the plugin
}); });
test('Wrap "addChannel" plugin in a function that validate the output of the plugin', async (t) => { test('Wrap "addChannel" plugin in a function that validate the output of the plugin', async (t) => {
const addChannel = stub().resolves(2); const addChannel = sinon.stub).resolves(2);
const plugin = normalize( const plugin = normalize(
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
'addChannel', 'addChannel',
@ -171,7 +172,7 @@ test('Wrap "addChannel" plugin in a function that validate the output of the plu
}); });
test('Plugin is called with "pluginConfig" (with object definition) and input', async (t) => { test('Plugin is called with "pluginConfig" (with object definition) and input', async (t) => {
const pluginFunction = stub().resolves(); const pluginFunction = sinon.stub).resolves();
const pluginConf = {path: pluginFunction, conf: 'confValue'}; const pluginConf = {path: pluginFunction, conf: 'confValue'};
const options = {global: 'globalValue'}; const options = {global: 'globalValue'};
const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {}); const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {});
@ -186,7 +187,7 @@ test('Plugin is called with "pluginConfig" (with object definition) and input',
}); });
test('Plugin is called with "pluginConfig" (with array definition) and input', async (t) => { test('Plugin is called with "pluginConfig" (with array definition) and input', async (t) => {
const pluginFunction = stub().resolves(); const pluginFunction = sinon.stub).resolves();
const pluginConf = [pluginFunction, {conf: 'confValue'}]; const pluginConf = [pluginFunction, {conf: 'confValue'}];
const options = {global: 'globalValue'}; const options = {global: 'globalValue'};
const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {}); const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {});
@ -201,7 +202,7 @@ test('Plugin is called with "pluginConfig" (with array definition) and input', a
}); });
test('Prevent plugins to modify "pluginConfig"', async (t) => { test('Prevent plugins to modify "pluginConfig"', async (t) => {
const pluginFunction = stub().callsFake((pluginConfig) => { const pluginFunction = sinon.stub).callsFake((pluginConfig) => {
pluginConfig.conf.subConf = 'otherConf'; pluginConfig.conf.subConf = 'otherConf';
}); });
const pluginConf = {path: pluginFunction, conf: {subConf: 'originalConf'}}; const pluginConf = {path: pluginFunction, conf: {subConf: 'originalConf'}};
@ -214,7 +215,7 @@ test('Prevent plugins to modify "pluginConfig"', async (t) => {
}); });
test('Prevent plugins to modify its input', async (t) => { test('Prevent plugins to modify its input', async (t) => {
const pluginFunction = stub().callsFake((pluginConfig, options) => { const pluginFunction = sinon.stub).callsFake((pluginConfig, options) => {
options.param.subParam = 'otherParam'; options.param.subParam = 'otherParam';
}); });
const input = {param: {subParam: 'originalSubParam'}, options: {}}; const input = {param: {subParam: 'originalSubParam'}, options: {}};

View File

@ -1,12 +1,12 @@
const test = require('ava'); import test from 'ava';
const {stub} = require('sinon'); import sinon 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 = sinon.stub).resolves(1);
const step2 = stub().resolves(2); const step2 = sinon.stub).resolves(2);
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const result = await pipeline([step1, step2, step3])(0); const result = await pipeline([step1, step2, step3])(0);
t.deepEqual(result, [1, 2, 3]); t.deepEqual(result, [1, 2, 3]);
@ -19,10 +19,10 @@ test('Execute each function in series passing the same input', async (t) => {
}); });
test('Execute each function in series passing a transformed input from "getNextInput"', async (t) => { test('Execute each function in series passing a transformed input from "getNextInput"', async (t) => {
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().resolves(2); const step2 = sinon.stub).resolves(2);
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const step4 = stub().resolves(4); const step4 = sinon.stub).resolves(4);
const getNextInput = (lastResult, result) => lastResult + result; const getNextInput = (lastResult, result) => lastResult + result;
const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(0); const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(0);
@ -38,11 +38,11 @@ test('Execute each function in series passing a transformed input from "getNextI
}); });
test('Execute each function in series passing the "lastResult" and "result" to "getNextInput"', async (t) => { test('Execute each function in series passing the "lastResult" and "result" to "getNextInput"', async (t) => {
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().resolves(2); const step2 = sinon.stub).resolves(2);
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const step4 = stub().resolves(4); const step4 = sinon.stub).resolves(4);
const getNextInput = stub().returnsArg(0); const getNextInput = sinon.stub).returnsArg(0);
const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5); const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5);
@ -56,12 +56,12 @@ test('Execute each function in series passing the "lastResult" and "result" to "
}); });
test('Execute each function in series calling "transform" to modify the results', async (t) => { test('Execute each function in series calling "transform" to modify the results', async (t) => {
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().resolves(2); const step2 = sinon.stub).resolves(2);
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const step4 = stub().resolves(4); const step4 = sinon.stub).resolves(4);
const getNextInput = stub().returnsArg(0); const getNextInput = sinon.stub).returnsArg(0);
const transform = stub().callsFake((result) => result + 1); const transform = sinon.stub).callsFake((result) => result + 1);
const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5); const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5);
@ -75,12 +75,12 @@ test('Execute each function in series calling "transform" to modify the results'
}); });
test('Execute each function in series calling "transform" to modify the results with "settleAll"', async (t) => { test('Execute each function in series calling "transform" to modify the results with "settleAll"', async (t) => {
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().resolves(2); const step2 = sinon.stub).resolves(2);
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const step4 = stub().resolves(4); const step4 = sinon.stub).resolves(4);
const getNextInput = stub().returnsArg(0); const getNextInput = sinon.stub).returnsArg(0);
const transform = stub().callsFake((result) => result + 1); const transform = sinon.stub).callsFake((result) => result + 1);
const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5); const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5);
@ -94,9 +94,9 @@ test('Execute each function in series calling "transform" to modify the results
}); });
test('Stop execution and throw error if a step rejects', async (t) => { test('Stop execution and throw error if a step rejects', async (t) => {
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().rejects(new Error('test error')); const step2 = sinon.stub).rejects(new Error('test error'));
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), { const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), {
instanceOf: Error, instanceOf: Error,
@ -112,9 +112,9 @@ test('Throw all errors from the first step throwing an AggregateError', async (t
const error1 = new Error('test error 1'); const error1 = new Error('test error 1');
const error2 = new Error('test error 2'); const error2 = new Error('test error 2');
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().rejects(new AggregateError([error1, error2])); const step2 = sinon.stub).rejects(new AggregateError([error1, error2]));
const step3 = stub().resolves(3); const step3 = sinon.stub).resolves(3);
const errors = await t.throwsAsync(pipeline([step1, step2, step3])(0)); const errors = await t.throwsAsync(pipeline([step1, step2, step3])(0));
@ -127,9 +127,9 @@ test('Throw all errors from the first step throwing an AggregateError', async (t
test('Execute all even if a Promise rejects', async (t) => { test('Execute all even if a Promise rejects', async (t) => {
const error1 = new Error('test error 1'); const error1 = new Error('test error 1');
const error2 = new Error('test error 2'); const error2 = new Error('test error 2');
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().rejects(error1); const step2 = sinon.stub).rejects(error1);
const step3 = stub().rejects(error2); const step3 = sinon.stub).rejects(error2);
const errors = await t.throwsAsync(pipeline([step1, step2, step3], {settleAll: true})(0)); const errors = await t.throwsAsync(pipeline([step1, step2, step3], {settleAll: true})(0));
@ -144,8 +144,8 @@ test('Throw all errors from all steps throwing an AggregateError', async (t) =>
const error2 = new Error('test error 2'); const error2 = new Error('test error 2');
const error3 = new Error('test error 3'); const error3 = new Error('test error 3');
const error4 = new Error('test error 4'); const error4 = new Error('test error 4');
const step1 = stub().rejects(new AggregateError([error1, error2])); const step1 = sinon.stub).rejects(new AggregateError([error1, error2]));
const step2 = stub().rejects(new AggregateError([error3, error4])); const step2 = sinon.stub).rejects(new AggregateError([error3, error4]));
const errors = await t.throwsAsync(pipeline([step1, step2], {settleAll: true})(0)); const errors = await t.throwsAsync(pipeline([step1, step2], {settleAll: true})(0));
@ -157,10 +157,10 @@ test('Throw all errors from all steps throwing an AggregateError', async (t) =>
test('Execute each function in series passing a transformed input even if a step rejects', async (t) => { test('Execute each function in series passing a transformed input even if a step rejects', async (t) => {
const error2 = new Error('test error 2'); const error2 = new Error('test error 2');
const error3 = new Error('test error 3'); const error3 = new Error('test error 3');
const step1 = stub().resolves(1); const step1 = sinon.stub).resolves(1);
const step2 = stub().rejects(error2); const step2 = sinon.stub).rejects(error2);
const step3 = stub().rejects(error3); const step3 = sinon.stub).rejects(error3);
const step4 = stub().resolves(4); const step4 = sinon.stub).resolves(4);
const getNextInput = (previousResult, result) => previousResult + result; const getNextInput = (previousResult, result) => previousResult + result;
const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0)); const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0));

View File

@ -1,17 +1,17 @@
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 sinon 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();
test.beforeEach((t) => { test.beforeEach((t) => {
// Stub the logger functions // Stub the logger functions
t.context.log = stub(); t.context.log = sinon.stub);
t.context.success = stub(); t.context.success = sinon.stub);
t.context.logger = {log: t.context.log, success: t.context.success, scope: () => t.context.logger}; t.context.logger = {log: t.context.log, success: t.context.success, scope: () => t.context.logger};
}); });
@ -56,8 +56,8 @@ test('Export plugins based on steps config', (t) => {
}); });
test('Export plugins based on "plugins" config (array)', async (t) => { test('Export plugins based on "plugins" config (array)', async (t) => {
const plugin1 = {verifyConditions: stub(), publish: stub()}; const plugin1 = {verifyConditions: sinon.stub), publish: sinon.stub)};
const plugin2 = {verifyConditions: stub(), verifyRelease: stub()}; const plugin2 = {verifyConditions: sinon.stub), verifyRelease: sinon.stub)};
const plugins = getPlugins( const plugins = getPlugins(
{cwd, logger: t.context.logger, options: {plugins: [plugin1, [plugin2, {}]], verifyRelease: () => {}}}, {cwd, logger: t.context.logger, options: {plugins: [plugin1, [plugin2, {}]], verifyRelease: () => {}}},
{} {}
@ -85,7 +85,7 @@ test('Export plugins based on "plugins" config (array)', async (t) => {
}); });
test('Export plugins based on "plugins" config (single definition)', async (t) => { test('Export plugins based on "plugins" config (single definition)', async (t) => {
const plugin1 = {verifyConditions: stub(), publish: stub()}; const plugin1 = {verifyConditions: sinon.stub), publish: sinon.stub)};
const plugins = getPlugins({cwd, logger: t.context.logger, options: {plugins: plugin1}}, {}); const plugins = getPlugins({cwd, logger: t.context.logger, options: {plugins: plugin1}}, {});
await plugins.verifyConditions({options: {}}); await plugins.verifyConditions({options: {}});
@ -106,8 +106,8 @@ test('Export plugins based on "plugins" config (single definition)', async (t) =
}); });
test('Merge global options, "plugins" options and step options', async (t) => { test('Merge global options, "plugins" options and step options', async (t) => {
const plugin1 = [{verifyConditions: stub(), publish: stub()}, {pluginOpt1: 'plugin1'}]; const plugin1 = [{verifyConditions: sinon.stub), publish: sinon.stub)}, {pluginOpt1: 'plugin1'}];
const plugin2 = [{verifyConditions: stub()}, {pluginOpt2: 'plugin2'}]; const plugin2 = [{verifyConditions: sinon.stub)}, {pluginOpt2: 'plugin2'}];
const plugin3 = [stub(), {pluginOpt3: 'plugin3'}]; const plugin3 = [stub(), {pluginOpt3: 'plugin3'}];
const plugins = getPlugins( const plugins = getPlugins(
{ {

View File

@ -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';

View File

@ -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')];

View File

@ -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();