chore(package): update ava to version 3.1.0

This commit is contained in:
greenkeeper[bot] 2020-01-19 15:22:52 +00:00 committed by Pierre Vanduynslager
parent bec57cd2ed
commit ef1b8a0b91
30 changed files with 255 additions and 232 deletions

View File

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

View File

@ -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});
@ -135,7 +135,7 @@ test('Enforce ranges with branching release workflow', async t => {
t.is( t.is(
getBranch(result, '1.0.x').range, getBranch(result, '1.0.x').range,
'>=1.0.1 <1.0.2', '>=1.0.1 <1.0.2',
'Cannot release on 1.0.x before 1.0.x version from master are merged' 'Cannot release on 1.0.x before 1.0.x version = require(master are merged'
); );
t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.2', 'Cannot release on 1.x before >= 2.0.0 is released on master'); t.is(getBranch(result, '1.x').range, '>=1.1.0 <1.0.2', 'Cannot release on 1.x before >= 2.0.0 is released on master');

View File

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

View File

@ -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();
@ -28,7 +28,7 @@ test('Get the valid tags', async t => {
]); ]);
}); });
test('Get the valid tags from multiple branches', async t => { test('Get the valid tags = require(multiple branches', async t => {
const {cwd} = await gitRepo(); const {cwd} = await gitRepo();
await gitCommits(['First'], {cwd}); await gitCommits(['First'], {cwd});
await gitTagVersion('v1.0.0', undefined, {cwd}); await gitTagVersion('v1.0.0', undefined, {cwd});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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',
@ -20,7 +20,7 @@ test.beforeEach(t => {
t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins}); t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins});
}); });
test('Default values, reading repositoryUrl from package.json', async t => { test('Default values, reading repositoryUrl = require(package.json', async t => {
const pkg = {repository: 'https://host.null/owner/package.git'}; const pkg = {repository: 'https://host.null/owner/package.git'};
// 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(true); const {cwd} = await gitRepo(true);
@ -47,7 +47,7 @@ test('Default values, reading repositoryUrl from package.json', async t => {
t.is(result.tagFormat, `v\${version}`); t.is(result.tagFormat, `v\${version}`);
}); });
test('Default values, reading repositoryUrl from repo if not set in package.json', async t => { test('Default values, reading repositoryUrl = require(repo if not set in package.json', 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(true); const {cwd} = await gitRepo(true);
// Add remote.origin.url config // Add remote.origin.url config
@ -68,7 +68,7 @@ test('Default values, reading repositoryUrl from repo if not set in package.json
t.is(result.tagFormat, `v\${version}`); t.is(result.tagFormat, `v\${version}`);
}); });
test('Default values, reading repositoryUrl (http url) from package.json if not set in repo', async t => { test('Default values, reading repositoryUrl (http url) = require(package.json if not set in repo', async t => {
const pkg = {repository: 'https://host.null/owner/module.git'}; const pkg = {repository: 'https://host.null/owner/module.git'};
// 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();
@ -102,7 +102,7 @@ test('Convert "ci" option to "noCi"', async t => {
t.is(result.noCi, true); t.is(result.noCi, true);
}); });
test('Read options from package.json', async t => { test('Read options = require(package.json', 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();
const options = { const options = {
@ -119,13 +119,13 @@ test('Read options from package.json', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from package.json // Verify the options contains the plugin config = require(package.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json // Verify the plugins module is called with the plugin options = require(package.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
test('Read options from .releaserc.yml', async t => { test('Read options = require(.releaserc.yml', 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();
const options = { const options = {
@ -141,13 +141,13 @@ test('Read options from .releaserc.yml', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from package.json // Verify the options contains the plugin config = require(package.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json // Verify the plugins module is called with the plugin options = require(package.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
test('Read options from .releaserc.json', async t => { test('Read options = require(.releaserc.json', 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();
const options = { const options = {
@ -163,13 +163,13 @@ test('Read options from .releaserc.json', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from package.json // Verify the options contains the plugin config = require(package.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json // Verify the plugins module is called with the plugin options = require(package.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
test('Read options from .releaserc.js', async t => { test('Read options = require(.releaserc.js', 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();
const options = { const options = {
@ -185,13 +185,13 @@ test('Read options from .releaserc.js', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from package.json // Verify the options contains the plugin config = require(package.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json // Verify the plugins module is called with the plugin options = require(package.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
test('Read options from release.config.js', async t => { test('Read options = require(release.config.js', 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();
const options = { const options = {
@ -207,9 +207,9 @@ test('Read options from release.config.js', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from package.json // Verify the options contains the plugin config = require(package.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json // Verify the plugins module is called with the plugin options = require(package.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
@ -237,13 +237,13 @@ test('Prioritise CLI/API parameters over file configuration and git repo', async
const result = await t.context.getConfig({cwd}, options); const result = await t.context.getConfig({cwd}, options);
const expected = {...options, branches: ['branch_cli']}; const expected = {...options, branches: ['branch_cli']};
// Verify the options contains the plugin config from CLI/API // Verify the options contains the plugin config = require(CLI/API
t.deepEqual(result.options, expected); t.deepEqual(result.options, expected);
// Verify the plugins module is called with the plugin options from CLI/API // Verify the plugins module is called with the plugin options = require(CLI/API
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
test('Read configuration from file path in "extends"', async t => { test('Read configuration = require(file path in "extends"', 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();
const pkgOptions = {extends: './shareable.json'}; const pkgOptions = {extends: './shareable.json'};
@ -262,9 +262,9 @@ test('Read configuration from file path in "extends"', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from shareable.json // Verify the options contains the plugin config = require(shareable.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from shareable.json // Verify the plugins module is called with the plugin options = require(shareable.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
t.deepEqual(t.context.plugins.args[0][1], { t.deepEqual(t.context.plugins.args[0][1], {
analyzeCommits: './shareable.json', analyzeCommits: './shareable.json',
@ -274,7 +274,7 @@ test('Read configuration from file path in "extends"', async t => {
}); });
}); });
test('Read configuration from module path in "extends"', async t => { test('Read configuration = require(module path in "extends"', 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();
const pkgOptions = {extends: 'shareable'}; const pkgOptions = {extends: 'shareable'};
@ -293,9 +293,9 @@ test('Read configuration from module path in "extends"', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options, branches: ['test_branch']}; const expected = {...options, branches: ['test_branch']};
// Verify the options contains the plugin config from shareable.json // Verify the options contains the plugin config = require(shareable.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from shareable.json // Verify the plugins module is called with the plugin options = require(shareable.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
t.deepEqual(t.context.plugins.args[0][1], { t.deepEqual(t.context.plugins.args[0][1], {
analyzeCommits: 'shareable', analyzeCommits: 'shareable',
@ -303,7 +303,7 @@ test('Read configuration from module path in "extends"', async t => {
}); });
}); });
test('Read configuration from an array of paths in "extends"', async t => { test('Read configuration = require(an array of paths in "extends"', 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();
const pkgOptions = {extends: ['./shareable1.json', './shareable2.json']}; const pkgOptions = {extends: ['./shareable1.json', './shareable2.json']};
@ -329,9 +329,9 @@ test('Read configuration from an array of paths in "extends"', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = {...options1, ...options2, branches: ['test_branch']}; const expected = {...options1, ...options2, branches: ['test_branch']};
// Verify the options contains the plugin config from shareable1.json and shareable2.json // Verify the options contains the plugin config = require(shareable1.json and shareable2.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from shareable1.json and shareable2.json // Verify the plugins module is called with the plugin options = require(shareable1.json and shareable2.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
t.deepEqual(t.context.plugins.args[0][1], { t.deepEqual(t.context.plugins.args[0][1], {
verifyRelease1: './shareable1.json', verifyRelease1: './shareable1.json',
@ -342,7 +342,7 @@ test('Read configuration from an array of paths in "extends"', async t => {
}); });
}); });
test('Prioritize configuration from config file over "extends"', async t => { test('Prioritize configuration = require(config file over "extends"', 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();
const pkgOptions = { const pkgOptions = {
@ -367,9 +367,9 @@ test('Prioritize configuration from config file over "extends"', async t => {
const {options: result} = await t.context.getConfig({cwd}); const {options: result} = await t.context.getConfig({cwd});
const expected = omit({...options1, ...pkgOptions, branches: ['test_pkg']}, 'extends'); const expected = omit({...options1, ...pkgOptions, branches: ['test_pkg']}, 'extends');
// Verify the options contains the plugin config from package.json and shareable.json // Verify the options contains the plugin config = require(package.json and shareable.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json and shareable.json // Verify the plugins module is called with the plugin options = require(package.json and shareable.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
t.deepEqual(t.context.plugins.args[0][1], { t.deepEqual(t.context.plugins.args[0][1], {
analyzeCommits: './shareable.json', analyzeCommits: './shareable.json',
@ -378,7 +378,7 @@ test('Prioritize configuration from config file over "extends"', async t => {
}); });
}); });
test('Prioritize configuration from cli/API options over "extends"', async t => { test('Prioritize configuration = require(cli/API options over "extends"', 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();
const cliOptions = { const cliOptions = {
@ -415,9 +415,9 @@ test('Prioritize configuration from cli/API options over "extends"', async t =>
const {options: result} = await t.context.getConfig({cwd}, cliOptions); const {options: result} = await t.context.getConfig({cwd}, cliOptions);
const expected = omit({...options2, ...pkgOptions, ...cliOptions, branches: ['branch_opts']}, 'extends'); const expected = omit({...options2, ...pkgOptions, ...cliOptions, branches: ['branch_opts']}, 'extends');
// Verify the options contains the plugin config from package.json and shareable2.json // Verify the options contains the plugin config = require(package.json and shareable2.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from package.json and shareable2.json // Verify the plugins module is called with the plugin options = require(package.json and shareable2.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
}); });
@ -443,13 +443,13 @@ test('Allow to unset properties defined in shareable config with "null"', async
const {options} = await t.context.getConfig({cwd}); const {options} = await t.context.getConfig({cwd});
// Verify the options contains the plugin config from shareable.json and the default `plugins` // Verify the options contains the plugin config = require(shareable.json and the default `plugins`
t.deepEqual(options, { t.deepEqual(options, {
...omit(options1, ['analyzeCommits']), ...omit(options1, ['analyzeCommits']),
...omit(pkgOptions, ['extends', 'analyzeCommits']), ...omit(pkgOptions, ['extends', 'analyzeCommits']),
plugins: DEFAULT_PLUGINS, plugins: DEFAULT_PLUGINS,
}); });
// Verify the plugins module is called with the plugin options from shareable.json and the default `plugins` // Verify the plugins module is called with the plugin options = require(shareable.json and the default `plugins`
t.deepEqual(t.context.plugins.args[0][0], { t.deepEqual(t.context.plugins.args[0][0], {
options: { options: {
...omit(options1, 'analyzeCommits'), ...omit(options1, 'analyzeCommits'),
@ -492,9 +492,9 @@ test('Allow to unset properties defined in shareable config with "undefined"', a
...omit(pkgOptions, ['extends', 'analyzeCommits']), ...omit(pkgOptions, ['extends', 'analyzeCommits']),
branches: ['test_branch'], branches: ['test_branch'],
}; };
// Verify the options contains the plugin config from shareable.json // Verify the options contains the plugin config = require(shareable.json
t.deepEqual(result, expected); t.deepEqual(result, expected);
// Verify the plugins module is called with the plugin options from shareable.json // Verify the plugins module is called with the plugin options = require(shareable.json
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd}); t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
t.deepEqual(t.context.plugins.args[0][1], { t.deepEqual(t.context.plugins.args[0][1], {
generateNotes: './shareable.json', generateNotes: './shareable.json',
@ -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'); });
}); });

View File

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

View File

@ -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({
@ -18,7 +18,7 @@ test('Get the highest non-prerelease valid tag', t => {
t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: 'v2.0.0', channels: undefined}); t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: 'v2.0.0', channels: undefined});
}); });
test('Get the highest prerelease valid tag, ignoring other tags from other prerelease channels', t => { test('Get the highest prerelease valid tag, ignoring other tags = require(other prerelease channels', t => {
const result = getLastRelease({ const result = getLastRelease({
branch: { branch: {
name: 'beta', name: 'beta',

View File

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

View File

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

View File

@ -1,7 +1,7 @@
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 = require(release to maintenance branch, excluding lower than branch start range', t => {
const result = getReleaseToAdd({ const result = getReleaseToAdd({
branch: { branch: {
name: '2.x', name: '2.x',
@ -188,7 +188,7 @@ test('Ignore pre-release versions', t => {
}); });
}); });
test('Exclude versions merged from release to maintenance branch if they have the same "channel"', t => { test('Exclude versions merged = require(release to maintenance branch if they have the same "channel"', t => {
const result = getReleaseToAdd({ const result = getReleaseToAdd({
branch: { branch: {
name: '2.x', name: '2.x',

View File

@ -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,
@ -34,7 +34,7 @@ import {
gitGetNote, gitGetNote,
gitFetch, gitFetch,
initGit, initGit,
} from './helpers/git-utils'; } = 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
@ -51,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 => {

View File

@ -1,10 +1,10 @@
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 information. * Commit message information.
@ -23,7 +23,7 @@ import {GIT_NOTE_REF} from '../../lib/definitions/constants';
* @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.
* @return {String} The path of the repository * @return {String} The path of the repository
*/ */
export async function initGit(withRemote) { async function initGit(withRemote) {
const cwd = tempy.directory(); const cwd = tempy.directory();
await execa('git', ['init', ...(withRemote ? ['--bare'] : [])], {cwd}); await execa('git', ['init', ...(withRemote ? ['--bare'] : [])], {cwd});
@ -41,7 +41,7 @@ export async function initGit(withRemote) {
* @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, repositoryUrl} = await initGit(withRemote); let {cwd, repositoryUrl} = await initGit(withRemote);
if (withRemote) { if (withRemote) {
await initBareRepo(repositoryUrl, branch); await initBareRepo(repositoryUrl, branch);
@ -66,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});
@ -82,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
@ -98,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(
@ -118,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);
} }
@ -128,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);
} }
@ -139,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;
} }
@ -150,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);
} }
@ -163,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], {
@ -179,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});
@ -189,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});
@ -207,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);
} }
@ -219,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;
} }
@ -232,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))
@ -247,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;
} }
@ -260,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);
} }
@ -270,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);
} }
@ -280,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);
} }
@ -290,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);
} }
@ -301,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);
} }
@ -311,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,
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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"}] */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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