Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub release options updates #2903

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions build/grunt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {gruntCustomizer, gruntOptionsMaker} from './options-customizer.js';
module.exports = function(grunt) {
require('time-grunt')(grunt);

Expand Down Expand Up @@ -41,6 +42,19 @@ module.exports = function(grunt) {
]
};

const githubReleaseDefaults = {
options: {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw
},
},
files: {
src: [`dist/video-js-${version.full}.zip`] // Files that you want to attach to Release
}
};

/**
* Customizes _.merge behavior in `browserifyGruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
Expand All @@ -52,11 +66,7 @@ module.exports = function(grunt) {
* @param {Mixed} sourceValue
* @return {Object}
*/
function browserifyGruntCustomizer(objectValue, sourceValue) {
if (Array.isArray(objectValue)) {
return objectValue.concat(sourceValue);
}
}
const browserifyGruntCustomizer = gruntCustomizer;

/**
* Creates a unique object of Browserify Grunt task options.
Expand All @@ -70,9 +80,10 @@ module.exports = function(grunt) {
*
* @return {Object}
*/
function browserifyGruntOptions(options = null, customizer = browserifyGruntCustomizer) {
return _.merge({}, browserifyGruntDefaults, options, customizer);
}
const browserifyGruntOptions = gruntOptionsMaker(browserifyGruntDefaults, browserifyGruntCustomizer);

const githubReleaseCustomizer = gruntCustomizer;
const githubReleaseOptions = gruntOptionsMaker(githubReleaseDefaults, githubReleaseCustomizer);

/**
* Creates processor functions for license banners.
Expand Down Expand Up @@ -296,28 +307,14 @@ module.exports = function(grunt) {
password: process.env.VJS_GITHUB_TOKEN
}
},
release: {
release: githubReleaseOptions(),
prerelease: githubReleaseOptions({
options: {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw
}
}
},
prerelease: {
options: {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw,
prerelease: true
}
}
},
files: {
src: [`dist/video-js-${version.full}.zip`] // Files that you want to attach to Release
}
})
},
browserify: {
options: browserifyGruntOptions(),
Expand Down
49 changes: 49 additions & 0 deletions build/options-customizer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import _ from 'lodash-compat';
/**
* Customizes _.merge behavior in `gruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
*
* @see https://lodash.com/docs#merge
* @function GruntCustomizer
* @private
* @param {Mixed} objectValue
* @param {Mixed} sourceValue
* @return {Object}
*/
function gruntCustomizer(objectValue, sourceValue) {
if (Array.isArray(objectValue)) {
return objectValue.concat(sourceValue);
}
}

/**
* Creates a gruntOptions instance for the specific defaultOptions and gruntCustomizer
*
* @function browserifyGruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=gruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Function}
*/
function gruntOptionsMaker(defaultOptions, gruntCustomizer) {
/**
* Creates a unique object of Browserify Grunt task options.
*
* @function gruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=browserifyGruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Object}
*/
return function gruntOptions(options = null, customizer = gruntCustomizer) {
return _.merge({}, defaultOptions, options, customizer);
}
};

export { gruntCustomizer, gruntOptionsMaker };