Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2caafbaa2b | ||
|
|
e722354f4f | ||
|
|
97748c5e25 | ||
|
|
aec96c791f | ||
|
|
5744c5ecd2 | ||
|
|
1275b8c005 | ||
|
|
8d8910577f | ||
|
|
9890584007 | ||
|
|
63f51ae6dd | ||
|
|
20e7a38cdb | ||
|
|
e06eb82cff | ||
|
|
751a5f1349 |
@@ -131,3 +131,6 @@ yarn.lock
|
||||
|
||||
# Gitbook
|
||||
_book
|
||||
|
||||
# Mockserver
|
||||
CertificateAuthorityCertificate.pem
|
||||
|
||||
@@ -48,8 +48,10 @@ For example the configuration `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next']`
|
||||
|
||||
### channel
|
||||
|
||||
The `channel` can be defined for any branch type. If it's not defined, releases will be done on the default distribution channel (for example the `@latest` [dist-tag](https://docs.npmjs.com/cli/dist-tag) for npm).
|
||||
The value of `channel`, if defined, is generated with [Lodash template](https://lodash.com/docs#template) with the variable `name` available.
|
||||
The `channel` can be defined for any branch type. By default releases will be done on the default distribution channel (for example the `@latest` [dist-tag](https://docs.npmjs.com/cli/dist-tag) for npm) for the first [release branch](#release-branches) and on a distribution channel named based on the branch `name` for any other branch.
|
||||
If the `channel` property is set to `false` the default channel will be used.
|
||||
|
||||
The value of `channel`, if defined as a string, is generated with [Lodash template](https://lodash.com/docs#template) with the variable `name` available.
|
||||
|
||||
For example the configuration `['master', {name: 'next', channel: 'channel-${name}'}]` will be expanded as:
|
||||
```js
|
||||
@@ -78,7 +80,7 @@ For example the configuration `['1.1.x', '1.2.x', 'master']` will be expanded as
|
||||
|
||||
### prerelease
|
||||
|
||||
A `prerelease` property applies only to pre-release branches, is required and The `prerelease` value must be valid per the [Semantic Versioning Specification](https://semver.org/#spec-item-9). It will determine the name of versions (for example if `prerelease` is set to `beta` the version be formatted like `2.0.0-beta.1`, `2.0.0-beta.2` etc...).
|
||||
A `prerelease` property applies only to pre-release branches and the `prerelease` value must be valid per the [Semantic Versioning Specification](https://semver.org/#spec-item-9). It will determine the name of versions (for example if `prerelease` is set to `beta` the version be formatted like `2.0.0-beta.1`, `2.0.0-beta.2` etc...).
|
||||
If the `prerelease` property is set to `true` the `name` value will be used.
|
||||
|
||||
The value of `prerelease`, if defined as a string, is generated with [Lodash template](https://lodash.com/docs#template) with the variable `name` available.
|
||||
|
||||
@@ -3,7 +3,6 @@ const marked = require('marked');
|
||||
const TerminalRenderer = require('marked-terminal');
|
||||
const envCi = require('env-ci');
|
||||
const hookStd = require('hook-std');
|
||||
const pEachSeries = require('p-each-series');
|
||||
const semver = require('semver');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const pkg = require('./package.json');
|
||||
@@ -13,7 +12,7 @@ const verify = require('./lib/verify');
|
||||
const getNextVersion = require('./lib/get-next-version');
|
||||
const getCommits = require('./lib/get-commits');
|
||||
const getLastRelease = require('./lib/get-last-release');
|
||||
const getReleasesToAdd = require('./lib/get-releases-to-add');
|
||||
const getReleaseToAdd = require('./lib/get-release-to-add');
|
||||
const {extractErrors, makeTag} = require('./lib/utils');
|
||||
const getGitAuthUrl = require('./lib/get-git-auth-url');
|
||||
const getBranches = require('./lib/branches');
|
||||
@@ -24,7 +23,7 @@ const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants');
|
||||
|
||||
marked.setOptions({renderer: new TerminalRenderer()});
|
||||
|
||||
/* eslint complexity: ["warn", 25] */
|
||||
/* eslint complexity: off */
|
||||
async function run(context, plugins) {
|
||||
const {cwd, env, options, logger} = context;
|
||||
const {isCi, branch: ciBranch, isPr} = envCi({env, cwd});
|
||||
@@ -92,35 +91,41 @@ async function run(context, plugins) {
|
||||
|
||||
await plugins.verifyConditions(context);
|
||||
|
||||
const releasesToAdd = getReleasesToAdd(context);
|
||||
const errors = [];
|
||||
context.releases = [];
|
||||
const releaseToAdd = getReleaseToAdd(context);
|
||||
|
||||
if (releaseToAdd) {
|
||||
const {lastRelease, currentRelease, nextRelease} = releaseToAdd;
|
||||
|
||||
await pEachSeries(releasesToAdd, async ({lastRelease, currentRelease, nextRelease}) => {
|
||||
nextRelease.gitHead = await getTagHead(nextRelease.gitHead, {cwd, env});
|
||||
currentRelease.gitHead = await getTagHead(currentRelease.gitHead, {cwd, env});
|
||||
if (context.branch.mergeRange && !semver.satisfies(nextRelease.version, context.branch.mergeRange)) {
|
||||
errors.push(getError('EINVALIDMAINTENANCEMERGE', {...context, nextRelease}));
|
||||
return;
|
||||
} else {
|
||||
const commits = await getCommits({...context, lastRelease, nextRelease});
|
||||
nextRelease.notes = await plugins.generateNotes({...context, commits, lastRelease, nextRelease});
|
||||
|
||||
if (options.dryRun) {
|
||||
logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
|
||||
} else {
|
||||
await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env});
|
||||
await push(options.repositoryUrl, {cwd, env});
|
||||
logger.success(`Created tag ${nextRelease.gitTag}`);
|
||||
}
|
||||
|
||||
context.branch.tags.push({
|
||||
version: nextRelease.version,
|
||||
channel: nextRelease.channel,
|
||||
gitTag: nextRelease.gitTag,
|
||||
gitHead: nextRelease.gitHead,
|
||||
});
|
||||
|
||||
const releases = await plugins.addChannel({...context, commits, lastRelease, currentRelease, nextRelease});
|
||||
context.releases.push(...releases);
|
||||
await plugins.success({...context, lastRelease, commits, nextRelease, releases});
|
||||
}
|
||||
|
||||
const commits = await getCommits({...context, lastRelease, nextRelease});
|
||||
nextRelease.notes = await plugins.generateNotes({...context, commits, lastRelease, nextRelease});
|
||||
|
||||
logger.log('Create tag %s', nextRelease.gitTag);
|
||||
await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env});
|
||||
await push(options.repositoryUrl, {cwd, env});
|
||||
context.branch.tags.push({
|
||||
version: nextRelease.version,
|
||||
channel: nextRelease.channel,
|
||||
gitTag: nextRelease.gitTag,
|
||||
gitHead: nextRelease.gitHead,
|
||||
});
|
||||
|
||||
const releases = await plugins.addChannel({...context, commits, lastRelease, currentRelease, nextRelease});
|
||||
context.releases.push(...releases);
|
||||
await plugins.success({...context, lastRelease, commits, nextRelease, releases});
|
||||
});
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
throw new AggregateError(errors);
|
||||
@@ -185,7 +190,9 @@ async function run(context, plugins) {
|
||||
|
||||
await plugins.success({...context, releases});
|
||||
|
||||
logger.success(`Published release ${nextRelease.version}`);
|
||||
logger.success(
|
||||
`Published release ${nextRelease.version} on ${nextRelease.channel ? nextRelease.channel : 'default'} channel`
|
||||
);
|
||||
|
||||
if (options.dryRun) {
|
||||
logger.log(`Release note for version ${nextRelease.version}:`);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {template, escapeRegExp} = require('lodash');
|
||||
const {template, escapeRegExp, flatMap} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const pReduce = require('p-reduce');
|
||||
const debug = require('debug')('semantic-release:get-tags');
|
||||
@@ -14,10 +14,21 @@ module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
|
||||
return pReduce(
|
||||
branches,
|
||||
async (branches, branch) => {
|
||||
const branchTags = (await getTags(branch.name, {cwd, env})).reduce((tags, tag) => {
|
||||
const versions = (await getTags(branch.name, {cwd, env})).reduce((versions, tag) => {
|
||||
const [, version, channel] = tag.match(tagRegexp) || [];
|
||||
return version && semver.valid(semver.clean(version)) ? [...tags, {gitTag: tag, version, channel}] : tags;
|
||||
}, []);
|
||||
if (version && semver.valid(semver.clean(version))) {
|
||||
return {
|
||||
...versions,
|
||||
[version]: versions[version]
|
||||
? {...versions[version], channels: [...versions[version].channels, channel]}
|
||||
: {gitTag: tag, version, channels: [channel]},
|
||||
};
|
||||
}
|
||||
|
||||
return versions;
|
||||
}, {});
|
||||
|
||||
const branchTags = flatMap(versions);
|
||||
|
||||
debug('found tags for branch %s: %o', branch.name, branchTags);
|
||||
return [...branches, {...branch, tags: branchTags}];
|
||||
|
||||
@@ -91,6 +91,7 @@ function release({release}) {
|
||||
name,
|
||||
range: getRange(min, bound),
|
||||
accept: bound ? RELEASE_TYPE.slice(0, RELEASE_TYPE.indexOf(diff)) : RELEASE_TYPE,
|
||||
main: idx === 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const {isUndefined, uniqBy} = require('lodash');
|
||||
const {isNil, uniqBy} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const {isMaintenanceRange} = require('../utils');
|
||||
|
||||
const maintenance = {
|
||||
filter: ({name, range}) => !isUndefined(range) || isMaintenanceRange(name),
|
||||
branchValidator: ({range}) => (isUndefined(range) ? true : isMaintenanceRange(range)),
|
||||
filter: ({name, range}) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
|
||||
branchValidator: ({range}) => (isNil(range) ? true : isMaintenanceRange(range)),
|
||||
branchesValidator: branches => uniqBy(branches, ({range}) => semver.validRange(range)).length === branches.length,
|
||||
};
|
||||
|
||||
const prerelease = {
|
||||
filter: ({prerelease}) => !isUndefined(prerelease),
|
||||
filter: ({prerelease}) => !isNil(prerelease) && prerelease !== false,
|
||||
branchValidator: ({name, prerelease}) =>
|
||||
Boolean(prerelease) && Boolean(semver.valid(`1.0.0-${prerelease === true ? name : prerelease}.1`)),
|
||||
branchesValidator: branches => uniqBy(branches, 'prerelease').length === branches.length,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const {isUndefined} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const {makeTag} = require('./utils');
|
||||
const {makeTag, isSameChannel} = require('./utils');
|
||||
|
||||
/**
|
||||
* Last release.
|
||||
@@ -27,13 +27,17 @@ const {makeTag} = require('./utils');
|
||||
* @return {LastRelease} The last tagged release or empty object if none is found.
|
||||
*/
|
||||
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
|
||||
const [{version, gitTag, channel} = {}] = branch.tags
|
||||
.filter(tag => (branch.type === 'prerelease' && branch.channel === tag.channel) || !semver.prerelease(tag.version))
|
||||
.filter(tag => isUndefined(before) || semver.lt(tag.version, before))
|
||||
const [{version, gitTag, channels} = {}] = branch.tags
|
||||
.filter(
|
||||
tag =>
|
||||
((branch.type === 'prerelease' && tag.channels.some(channel => isSameChannel(branch.channel, channel))) ||
|
||||
!semver.prerelease(tag.version)) &&
|
||||
(isUndefined(before) || semver.lt(tag.version, before))
|
||||
)
|
||||
.sort((a, b) => semver.rcompare(a.version, b.version));
|
||||
|
||||
if (gitTag) {
|
||||
return {version, gitTag, channel, gitHead: gitTag, name: makeTag(tagFormat, version)};
|
||||
return {version, gitTag, channels, gitHead: gitTag, name: makeTag(tagFormat, version)};
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const semver = require('semver');
|
||||
const {FIRST_RELEASE, FIRSTPRERELEASE} = require('./definitions/constants');
|
||||
const {isSameChannel} = require('./utils');
|
||||
|
||||
module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
|
||||
let version;
|
||||
@@ -7,7 +8,8 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
|
||||
const {major, minor, patch} = semver.parse(lastRelease.version);
|
||||
version =
|
||||
branch.type === 'prerelease'
|
||||
? semver.prerelease(lastRelease.version) && lastRelease.channel === channel
|
||||
? semver.prerelease(lastRelease.version) &&
|
||||
lastRelease.channels.some(lastReleaseChannel => isSameChannel(lastReleaseChannel, channel))
|
||||
? semver.inc(lastRelease.version, 'prerelease')
|
||||
: `${semver.inc(`${major}.${minor}.${patch}`, type)}-${branch.prerelease}.${FIRSTPRERELEASE}`
|
||||
: semver.inc(lastRelease.version, type);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
const {uniqBy, intersection} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const semverDiff = require('semver-diff');
|
||||
const getLastRelease = require('./get-last-release');
|
||||
const {makeTag, getLowerBound} = require('./utils');
|
||||
|
||||
/**
|
||||
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
||||
*
|
||||
* @param {Object} context semantic-release context.
|
||||
*
|
||||
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
||||
*/
|
||||
module.exports = context => {
|
||||
const {
|
||||
branch,
|
||||
branches,
|
||||
options: {tagFormat},
|
||||
} = context;
|
||||
|
||||
const higherChannels = branches
|
||||
// Consider only releases of higher branches
|
||||
.slice(branches.findIndex(({name}) => name === branch.name) + 1)
|
||||
// Exclude prerelease branches
|
||||
.filter(({type}) => type !== 'prerelease')
|
||||
.map(({channel}) => channel);
|
||||
|
||||
const versiontoAdd = uniqBy(
|
||||
branch.tags.filter(
|
||||
({channels, version}) =>
|
||||
!channels.includes(branch.channel) &&
|
||||
intersection(channels, higherChannels).length > 0 &&
|
||||
(branch.type !== 'maintenance' || semver.gte(version, getLowerBound(branch.mergeRange)))
|
||||
),
|
||||
'version'
|
||||
).sort((a, b) => semver.compare(b.version, a.version))[0];
|
||||
|
||||
if (versiontoAdd) {
|
||||
const {version, gitTag, channels} = versiontoAdd;
|
||||
const lastRelease = getLastRelease(context, {before: version});
|
||||
if (semver.gt(getLastRelease(context).version, version)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const type = lastRelease.version ? semverDiff(lastRelease.version, version) : 'major';
|
||||
const name = makeTag(tagFormat, version);
|
||||
return {
|
||||
lastRelease,
|
||||
currentRelease: {type, version, channels, gitTag, name, gitHead: gitTag},
|
||||
nextRelease: {
|
||||
type,
|
||||
version,
|
||||
channel: branch.channel,
|
||||
gitTag: makeTag(tagFormat, version, branch.channel),
|
||||
name,
|
||||
gitHead: gitTag,
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,71 +0,0 @@
|
||||
const {uniq} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const semverDiff = require('semver-diff');
|
||||
const getLastRelease = require('./get-last-release');
|
||||
const {makeTag, getLowerBound} = require('./utils');
|
||||
|
||||
/**
|
||||
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
||||
*
|
||||
* @param {Object} context semantic-release context.
|
||||
*
|
||||
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
||||
*/
|
||||
module.exports = context => {
|
||||
const {
|
||||
branch,
|
||||
branches,
|
||||
options: {tagFormat},
|
||||
} = context;
|
||||
|
||||
return (
|
||||
branches
|
||||
// Consider only releases of higher branches
|
||||
.slice(branches.findIndex(({name}) => name === branch.name) + 1)
|
||||
// Exclude prerelease branches
|
||||
.filter(({type}) => type !== 'prerelease')
|
||||
// Find higher branch releases merged to building branch but not released on associated channel
|
||||
.reduce(
|
||||
(releases, higherBranch) => [
|
||||
...releases,
|
||||
// For all unique release version of the higher branch merged on current branch, excluding lower than start range version for maintenance branches
|
||||
...uniq(
|
||||
branch.tags.filter(
|
||||
({channel, version}) =>
|
||||
channel === higherBranch.channel &&
|
||||
channel !== branch.channel &&
|
||||
(branch.type !== 'maintenance' || semver.gte(version, getLowerBound(branch.mergeRange)))
|
||||
)
|
||||
)
|
||||
// Find ones that are not released on the building branch channel
|
||||
.filter(tag =>
|
||||
branch.tags.every(
|
||||
({version, channel}) =>
|
||||
version !== tag.version || channel === higherBranch.channel || channel !== branch.channel
|
||||
)
|
||||
)
|
||||
// Sort in ascending order to add the most recent release last
|
||||
.sort((a, b) => semver.compare(a.version, b.version))
|
||||
// Construct the last and next release to add to the building branch channel
|
||||
.map(({version, gitTag}) => {
|
||||
const lastRelease = getLastRelease(context, {before: version});
|
||||
const type = lastRelease.version ? semverDiff(lastRelease.version, version) : 'major';
|
||||
const name = makeTag(tagFormat, version);
|
||||
return {
|
||||
lastRelease,
|
||||
currentRelease: {type, version, channel: higherBranch.channel, gitTag, name, gitHead: gitTag},
|
||||
nextRelease: {
|
||||
type,
|
||||
version,
|
||||
channel: branch.channel,
|
||||
gitTag: makeTag(tagFormat, version, branch.channel),
|
||||
name,
|
||||
gitHead: gitTag,
|
||||
},
|
||||
};
|
||||
}),
|
||||
],
|
||||
[]
|
||||
)
|
||||
);
|
||||
};
|
||||
+7
-5
@@ -42,12 +42,14 @@ async function getTags(branch, execaOpts) {
|
||||
* @return {Promise<Array<Object>>} The list of commits between `from` and `to`.
|
||||
*/
|
||||
async function getCommits(from, to, execaOpts) {
|
||||
return (await getStream.array(
|
||||
gitLogParser.parse(
|
||||
{_: `${from ? from + '..' : ''}${to}`},
|
||||
{cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}}
|
||||
return (
|
||||
await getStream.array(
|
||||
gitLogParser.parse(
|
||||
{_: `${from ? from + '..' : ''}${to}`},
|
||||
{cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}}
|
||||
)
|
||||
)
|
||||
)).map(({message, gitTags, ...commit}) => ({...commit, message: message.trim(), gitTags: gitTags.trim()}));
|
||||
).map(({message, gitTags, ...commit}) => ({...commit, message: message.trim(), gitTags: gitTags.trim()}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,6 +71,10 @@ function makeTag(tagFormat, version, channel) {
|
||||
return template(tagFormat)({version: `${version}${channel ? `@${channel}` : ''}`});
|
||||
}
|
||||
|
||||
function isSameChannel(channel, otherChannel) {
|
||||
return channel === otherChannel || (!channel && !otherChannel);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
extractErrors,
|
||||
hideSensitiveValues,
|
||||
@@ -86,4 +90,5 @@ module.exports = {
|
||||
getFirstVersion,
|
||||
getRange,
|
||||
makeTag,
|
||||
isSameChannel,
|
||||
};
|
||||
|
||||
+3
-3
@@ -22,10 +22,10 @@
|
||||
"Pierre Vanduynslager (https://twitter.com/@pvdlg_)"
|
||||
],
|
||||
"dependencies": {
|
||||
"@semantic-release/commit-analyzer": "7.0.0-beta.4",
|
||||
"@semantic-release/commit-analyzer": "^7.0.0-beta",
|
||||
"@semantic-release/error": "^2.2.0",
|
||||
"@semantic-release/github": "5.6.0-beta.2",
|
||||
"@semantic-release/npm": "6.0.0-beta.3",
|
||||
"@semantic-release/github": "^5.6.0-beta",
|
||||
"@semantic-release/npm": "^6.0.0-beta",
|
||||
"@semantic-release/release-notes-generator": "^7.1.2",
|
||||
"aggregate-error": "^3.0.0",
|
||||
"cosmiconfig": "^5.0.1",
|
||||
|
||||
@@ -171,7 +171,10 @@ test('Throw SemanticReleaseError for invalid configurations', async t => {
|
||||
});
|
||||
|
||||
test('Throw a SemanticReleaseError if there is duplicate branches', async t => {
|
||||
const branches = [{name: 'master', tags: []}, {name: 'master', tags: []}];
|
||||
const branches = [
|
||||
{name: 'master', tags: []},
|
||||
{name: 'master', tags: []},
|
||||
];
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
|
||||
|
||||
const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', {options: {branches}})))];
|
||||
@@ -183,7 +186,10 @@ test('Throw a SemanticReleaseError if there is duplicate branches', async t => {
|
||||
});
|
||||
|
||||
test('Throw a SemanticReleaseError for each invalid branch name', async t => {
|
||||
const branches = [{name: '~master', tags: []}, {name: '^master', tags: []}];
|
||||
const branches = [
|
||||
{name: '~master', tags: []},
|
||||
{name: '^master', tags: []},
|
||||
];
|
||||
const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []});
|
||||
|
||||
const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', {options: {branches}})))];
|
||||
|
||||
@@ -20,9 +20,9 @@ test('Get the valid tags', async t => {
|
||||
{
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channel: undefined},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channel: undefined},
|
||||
{gitTag: 'v3.0.0-beta.1', version: '3.0.0-beta.1', channel: undefined},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined]},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined]},
|
||||
{gitTag: 'v3.0.0-beta.1', version: '3.0.0-beta.1', channels: [undefined]},
|
||||
],
|
||||
},
|
||||
]);
|
||||
@@ -55,23 +55,17 @@ test('Get the valid tags from multiple branches', async t => {
|
||||
{
|
||||
name: '1.x',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channel: undefined},
|
||||
{gitTag: 'v1.0.0@1.x', version: '1.0.0', channel: '1.x'},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0', channel: undefined},
|
||||
{gitTag: 'v1.1.0@1.x', version: '1.1.0', channel: '1.x'},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined, '1.x']},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0', channels: [undefined, '1.x']},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'master',
|
||||
tags: [
|
||||
...result[0].tags,
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channel: undefined},
|
||||
{gitTag: 'v2.0.0@next', version: '2.0.0', channel: 'next'},
|
||||
],
|
||||
tags: [...result[0].tags, {gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined, 'next']}],
|
||||
},
|
||||
{
|
||||
name: 'next',
|
||||
tags: [...result[1].tags, {gitTag: 'v3.0.0@next', version: '3.0.0', channel: 'next'}],
|
||||
tags: [...result[1].tags, {gitTag: 'v3.0.0@next', version: '3.0.0', channels: ['next']}],
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -91,10 +85,8 @@ test('Match the tag name from the begining of the string and the channel from th
|
||||
{
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'prefix@v1.0.0', version: '1.0.0', channel: undefined},
|
||||
{gitTag: 'prefix@v1.0.0@next', version: '1.0.0', channel: 'next'},
|
||||
{gitTag: 'prefix@v2.0.0', version: '2.0.0', channel: undefined},
|
||||
{gitTag: 'prefix@v2.0.0@next', version: '2.0.0', channel: 'next'},
|
||||
{gitTag: 'prefix@v1.0.0', version: '1.0.0', channels: [undefined, 'next']},
|
||||
{gitTag: 'prefix@v2.0.0', version: '2.0.0', channels: [undefined, 'next']},
|
||||
],
|
||||
},
|
||||
]);
|
||||
@@ -129,7 +121,10 @@ test('Return branches with and empty tags array if no valid tag is found in hist
|
||||
|
||||
const result = await getTags({cwd, options: {tagFormat: `prefix@v\${version}`}}, [{name: 'master'}, {name: 'next'}]);
|
||||
|
||||
t.deepEqual(result, [{name: 'master', tags: []}, {name: 'next', tags: []}]);
|
||||
t.deepEqual(result, [
|
||||
{name: 'master', tags: []},
|
||||
{name: 'next', tags: []},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Get the highest valid tag corresponding to the "tagFormat"', async t => {
|
||||
@@ -138,19 +133,19 @@ test('Get the highest valid tag corresponding to the "tagFormat"', async t => {
|
||||
|
||||
await gitTagVersion('1.0.0', undefined, {cwd});
|
||||
t.deepEqual(await getTags({cwd, options: {tagFormat: `\${version}`}}, [{name: 'master'}]), [
|
||||
{name: 'master', tags: [{gitTag: '1.0.0', version: '1.0.0', channel: undefined}]},
|
||||
{name: 'master', tags: [{gitTag: '1.0.0', version: '1.0.0', channels: [undefined]}]},
|
||||
]);
|
||||
|
||||
await gitTagVersion('foo-1.0.0-bar', undefined, {cwd});
|
||||
t.deepEqual(await getTags({cwd, options: {tagFormat: `foo-\${version}-bar`}}, [{name: 'master'}]), [
|
||||
{name: 'master', tags: [{gitTag: 'foo-1.0.0-bar', version: '1.0.0', channel: undefined}]},
|
||||
{name: 'master', tags: [{gitTag: 'foo-1.0.0-bar', version: '1.0.0', channels: [undefined]}]},
|
||||
]);
|
||||
|
||||
await gitTagVersion('foo-v1.0.0-bar', undefined, {cwd});
|
||||
t.deepEqual(await getTags({cwd, options: {tagFormat: `foo-v\${version}-bar`}}, [{name: 'master'}]), [
|
||||
{
|
||||
name: 'master',
|
||||
tags: [{gitTag: 'foo-v1.0.0-bar', version: '1.0.0', channel: undefined}],
|
||||
tags: [{gitTag: 'foo-v1.0.0-bar', version: '1.0.0', channels: [undefined]}],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -158,7 +153,7 @@ test('Get the highest valid tag corresponding to the "tagFormat"', async t => {
|
||||
t.deepEqual(await getTags({cwd, options: {tagFormat: `(.+)/\${version}/(a-z)`}}, [{name: 'master'}]), [
|
||||
{
|
||||
name: 'master',
|
||||
tags: [{gitTag: '(.+)/1.0.0/(a-z)', version: '1.0.0', channel: undefined}],
|
||||
tags: [{gitTag: '(.+)/1.0.0/(a-z)', version: '1.0.0', channels: [undefined]}],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -166,12 +161,12 @@ test('Get the highest valid tag corresponding to the "tagFormat"', async t => {
|
||||
t.deepEqual(await getTags({cwd, options: {tagFormat: `2.0.0-\${version}-bar.1`}}, [{name: 'master'}]), [
|
||||
{
|
||||
name: 'master',
|
||||
tags: [{gitTag: '2.0.0-1.0.0-bar.1', version: '1.0.0', channel: undefined}],
|
||||
tags: [{gitTag: '2.0.0-1.0.0-bar.1', version: '1.0.0', channels: [undefined]}],
|
||||
},
|
||||
]);
|
||||
|
||||
await gitTagVersion('3.0.0-bar.2', undefined, {cwd});
|
||||
t.deepEqual(await getTags({cwd, options: {tagFormat: `\${version}-bar.2`}}, [{name: 'master'}]), [
|
||||
{name: 'master', tags: [{gitTag: '3.0.0-bar.2', version: '3.0.0', channel: undefined}]},
|
||||
{name: 'master', tags: [{gitTag: '3.0.0-bar.2', version: '3.0.0', channels: [undefined]}]},
|
||||
]);
|
||||
});
|
||||
|
||||
+127
-37
@@ -4,7 +4,11 @@ import normalize from '../../lib/branches/normalize';
|
||||
const toTags = versions => versions.map(version => ({version}));
|
||||
|
||||
test('Maintenance branches - initial state', t => {
|
||||
const maintenance = [{name: '1.x', channel: '1.x', tags: []}, {name: '1.1.x', tags: []}, {name: '1.2.x', tags: []}];
|
||||
const maintenance = [
|
||||
{name: '1.x', channel: '1.x', tags: []},
|
||||
{name: '1.1.x', tags: []},
|
||||
{name: '1.2.x', tags: []},
|
||||
];
|
||||
const release = [{name: 'master', tags: []}];
|
||||
t.deepEqual(
|
||||
normalize.maintenance({maintenance, release}).map(({type, name, range, accept, channel, mergeRange}) => ({
|
||||
@@ -151,16 +155,26 @@ test('Release branches - initial state', t => {
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=1.0.0 <1.1.0', accept: ['patch'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=1.1.0 <2.0.0', accept: ['patch', 'minor'], channel: 'next'},
|
||||
{type: 'release', name: 'master', range: '>=1.0.0 <1.1.0', accept: ['patch'], channel: undefined, main: true},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next',
|
||||
range: '>=1.1.0 <2.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
channel: 'next',
|
||||
main: false,
|
||||
},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next-major',
|
||||
range: '>=2.0.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next-major',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -174,16 +188,26 @@ test('Release branches - 3 release branches', t => {
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=1.0.2 <1.1.0', accept: ['patch'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=1.2.0 <2.0.0', accept: ['patch', 'minor'], channel: 'next'},
|
||||
{type: 'release', name: 'master', range: '>=1.0.2 <1.1.0', accept: ['patch'], channel: undefined, main: true},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next',
|
||||
range: '>=1.2.0 <2.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
channel: 'next',
|
||||
main: false,
|
||||
},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next-major',
|
||||
range: '>=2.1.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next-major',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -196,10 +220,26 @@ test('Release branches - 2 release branches', t => {
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=1.2.0 <2.0.0', accept: ['patch', 'minor'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=2.1.0', accept: ['patch', 'minor', 'major'], channel: 'next'},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'master',
|
||||
range: '>=1.2.0 <2.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
channel: undefined,
|
||||
main: true,
|
||||
},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next',
|
||||
range: '>=2.1.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -221,16 +261,19 @@ test('Release branches - cap ranges to first release only present on following b
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=2.0.0 <2.1.0', accept: ['patch'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=2.1.0 <2.2.0', accept: ['patch'], channel: 'next'},
|
||||
{type: 'release', name: 'master', range: '>=2.0.0 <2.1.0', accept: ['patch'], channel: undefined, main: true},
|
||||
{type: 'release', name: 'next', range: '>=2.1.0 <2.2.0', accept: ['patch'], channel: 'next', main: false},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next-major',
|
||||
range: '>=2.2.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next-major',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -243,10 +286,26 @@ test('Release branches - Handle missing previous tags in branch history', t => {
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=2.0.0 <3.0.0', accept: ['patch', 'minor'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=3.0.0', accept: ['patch', 'minor', 'major'], channel: 'next'},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'master',
|
||||
range: '>=2.0.0 <3.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
channel: undefined,
|
||||
main: true,
|
||||
},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next',
|
||||
range: '>=3.0.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -259,16 +318,26 @@ test('Release branches - enforce release gaps after downstream merge', t => {
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=2.0.0 <2.1.0', accept: ['patch'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=2.1.0 <3.0.0', accept: ['patch', 'minor'], channel: 'next'},
|
||||
{type: 'release', name: 'master', range: '>=2.0.0 <2.1.0', accept: ['patch'], channel: undefined, main: true},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next',
|
||||
range: '>=2.1.0 <3.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
channel: 'next',
|
||||
main: false,
|
||||
},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next-major',
|
||||
range: '>=3.0.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next-major',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -282,16 +351,26 @@ test('Release branches - limit releases on 2nd and 3rd branche based on 1st bran
|
||||
];
|
||||
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({type, name, range, accept, channel}) => ({type, name, range, accept, channel})),
|
||||
normalize
|
||||
.release({release})
|
||||
.map(({type, name, range, accept, channel, main}) => ({type, name, range, accept, channel, main})),
|
||||
[
|
||||
{type: 'release', name: 'master', range: '>=3.0.0 <3.1.0', accept: ['patch'], channel: undefined},
|
||||
{type: 'release', name: 'next', range: '>=3.1.0 <4.0.0', accept: ['patch', 'minor'], channel: 'next'},
|
||||
{type: 'release', name: 'master', range: '>=3.0.0 <3.1.0', accept: ['patch'], channel: undefined, main: true},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next',
|
||||
range: '>=3.1.0 <4.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
channel: 'next',
|
||||
main: false,
|
||||
},
|
||||
{
|
||||
type: 'release',
|
||||
name: 'next-major',
|
||||
range: '>=4.0.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
channel: 'next-major',
|
||||
main: false,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -303,24 +382,35 @@ test('Prerelease branches', t => {
|
||||
{name: 'alpha', prerelease: 'preview', tags: []},
|
||||
];
|
||||
|
||||
t.deepEqual(normalize.prerelease({prerelease}).map(({type, name, channel}) => ({type, name, channel})), [
|
||||
{type: 'prerelease', name: 'beta', channel: 'beta'},
|
||||
{type: 'prerelease', name: 'alpha', channel: 'alpha'},
|
||||
]);
|
||||
t.deepEqual(
|
||||
normalize.prerelease({prerelease}).map(({type, name, channel}) => ({type, name, channel})),
|
||||
[
|
||||
{type: 'prerelease', name: 'beta', channel: 'beta'},
|
||||
{type: 'prerelease', name: 'alpha', channel: 'alpha'},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test('Allow to set channel to "false" to prevent default', t => {
|
||||
const maintenance = [{name: '1.x', channel: false, tags: []}];
|
||||
const release = [{name: 'master', channel: false, tags: []}, {name: 'next', channel: false, tags: []}];
|
||||
const release = [
|
||||
{name: 'master', channel: false, tags: []},
|
||||
{name: 'next', channel: false, tags: []},
|
||||
];
|
||||
const prerelease = [{name: 'beta', channel: false, prerelease: true, tags: []}];
|
||||
t.deepEqual(normalize.maintenance({maintenance, release}).map(({name, channel}) => ({name, channel})), [
|
||||
{name: '1.x', channel: false},
|
||||
]);
|
||||
t.deepEqual(normalize.release({release}).map(({name, channel}) => ({name, channel})), [
|
||||
{name: 'master', channel: false},
|
||||
{name: 'next', channel: false},
|
||||
]);
|
||||
t.deepEqual(normalize.prerelease({prerelease}).map(({name, channel}) => ({name, channel})), [
|
||||
{name: 'beta', channel: false},
|
||||
]);
|
||||
t.deepEqual(
|
||||
normalize.maintenance({maintenance, release}).map(({name, channel}) => ({name, channel})),
|
||||
[{name: '1.x', channel: false}]
|
||||
);
|
||||
t.deepEqual(
|
||||
normalize.release({release}).map(({name, channel}) => ({name, channel})),
|
||||
[
|
||||
{name: 'master', channel: false},
|
||||
{name: 'next', channel: false},
|
||||
]
|
||||
);
|
||||
t.deepEqual(
|
||||
normalize.prerelease({prerelease}).map(({name, channel}) => ({name, channel})),
|
||||
[{name: 'beta', channel: false}]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -8,9 +8,10 @@ test('A "maintenance" branch is identified by having a "range" property or a "na
|
||||
t.true(maintenance.filter({name: 'some-name', range: '1.x.x'}));
|
||||
t.true(maintenance.filter({name: 'some-name', range: '1.1.x'}));
|
||||
t.true(maintenance.filter({name: 'some-name', range: ''}));
|
||||
t.true(maintenance.filter({name: 'some-name', range: null}));
|
||||
t.true(maintenance.filter({name: 'some-name', range: false}));
|
||||
t.true(maintenance.filter({name: 'some-name', range: true}));
|
||||
|
||||
t.false(maintenance.filter({name: 'some-name', range: null}));
|
||||
t.false(maintenance.filter({name: 'some-name', range: false}));
|
||||
t.false(maintenance.filter({name: 'some-name'}));
|
||||
t.false(maintenance.filter({name: '1.0.0'}));
|
||||
t.false(maintenance.filter({name: 'x.x.x'}));
|
||||
@@ -24,9 +25,8 @@ test('A "maintenance" branches must have a "range" property formatted like "N.x"
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: '>=1.0.0 <2.0.0'}));
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: '1.0.0'}));
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: 'wrong-range'}));
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: true}));
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: ''}));
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: null}));
|
||||
t.false(maintenance.branchValidator({name: 'some-name', range: false}));
|
||||
});
|
||||
|
||||
test('The "maintenance" branches must have unique ranges', t => {
|
||||
@@ -36,13 +36,13 @@ test('The "maintenance" branches must have unique ranges', t => {
|
||||
t.false(maintenance.branchesValidator([{range: '1.x.x'}, {range: '1.x'}]));
|
||||
});
|
||||
|
||||
test('A "prerelease" branch is identified by having a range "prerelease" property', t => {
|
||||
test('A "prerelease" branch is identified by having a thruthy "prerelease" property', t => {
|
||||
t.true(prerelease.filter({name: 'some-name', prerelease: true}));
|
||||
t.true(prerelease.filter({name: 'some-name', prerelease: 'beta'}));
|
||||
t.true(prerelease.filter({name: 'some-name', prerelease: ''}));
|
||||
t.true(prerelease.filter({name: 'some-name', prerelease: null}));
|
||||
t.true(prerelease.filter({name: 'some-name', prerelease: false}));
|
||||
|
||||
t.false(prerelease.filter({name: 'some-name', prerelease: null}));
|
||||
t.false(prerelease.filter({name: 'some-name', prerelease: false}));
|
||||
t.false(prerelease.filter({name: 'some-name'}));
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ test('Get the highest non-prerelease valid tag', t => {
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: 'v2.0.0', channel: 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 => {
|
||||
@@ -25,9 +25,14 @@ test('Get the highest prerelease valid tag, ignoring other tags from other prere
|
||||
prerelease: 'beta',
|
||||
channel: 'beta',
|
||||
tags: [
|
||||
{version: '1.0.0-beta.1', gitTag: 'v1.0.0-beta.1@beta', gitHead: 'v1.0.0-beta.1@beta', channel: 'beta'},
|
||||
{version: '1.0.0-beta.2', gitTag: 'v1.0.0-beta.2@beta', gitHead: 'v1.0.0-beta.2@beta', channel: 'beta'},
|
||||
{version: '1.0.0-alpha.1', gitTag: 'v1.0.0-alpha.1@alpha', gitHead: 'v1.0.0-alpha.1@alpha', channel: 'alpha'},
|
||||
{version: '1.0.0-beta.1', gitTag: 'v1.0.0-beta.1@beta', gitHead: 'v1.0.0-beta.1@beta', channels: ['beta']},
|
||||
{version: '1.0.0-beta.2', gitTag: 'v1.0.0-beta.2@beta', gitHead: 'v1.0.0-beta.2@beta', channels: ['beta']},
|
||||
{
|
||||
version: '1.0.0-alpha.1',
|
||||
gitTag: 'v1.0.0-alpha.1@alpha',
|
||||
gitHead: 'v1.0.0-alpha.1@alpha',
|
||||
channels: ['alpha'],
|
||||
},
|
||||
],
|
||||
type: 'prerelease',
|
||||
},
|
||||
@@ -39,7 +44,7 @@ test('Get the highest prerelease valid tag, ignoring other tags from other prere
|
||||
gitTag: 'v1.0.0-beta.2@beta',
|
||||
name: 'v1.0.0-beta.2',
|
||||
gitHead: 'v1.0.0-beta.2@beta',
|
||||
channel: 'beta',
|
||||
channels: ['beta'],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -76,5 +81,5 @@ test('Get the highest non-prerelease valid tag before a certain version', t => {
|
||||
{before: '2.1.0'}
|
||||
);
|
||||
|
||||
t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: 'v2.0.0', channel: undefined});
|
||||
t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: 'v2.0.0', channels: undefined});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ test('Increase version for patch release', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'master', type: 'release'},
|
||||
nextRelease: {type: 'patch'},
|
||||
lastRelease: {version: '1.0.0'},
|
||||
lastRelease: {version: '1.0.0', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.1'
|
||||
@@ -25,7 +25,7 @@ test('Increase version for minor release', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'master', type: 'release'},
|
||||
nextRelease: {type: 'minor'},
|
||||
lastRelease: {version: '1.0.0'},
|
||||
lastRelease: {version: '1.0.0', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.1.0'
|
||||
@@ -37,7 +37,7 @@ test('Increase version for major release', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'master', type: 'release'},
|
||||
nextRelease: {type: 'major'},
|
||||
lastRelease: {version: '1.0.0'},
|
||||
lastRelease: {version: '1.0.0', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'2.0.0'
|
||||
@@ -61,7 +61,7 @@ test('Increase version for patch release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
|
||||
nextRelease: {type: 'patch'},
|
||||
lastRelease: {version: '1.0.0'},
|
||||
lastRelease: {version: '1.0.0', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.1-beta.1'
|
||||
@@ -71,7 +71,7 @@ test('Increase version for patch release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
|
||||
nextRelease: {type: 'patch'},
|
||||
lastRelease: {version: '1.0.0-beta.1'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.0-beta.2'
|
||||
@@ -81,7 +81,7 @@ test('Increase version for patch release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'alpha', type: 'prerelease', prerelease: 'alpha'},
|
||||
nextRelease: {type: 'patch', channel: 'alpha'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channel: 'beta'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channels: ['beta']},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.1-alpha.1'
|
||||
@@ -93,7 +93,7 @@ test('Increase version for minor release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
|
||||
nextRelease: {type: 'minor'},
|
||||
lastRelease: {version: '1.0.0'},
|
||||
lastRelease: {version: '1.0.0', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.1.0-beta.1'
|
||||
@@ -103,7 +103,7 @@ test('Increase version for minor release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
|
||||
nextRelease: {type: 'minor'},
|
||||
lastRelease: {version: '1.0.0-beta.1'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.0-beta.2'
|
||||
@@ -113,7 +113,7 @@ test('Increase version for minor release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'alpha', type: 'prerelease', prerelease: 'alpha'},
|
||||
nextRelease: {type: 'minor', channel: 'alpha'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channel: 'beta'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channels: ['beta']},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.1.0-alpha.1'
|
||||
@@ -125,7 +125,7 @@ test('Increase version for major release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
|
||||
nextRelease: {type: 'major'},
|
||||
lastRelease: {version: '1.0.0'},
|
||||
lastRelease: {version: '1.0.0', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'2.0.0-beta.1'
|
||||
@@ -135,7 +135,7 @@ test('Increase version for major release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
|
||||
nextRelease: {type: 'major'},
|
||||
lastRelease: {version: '1.0.0-beta.1'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channels: [undefined]},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'1.0.0-beta.2'
|
||||
@@ -145,7 +145,7 @@ test('Increase version for major release on prerelease branch', t => {
|
||||
getNextVersion({
|
||||
branch: {name: 'alpha', type: 'prerelease', prerelease: 'alpha'},
|
||||
nextRelease: {type: 'major', channel: 'alpha'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channel: 'beta'},
|
||||
lastRelease: {version: '1.0.0-beta.1', channels: ['beta']},
|
||||
logger: t.context.logger,
|
||||
}),
|
||||
'2.0.0-alpha.1'
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
import test from 'ava';
|
||||
import getReleaseToAdd from '../lib/get-release-to-add';
|
||||
|
||||
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: '2.x',
|
||||
channel: '2.x',
|
||||
type: 'maintenance',
|
||||
mergeRange: '>=2.0.0 <3.0.0',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0@2.x', version: '2.0.0', channels: ['2.x']},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined]},
|
||||
{gitTag: 'v2.1.0', version: '2.1.0', channels: [undefined]},
|
||||
{gitTag: 'v2.1.1', version: '2.1.1', channels: [undefined]},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined]},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0', channels: [undefined]},
|
||||
],
|
||||
},
|
||||
branches: [{name: '2.x', channel: '2.x'}, {name: 'master'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, {
|
||||
lastRelease: {version: '2.1.0', channels: [undefined], gitTag: 'v2.1.0', name: 'v2.1.0', gitHead: 'v2.1.0'},
|
||||
currentRelease: {
|
||||
type: 'patch',
|
||||
version: '2.1.1',
|
||||
channels: [undefined],
|
||||
gitTag: 'v2.1.1',
|
||||
name: 'v2.1.1',
|
||||
gitHead: 'v2.1.1',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'patch',
|
||||
version: '2.1.1',
|
||||
channel: '2.x',
|
||||
gitTag: 'v2.1.1@2.x',
|
||||
name: 'v2.1.1',
|
||||
gitHead: 'v2.1.1',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Return versions merged between release branches', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined, 'next']},
|
||||
{gitTag: 'v1.1.0@next', version: '1.1.0', channels: ['next']},
|
||||
{gitTag: 'v2.0.0@next-major', version: '2.0.0', channels: ['next-major']},
|
||||
],
|
||||
},
|
||||
branches: [{name: 'master'}, {name: 'next', channel: 'next'}, {name: 'next-major', channel: 'next-major'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, {
|
||||
lastRelease: {
|
||||
version: '1.1.0',
|
||||
gitTag: 'v1.1.0@next',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
channels: ['next'],
|
||||
},
|
||||
currentRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channels: ['next-major'],
|
||||
gitTag: 'v2.0.0@next-major',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.0.0',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Return releases sorted by ascending order', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0@next-major', version: '2.0.0', channels: ['next-major']},
|
||||
{gitTag: 'v1.1.0@next', version: '1.1.0', channels: ['next']},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined, 'next']},
|
||||
// {gitTag: 'v1.0.0@next', version: '1.0.0', channel: 'next'},
|
||||
],
|
||||
},
|
||||
branches: [{name: 'master'}, {name: 'next', channel: 'next'}, {name: 'next-major', channel: 'next-major'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, {
|
||||
lastRelease: {version: '1.1.0', gitTag: 'v1.1.0@next', name: 'v1.1.0', gitHead: 'v1.1.0@next', channels: ['next']},
|
||||
currentRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channels: ['next-major'],
|
||||
gitTag: 'v2.0.0@next-major',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.0.0',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('No lastRelease', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [{gitTag: 'v1.0.0@next', version: '1.0.0', channels: ['next']}],
|
||||
},
|
||||
branches: [{name: 'master'}, {name: 'next', channel: 'next'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, {
|
||||
lastRelease: {},
|
||||
currentRelease: {
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channels: ['next'],
|
||||
gitTag: 'v1.0.0@next',
|
||||
name: 'v1.0.0',
|
||||
gitHead: 'v1.0.0@next',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v1.0.0',
|
||||
name: 'v1.0.0',
|
||||
gitHead: 'v1.0.0@next',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Ignore pre-release versions', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined, 'next']},
|
||||
{gitTag: 'v1.1.0@next', version: '1.1.0', channels: ['next']},
|
||||
{gitTag: 'v2.0.0-alpha.1@alpha', version: '2.0.0-alpha.1', channels: ['alpha']},
|
||||
],
|
||||
},
|
||||
branches: [
|
||||
{name: 'master'},
|
||||
{name: 'next', channel: 'next'},
|
||||
{name: 'alpha', type: 'prerelease', channel: 'alpha'},
|
||||
],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, {
|
||||
lastRelease: {version: '1.0.0', channels: [undefined, 'next'], gitTag: 'v1.0.0', name: 'v1.0.0', gitHead: 'v1.0.0'},
|
||||
currentRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channels: ['next'],
|
||||
gitTag: 'v1.1.0@next',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v1.1.0',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Exclude versions merged from release to maintenance branch if they have the same "channel"', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: '2.x',
|
||||
channel: 'latest',
|
||||
type: 'maintenance',
|
||||
mergeRange: '>=2.0.0 <3.0.0',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined]},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined]},
|
||||
{gitTag: 'v2.1.0', version: '2.1.0', channels: [undefined]},
|
||||
{gitTag: 'v2.1.1', version: '2.1.1', channels: [undefined]},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined]},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0', channels: [undefined]},
|
||||
],
|
||||
},
|
||||
branches: [
|
||||
{name: '2.x', channel: 'latest'},
|
||||
{name: 'master', channel: 'latest'},
|
||||
],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.is(result, undefined);
|
||||
});
|
||||
|
||||
test('Exclude versions merged between release branches if they have the same "channel"', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
channel: 'latest',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', channels: ['latest'], version: '1.0.0'},
|
||||
{gitTag: 'v1.1.0', channels: ['latest'], version: '1.1.0'},
|
||||
{gitTag: 'v2.0.0', channels: ['latest'], version: '2.0.0'},
|
||||
],
|
||||
},
|
||||
branches: [
|
||||
{name: 'master', channel: 'latest'},
|
||||
{name: 'next', channel: 'latest'},
|
||||
{name: 'next-major', channel: 'latest'},
|
||||
],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.is(result, undefined);
|
||||
});
|
||||
|
||||
test('Exclude versions merged between release branches if they all have "channel" set to "false"', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
channel: false,
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined]},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0', channels: [undefined]},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined]},
|
||||
],
|
||||
},
|
||||
branches: [
|
||||
{name: 'master', channel: false},
|
||||
{name: 'next', channel: false},
|
||||
{name: 'next-major', channel: false},
|
||||
],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.is(result, undefined);
|
||||
});
|
||||
|
||||
test('Exclude versions number less than the latest version already released on that branch', t => {
|
||||
const result = getReleaseToAdd({
|
||||
branch: {
|
||||
name: '2.x',
|
||||
channel: '2.x',
|
||||
type: 'maintenance',
|
||||
mergeRange: '>=2.0.0 <3.0.0',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0@2.x', version: '2.0.0', channels: ['2.x']},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0', channels: [undefined]},
|
||||
{gitTag: 'v2.1.0', version: '2.1.0', channels: [undefined]},
|
||||
{gitTag: 'v2.1.1', version: '2.1.1', channels: [undefined, '2.x']},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0', channels: [undefined]},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0', channels: [undefined]},
|
||||
],
|
||||
},
|
||||
branches: [{name: '2.x', channel: '2.x'}, {name: 'master'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.is(result, undefined);
|
||||
});
|
||||
@@ -1,316 +0,0 @@
|
||||
import test from 'ava';
|
||||
import getReleasesToAdd from '../lib/get-releases-to-add';
|
||||
|
||||
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: '2.x',
|
||||
channel: '2.x',
|
||||
type: 'maintenance',
|
||||
mergeRange: '>=2.0.0 <3.0.0',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0@2.x', version: '2.0.0', channel: '2.x'},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0'},
|
||||
{gitTag: 'v2.1.0', version: '2.1.0'},
|
||||
{gitTag: 'v2.1.1', version: '2.1.1'},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0'},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0'},
|
||||
],
|
||||
},
|
||||
branches: [{name: '2.x', channel: '2.x'}, {name: 'master'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, [
|
||||
{
|
||||
lastRelease: {version: '2.0.0', channel: '2.x', gitTag: 'v2.0.0@2.x', name: 'v2.0.0', gitHead: 'v2.0.0@2.x'},
|
||||
currentRelease: {
|
||||
type: 'minor',
|
||||
version: '2.1.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.1.0',
|
||||
name: 'v2.1.0',
|
||||
gitHead: 'v2.1.0',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'minor',
|
||||
version: '2.1.0',
|
||||
channel: '2.x',
|
||||
gitTag: 'v2.1.0@2.x',
|
||||
name: 'v2.1.0',
|
||||
gitHead: 'v2.1.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
lastRelease: {version: '2.1.0', channel: undefined, gitTag: 'v2.1.0', name: 'v2.1.0', gitHead: 'v2.1.0'},
|
||||
currentRelease: {
|
||||
type: 'patch',
|
||||
version: '2.1.1',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.1.1',
|
||||
name: 'v2.1.1',
|
||||
gitHead: 'v2.1.1',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'patch',
|
||||
version: '2.1.1',
|
||||
channel: '2.x',
|
||||
gitTag: 'v2.1.1@2.x',
|
||||
name: 'v2.1.1',
|
||||
gitHead: 'v2.1.1',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Return versions merged between release branches', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0'},
|
||||
{gitTag: 'v1.0.0@next', version: '1.0.0', channel: 'next'},
|
||||
{gitTag: 'v1.1.0@next', version: '1.1.0', channel: 'next'},
|
||||
{gitTag: 'v2.0.0@next-major', version: '2.0.0', channel: 'next-major'},
|
||||
],
|
||||
},
|
||||
branches: [{name: 'master'}, {name: 'next', channel: 'next'}, {name: 'next-major', channel: 'next-major'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, [
|
||||
{
|
||||
lastRelease: {version: '1.0.0', channel: undefined, gitTag: 'v1.0.0', name: 'v1.0.0', gitHead: 'v1.0.0'},
|
||||
currentRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: 'next',
|
||||
gitTag: 'v1.1.0@next',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v1.1.0',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
},
|
||||
{
|
||||
lastRelease: {version: '1.1.0', gitTag: 'v1.1.0@next', name: 'v1.1.0', gitHead: 'v1.1.0@next', channel: 'next'},
|
||||
currentRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: 'next-major',
|
||||
gitTag: 'v2.0.0@next-major',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.0.0',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Return releases sorted by ascending order', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0@next-major', version: '2.0.0', channel: 'next-major'},
|
||||
{gitTag: 'v1.1.0@next', version: '1.1.0', channel: 'next'},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0'},
|
||||
{gitTag: 'v1.0.0@next', version: '1.0.0', channel: 'next'},
|
||||
],
|
||||
},
|
||||
branches: [{name: 'master'}, {name: 'next', channel: 'next'}, {name: 'next-major', channel: 'next-major'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, [
|
||||
{
|
||||
lastRelease: {version: '1.0.0', channel: undefined, gitTag: 'v1.0.0', name: 'v1.0.0', gitHead: 'v1.0.0'},
|
||||
currentRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: 'next',
|
||||
gitTag: 'v1.1.0@next',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v1.1.0',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
},
|
||||
{
|
||||
lastRelease: {version: '1.1.0', gitTag: 'v1.1.0@next', name: 'v1.1.0', gitHead: 'v1.1.0@next', channel: 'next'},
|
||||
currentRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: 'next-major',
|
||||
gitTag: 'v2.0.0@next-major',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.0.0',
|
||||
name: 'v2.0.0',
|
||||
gitHead: 'v2.0.0@next-major',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('No lastRelease', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [{gitTag: 'v1.0.0@next', version: '1.0.0', channel: 'next'}],
|
||||
},
|
||||
branches: [{name: 'master'}, {name: 'next', channel: 'next'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, [
|
||||
{
|
||||
lastRelease: {},
|
||||
currentRelease: {
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: 'next',
|
||||
gitTag: 'v1.0.0@next',
|
||||
name: 'v1.0.0',
|
||||
gitHead: 'v1.0.0@next',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v1.0.0',
|
||||
name: 'v1.0.0',
|
||||
gitHead: 'v1.0.0@next',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Ignore pre-release versions', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0'},
|
||||
{gitTag: 'v1.0.0@next', version: '1.0.0', channel: 'next'},
|
||||
{gitTag: 'v1.1.0@next', version: '1.1.0', channel: 'next'},
|
||||
{gitTag: 'v2.0.0-alpha.1@alpha', version: '2.0.0', channel: 'alpha'},
|
||||
],
|
||||
},
|
||||
branches: [
|
||||
{name: 'master'},
|
||||
{name: 'next', channel: 'next'},
|
||||
{name: 'alpha', type: 'prerelease', channel: 'alpha'},
|
||||
],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, [
|
||||
{
|
||||
lastRelease: {version: '1.0.0', channel: undefined, gitTag: 'v1.0.0', name: 'v1.0.0', gitHead: 'v1.0.0'},
|
||||
currentRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: 'next',
|
||||
gitTag: 'v1.1.0@next',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
nextRelease: {
|
||||
type: 'minor',
|
||||
version: '1.1.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v1.1.0',
|
||||
name: 'v1.1.0',
|
||||
gitHead: 'v1.1.0@next',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Exclude versions merged from release to maintenance branch if they have the same "channel"', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: '2.x',
|
||||
channel: 'latest',
|
||||
type: 'maintenance',
|
||||
mergeRange: '>=2.0.0 <3.0.0',
|
||||
tags: [
|
||||
{gitTag: 'v2.0.0', version: '2.0.0'},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0'},
|
||||
{gitTag: 'v2.1.0', version: '2.1.0'},
|
||||
{gitTag: 'v2.1.1', version: '2.1.1'},
|
||||
{gitTag: 'v1.0.0', version: '1.0.0'},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0'},
|
||||
],
|
||||
},
|
||||
branches: [{name: '2.x', channel: 'latest'}, {name: 'master', channel: 'latest'}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, []);
|
||||
});
|
||||
|
||||
test('Exclude versions merged between release branches if they have the same "channel"', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
channel: 'latest',
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', channel: 'latest', version: '1.0.0'},
|
||||
{gitTag: 'v1.1.0', channel: 'latest', version: '1.1.0'},
|
||||
{gitTag: 'v2.0.0', channel: 'latest', version: '2.0.0'},
|
||||
],
|
||||
},
|
||||
branches: [
|
||||
{name: 'master', channel: 'latest'},
|
||||
{name: 'next', channel: 'latest'},
|
||||
{name: 'next-major', channel: 'latest'},
|
||||
],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, []);
|
||||
});
|
||||
|
||||
test('Exclude versions merged between release branches if they all have "channel" set to "false"', t => {
|
||||
const result = getReleasesToAdd({
|
||||
branch: {
|
||||
name: 'master',
|
||||
channel: false,
|
||||
tags: [
|
||||
{gitTag: 'v1.0.0', version: '1.0.0'},
|
||||
{gitTag: 'v1.1.0', version: '1.1.0'},
|
||||
{gitTag: 'v2.0.0', version: '2.0.0'},
|
||||
],
|
||||
},
|
||||
branches: [{name: 'master', channel: false}, {name: 'next', channel: false}, {name: 'next-major', channel: false}],
|
||||
options: {tagFormat: `v\${version}`},
|
||||
});
|
||||
|
||||
t.deepEqual(result, []);
|
||||
});
|
||||
@@ -86,9 +86,11 @@ export async function gitCommits(messages, execaOpts) {
|
||||
*/
|
||||
export async function gitGetCommits(from, execaOpts) {
|
||||
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
|
||||
return (await getStream.array(
|
||||
gitLogParser.parse({_: `${from ? from + '..' : ''}HEAD`}, {...execaOpts, env: {...process.env, ...execaOpts.env}})
|
||||
)).map(commit => {
|
||||
return (
|
||||
await getStream.array(
|
||||
gitLogParser.parse({_: `${from ? from + '..' : ''}HEAD`}, {...execaOpts, env: {...process.env, ...execaOpts.env}})
|
||||
)
|
||||
).map(commit => {
|
||||
commit.message = commit.message.trim();
|
||||
commit.gitTags = commit.gitTags.trim();
|
||||
return commit;
|
||||
|
||||
+125
-35
@@ -1,5 +1,5 @@
|
||||
import test from 'ava';
|
||||
import {escapeRegExp, isString, sortBy} from 'lodash';
|
||||
import {escapeRegExp, isString, sortBy, omit} from 'lodash';
|
||||
import proxyquire from 'proxyquire';
|
||||
import {spy, stub} from 'sinon';
|
||||
import {WritableStreamBuffer} from 'stream-buffers';
|
||||
@@ -57,7 +57,7 @@ test('Plugins are called with expected values', async t => {
|
||||
gitHead: commits[commits.length - 1].hash,
|
||||
gitTag: 'v1.0.0@next',
|
||||
name: 'v1.0.0',
|
||||
channel: 'next',
|
||||
channels: ['next'],
|
||||
};
|
||||
const nextRelease = {
|
||||
name: 'v1.1.0',
|
||||
@@ -96,16 +96,18 @@ test('Plugins are called with expected values', async t => {
|
||||
name: 'master',
|
||||
range: '>=1.0.0 <2.0.0',
|
||||
accept: ['patch', 'minor'],
|
||||
tags: [{channel: 'next', gitTag: 'v1.0.0@next', version: '1.0.0'}],
|
||||
tags: [{channels: ['next'], gitTag: 'v1.0.0@next', version: '1.0.0'}],
|
||||
type: 'release',
|
||||
main: true,
|
||||
},
|
||||
{
|
||||
channel: 'next',
|
||||
name: 'next',
|
||||
range: '>=2.0.0',
|
||||
accept: ['patch', 'minor', 'major'],
|
||||
tags: [{channel: 'next', gitTag: 'v1.0.0@next', version: '1.0.0'}],
|
||||
tags: [{channels: ['next'], gitTag: 'v1.0.0@next', version: '1.0.0'}],
|
||||
type: 'release',
|
||||
main: false,
|
||||
},
|
||||
];
|
||||
const branch = branches[0];
|
||||
@@ -124,7 +126,7 @@ test('Plugins are called with expected values', async t => {
|
||||
|
||||
const releases = [
|
||||
{
|
||||
...lastRelease,
|
||||
...omit(lastRelease, 'channels'),
|
||||
...release1,
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
@@ -176,7 +178,7 @@ test('Plugins are called with expected values', async t => {
|
||||
t.deepEqual(generateNotes1.args[0][1].commits[0].hash, commits[1].hash);
|
||||
t.deepEqual(generateNotes1.args[0][1].commits[0].message, commits[1].message);
|
||||
t.deepEqual(generateNotes1.args[0][1].nextRelease, {
|
||||
...lastRelease,
|
||||
...omit(lastRelease, 'channels'),
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
@@ -193,7 +195,7 @@ test('Plugins are called with expected values', async t => {
|
||||
t.deepEqual(generateNotes2.args[0][1].commits[0].hash, commits[1].hash);
|
||||
t.deepEqual(generateNotes2.args[0][1].commits[0].message, commits[1].message);
|
||||
t.deepEqual(generateNotes2.args[0][1].nextRelease, {
|
||||
...lastRelease,
|
||||
...omit(lastRelease, 'channels'),
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
@@ -211,7 +213,7 @@ test('Plugins are called with expected values', async t => {
|
||||
t.deepEqual(generateNotes3.args[0][1].commits[0].hash, commits[1].hash);
|
||||
t.deepEqual(generateNotes3.args[0][1].commits[0].message, commits[1].message);
|
||||
t.deepEqual(generateNotes3.args[0][1].nextRelease, {
|
||||
...lastRelease,
|
||||
...omit(lastRelease, 'channels'),
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
@@ -236,7 +238,7 @@ test('Plugins are called with expected values', async t => {
|
||||
t.deepEqual(addChannel.args[0][1].lastRelease, {});
|
||||
t.deepEqual(addChannel.args[0][1].currentRelease, {...lastRelease, type: 'major'});
|
||||
t.deepEqual(addChannel.args[0][1].nextRelease, {
|
||||
...lastRelease,
|
||||
...omit(lastRelease, 'channels'),
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
@@ -330,7 +332,7 @@ test('Plugins are called with expected values', async t => {
|
||||
t.deepEqual(success.args[0][1].commits[0].hash, commits[1].hash);
|
||||
t.deepEqual(success.args[0][1].commits[0].message, commits[1].message);
|
||||
t.deepEqual(success.args[0][1].nextRelease, {
|
||||
...lastRelease,
|
||||
...omit(lastRelease, 'channels'),
|
||||
type: 'major',
|
||||
version: '1.0.0',
|
||||
channel: undefined,
|
||||
@@ -581,6 +583,117 @@ test('Publish a pre-release version', async t => {
|
||||
t.is(releases[0].gitTag, 'v1.1.0-beta.2@beta');
|
||||
});
|
||||
|
||||
test('Publish releases from different branch on the same channel', async t => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
await gitCommits(['feat: initial commit'], {cwd});
|
||||
await gitTagVersion('v1.0.0', undefined, {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
await gitCheckout('next-major', true, {cwd});
|
||||
await gitPush(repositoryUrl, 'next-major', {cwd});
|
||||
await gitCheckout('next', true, {cwd});
|
||||
await gitCommits(['feat: a feature'], {cwd});
|
||||
await gitPush(repositoryUrl, 'next', {cwd});
|
||||
|
||||
const config = {
|
||||
branches: ['master', {name: 'next', channel: false}, {name: 'next-major', channel: false}],
|
||||
repositoryUrl,
|
||||
};
|
||||
const addChannel = stub().resolves({});
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(''),
|
||||
addChannel,
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
};
|
||||
|
||||
let semanticRelease = requireNoCache('..', {
|
||||
'./lib/get-logger': () => t.context.logger,
|
||||
'env-ci': () => ({isCi: true, branch: 'next', isPr: false}),
|
||||
});
|
||||
let {releases} = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
|
||||
|
||||
t.is(releases.length, 1);
|
||||
t.is(releases[0].version, '1.1.0');
|
||||
t.is(releases[0].gitTag, 'v1.1.0');
|
||||
|
||||
await gitCommits(['fix: a fix'], {cwd});
|
||||
({releases} = await semanticRelease(options, {
|
||||
cwd,
|
||||
env: {},
|
||||
stdout: {write: () => {}},
|
||||
stderr: {write: () => {}},
|
||||
}));
|
||||
|
||||
t.is(releases.length, 1);
|
||||
t.is(releases[0].version, '1.1.1');
|
||||
t.is(releases[0].gitTag, 'v1.1.1');
|
||||
|
||||
await gitCheckout('master', false, {cwd});
|
||||
await merge('next', {cwd});
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
|
||||
semanticRelease = requireNoCache('..', {
|
||||
'./lib/get-logger': () => t.context.logger,
|
||||
'env-ci': () => ({isCi: true, branch: 'master', isPr: false}),
|
||||
});
|
||||
|
||||
t.falsy(await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}));
|
||||
t.is(addChannel.callCount, 0);
|
||||
});
|
||||
|
||||
test('Publish pre-releases the same channel as regular releases', async t => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
await gitCommits(['feat: initial commit'], {cwd});
|
||||
await gitTagVersion('v1.0.0', undefined, {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
await gitCheckout('beta', true, {cwd});
|
||||
await gitCommits(['feat: a feature'], {cwd});
|
||||
await gitPush(repositoryUrl, 'beta', {cwd});
|
||||
|
||||
const config = {
|
||||
branches: ['master', {name: 'beta', channel: false, prerelease: true}],
|
||||
repositoryUrl,
|
||||
};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(''),
|
||||
addChannel: false,
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
'./lib/get-logger': () => t.context.logger,
|
||||
'env-ci': () => ({isCi: true, branch: 'beta', isPr: false}),
|
||||
});
|
||||
let {releases} = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
|
||||
|
||||
t.is(releases.length, 1);
|
||||
t.is(releases[0].version, '1.1.0-beta.1');
|
||||
t.is(releases[0].gitTag, 'v1.1.0-beta.1');
|
||||
|
||||
await gitCommits(['fix: a fix'], {cwd});
|
||||
({releases} = await semanticRelease(options, {
|
||||
cwd,
|
||||
env: {},
|
||||
stdout: {write: () => {}},
|
||||
stderr: {write: () => {}},
|
||||
}));
|
||||
|
||||
t.is(releases.length, 1);
|
||||
t.is(releases[0].version, '1.1.0-beta.2');
|
||||
t.is(releases[0].gitTag, 'v1.1.0-beta.2');
|
||||
});
|
||||
|
||||
test('Do not add pre-releases to a different channel', async t => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
const commits = await gitCommits(['feat: initial release'], {cwd});
|
||||
@@ -671,14 +784,6 @@ async function addChannelMacro(t, mergeFunction) {
|
||||
publish,
|
||||
success,
|
||||
};
|
||||
const nextRelease1 = {
|
||||
name: 'v2.0.0',
|
||||
type: 'major',
|
||||
version: '2.0.0',
|
||||
channel: undefined,
|
||||
gitTag: 'v2.0.0',
|
||||
gitHead: commits[1].hash,
|
||||
};
|
||||
const nextRelease2 = {
|
||||
name: 'v2.0.1',
|
||||
type: 'patch',
|
||||
@@ -695,15 +800,11 @@ async function addChannelMacro(t, mergeFunction) {
|
||||
const result = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}});
|
||||
|
||||
t.deepEqual(result.releases, [
|
||||
{...nextRelease1, ...release1, notes, pluginName: '[Function: functionStub]'},
|
||||
{...nextRelease1, notes, pluginName: '[Function: functionStub]'},
|
||||
{...nextRelease2, ...release1, notes, pluginName: '[Function: functionStub]'},
|
||||
{...nextRelease2, notes, pluginName: '[Function: functionStub]'},
|
||||
]);
|
||||
|
||||
// Verify the tag has been created on the local and remote repo and reference
|
||||
t.is(await gitTagHead(nextRelease1.gitTag, {cwd}), nextRelease1.gitHead);
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease1.gitTag, {cwd}), nextRelease1.gitHead);
|
||||
t.is(await gitTagHead(nextRelease2.gitTag, {cwd}), nextRelease2.gitHead);
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease2.gitTag, {cwd}), nextRelease2.gitHead);
|
||||
}
|
||||
@@ -1379,15 +1480,6 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma
|
||||
fail,
|
||||
};
|
||||
|
||||
const nextRelease = {
|
||||
type: 'patch',
|
||||
version: '1.1.1',
|
||||
channel: '1.1.x',
|
||||
gitTag: 'v1.1.1@1.1.x',
|
||||
name: 'v1.1.1',
|
||||
gitHead: commits[2].hash,
|
||||
};
|
||||
|
||||
const semanticRelease = proxyquire('..', {
|
||||
'./lib/logger': t.context.logger,
|
||||
'env-ci': () => ({isCi: true, branch: '1.1.x', isPr: false}),
|
||||
@@ -1398,13 +1490,11 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma
|
||||
)),
|
||||
];
|
||||
|
||||
t.is(addChannel.callCount, 1);
|
||||
t.deepEqual(addChannel.args[0][1].nextRelease, {...nextRelease, notes});
|
||||
t.is(addChannel.callCount, 0);
|
||||
|
||||
t.is(publish.callCount, 0);
|
||||
|
||||
t.is(success.callCount, 1);
|
||||
t.deepEqual(success.args[0][1].releases, [{...nextRelease, notes, pluginName: '[Function: functionStub]'}]);
|
||||
t.is(success.callCount, 0);
|
||||
|
||||
t.is(fail.callCount, 1);
|
||||
t.deepEqual(fail.args[0][1].errors, errors);
|
||||
|
||||
@@ -269,7 +269,7 @@ test('Release patch, minor and major versions', async t => {
|
||||
const updateReleaseMock = await mockServer.mock(
|
||||
`/repos/${owner}/${packageName}/releases/${releaseId}`,
|
||||
{
|
||||
body: {tag_name: `v${version}`, name: `v${version}`, prerelease: false},
|
||||
body: {name: `v${version}`, prerelease: false},
|
||||
headers: [{name: 'Authorization', values: [`token ${env.GH_TOKEN}`]}],
|
||||
},
|
||||
{body: {html_url: `release-url/${version}`}, method: 'PATCH'}
|
||||
|
||||
@@ -47,7 +47,12 @@ test('Execute each function in series passing the "lastResult" and "result" to "
|
||||
const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5);
|
||||
|
||||
t.deepEqual(result, [1, 2, 3, 4]);
|
||||
t.deepEqual(getNextInput.args, [[5, 1], [5, 2], [5, 3], [5, 4]]);
|
||||
t.deepEqual(getNextInput.args, [
|
||||
[5, 1],
|
||||
[5, 2],
|
||||
[5, 3],
|
||||
[5, 4],
|
||||
]);
|
||||
});
|
||||
|
||||
test('Execute each function in series calling "transform" to modify the results', async t => {
|
||||
@@ -61,7 +66,12 @@ test('Execute each function in series calling "transform" to modify the results'
|
||||
const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5);
|
||||
|
||||
t.deepEqual(result, [1 + 1, 2 + 1, 3 + 1, 4 + 1]);
|
||||
t.deepEqual(getNextInput.args, [[5, 1 + 1], [5, 2 + 1], [5, 3 + 1], [5, 4 + 1]]);
|
||||
t.deepEqual(getNextInput.args, [
|
||||
[5, 1 + 1],
|
||||
[5, 2 + 1],
|
||||
[5, 3 + 1],
|
||||
[5, 4 + 1],
|
||||
]);
|
||||
});
|
||||
|
||||
test('Execute each function in series calling "transform" to modify the results with "settleAll"', async t => {
|
||||
@@ -75,7 +85,12 @@ test('Execute each function in series calling "transform" to modify the results
|
||||
const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5);
|
||||
|
||||
t.deepEqual(result, [1 + 1, 2 + 1, 3 + 1, 4 + 1]);
|
||||
t.deepEqual(getNextInput.args, [[5, 1 + 1], [5, 2 + 1], [5, 3 + 1], [5, 4 + 1]]);
|
||||
t.deepEqual(getNextInput.args, [
|
||||
[5, 1 + 1],
|
||||
[5, 2 + 1],
|
||||
[5, 3 + 1],
|
||||
[5, 4 + 1],
|
||||
]);
|
||||
});
|
||||
|
||||
test('Stop execution and throw error if a step rejects', async t => {
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
getFirstVersion,
|
||||
getRange,
|
||||
makeTag,
|
||||
isSameChannel,
|
||||
} from '../lib/utils';
|
||||
|
||||
test('extractErrors', t => {
|
||||
@@ -178,3 +179,12 @@ test('makeTag', t => {
|
||||
t.is(makeTag(`v\${version}`, '1.0.0', 'next'), 'v1.0.0@next');
|
||||
t.is(makeTag(`v\${version}@test`, '1.0.0', 'next'), 'v1.0.0@next@test');
|
||||
});
|
||||
|
||||
test('isSameChannel', t => {
|
||||
t.true(isSameChannel('next', 'next'));
|
||||
t.true(isSameChannel(null, undefined));
|
||||
t.true(isSameChannel(false, undefined));
|
||||
t.true(isSameChannel('', false));
|
||||
|
||||
t.false(isSameChannel('next', false));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user