Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45695b9183 | ||
|
|
3c7b114eed | ||
|
|
f2b5826c0c | ||
|
|
c48bd3ac36 | ||
|
|
bc97537c97 | ||
|
|
c7e461dc1c | ||
|
|
ef1b8a0b91 | ||
|
|
bec57cd2ed | ||
|
|
c6b10766a7 |
@@ -1,3 +1,3 @@
|
|||||||
node_js:
|
node_js:
|
||||||
- 12
|
- 12
|
||||||
- 10.13
|
- 10.18
|
||||||
|
|||||||
@@ -101,7 +101,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.13 or higher](docs/support/FAQ.md#why-does-semantic-release-require-node-version--1013) 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
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|||||||
@@ -95,3 +95,7 @@
|
|||||||
- `verifyConditions`: Checks the project.clj is syntactically valid.
|
- `verifyConditions`: Checks the project.clj is syntactically valid.
|
||||||
- `prepare`: Update the project.clj version and package the output jar file.
|
- `prepare`: Update the project.clj version and package the output jar file.
|
||||||
- `publish`: Publish the jar (and generated Maven metadata) to a maven repository (or clojars).
|
- `publish`: Publish the jar (and generated Maven metadata) to a maven repository (or clojars).
|
||||||
|
- [@saithodev/semantic-release-gitea](https://github.com/saitho/semantic-release-gitea)
|
||||||
|
- `verifyConditions`: Verify the presence and the validity of the authentication and the assets option configuration.
|
||||||
|
- `publish`: Publish a Gitea release, optionally uploading file assets.
|
||||||
|
- `addChannel`: Update a Gitea release's pre-release field.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ In this example an [`NPM_TOKEN`](https://docs.npmjs.com/creating-and-viewing-aut
|
|||||||
|
|
||||||
[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.13](../support/FAQ.md#why-does-semantic-release-require-node-version--1013).
|
**Note**: The publish pipeline must run on [Node version >= 10.18](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
|
||||||
|
|
||||||
### `.github/workflows/release.yml` configuration for Node projects
|
### `.github/workflows/release.yml` configuration for Node projects
|
||||||
|
|
||||||
|
|||||||
@@ -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.13 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1013).
|
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
|
||||||
|
|
||||||
### `.gitlab-ci.yml` configuration for Node projects
|
### `.gitlab-ci.yml` configuration for Node projects
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -38,7 +38,7 @@ Yes with the [dry-run options](../usage/configuration.md#dryrun) which prints to
|
|||||||
|
|
||||||
## Can I use semantic-release with Yarn?
|
## 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.13](#why-does-semantic-release-require-node-version--1013) and specifies it in its `package.json`s [`engines`](https://docs.npmjs.com/files/package.json#engines) key.
|
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:
|
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:
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ $ 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`.
|
**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.13.
|
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:
|
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:
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ Yes, **semantic-release** is a Node CLI application but it can be used to publis
|
|||||||
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.13](#why-does-semantic-release-require-node-version--1013) to execute the `semantic-release` command
|
- 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
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@@ -232,9 +232,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.13?
|
## Why does semantic-release require Node version >= 10.18?
|
||||||
|
|
||||||
**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.13 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 10.18 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.
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ See our [Node Support Policy](node-support-policy.md) for our long-term promise
|
|||||||
|
|
||||||
## Recommended solution
|
## Recommended solution
|
||||||
|
|
||||||
### Run at least one CI job with Node >= 10.13
|
### Run at least one CI job with Node >= 10.18
|
||||||
|
|
||||||
The recommended approach is to run the `semantic-release` command from a CI job running on Node 10.13 or higher. This can either be a job used by your project to test on Node >= 10.13 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 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.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -65,8 +65,8 @@ async function getCommits(from, to, execaOpts) {
|
|||||||
async function getBranches(repositoryUrl, execaOpts) {
|
async function getBranches(repositoryUrl, execaOpts) {
|
||||||
return (await execa('git', ['ls-remote', '--heads', repositoryUrl], execaOpts)).stdout
|
return (await execa('git', ['ls-remote', '--heads', repositoryUrl], execaOpts)).stdout
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(branch => branch.match(/^.+refs\/heads\/(?<branch>.+)$/)[1])
|
.filter(Boolean)
|
||||||
.filter(Boolean);
|
.map(branch => branch.match(/^.+refs\/heads\/(?<branch>.+)$/)[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+7
-9
@@ -7,9 +7,7 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"test/**/*.test.js"
|
"test/**/*.test.js"
|
||||||
],
|
],
|
||||||
"helpers": [
|
"timeout": "2m"
|
||||||
"test/helpers/**/*"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"semantic-release": "bin/semantic-release.js"
|
"semantic-release": "bin/semantic-release.js"
|
||||||
@@ -22,11 +20,11 @@
|
|||||||
"Pierre Vanduynslager (https://twitter.com/@pvdlg_)"
|
"Pierre Vanduynslager (https://twitter.com/@pvdlg_)"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@semantic-release/commit-analyzer": "^7.0.0",
|
"@semantic-release/commit-analyzer": "^8.0.0",
|
||||||
"@semantic-release/error": "^2.2.0",
|
"@semantic-release/error": "^2.2.0",
|
||||||
"@semantic-release/github": "^6.0.0",
|
"@semantic-release/github": "^7.0.0",
|
||||||
"@semantic-release/npm": "^6.0.0",
|
"@semantic-release/npm": "^7.0.0",
|
||||||
"@semantic-release/release-notes-generator": "^7.1.2",
|
"@semantic-release/release-notes-generator": "^9.0.0",
|
||||||
"aggregate-error": "^3.0.0",
|
"aggregate-error": "^3.0.0",
|
||||||
"cosmiconfig": "^6.0.0",
|
"cosmiconfig": "^6.0.0",
|
||||||
"debug": "^4.0.0",
|
"debug": "^4.0.0",
|
||||||
@@ -52,7 +50,7 @@
|
|||||||
"yargs": "^15.0.1"
|
"yargs": "^15.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^2.0.0",
|
"ava": "^3.1.0",
|
||||||
"clear-module": "^4.0.0",
|
"clear-module": "^4.0.0",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
"delay": "^4.0.0",
|
"delay": "^4.0.0",
|
||||||
@@ -72,7 +70,7 @@
|
|||||||
"xo": "^0.25.0"
|
"xo": "^0.25.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13"
|
"node": ">=10.18"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"bin",
|
"bin",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {union} from 'lodash';
|
const {union} = require('lodash');
|
||||||
import semver from 'semver';
|
const semver = require('semver');
|
||||||
import proxyquire from 'proxyquire';
|
const proxyquire = require('proxyquire');
|
||||||
|
|
||||||
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
|
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
|
||||||
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
|
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import expand from '../../lib/branches/expand';
|
const expand = require('../../lib/branches/expand');
|
||||||
import {gitRepo, gitCommits, gitCheckout, gitPush} from '../helpers/git-utils';
|
const {gitRepo, gitCommits, gitCheckout, gitPush} = require('../helpers/git-utils');
|
||||||
|
|
||||||
test('Expand branches defined with globs', async t => {
|
test('Expand branches defined with globs', async t => {
|
||||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import getTags from '../../lib/branches/get-tags';
|
const getTags = require('../../lib/branches/get-tags');
|
||||||
import {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} from '../helpers/git-utils';
|
const {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} = require('../helpers/git-utils');
|
||||||
|
|
||||||
test('Get the valid tags', async t => {
|
test('Get the valid tags', async t => {
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import normalize from '../../lib/branches/normalize';
|
const normalize = require('../../lib/branches/normalize');
|
||||||
|
|
||||||
const toTags = versions => versions.map(version => ({version}));
|
const toTags = versions => versions.map(version => ({version}));
|
||||||
|
|
||||||
|
|||||||
+15
-17
@@ -1,10 +1,8 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {escapeRegExp} from 'lodash';
|
const {escapeRegExp} = require('lodash');
|
||||||
import proxyquire from 'proxyquire';
|
const proxyquire = require('proxyquire').noPreserveCache();
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import {SECRET_REPLACEMENT} from '../lib/definitions/constants';
|
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
||||||
|
|
||||||
const requireNoCache = proxyquire.noPreserveCache();
|
|
||||||
|
|
||||||
test.beforeEach(t => {
|
test.beforeEach(t => {
|
||||||
t.context.logs = '';
|
t.context.logs = '';
|
||||||
@@ -65,7 +63,7 @@ test.serial('Pass options to semantic-release API', async t => {
|
|||||||
'--debug',
|
'--debug',
|
||||||
'-d',
|
'-d',
|
||||||
];
|
];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -107,7 +105,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async t
|
|||||||
'config2',
|
'config2',
|
||||||
'--dry-run',
|
'--dry-run',
|
||||||
];
|
];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -124,7 +122,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async t
|
|||||||
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 = 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 = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -138,7 +136,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 = stub().resolves(true);
|
||||||
const argv = ['', '', '--publish', 'false'];
|
const argv = ['', '', '--publish', 'false'];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -150,7 +148,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 = stub().resolves(true);
|
||||||
const argv = ['', '', '-b', 'master'];
|
const argv = ['', '', '-b', 'master'];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
await cli();
|
await cli();
|
||||||
|
|
||||||
@@ -167,7 +165,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 = stub().resolves(true);
|
||||||
const argv = ['', '', '--help'];
|
const argv = ['', '', '--help'];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -178,7 +176,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 = stub().resolves(true);
|
||||||
const argv = ['', '', 'pre'];
|
const argv = ['', '', 'pre'];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -190,7 +188,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 = stub().resolves(true);
|
||||||
const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2'];
|
const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2'];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -202,7 +200,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 = stub().rejects(new Error('semantic-release error'));
|
||||||
const argv = ['', ''];
|
const argv = ['', ''];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
@@ -214,7 +212,7 @@ 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 = stub().rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`));
|
||||||
const argv = ['', ''];
|
const argv = ['', ''];
|
||||||
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}});
|
const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}});
|
||||||
|
|
||||||
const exitCode = await cli();
|
const exitCode = await cli();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {maintenance, prerelease, release} from '../../lib/definitions/branches';
|
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');
|
||||||
|
|
||||||
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', t => {
|
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', t => {
|
||||||
t.true(maintenance.filter({name: '1.x.x'}));
|
t.true(maintenance.filter({name: '1.x.x'}));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import plugins from '../../lib/definitions/plugins';
|
const plugins = require('../../lib/definitions/plugins');
|
||||||
import {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} from '../../lib/definitions/constants';
|
const {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} = require('../../lib/definitions/constants');
|
||||||
|
|
||||||
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'));
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import getCommits from '../lib/get-commits';
|
const getCommits = require('../lib/get-commits');
|
||||||
import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils';
|
const {gitRepo, gitCommits, gitDetachedHead} = require('./helpers/git-utils');
|
||||||
|
|
||||||
test.beforeEach(t => {
|
test.beforeEach(t => {
|
||||||
// Stub the logger functions
|
// Stub the logger functions
|
||||||
|
|||||||
+13
-13
@@ -1,12 +1,12 @@
|
|||||||
import path from 'path';
|
const path = require('path');
|
||||||
import {format} from 'util';
|
const {format} = require('util');
|
||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {writeFile, outputJson} from 'fs-extra';
|
const {writeFile, outputJson} = require('fs-extra');
|
||||||
import {omit} from 'lodash';
|
const {omit} = require('lodash');
|
||||||
import proxyquire from 'proxyquire';
|
const proxyquire = require('proxyquire');
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import yaml from 'js-yaml';
|
const yaml = require('js-yaml');
|
||||||
import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils';
|
const {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} = require('./helpers/git-utils');
|
||||||
|
|
||||||
const DEFAULT_PLUGINS = [
|
const DEFAULT_PLUGINS = [
|
||||||
'@semantic-release/commit-analyzer',
|
'@semantic-release/commit-analyzer',
|
||||||
@@ -511,8 +511,8 @@ test('Throw an Error if one of the shareable config cannot be found', async t =>
|
|||||||
await outputJson(path.resolve(cwd, 'package.json'), {release: pkhOptions});
|
await outputJson(path.resolve(cwd, 'package.json'), {release: pkhOptions});
|
||||||
await outputJson(path.resolve(cwd, 'shareable1.json'), options1);
|
await outputJson(path.resolve(cwd, 'shareable1.json'), options1);
|
||||||
|
|
||||||
const error = await t.throwsAsync(t.context.getConfig({cwd}), Error);
|
await t.throwsAsync(t.context.getConfig({cwd}), {
|
||||||
|
message: /Cannot find module 'non-existing-path'/,
|
||||||
t.regex(error.message, /Cannot find module 'non-existing-path'/);
|
code: 'MODULE_NOT_FOUND',
|
||||||
t.is(error.code, 'MODULE_NOT_FOUND');
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import getAuthUrl from '../lib/get-git-auth-url';
|
const getAuthUrl = require('../lib/get-git-auth-url');
|
||||||
import {gitRepo} from './helpers/git-utils';
|
const {gitRepo} = require('./helpers/git-utils');
|
||||||
|
|
||||||
const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0};
|
const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import getLastRelease from '../lib/get-last-release';
|
const getLastRelease = require('../lib/get-last-release');
|
||||||
|
|
||||||
test('Get the highest non-prerelease valid tag', t => {
|
test('Get the highest non-prerelease valid tag', t => {
|
||||||
const result = getLastRelease({
|
const result = getLastRelease({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {spy} from 'sinon';
|
const {spy} = require('sinon');
|
||||||
import getLogger from '../lib/get-logger';
|
const getLogger = require('../lib/get-logger');
|
||||||
|
|
||||||
test('Expose "error", "success" and "log" functions', t => {
|
test('Expose "error", "success" and "log" functions', t => {
|
||||||
const stdout = spy();
|
const stdout = spy();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import getNextVersion from '../lib/get-next-version';
|
const getNextVersion = require('../lib/get-next-version');
|
||||||
|
|
||||||
test.beforeEach(t => {
|
test.beforeEach(t => {
|
||||||
// Stub the logger functions
|
// Stub the logger functions
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import getReleaseToAdd from '../lib/get-release-to-add';
|
const getReleaseToAdd = require('../lib/get-release-to-add');
|
||||||
|
|
||||||
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({
|
||||||
|
|||||||
+13
-7
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import tempy from 'tempy';
|
const tempy = require('tempy');
|
||||||
import {
|
const {
|
||||||
getTagHead,
|
getTagHead,
|
||||||
isRefExists,
|
isRefExists,
|
||||||
fetch,
|
fetch,
|
||||||
@@ -16,8 +16,8 @@ import {
|
|||||||
getNote,
|
getNote,
|
||||||
addNote,
|
addNote,
|
||||||
fetchNotes,
|
fetchNotes,
|
||||||
} from '../lib/git';
|
} = require('../lib/git');
|
||||||
import {
|
const {
|
||||||
gitRepo,
|
gitRepo,
|
||||||
gitCommits,
|
gitCommits,
|
||||||
gitCheckout,
|
gitCheckout,
|
||||||
@@ -33,7 +33,8 @@ import {
|
|||||||
gitAddNote,
|
gitAddNote,
|
||||||
gitGetNote,
|
gitGetNote,
|
||||||
gitFetch,
|
gitFetch,
|
||||||
} from './helpers/git-utils';
|
initGit,
|
||||||
|
} = require('./helpers/git-utils');
|
||||||
|
|
||||||
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
|
||||||
@@ -50,7 +51,7 @@ test('Throw error if the last commit sha cannot be found', 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
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
|
||||||
await t.throwsAsync(getGitHead({cwd}), Error);
|
await t.throwsAsync(getGitHead({cwd}));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Unshallow and fetch repository', async t => {
|
test('Unshallow and fetch repository', async t => {
|
||||||
@@ -182,6 +183,11 @@ test('Get all branches', async t => {
|
|||||||
t.deepEqual((await getBranches(repositoryUrl, {cwd})).sort(), ['master', 'second-branch', 'third-branch'].sort());
|
t.deepEqual((await getBranches(repositoryUrl, {cwd})).sort(), ['master', 'second-branch', 'third-branch'].sort());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Return empty array if there are no branches', async t => {
|
||||||
|
const {cwd, repositoryUrl} = await initGit(true);
|
||||||
|
t.deepEqual(await getBranches(repositoryUrl, {cwd}), []);
|
||||||
|
});
|
||||||
|
|
||||||
test('Get the commit sha for a given tag', async t => {
|
test('Get the commit sha for a given tag', 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
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
|||||||
+74
-36
@@ -1,13 +1,13 @@
|
|||||||
import tempy from 'tempy';
|
const tempy = require('tempy');
|
||||||
import execa from 'execa';
|
const execa = require('execa');
|
||||||
import fileUrl from 'file-url';
|
const fileUrl = require('file-url');
|
||||||
import pEachSeries from 'p-each-series';
|
const pEachSeries = require('p-each-series');
|
||||||
import gitLogParser from 'git-log-parser';
|
const gitLogParser = require('git-log-parser');
|
||||||
import getStream from 'get-stream';
|
const getStream = require('get-stream');
|
||||||
import {GIT_NOTE_REF} from '../../lib/definitions/constants';
|
const {GIT_NOTE_REF} = require('../../lib/definitions/constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commit message informations.
|
* Commit message information.
|
||||||
*
|
*
|
||||||
* @typedef {Object} Commit
|
* @typedef {Object} Commit
|
||||||
* @property {String} branch The commit branch.
|
* @property {String} branch The commit branch.
|
||||||
@@ -15,21 +15,34 @@ import {GIT_NOTE_REF} from '../../lib/definitions/constants';
|
|||||||
* @property {String} message The commit message.
|
* @property {String} message The commit message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize git repository
|
||||||
|
* If `withRemote` is `true`, creates a bare repository and initialize it.
|
||||||
|
* If `withRemote` is `false`, creates a regular repository and initialize it.
|
||||||
|
*
|
||||||
|
* @param {Boolean} withRemote `true` to create a shallow clone of a bare repository.
|
||||||
|
* @return {String} The path of the repository
|
||||||
|
*/
|
||||||
|
async function initGit(withRemote) {
|
||||||
|
const cwd = tempy.directory();
|
||||||
|
|
||||||
|
await execa('git', ['init', ...(withRemote ? ['--bare'] : [])], {cwd});
|
||||||
|
const repositoryUrl = fileUrl(cwd);
|
||||||
|
return {cwd, repositoryUrl};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a temporary git repository.
|
* Create a temporary git repository.
|
||||||
* If `withRemote` is `true`, creates a bare repository, initialize it and create a shallow clone. Change the current working directory to the clone root.
|
* If `withRemote` is `true`, creates a shallow clone. Change the current working directory to the clone root.
|
||||||
* If `withRemote` is `false`, creates a regular repository and initialize it. Change the current working directory to the repository root.
|
* If `withRemote` is `false`, just change the current working directory to the repository root.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @param {Boolean} withRemote `true` to create a shallow clone of a bare repository.
|
* @param {Boolean} withRemote `true` to create a shallow clone of a bare repository.
|
||||||
* @param {String} [branch='master'] The branch to initialize.
|
* @param {String} [branch='master'] The branch to initialize.
|
||||||
* @return {String} The path of the clone if `withRemote` is `true`, the path of the repository otherwise.
|
* @return {String} The path of the clone if `withRemote` is `true`, the path of the repository otherwise.
|
||||||
*/
|
*/
|
||||||
export async function gitRepo(withRemote, branch = 'master') {
|
async function gitRepo(withRemote, branch = 'master') {
|
||||||
let cwd = tempy.directory();
|
let {cwd, repositoryUrl} = await initGit(withRemote);
|
||||||
|
|
||||||
await execa('git', ['init', ...(withRemote ? ['--bare'] : [])], {cwd});
|
|
||||||
|
|
||||||
const repositoryUrl = fileUrl(cwd);
|
|
||||||
if (withRemote) {
|
if (withRemote) {
|
||||||
await initBareRepo(repositoryUrl, branch);
|
await initBareRepo(repositoryUrl, branch);
|
||||||
cwd = await gitShallowClone(repositoryUrl, branch);
|
cwd = await gitShallowClone(repositoryUrl, branch);
|
||||||
@@ -53,7 +66,7 @@ export async function gitRepo(withRemote, branch = 'master') {
|
|||||||
* @param {String} repositoryUrl The URL of the bare repository.
|
* @param {String} repositoryUrl The URL of the bare repository.
|
||||||
* @param {String} [branch='master'] the branch to initialize.
|
* @param {String} [branch='master'] the branch to initialize.
|
||||||
*/
|
*/
|
||||||
export async function initBareRepo(repositoryUrl, branch = 'master') {
|
async function initBareRepo(repositoryUrl, branch = 'master') {
|
||||||
const cwd = tempy.directory();
|
const cwd = tempy.directory();
|
||||||
await execa('git', ['clone', '--no-hardlinks', repositoryUrl, cwd], {cwd});
|
await execa('git', ['clone', '--no-hardlinks', repositoryUrl, cwd], {cwd});
|
||||||
await gitCheckout(branch, true, {cwd});
|
await gitCheckout(branch, true, {cwd});
|
||||||
@@ -69,7 +82,7 @@ export async function initBareRepo(repositoryUrl, branch = 'master') {
|
|||||||
*
|
*
|
||||||
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
|
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
|
||||||
*/
|
*/
|
||||||
export async function gitCommits(messages, execaOpts) {
|
async function gitCommits(messages, execaOpts) {
|
||||||
await pEachSeries(
|
await pEachSeries(
|
||||||
messages,
|
messages,
|
||||||
async message => (await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout
|
async message => (await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout
|
||||||
@@ -85,7 +98,7 @@ export async function gitCommits(messages, execaOpts) {
|
|||||||
*
|
*
|
||||||
* @return {Array<Object>} The list of parsed commits.
|
* @return {Array<Object>} The list of parsed commits.
|
||||||
*/
|
*/
|
||||||
export async function gitGetCommits(from, execaOpts) {
|
async function gitGetCommits(from, execaOpts) {
|
||||||
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}});
|
||||||
return (
|
return (
|
||||||
await getStream.array(
|
await getStream.array(
|
||||||
@@ -105,7 +118,7 @@ export async function gitGetCommits(from, execaOpts) {
|
|||||||
* @param {Boolean} create to create the branch, `false` to checkout an existing branch.
|
* @param {Boolean} create to create the branch, `false` to checkout an existing branch.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function gitCheckout(branch, create, execaOpts) {
|
async function gitCheckout(branch, create, execaOpts) {
|
||||||
await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts);
|
await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +128,7 @@ export async function gitCheckout(branch, create, execaOpts) {
|
|||||||
* @param {String} repositoryUrl The repository remote URL.
|
* @param {String} repositoryUrl The repository remote URL.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function gitFetch(repositoryUrl, execaOpts) {
|
async function gitFetch(repositoryUrl, execaOpts) {
|
||||||
await execa('git', ['fetch', repositoryUrl], execaOpts);
|
await execa('git', ['fetch', repositoryUrl], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +139,7 @@ export async function gitFetch(repositoryUrl, execaOpts) {
|
|||||||
*
|
*
|
||||||
* @return {String} The sha of the head commit in the current git repository.
|
* @return {String} The sha of the head commit in the current git repository.
|
||||||
*/
|
*/
|
||||||
export async function gitHead(execaOpts) {
|
async function gitHead(execaOpts) {
|
||||||
return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout;
|
return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +150,7 @@ export async function gitHead(execaOpts) {
|
|||||||
* @param {String} [sha] The commit on which to create the tag. If undefined the tag is created on the last commit.
|
* @param {String} [sha] The commit on which to create the tag. If undefined the tag is created on the last commit.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function gitTagVersion(tagName, sha, execaOpts) {
|
async function gitTagVersion(tagName, sha, execaOpts) {
|
||||||
await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName], execaOpts);
|
await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +163,7 @@ export async function gitTagVersion(tagName, sha, execaOpts) {
|
|||||||
* @param {Number} [depth=1] The number of commit to clone.
|
* @param {Number} [depth=1] The number of commit to clone.
|
||||||
* @return {String} The path of the cloned repository.
|
* @return {String} The path of the cloned repository.
|
||||||
*/
|
*/
|
||||||
export async function gitShallowClone(repositoryUrl, branch = 'master', depth = 1) {
|
async function gitShallowClone(repositoryUrl, branch = 'master', depth = 1) {
|
||||||
const cwd = tempy.directory();
|
const cwd = tempy.directory();
|
||||||
|
|
||||||
await execa('git', ['clone', '--no-hardlinks', '--no-tags', '-b', branch, '--depth', depth, repositoryUrl, cwd], {
|
await execa('git', ['clone', '--no-hardlinks', '--no-tags', '-b', branch, '--depth', depth, repositoryUrl, cwd], {
|
||||||
@@ -166,7 +179,7 @@ export async function gitShallowClone(repositoryUrl, branch = 'master', depth =
|
|||||||
* @param {Number} head A commit sha of the remote repo that will become the detached head of the new one.
|
* @param {Number} head A commit sha of the remote repo that will become the detached head of the new one.
|
||||||
* @return {String} The path of the new repository.
|
* @return {String} The path of the new repository.
|
||||||
*/
|
*/
|
||||||
export async function gitDetachedHead(repositoryUrl, head) {
|
async function gitDetachedHead(repositoryUrl, head) {
|
||||||
const cwd = tempy.directory();
|
const cwd = tempy.directory();
|
||||||
|
|
||||||
await execa('git', ['init'], {cwd});
|
await execa('git', ['init'], {cwd});
|
||||||
@@ -176,7 +189,7 @@ export async function gitDetachedHead(repositoryUrl, head) {
|
|||||||
return cwd;
|
return cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) {
|
async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) {
|
||||||
const cwd = tempy.directory();
|
const cwd = tempy.directory();
|
||||||
|
|
||||||
await execa('git', ['init'], {cwd});
|
await execa('git', ['init'], {cwd});
|
||||||
@@ -194,7 +207,7 @@ export async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) {
|
|||||||
* @param {String} value Config value.
|
* @param {String} value Config value.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function gitAddConfig(name, value, execaOpts) {
|
async function gitAddConfig(name, value, execaOpts) {
|
||||||
await execa('git', ['config', '--add', name, value], execaOpts);
|
await execa('git', ['config', '--add', name, value], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +219,7 @@ export async function gitAddConfig(name, value, execaOpts) {
|
|||||||
*
|
*
|
||||||
* @return {String} The sha of the commit associated with `tagName` on the local repository.
|
* @return {String} The sha of the commit associated with `tagName` on the local repository.
|
||||||
*/
|
*/
|
||||||
export async function gitTagHead(tagName, execaOpts) {
|
async function gitTagHead(tagName, execaOpts) {
|
||||||
return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout;
|
return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +232,7 @@ export async function gitTagHead(tagName, execaOpts) {
|
|||||||
*
|
*
|
||||||
* @return {String} The sha of the commit associated with `tagName` on the remote repository.
|
* @return {String} The sha of the commit associated with `tagName` on the remote repository.
|
||||||
*/
|
*/
|
||||||
export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
|
async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
|
||||||
return (await execa('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts)).stdout
|
return (await execa('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts)).stdout
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(tag => Boolean(tag))
|
.filter(tag => Boolean(tag))
|
||||||
@@ -234,7 +247,7 @@ export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
|
|||||||
*
|
*
|
||||||
* @return {String} The tag associatedwith the sha in parameter or `null`.
|
* @return {String} The tag associatedwith the sha in parameter or `null`.
|
||||||
*/
|
*/
|
||||||
export async function gitCommitTag(gitHead, execaOpts) {
|
async function gitCommitTag(gitHead, execaOpts) {
|
||||||
return (await execa('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts)).stdout;
|
return (await execa('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts)).stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +260,7 @@ export async function gitCommitTag(gitHead, execaOpts) {
|
|||||||
*
|
*
|
||||||
* @throws {Error} if the push failed.
|
* @throws {Error} if the push failed.
|
||||||
*/
|
*/
|
||||||
export async function gitPush(repositoryUrl, branch, execaOpts) {
|
async function gitPush(repositoryUrl, branch, execaOpts) {
|
||||||
await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts);
|
await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +270,7 @@ export async function gitPush(repositoryUrl, branch, execaOpts) {
|
|||||||
* @param {String} ref The ref to merge.
|
* @param {String} ref The ref to merge.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function merge(ref, execaOpts) {
|
async function merge(ref, execaOpts) {
|
||||||
await execa('git', ['merge', '--no-ff', ref], execaOpts);
|
await execa('git', ['merge', '--no-ff', ref], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +280,7 @@ export async function merge(ref, execaOpts) {
|
|||||||
* @param {String} ref The ref to merge.
|
* @param {String} ref The ref to merge.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function mergeFf(ref, execaOpts) {
|
async function mergeFf(ref, execaOpts) {
|
||||||
await execa('git', ['merge', '--ff', ref], execaOpts);
|
await execa('git', ['merge', '--ff', ref], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +290,7 @@ export async function mergeFf(ref, execaOpts) {
|
|||||||
* @param {String} ref The ref to merge.
|
* @param {String} ref The ref to merge.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function rebase(ref, execaOpts) {
|
async function rebase(ref, execaOpts) {
|
||||||
await execa('git', ['rebase', ref], execaOpts);
|
await execa('git', ['rebase', ref], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +301,7 @@ export async function rebase(ref, execaOpts) {
|
|||||||
* @param {String} ref The ref to add the note to.
|
* @param {String} ref The ref to add the note to.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function gitAddNote(note, ref, execaOpts) {
|
async function gitAddNote(note, ref, execaOpts) {
|
||||||
await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-m', note, ref], execaOpts);
|
await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-m', note, ref], execaOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +311,31 @@ export async function gitAddNote(note, ref, execaOpts) {
|
|||||||
* @param {String} ref The ref to get the note from.
|
* @param {String} ref The ref to get the note from.
|
||||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||||
*/
|
*/
|
||||||
export async function gitGetNote(ref, execaOpts) {
|
async function gitGetNote(ref, execaOpts) {
|
||||||
return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOpts)).stdout;
|
return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOpts)).stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
initGit,
|
||||||
|
gitRepo,
|
||||||
|
initBareRepo,
|
||||||
|
gitCommits,
|
||||||
|
gitGetCommits,
|
||||||
|
gitCheckout,
|
||||||
|
gitFetch,
|
||||||
|
gitHead,
|
||||||
|
gitTagVersion,
|
||||||
|
gitShallowClone,
|
||||||
|
gitDetachedHead,
|
||||||
|
gitDetachedHeadFromBranch,
|
||||||
|
gitAddConfig,
|
||||||
|
gitTagHead,
|
||||||
|
gitRemoteTagHead,
|
||||||
|
gitCommitTag,
|
||||||
|
gitPush,
|
||||||
|
merge,
|
||||||
|
mergeFf,
|
||||||
|
rebase,
|
||||||
|
gitAddNote,
|
||||||
|
gitGetNote,
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Docker from 'dockerode';
|
const Docker = require('dockerode');
|
||||||
import getStream from 'get-stream';
|
const getStream = require('get-stream');
|
||||||
import pRetry from 'p-retry';
|
const pRetry = require('p-retry');
|
||||||
import {initBareRepo, gitShallowClone} from './git-utils';
|
const {initBareRepo, gitShallowClone} = require('./git-utils');
|
||||||
|
|
||||||
const IMAGE = 'pvdlg/docker-gitbox:latest';
|
const IMAGE = 'pvdlg/docker-gitbox:latest';
|
||||||
const SERVER_PORT = 80;
|
const SERVER_PORT = 80;
|
||||||
@@ -69,4 +69,4 @@ async function createRepo(name, branch = 'master', description = `Repository ${n
|
|||||||
return {cwd, repositoryUrl, authUrl};
|
return {cwd, repositoryUrl, authUrl};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {start, stop, gitCredential, createRepo};
|
module.exports = {start, stop, gitCredential, createRepo};
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import Docker from 'dockerode';
|
const Docker = require('dockerode');
|
||||||
import getStream from 'get-stream';
|
const getStream = require('get-stream');
|
||||||
import got from 'got';
|
const got = require('got');
|
||||||
import pRetry from 'p-retry';
|
const pRetry = require('p-retry');
|
||||||
import {mockServerClient} from 'mockserver-client';
|
const {mockServerClient} = require('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,4 @@ function verify(expectation) {
|
|||||||
return client.verify(expectation);
|
return client.verify(expectation);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {start, stop, mock, verify, url};
|
module.exports = {start, stop, mock, verify, url};
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import Docker from 'dockerode';
|
const Docker = require('dockerode');
|
||||||
import getStream from 'get-stream';
|
const getStream = require('get-stream');
|
||||||
import got from 'got';
|
const got = require('got');
|
||||||
import delay from 'delay';
|
const delay = require('delay');
|
||||||
import pRetry from 'p-retry';
|
const pRetry = require('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,4 @@ async function stop() {
|
|||||||
await container.remove();
|
await container.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {start, stop, authEnv, url};
|
module.exports = {start, stop, authEnv, url};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import execa from 'execa';
|
const execa = require('execa');
|
||||||
|
|
||||||
export 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};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {repeat} from 'lodash';
|
const {repeat} = require('lodash');
|
||||||
import hideSensitive from '../lib/hide-sensitive';
|
const hideSensitive = require('../lib/hide-sensitive');
|
||||||
import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from '../lib/definitions/constants';
|
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('../lib/definitions/constants');
|
||||||
|
|
||||||
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'};
|
||||||
|
|||||||
+13
-14
@@ -1,13 +1,13 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {escapeRegExp, isString, sortBy, omit} from 'lodash';
|
const {escapeRegExp, isString, sortBy, omit} = require('lodash');
|
||||||
import proxyquire from 'proxyquire';
|
const proxyquire = require('proxyquire');
|
||||||
import {spy, stub} from 'sinon';
|
const {spy, stub} = require('sinon');
|
||||||
import {WritableStreamBuffer} from 'stream-buffers';
|
const {WritableStreamBuffer} = require('stream-buffers');
|
||||||
import AggregateError from 'aggregate-error';
|
const AggregateError = require('aggregate-error');
|
||||||
import SemanticReleaseError from '@semantic-release/error';
|
const SemanticReleaseError = require('@semantic-release/error');
|
||||||
import {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} from '../lib/definitions/constants';
|
const {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
||||||
import {
|
const {
|
||||||
gitHead as getGitHead,
|
gitHead: getGitHead,
|
||||||
gitCheckout,
|
gitCheckout,
|
||||||
gitTagHead,
|
gitTagHead,
|
||||||
gitRepo,
|
gitRepo,
|
||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
rebase,
|
rebase,
|
||||||
gitAddNote,
|
gitAddNote,
|
||||||
gitGetNote,
|
gitGetNote,
|
||||||
} from './helpers/git-utils';
|
} = require('./helpers/git-utils');
|
||||||
|
|
||||||
const requireNoCache = proxyquire.noPreserveCache();
|
const requireNoCache = proxyquire.noPreserveCache();
|
||||||
const pluginNoop = require.resolve('./fixtures/plugin-noop');
|
const pluginNoop = require.resolve('./fixtures/plugin-noop');
|
||||||
@@ -1807,7 +1807,7 @@ test('Throw an Error if plugin returns an unexpected value', async t => {
|
|||||||
});
|
});
|
||||||
const error = await t.throwsAsync(
|
const error = await t.throwsAsync(
|
||||||
semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}),
|
semanticRelease(options, {cwd, env: {}, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}),
|
||||||
Error
|
{instanceOf: SemanticReleaseError}
|
||||||
);
|
);
|
||||||
t.regex(error.details, /string/);
|
t.regex(error.details, /string/);
|
||||||
});
|
});
|
||||||
@@ -1836,8 +1836,7 @@ test('Hide sensitive information passed to "fail" plugin', async t => {
|
|||||||
'env-ci': () => ({isCi: true, branch: 'master', isPr: false}),
|
'env-ci': () => ({isCi: true, branch: 'master', isPr: false}),
|
||||||
});
|
});
|
||||||
await t.throwsAsync(
|
await t.throwsAsync(
|
||||||
semanticRelease(options, {cwd, env, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()}),
|
semanticRelease(options, {cwd, env, stdout: new WritableStreamBuffer(), stderr: new WritableStreamBuffer()})
|
||||||
Error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const error = fail.args[0][1].errors[0];
|
const error = fail.args[0][1].errors[0];
|
||||||
|
|||||||
+15
-15
@@ -1,13 +1,13 @@
|
|||||||
import path from 'path';
|
const path = require('path');
|
||||||
import proxyquire from 'proxyquire';
|
const test = require('ava');
|
||||||
import test from 'ava';
|
const proxyquire = require('proxyquire');
|
||||||
import {escapeRegExp} from 'lodash';
|
const {escapeRegExp} = require('lodash');
|
||||||
import {writeJson, readJson} from 'fs-extra';
|
const {writeJson, readJson} = require('fs-extra');
|
||||||
import execa from 'execa';
|
const execa = require('execa');
|
||||||
import {WritableStreamBuffer} from 'stream-buffers';
|
const {WritableStreamBuffer} = require('stream-buffers');
|
||||||
import delay from 'delay';
|
const delay = require('delay');
|
||||||
import {SECRET_REPLACEMENT} from '../lib/definitions/constants';
|
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
||||||
import {
|
const {
|
||||||
gitHead,
|
gitHead,
|
||||||
gitTagHead,
|
gitTagHead,
|
||||||
gitRepo,
|
gitRepo,
|
||||||
@@ -17,11 +17,11 @@ import {
|
|||||||
gitCheckout,
|
gitCheckout,
|
||||||
merge,
|
merge,
|
||||||
gitGetNote,
|
gitGetNote,
|
||||||
} from './helpers/git-utils';
|
} = require('./helpers/git-utils');
|
||||||
import {npmView} from './helpers/npm-utils';
|
const {npmView} = require('./helpers/npm-utils');
|
||||||
import gitbox from './helpers/gitbox';
|
const gitbox = require('./helpers/gitbox');
|
||||||
import mockServer from './helpers/mockserver';
|
const mockServer = require('./helpers/mockserver');
|
||||||
import npmRegistry from './helpers/npm-registry';
|
const npmRegistry = require('./helpers/npm-registry');
|
||||||
|
|
||||||
/* eslint camelcase: ["error", {properties: "never"}] */
|
/* eslint camelcase: ["error", {properties: "never"}] */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {noop} from 'lodash';
|
const {noop} = require('lodash');
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import normalize from '../../lib/plugins/normalize';
|
const normalize = require('../../lib/plugins/normalize');
|
||||||
|
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
|
|
||||||
@@ -268,11 +268,9 @@ test('Throws an error if the plugin return an object without the expected plugin
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Throws an error if the plugin is not found', t => {
|
test('Throws an error if the plugin is not found', t => {
|
||||||
const error = t.throws(
|
t.throws(() => normalize({cwd, options: {}, logger: t.context.logger}, 'inexistantPlugin', 'non-existing-path', {}), {
|
||||||
() => normalize({cwd, options: {}, logger: t.context.logger}, 'inexistantPlugin', 'non-existing-path', {}),
|
message: /Cannot find module 'non-existing-path'/,
|
||||||
Error
|
code: 'MODULE_NOT_FOUND',
|
||||||
);
|
instanceOf: Error,
|
||||||
|
});
|
||||||
t.regex(error.message, /Cannot find module 'non-existing-path'/);
|
|
||||||
t.is(error.code, 'MODULE_NOT_FOUND');
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import AggregateError from 'aggregate-error';
|
const AggregateError = require('aggregate-error');
|
||||||
import pipeline from '../../lib/plugins/pipeline';
|
const pipeline = require('../../lib/plugins/pipeline');
|
||||||
|
|
||||||
test('Execute each function in series passing the same input', async t => {
|
test('Execute each function in series passing the same input', async t => {
|
||||||
const step1 = stub().resolves(1);
|
const step1 = stub().resolves(1);
|
||||||
@@ -98,7 +98,10 @@ test('Stop execution and throw error if a step rejects', async t => {
|
|||||||
const step2 = stub().rejects(new Error('test error'));
|
const step2 = stub().rejects(new Error('test error'));
|
||||||
const step3 = stub().resolves(3);
|
const step3 = stub().resolves(3);
|
||||||
|
|
||||||
const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), Error);
|
const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), {
|
||||||
|
instanceOf: Error,
|
||||||
|
message: 'test error',
|
||||||
|
});
|
||||||
t.is(error.message, 'test error');
|
t.is(error.message, 'test error');
|
||||||
t.true(step1.calledWith(0));
|
t.true(step1.calledWith(0));
|
||||||
t.true(step2.calledWith(0));
|
t.true(step2.calledWith(0));
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import path from 'path';
|
const path = require('path');
|
||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {copy, outputFile} from 'fs-extra';
|
const {copy, outputFile} = require('fs-extra');
|
||||||
import {stub} from 'sinon';
|
const {stub} = require('sinon');
|
||||||
import tempy from 'tempy';
|
const tempy = require('tempy');
|
||||||
import getPlugins from '../../lib/plugins';
|
const getPlugins = require('../../lib/plugins');
|
||||||
|
|
||||||
// Save the current working diretory
|
// Save the current working diretory
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import {validatePlugin, validateStep, loadPlugin, parseConfig} from '../../lib/plugins/utils';
|
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('../../lib/plugins/utils');
|
||||||
|
|
||||||
test('validatePlugin', t => {
|
test('validatePlugin', t => {
|
||||||
const path = 'plugin-module';
|
const path = 'plugin-module';
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import AggregateError from 'aggregate-error';
|
const AggregateError = require('aggregate-error');
|
||||||
import {
|
const {
|
||||||
extractErrors,
|
extractErrors,
|
||||||
tagsToVersions,
|
tagsToVersions,
|
||||||
isMajorRange,
|
isMajorRange,
|
||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
getRange,
|
getRange,
|
||||||
makeTag,
|
makeTag,
|
||||||
isSameChannel,
|
isSameChannel,
|
||||||
} from '../lib/utils';
|
} = require('../lib/utils');
|
||||||
|
|
||||||
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')];
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import test from 'ava';
|
const test = require('ava');
|
||||||
import tempy from 'tempy';
|
const tempy = require('tempy');
|
||||||
import verify from '../lib/verify';
|
const verify = require('../lib/verify');
|
||||||
import {gitRepo} from './helpers/git-utils';
|
const {gitRepo} = require('./helpers/git-utils');
|
||||||
|
|
||||||
test('Throw a AggregateError', async t => {
|
test('Throw a AggregateError', async t => {
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
|||||||
Reference in New Issue
Block a user