- Allow to configure multiple branches to release from - Allow to define a distribution channel associated with each branch - Manage the availability on distribution channels based on git merges - Support regular releases, maintenance releases and pre-releases - Add the `addChannel` plugin step to make an existing release available on a different distribution channel BREAKING CHANGE: the `branch` option has been removed in favor of `branches` The new `branches` option expect either an Array or a single branch definition. To migrate your configuration: - If you want to publish package from multiple branches, please the configuration documentation - If you use the default configuration and want to publish only from `master`: nothing to change - If you use the `branch` configuration and want to publish only from one branch: replace `branch` by `branches` (`"branch": "my-release-branch"` => `"branches": "my-release-branch"`)
		
			
				
	
	
		
			74 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import test from 'ava';
 | 
						|
import plugins from '../../lib/definitions/plugins';
 | 
						|
import {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} from '../../lib/definitions/constants';
 | 
						|
 | 
						|
test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', t => {
 | 
						|
  t.false(plugins.analyzeCommits.outputValidator('invalid'));
 | 
						|
  t.false(plugins.analyzeCommits.outputValidator(1));
 | 
						|
  t.false(plugins.analyzeCommits.outputValidator({}));
 | 
						|
 | 
						|
  t.true(plugins.analyzeCommits.outputValidator());
 | 
						|
  t.true(plugins.analyzeCommits.outputValidator(null));
 | 
						|
  t.true(plugins.analyzeCommits.outputValidator('major'));
 | 
						|
});
 | 
						|
 | 
						|
test('The "generateNotes" plugin output, if defined, must be a string', t => {
 | 
						|
  t.false(plugins.generateNotes.outputValidator(1));
 | 
						|
  t.false(plugins.generateNotes.outputValidator({}));
 | 
						|
 | 
						|
  t.true(plugins.generateNotes.outputValidator());
 | 
						|
  t.true(plugins.generateNotes.outputValidator(null));
 | 
						|
  t.true(plugins.generateNotes.outputValidator(''));
 | 
						|
  t.true(plugins.generateNotes.outputValidator('string'));
 | 
						|
});
 | 
						|
 | 
						|
test('The "publish" plugin output, if defined, must be an object', t => {
 | 
						|
  t.false(plugins.publish.outputValidator(1));
 | 
						|
  t.false(plugins.publish.outputValidator('string'));
 | 
						|
 | 
						|
  t.true(plugins.publish.outputValidator({}));
 | 
						|
  t.true(plugins.publish.outputValidator());
 | 
						|
  t.true(plugins.publish.outputValidator(null));
 | 
						|
  t.true(plugins.publish.outputValidator(''));
 | 
						|
});
 | 
						|
 | 
						|
test('The "addChannel" plugin output, if defined, must be an object', t => {
 | 
						|
  t.false(plugins.addChannel.outputValidator(1));
 | 
						|
  t.false(plugins.addChannel.outputValidator('string'));
 | 
						|
 | 
						|
  t.true(plugins.addChannel.outputValidator({}));
 | 
						|
  t.true(plugins.addChannel.outputValidator());
 | 
						|
  t.true(plugins.addChannel.outputValidator(null));
 | 
						|
  t.true(plugins.addChannel.outputValidator(''));
 | 
						|
});
 | 
						|
 | 
						|
test('The "generateNotes" plugins output are concatenated with separator and sensitive data is hidden', t => {
 | 
						|
  const env = {MY_TOKEN: 'secret token'};
 | 
						|
  t.is(plugins.generateNotes.postprocess(['note 1', 'note 2'], {env}), `note 1${RELEASE_NOTES_SEPARATOR}note 2`);
 | 
						|
  t.is(plugins.generateNotes.postprocess(['', 'note'], {env}), 'note');
 | 
						|
  t.is(plugins.generateNotes.postprocess([undefined, 'note'], {env}), 'note');
 | 
						|
  t.is(plugins.generateNotes.postprocess(['note 1', '', 'note 2'], {env}), `note 1${RELEASE_NOTES_SEPARATOR}note 2`);
 | 
						|
  t.is(
 | 
						|
    plugins.generateNotes.postprocess(['note 1', undefined, 'note 2'], {env}),
 | 
						|
    `note 1${RELEASE_NOTES_SEPARATOR}note 2`
 | 
						|
  );
 | 
						|
 | 
						|
  t.is(
 | 
						|
    plugins.generateNotes.postprocess(
 | 
						|
      [`Note 1: Exposing token ${env.MY_TOKEN}`, `Note 2: Exposing token ${SECRET_REPLACEMENT}`],
 | 
						|
      {env}
 | 
						|
    ),
 | 
						|
    `Note 1: Exposing token ${SECRET_REPLACEMENT}${RELEASE_NOTES_SEPARATOR}Note 2: Exposing token ${SECRET_REPLACEMENT}`
 | 
						|
  );
 | 
						|
});
 | 
						|
 | 
						|
test('The "analyzeCommits" plugins output are reduced to the highest release type', t => {
 | 
						|
  t.is(plugins.analyzeCommits.postprocess(['major', 'minor']), 'major');
 | 
						|
  t.is(plugins.analyzeCommits.postprocess(['', 'minor']), 'minor');
 | 
						|
  t.is(plugins.analyzeCommits.postprocess([undefined, 'patch']), 'patch');
 | 
						|
  t.is(plugins.analyzeCommits.postprocess([null, 'patch']), 'patch');
 | 
						|
  t.is(plugins.analyzeCommits.postprocess(['wrong_type', 'minor']), 'minor');
 | 
						|
  t.is(plugins.analyzeCommits.postprocess([]), undefined);
 | 
						|
  t.is(plugins.analyzeCommits.postprocess(['wrong_type']), undefined);
 | 
						|
});
 |