This commit is contained in:
Gregor Martynus
2021-07-30 13:57:35 -07:00
parent d9605a5e45
commit ce263c5f4a
67 changed files with 4180 additions and 323 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
const test = require('ava');
const {union} = require('lodash');
const semver = require('semver');
const proxyquire = require('proxyquire');
import test from 'ava';
import {union} from 'lodash';
import semver from 'semver';
import proxyquire from 'proxyquire';
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
+3 -3
View File
@@ -1,6 +1,6 @@
const test = require('ava');
const expand = require('../../lib/branches/expand');
const {gitRepo, gitCommits, gitCheckout, gitPush} = require('../helpers/git-utils');
import test from 'ava';
import expand from '../../lib/branches/expand.js';
import {gitRepo, gitCommits, gitCheckout, gitPush} from '../helpers/git-utils.js';
test('Expand branches defined with globs', async (t) => {
const {cwd, repositoryUrl} = await gitRepo(true);
+3 -3
View File
@@ -1,6 +1,6 @@
const test = require('ava');
const getTags = require('../../lib/branches/get-tags');
const {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} = require('../helpers/git-utils');
import test from 'ava';
import getTags from '../../lib/branches/get-tags.js';
import {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} from '../helpers/git-utils.js';
test('Get the valid tags', async (t) => {
const {cwd} = await gitRepo();
+2 -2
View File
@@ -1,5 +1,5 @@
const test = require('ava');
const normalize = require('../../lib/branches/normalize');
import test from 'ava';
import normalize from '../../lib/branches/normalize.js';
const toTags = (versions) => versions.map((version) => ({version}));
+4 -4
View File
@@ -1,8 +1,8 @@
const test = require('ava');
const {escapeRegExp} = require('lodash');
import test from 'ava';
import {escapeRegExp} from 'lodash';
const proxyquire = require('proxyquire').noPreserveCache();
const {stub} = require('sinon');
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
import {stub} from 'sinon';
import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
test.beforeEach((t) => {
t.context.logs = '';
+2 -2
View File
@@ -1,5 +1,5 @@
const test = require('ava');
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');
import test from 'ava';
import {maintenance, prerelease, release} from '../../lib/definitions/branches.js';
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
t.true(maintenance.filter({name: '1.x.x'}));
+3 -3
View File
@@ -1,6 +1,6 @@
const test = require('ava');
const plugins = require('../../lib/definitions/plugins');
const {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} = require('../../lib/definitions/constants');
import test from 'ava';
import plugins from '../../lib/definitions/plugins.js';
import {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} from '../../lib/definitions/constants.js';
test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', (t) => {
t.false(plugins.analyzeCommits.outputValidator('invalid'));
+1 -1
View File
@@ -1 +1 @@
module.exports = () => {};
export default () => {};
+5 -1
View File
@@ -1,4 +1,4 @@
module.exports = {
const exported = {
verifyConditions: () => {},
getLastRelease: () => {},
analyzeCommits: () => {},
@@ -6,3 +6,7 @@ module.exports = {
generateNotes: () => {},
publish: () => {},
};
export default exported;
export const {verifyConditions, getLastRelease, analyzeCommits, verifyRelease, generateNotes, publish} = exported;
+2 -2
View File
@@ -1,4 +1,4 @@
const SemanticReleaseError = require('@semantic-release/error');
import SemanticReleaseError from '@semantic-release/error';
class InheritedError extends SemanticReleaseError {
constructor(message, code) {
@@ -9,6 +9,6 @@ class InheritedError extends SemanticReleaseError {
}
}
module.exports = () => {
export default () => {
throw new InheritedError('Inherited error', 'EINHERITED');
};
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = () => {
export default () => {
const error = new Error('a');
error.errorProperty = 'errorProperty';
throw error;
+2 -2
View File
@@ -1,5 +1,5 @@
const AggregateError = require('aggregate-error');
import AggregateError from 'aggregate-error';
module.exports = () => {
export default () => {
throw new AggregateError([new Error('a'), new Error('b')]);
};
+1 -1
View File
@@ -1 +1 @@
module.exports = (pluginConfig, context) => context;
export default (pluginConfig, context) => context;
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = (pluginConfig, {env, logger}) => {
export default (pluginConfig, {env, logger}) => {
console.log(`Console: Exposing token ${env.MY_TOKEN}`);
logger.log(`Log: Exposing token ${env.MY_TOKEN}`);
logger.error(`Error: Console token ${env.MY_TOKEN}`);
+1 -1
View File
@@ -1 +1 @@
module.exports = () => {};
export default () => {};
+1 -1
View File
@@ -1 +1 @@
module.exports = (pluginConfig, context) => ({pluginConfig, context});
export default (pluginConfig, context) => ({pluginConfig, context});
+4 -4
View File
@@ -1,7 +1,7 @@
const test = require('ava');
const {stub} = require('sinon');
const getCommits = require('../lib/get-commits');
const {gitRepo, gitCommits, gitDetachedHead} = require('./helpers/git-utils');
import test from 'ava';
import {stub} from 'sinon';
import getCommits from '../lib/get-commits.js';
import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils.js';
test.beforeEach((t) => {
// Stub the logger functions
+9 -9
View File
@@ -1,12 +1,12 @@
const path = require('path');
const {format} = require('util');
const test = require('ava');
const {writeFile, outputJson} = require('fs-extra');
const {omit} = require('lodash');
const proxyquire = require('proxyquire');
const {stub} = require('sinon');
const yaml = require('js-yaml');
const {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} = require('./helpers/git-utils');
import path from 'path';
import {format} from 'util';
import test from 'ava';
import {writeFile, outputJson} from 'fs-extra';
import {omit} from 'lodash';
import proxyquire from 'proxyquire';
import {stub} from 'sinon';
import yaml from 'js-yaml';
import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils.js';
const DEFAULT_PLUGINS = [
'@semantic-release/commit-analyzer',
+3 -3
View File
@@ -1,6 +1,6 @@
const test = require('ava');
const getAuthUrl = require('../lib/get-git-auth-url');
const {gitRepo} = require('./helpers/git-utils');
import test from 'ava';
import getAuthUrl from '../lib/get-git-auth-url.js';
import {gitRepo} from './helpers/git-utils.js';
const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0};
+2 -2
View File
@@ -1,5 +1,5 @@
const test = require('ava');
const getLastRelease = require('../lib/get-last-release');
import test from 'ava';
import getLastRelease from '../lib/get-last-release.js';
test('Get the highest non-prerelease valid tag', (t) => {
const result = getLastRelease({
+3 -3
View File
@@ -1,6 +1,6 @@
const test = require('ava');
const {spy} = require('sinon');
const getLogger = require('../lib/get-logger');
import test from 'ava';
import {spy} from 'sinon';
import getLogger from '../lib/get-logger.js';
test('Expose "error", "success" and "log" functions', (t) => {
const stdout = spy();
+3 -3
View File
@@ -1,6 +1,6 @@
const test = require('ava');
const {stub} = require('sinon');
const getNextVersion = require('../lib/get-next-version');
import test from 'ava';
import {stub} from 'sinon';
import getNextVersion from '../lib/get-next-version.js';
test.beforeEach((t) => {
// Stub the logger functions
+2 -2
View File
@@ -1,5 +1,5 @@
const test = require('ava');
const getReleaseToAdd = require('../lib/get-release-to-add');
import test from 'ava';
import getReleaseToAdd from '../lib/get-release-to-add.js';
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', (t) => {
const result = getReleaseToAdd({
+8 -6
View File
@@ -1,6 +1,7 @@
const test = require('ava');
const tempy = require('tempy');
const {
import test from 'ava';
import tempy from 'tempy';
import {
getTagHead,
isRefExists,
fetch,
@@ -16,8 +17,9 @@ const {
getNote,
addNote,
fetchNotes,
} = require('../lib/git');
const {
} from '../lib/git.js';
import {
gitRepo,
gitCommits,
gitCheckout,
@@ -34,7 +36,7 @@ const {
gitGetNote,
gitFetch,
initGit,
} = require('./helpers/git-utils');
} from './helpers/git-utils.js';
test('Get the last commit sha', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
+34 -8
View File
@@ -1,10 +1,10 @@
const tempy = require('tempy');
const execa = require('execa');
const fileUrl = require('file-url');
const pEachSeries = require('p-each-series');
const gitLogParser = require('git-log-parser');
const getStream = require('get-stream');
const {GIT_NOTE_REF} = require('../../lib/definitions/constants');
import tempy from 'tempy';
import execa from 'execa';
import fileUrl from 'file-url';
import pEachSeries from 'p-each-series';
import gitLogParser from 'git-log-parser';
import getStream from 'get-stream';
import {GIT_NOTE_REF} from '../../lib/definitions/constants.js';
/**
* Commit message information.
@@ -323,7 +323,33 @@ async function gitGetNote(ref, execaOptions) {
return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout;
}
module.exports = {
const exported = {
initGit,
gitRepo,
initBareRepo,
gitCommits,
gitGetCommits,
gitCheckout,
gitFetch,
gitHead,
gitTagVersion,
gitShallowClone,
gitDetachedHead,
gitDetachedHeadFromBranch,
gitAddConfig,
gitTagHead,
gitRemoteTagHead,
gitCommitTag,
gitPush,
merge,
mergeFf,
rebase,
gitAddNote,
gitGetNote,
};
export default exported;
export {
initGit,
gitRepo,
initBareRepo,
+13 -5
View File
@@ -1,7 +1,7 @@
const Docker = require('dockerode');
const getStream = require('get-stream');
const pRetry = require('p-retry');
const {initBareRepo, gitShallowClone} = require('./git-utils');
import Docker from 'dockerode';
import getStream from 'get-stream';
import pRetry from 'p-retry';
import {initBareRepo, gitShallowClone} from './git-utils.js';
const IMAGE = 'pvdlg/docker-gitbox:latest';
const SERVER_PORT = 80;
@@ -69,4 +69,12 @@ async function createRepo(name, branch = 'master', description = `Repository ${n
return {cwd, repositoryUrl, authUrl};
}
module.exports = {start, stop, gitCredential, createRepo};
const exported = {
start,
stop,
gitCredential,
createRepo,
};
export default exported;
export {start, stop, gitCredential, createRepo};
+15 -6
View File
@@ -1,8 +1,8 @@
const Docker = require('dockerode');
const getStream = require('get-stream');
const got = require('got');
const pRetry = require('p-retry');
const {mockServerClient} = require('mockserver-client');
import Docker from 'dockerode';
import getStream from 'get-stream';
import got from 'got';
import pRetry from 'p-retry';
import {mockServerClient} from 'mockserver-client';
const IMAGE = 'jamesdbloom/mockserver:latest';
const MOCK_SERVER_PORT = 1080;
@@ -100,4 +100,13 @@ function verify(expectation) {
return client.verify(expectation);
}
module.exports = {start, stop, mock, verify, url};
const exported = {
start,
stop,
mock,
verify,
url,
};
export default exported;
export {start, stop, mock, verify, url};
+14 -6
View File
@@ -1,8 +1,8 @@
const Docker = require('dockerode');
const getStream = require('get-stream');
const got = require('got');
const delay = require('delay');
const pRetry = require('p-retry');
import Docker from 'dockerode';
import getStream from 'get-stream';
import got from 'got';
import delay from 'delay';
import pRetry from 'p-retry';
const IMAGE = 'semanticrelease/npm-registry-docker:latest';
const SERVER_PORT = 15986;
@@ -76,4 +76,12 @@ async function stop() {
await container.remove();
}
module.exports = {start, stop, authEnv, url};
const exported = {
start,
stop,
authEnv,
url,
};
export default exported;
export {start, stop, authEnv, url};
+7 -2
View File
@@ -1,7 +1,12 @@
const execa = require('execa');
import execa from 'execa';
async function npmView(packageName, env) {
return JSON.parse((await execa('npm', ['view', packageName, '--json'], {env})).stdout);
}
module.exports = {npmView};
const exported = {
npmView,
};
export default exported;
export {npmView};
+4 -4
View File
@@ -1,7 +1,7 @@
const test = require('ava');
const {repeat} = require('lodash');
const hideSensitive = require('../lib/hide-sensitive');
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('../lib/definitions/constants');
import test from 'ava';
import {repeat} from 'lodash';
import hideSensitive from '../lib/hide-sensitive.js';
import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from '../lib/definitions/constants.js';
test('Replace multiple sensitive environment variable values', (t) => {
const env = {SOME_PASSWORD: 'password', SOME_TOKEN: 'secret'};
+12 -11
View File
@@ -1,13 +1,14 @@
const test = require('ava');
const {escapeRegExp, isString, sortBy, omit} = require('lodash');
const proxyquire = require('proxyquire');
const {spy, stub} = require('sinon');
const {WritableStreamBuffer} = require('stream-buffers');
const AggregateError = require('aggregate-error');
const SemanticReleaseError = require('@semantic-release/error');
const {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} = require('../lib/definitions/constants');
const {
gitHead: getGitHead,
import test from 'ava';
import {escapeRegExp, isString, sortBy, omit} from 'lodash';
import proxyquire from 'proxyquire';
import {spy, stub} from 'sinon';
import {WritableStreamBuffer} from 'stream-buffers';
import AggregateError from 'aggregate-error';
import SemanticReleaseError from '@semantic-release/error';
import {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
import {
gitHead as getGitHead,
gitCheckout,
gitTagHead,
gitRepo,
@@ -21,7 +22,7 @@ const {
rebase,
gitAddNote,
gitGetNote,
} = require('./helpers/git-utils');
} from './helpers/git-utils.js';
const requireNoCache = proxyquire.noPreserveCache();
const pluginNoop = require.resolve('./fixtures/plugin-noop');
+18 -16
View File
@@ -1,14 +1,15 @@
const path = require('path');
const test = require('ava');
const proxyquire = require('proxyquire');
const {escapeRegExp} = require('lodash');
const {writeJson, readJson} = require('fs-extra');
const execa = require('execa');
const {WritableStreamBuffer} = require('stream-buffers');
const delay = require('delay');
const getAuthUrl = require('../lib/get-git-auth-url');
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
const {
import path from 'path';
import test from 'ava';
import proxyquire from 'proxyquire';
import {escapeRegExp} from 'lodash';
import {writeJson, readJson} from 'fs-extra';
import execa from 'execa';
import {WritableStreamBuffer} from 'stream-buffers';
import delay from 'delay';
import getAuthUrl from '../lib/get-git-auth-url.js';
import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
import {
gitHead,
gitTagHead,
gitRepo,
@@ -18,11 +19,12 @@ const {
gitCheckout,
merge,
gitGetNote,
} = require('./helpers/git-utils');
const {npmView} = require('./helpers/npm-utils');
const gitbox = require('./helpers/gitbox');
const mockServer = require('./helpers/mockserver');
const npmRegistry = require('./helpers/npm-registry');
} from './helpers/git-utils.js';
import {npmView} from './helpers/npm-utils.js';
import gitbox from './helpers/gitbox.js';
import mockServer from './helpers/mockserver.js';
import npmRegistry from './helpers/npm-registry.js';
/* eslint camelcase: ["error", {properties: "never"}] */
+4 -4
View File
@@ -1,7 +1,7 @@
const test = require('ava');
const {noop} = require('lodash');
const {stub} = require('sinon');
const normalize = require('../../lib/plugins/normalize');
import test from 'ava';
import {noop} from 'lodash';
import {stub} from 'sinon';
import normalize from '../../lib/plugins/normalize.js';
const cwd = process.cwd();
+4 -4
View File
@@ -1,7 +1,7 @@
const test = require('ava');
const {stub} = require('sinon');
const AggregateError = require('aggregate-error');
const pipeline = require('../../lib/plugins/pipeline');
import test from 'ava';
import {stub} from 'sinon';
import AggregateError from 'aggregate-error';
import pipeline from '../../lib/plugins/pipeline.js';
test('Execute each function in series passing the same input', async (t) => {
const step1 = stub().resolves(1);
+6 -6
View File
@@ -1,9 +1,9 @@
const path = require('path');
const test = require('ava');
const {copy, outputFile} = require('fs-extra');
const {stub} = require('sinon');
const tempy = require('tempy');
const getPlugins = require('../../lib/plugins');
import path from 'path';
import test from 'ava';
import {copy, outputFile} from 'fs-extra';
import {stub} from 'sinon';
import tempy from 'tempy';
import getPlugins from '../../lib/plugins';
// Save the current working diretory
const cwd = process.cwd();
+2 -2
View File
@@ -1,5 +1,5 @@
const test = require('ava');
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('../../lib/plugins/utils');
import test from 'ava';
import {validatePlugin, validateStep, loadPlugin, parseConfig} from '../../lib/plugins/utils.js';
test('validatePlugin', (t) => {
const path = 'plugin-module';
+5 -4
View File
@@ -1,6 +1,7 @@
const test = require('ava');
const AggregateError = require('aggregate-error');
const {
import test from 'ava';
import AggregateError from 'aggregate-error';
import {
extractErrors,
tagsToVersions,
isMajorRange,
@@ -15,7 +16,7 @@ const {
getRange,
makeTag,
isSameChannel,
} = require('../lib/utils');
} from '../lib/utils.js';
test('extractErrors', (t) => {
const errors = [new Error('Error 1'), new Error('Error 2')];
+4 -4
View File
@@ -1,7 +1,7 @@
const test = require('ava');
const tempy = require('tempy');
const verify = require('../lib/verify');
const {gitRepo} = require('./helpers/git-utils');
import test from 'ava';
import tempy from 'tempy';
import verify from '../lib/verify.js';
import {gitRepo} from './helpers/git-utils.js';
test('Throw a AggregateError', async (t) => {
const {cwd} = await gitRepo();