2013-01-12 10:02:20 +03:00
|
|
|
module.exports = function(grunt) {
|
2013-06-12 01:14:36 +03:00
|
|
|
var pkg, s3, semver, version, verParts, uglify;
|
2013-01-12 10:02:20 +03:00
|
|
|
|
2013-05-04 09:05:33 +03:00
|
|
|
semver = require('semver');
|
|
|
|
pkg = grunt.file.readJSON('package.json');
|
2013-06-12 01:14:36 +03:00
|
|
|
uglify = require('uglify-js');
|
2013-05-04 09:05:33 +03:00
|
|
|
|
|
|
|
try {
|
2013-05-09 00:12:22 +03:00
|
|
|
s3 = grunt.file.readJSON('.s3config.json');
|
2013-05-04 09:05:33 +03:00
|
|
|
} catch(e) {
|
|
|
|
s3 = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
verParts = pkg.version.split('.');
|
|
|
|
version = {
|
|
|
|
full: pkg.version,
|
|
|
|
major: verParts[0],
|
|
|
|
minor: verParts[1],
|
|
|
|
patch: verParts[2]
|
|
|
|
};
|
|
|
|
version.majorMinor = version.major + '.' + version.minor;
|
2013-04-22 08:44:36 +03:00
|
|
|
|
2013-10-29 04:25:28 +03:00
|
|
|
// loading predefined source order from source-loader.js
|
|
|
|
// trust me, this is the easist way to do it so far
|
|
|
|
/*jshint undef:false, evil:true */
|
|
|
|
var blockSourceLoading = true;
|
|
|
|
var sourceFiles; // Needed to satisfy jshint
|
|
|
|
eval(grunt.file.read('./build/source-loader.js'));
|
|
|
|
|
2013-01-12 10:02:20 +03:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2013-04-22 08:44:36 +03:00
|
|
|
pkg: pkg,
|
2013-01-26 02:22:14 +03:00
|
|
|
|
2013-01-13 09:23:22 +03:00
|
|
|
build: {
|
2013-02-23 06:26:58 +03:00
|
|
|
src: 'src/js/dependencies.js',
|
|
|
|
options: {
|
|
|
|
baseDir: 'src/js/'
|
|
|
|
}
|
|
|
|
},
|
2013-01-26 02:22:14 +03:00
|
|
|
clean: {
|
|
|
|
build: ['build/files/*'],
|
|
|
|
dist: ['dist/*']
|
2013-01-12 10:02:20 +03:00
|
|
|
},
|
|
|
|
jshint: {
|
2013-01-13 09:23:22 +03:00
|
|
|
src: {
|
2013-02-09 01:08:31 +03:00
|
|
|
src: ['src/js/*.js', 'Gruntfile.js', 'test/unit/*.js'],
|
2013-01-12 10:02:20 +03:00
|
|
|
options: {
|
2013-02-09 01:08:31 +03:00
|
|
|
jshintrc: '.jshintrc'
|
2013-01-12 10:02:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-01-26 02:22:14 +03:00
|
|
|
minify: {
|
|
|
|
source:{
|
2013-04-09 23:43:35 +03:00
|
|
|
src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js'],
|
2013-11-27 02:42:37 +03:00
|
|
|
externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js'],
|
2013-01-26 02:22:14 +03:00
|
|
|
dest: 'build/files/minified.video.js'
|
2013-01-13 09:23:22 +03:00
|
|
|
},
|
2013-01-26 02:22:14 +03:00
|
|
|
tests: {
|
2014-02-11 04:24:48 +03:00
|
|
|
src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js', 'test/unit/*.js'],
|
2013-12-03 04:29:34 +03:00
|
|
|
externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js', 'test/qunit-externs.js'],
|
2013-01-26 02:22:14 +03:00
|
|
|
dest: 'build/files/test.minified.video.js'
|
2013-01-13 09:23:22 +03:00
|
|
|
}
|
|
|
|
},
|
2013-01-26 02:22:14 +03:00
|
|
|
dist: {},
|
2013-01-12 10:02:20 +03:00
|
|
|
qunit: {
|
2013-01-26 02:22:14 +03:00
|
|
|
source: ['test/index.html'],
|
2013-03-05 23:39:43 +03:00
|
|
|
minified: ['test/minified.html'],
|
2013-03-08 00:24:52 +03:00
|
|
|
minified_api: ['test/minified-api.html']
|
2013-01-12 10:02:20 +03:00
|
|
|
},
|
|
|
|
watch: {
|
2013-07-20 06:18:39 +03:00
|
|
|
files: [ 'src/**/*', 'test/unit/*.js', 'Gruntfile.js' ],
|
2013-02-09 01:08:31 +03:00
|
|
|
tasks: 'dev'
|
2013-05-04 09:05:33 +03:00
|
|
|
},
|
2014-03-26 01:22:29 +03:00
|
|
|
connect: {
|
|
|
|
dev: {
|
|
|
|
options: {
|
|
|
|
port: 9999,
|
|
|
|
keepalive: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-05-04 09:05:33 +03:00
|
|
|
copy: {
|
|
|
|
minor: {
|
|
|
|
files: [
|
|
|
|
{expand: true, cwd: 'build/files/', src: ['*'], dest: 'dist/'+version.majorMinor+'/', filter: 'isFile'} // includes files in path
|
|
|
|
]
|
|
|
|
},
|
|
|
|
patch: {
|
|
|
|
files: [
|
|
|
|
{expand: true, cwd: 'build/files/', src: ['*'], dest: 'dist/'+version.full+'/', filter: 'isFile'} // includes files in path
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
s3: {
|
|
|
|
options: s3,
|
2013-05-23 23:10:29 +03:00
|
|
|
minor: {
|
2013-05-04 09:05:33 +03:00
|
|
|
upload: [
|
|
|
|
{
|
2013-05-09 08:30:52 +03:00
|
|
|
src: 'dist/cdn/*',
|
2013-05-23 23:10:29 +03:00
|
|
|
dest: 'vjs/'+version.majorMinor+'/',
|
2013-05-09 08:30:52 +03:00
|
|
|
rel: 'dist/cdn/',
|
|
|
|
headers: {
|
2013-05-23 23:10:29 +03:00
|
|
|
'Cache-Control': 'public, max-age=2628000'
|
2013-05-09 08:30:52 +03:00
|
|
|
}
|
2013-05-23 23:10:29 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
patch: {
|
|
|
|
upload: [
|
2013-05-09 08:30:52 +03:00
|
|
|
{
|
|
|
|
src: 'dist/cdn/*',
|
2013-05-23 23:10:29 +03:00
|
|
|
dest: 'vjs/'+version.full+'/',
|
2013-05-09 08:30:52 +03:00
|
|
|
rel: 'dist/cdn/',
|
|
|
|
headers: {
|
2013-05-23 23:10:29 +03:00
|
|
|
'Cache-Control': 'public, max-age=31536000'
|
2013-05-09 08:30:52 +03:00
|
|
|
}
|
2013-05-04 09:05:33 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2013-05-23 23:10:29 +03:00
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
minify: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'build/files/',
|
|
|
|
src: ['video-js.css'],
|
|
|
|
dest: 'build/files/',
|
|
|
|
ext: '.min.css'
|
|
|
|
}
|
2013-07-20 06:18:39 +03:00
|
|
|
},
|
|
|
|
less: {
|
|
|
|
dev: {
|
|
|
|
files: {
|
|
|
|
'build/files/video-js.css': 'src/css/video-js.less'
|
|
|
|
}
|
|
|
|
}
|
2013-09-19 19:24:06 +03:00
|
|
|
},
|
|
|
|
karma: {
|
|
|
|
options: {
|
|
|
|
configFile: 'test/karma.conf.js'
|
|
|
|
},
|
|
|
|
dev: {
|
|
|
|
configFile: 'test/karma.conf.js',
|
|
|
|
autoWatch: true
|
|
|
|
},
|
|
|
|
ci: {
|
|
|
|
configFile: 'test/karma.conf.js',
|
|
|
|
autoWatch: false
|
|
|
|
}
|
2013-10-29 04:25:28 +03:00
|
|
|
},
|
|
|
|
vjsdocs: {
|
|
|
|
all: {
|
|
|
|
src: sourceFiles,
|
|
|
|
dest: 'docs/api',
|
|
|
|
options: {
|
|
|
|
baseURL: 'https://github.com/videojs/video.js/blob/master/'
|
|
|
|
}
|
|
|
|
}
|
2014-01-16 22:25:07 +03:00
|
|
|
},
|
|
|
|
zip: {
|
|
|
|
dist: {
|
|
|
|
router: function (filepath) {
|
|
|
|
var path = require('path');
|
|
|
|
return path.relative('dist', filepath);
|
|
|
|
},
|
2014-03-07 00:15:53 +03:00
|
|
|
// compression: 'DEFLATE',
|
2014-01-16 22:25:07 +03:00
|
|
|
src: ['dist/video-js/**/*'],
|
|
|
|
dest: 'dist/video-js-' + version.full + '.zip'
|
|
|
|
}
|
2014-02-14 08:09:42 +03:00
|
|
|
},
|
2014-02-14 06:20:30 +03:00
|
|
|
usebanner: {
|
|
|
|
dist: {
|
|
|
|
options: {
|
|
|
|
position: 'top',
|
|
|
|
banner: '/*! Video.js v' + version.full + ' <%= pkg.copyright %> */ ',
|
|
|
|
linebreak: true
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
src: [ 'build/files/minified.video.js']
|
|
|
|
}
|
|
|
|
}
|
2014-02-15 03:52:48 +03:00
|
|
|
},
|
|
|
|
bump: {
|
|
|
|
files: ['package.json'],
|
|
|
|
updateConfigs: ['pkg']
|
|
|
|
},
|
|
|
|
tagrelease: {
|
|
|
|
file: 'package.json',
|
|
|
|
commit: true,
|
|
|
|
message: 'Release %version%',
|
|
|
|
prefix: 'v'
|
2014-02-14 06:20:30 +03:00
|
|
|
}
|
2013-01-12 10:02:20 +03:00
|
|
|
});
|
|
|
|
|
2014-03-26 01:22:29 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
2013-02-09 01:08:31 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
2013-05-23 23:10:29 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
2013-07-20 06:18:39 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-less');
|
2013-05-04 09:05:33 +03:00
|
|
|
grunt.loadNpmTasks('grunt-s3');
|
2013-03-26 02:52:36 +03:00
|
|
|
grunt.loadNpmTasks('contribflow');
|
2013-09-19 19:24:06 +03:00
|
|
|
grunt.loadNpmTasks('grunt-karma');
|
2013-10-29 04:25:28 +03:00
|
|
|
grunt.loadNpmTasks('videojs-doc-generator');
|
2014-01-16 22:25:07 +03:00
|
|
|
grunt.loadNpmTasks('grunt-zip');
|
2014-02-14 06:20:30 +03:00
|
|
|
grunt.loadNpmTasks('grunt-banner');
|
2014-02-15 03:52:48 +03:00
|
|
|
grunt.loadNpmTasks('grunt-bump');
|
|
|
|
grunt.loadNpmTasks('grunt-tagrelease');
|
|
|
|
grunt.loadNpmTasks('chg');
|
2013-10-29 04:25:28 +03:00
|
|
|
|
|
|
|
// grunt.loadTasks('./docs/tasks/');
|
|
|
|
// grunt.loadTasks('../videojs-doc-generator/tasks/');
|
2013-01-12 10:02:20 +03:00
|
|
|
|
2013-01-13 09:23:22 +03:00
|
|
|
// Default task.
|
2014-02-14 06:20:30 +03:00
|
|
|
grunt.registerTask('default', ['jshint', 'less', 'build', 'minify', 'usebanner', 'dist']);
|
2013-01-13 09:23:22 +03:00
|
|
|
// Development watch task
|
2013-07-20 06:18:39 +03:00
|
|
|
grunt.registerTask('dev', ['jshint', 'less', 'build', 'qunit:source']);
|
2014-02-14 06:28:13 +03:00
|
|
|
grunt.registerTask('test', ['jshint', 'less', 'build', 'minify', 'usebanner', 'qunit']);
|
2013-01-12 10:02:20 +03:00
|
|
|
|
2013-01-13 09:23:22 +03:00
|
|
|
var fs = require('fs'),
|
2013-01-12 10:02:20 +03:00
|
|
|
gzip = require('zlib').gzip;
|
|
|
|
|
2013-02-23 06:26:58 +03:00
|
|
|
grunt.registerMultiTask('build', 'Building Source', function(){
|
|
|
|
// Fix windows file path delimiter issue
|
|
|
|
var i = sourceFiles.length;
|
|
|
|
while (i--) {
|
|
|
|
sourceFiles[i] = sourceFiles[i].replace(/\\/g, '/');
|
|
|
|
}
|
2013-01-13 09:23:22 +03:00
|
|
|
|
2013-02-23 06:26:58 +03:00
|
|
|
// Create a combined sources file. https://github.com/zencoder/video-js/issues/287
|
|
|
|
var combined = '';
|
|
|
|
sourceFiles.forEach(function(result){
|
|
|
|
combined += grunt.file.read(result);
|
2013-01-13 09:23:22 +03:00
|
|
|
});
|
2013-05-23 23:10:29 +03:00
|
|
|
// Replace CDN version ref in js. Use major/minor version.
|
|
|
|
combined = combined.replace(/GENERATED_CDN_VSN/g, version.majorMinor);
|
2013-02-23 06:26:58 +03:00
|
|
|
grunt.file.write('build/files/combined.video.js', combined);
|
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Copy over other files
|
2013-07-20 06:18:39 +03:00
|
|
|
// grunt.file.copy('src/css/video-js.png', 'build/files/video-js.png');
|
2014-01-24 04:15:41 +03:00
|
|
|
grunt.file.copy('node_modules/videojs-swf/dist/video-js.swf', 'build/files/video-js.swf');
|
2013-05-09 08:30:52 +03:00
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Inject version number into css file
|
|
|
|
var css = grunt.file.read('build/files/video-js.css');
|
|
|
|
css = css.replace(/GENERATED_AT_BUILD/g, version.full);
|
|
|
|
grunt.file.write('build/files/video-js.css', css);
|
|
|
|
|
|
|
|
// Copy over font files
|
2013-05-09 08:30:52 +03:00
|
|
|
grunt.file.recurse('src/css/font', function(absdir, rootdir, subdir, filename) {
|
|
|
|
// Block .DS_Store files
|
|
|
|
if ('filename'.substring(0,1) !== '.') {
|
|
|
|
grunt.file.copy(absdir, 'build/files/font/' + filename);
|
|
|
|
}
|
|
|
|
});
|
2013-05-23 23:10:29 +03:00
|
|
|
|
|
|
|
// Minify CSS
|
|
|
|
grunt.task.run(['cssmin']);
|
2013-01-12 10:02:20 +03:00
|
|
|
});
|
|
|
|
|
2013-01-26 02:22:14 +03:00
|
|
|
grunt.registerMultiTask('minify', 'Minify JS files using Closure Compiler.', function() {
|
2013-01-12 10:02:20 +03:00
|
|
|
var done = this.async();
|
2013-01-13 09:23:22 +03:00
|
|
|
var exec = require('child_process').exec;
|
2013-01-12 10:02:20 +03:00
|
|
|
|
2013-04-23 17:45:05 +03:00
|
|
|
var externs = this.data.externs || [];
|
|
|
|
var dest = this.data.dest;
|
|
|
|
var filePatterns = [];
|
2013-01-26 02:22:14 +03:00
|
|
|
|
|
|
|
// Make sure deeper directories exist for compiler
|
|
|
|
grunt.file.write(dest, '');
|
|
|
|
|
2013-04-23 17:45:05 +03:00
|
|
|
if (this.data.sourcelist) {
|
|
|
|
filePatterns = filePatterns.concat(grunt.file.read(this.data.sourcelist).split(','));
|
2013-01-13 09:23:22 +03:00
|
|
|
}
|
2013-04-23 17:45:05 +03:00
|
|
|
if (this.data.src) {
|
|
|
|
filePatterns = filePatterns.concat(this.data.src);
|
2013-01-13 09:23:22 +03:00
|
|
|
}
|
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Build closure compiler shell command
|
2013-01-13 09:23:22 +03:00
|
|
|
var command = 'java -jar build/compiler/compiler.jar'
|
|
|
|
+ ' --compilation_level ADVANCED_OPTIMIZATIONS'
|
|
|
|
// + ' --formatting=pretty_print'
|
|
|
|
+ ' --js_output_file=' + dest
|
|
|
|
+ ' --create_source_map ' + dest + '.map --source_map_format=V3'
|
2013-04-18 22:27:14 +03:00
|
|
|
+ ' --jscomp_warning=checkTypes --warning_level=VERBOSE'
|
2014-02-14 06:20:30 +03:00
|
|
|
+ ' --output_wrapper "(function() {%output%})();"';
|
2013-09-05 23:03:16 +03:00
|
|
|
//@ sourceMappingURL=video.js.map
|
2013-01-12 10:02:20 +03:00
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Add each js file
|
2013-04-23 17:45:05 +03:00
|
|
|
grunt.file.expand(filePatterns).forEach(function(file){
|
2013-01-13 09:23:22 +03:00
|
|
|
command += ' --js='+file;
|
2013-01-12 10:02:20 +03:00
|
|
|
});
|
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Add externs
|
2013-01-13 09:23:22 +03:00
|
|
|
externs.forEach(function(extern){
|
|
|
|
command += ' --externs='+extern;
|
|
|
|
});
|
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Run command
|
2013-01-12 10:02:20 +03:00
|
|
|
exec(command, { maxBuffer: 500*1024 }, function(err, stdout, stderr){
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
grunt.warn(err);
|
|
|
|
done(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stdout) {
|
|
|
|
grunt.log.writeln(stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-16 22:25:07 +03:00
|
|
|
grunt.registerTask('dist-copy', 'Assembling distribution', function(){
|
2013-06-12 01:14:36 +03:00
|
|
|
var css, jsmin, jsdev, cdnjs;
|
2013-04-22 08:44:36 +03:00
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Manually copy each source file
|
2013-01-26 02:22:14 +03:00
|
|
|
grunt.file.copy('build/files/minified.video.js', 'dist/video-js/video.js');
|
2013-05-09 08:30:52 +03:00
|
|
|
grunt.file.copy('build/files/combined.video.js', 'dist/video-js/video.dev.js');
|
2013-01-26 02:22:14 +03:00
|
|
|
grunt.file.copy('build/files/video-js.css', 'dist/video-js/video-js.css');
|
2013-05-23 23:10:29 +03:00
|
|
|
grunt.file.copy('build/files/video-js.min.css', 'dist/video-js/video-js.min.css');
|
2014-01-24 04:15:41 +03:00
|
|
|
grunt.file.copy('node_modules/videojs-swf/dist/video-js.swf', 'dist/video-js/video-js.swf');
|
2013-01-26 02:22:14 +03:00
|
|
|
grunt.file.copy('build/demo-files/demo.html', 'dist/video-js/demo.html');
|
|
|
|
grunt.file.copy('build/demo-files/demo.captions.vtt', 'dist/video-js/demo.captions.vtt');
|
2014-03-04 17:50:58 +03:00
|
|
|
grunt.file.copy('src/css/video-js.less', 'dist/video-js/video-js.less');
|
|
|
|
|
2013-02-23 06:26:58 +03:00
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Copy over font files
|
2013-05-09 08:30:52 +03:00
|
|
|
grunt.file.recurse('build/files/font', function(absdir, rootdir, subdir, filename) {
|
|
|
|
// Block .DS_Store files
|
|
|
|
if ('filename'.substring(0,1) !== '.') {
|
|
|
|
grunt.file.copy(absdir, 'dist/video-js/font/' + filename);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-02-19 02:40:56 +03:00
|
|
|
// ds_store files sometime find their way in
|
|
|
|
if (grunt.file.exists('dist/video-js/.DS_Store')) {
|
|
|
|
grunt.file['delete']('dist/video-js/.DS_Store');
|
|
|
|
}
|
|
|
|
|
2013-05-09 08:30:52 +03:00
|
|
|
// CDN version uses already hosted font files
|
2013-05-23 23:10:29 +03:00
|
|
|
// Minified version only, doesn't need demo files
|
2013-05-09 00:12:22 +03:00
|
|
|
grunt.file.copy('build/files/minified.video.js', 'dist/cdn/video.js');
|
2013-05-23 23:10:29 +03:00
|
|
|
grunt.file.copy('build/files/video-js.min.css', 'dist/cdn/video-js.css');
|
2014-01-24 04:15:41 +03:00
|
|
|
grunt.file.copy('node_modules/videojs-swf/dist/video-js.swf', 'dist/cdn/video-js.swf');
|
2013-11-05 02:35:44 +03:00
|
|
|
grunt.file.copy('build/demo-files/demo.captions.vtt', 'dist/cdn/demo.captions.vtt');
|
|
|
|
grunt.file.copy('build/demo-files/demo.html', 'dist/cdn/demo.html');
|
2013-05-09 08:30:52 +03:00
|
|
|
|
2013-05-23 23:10:29 +03:00
|
|
|
// Replace font urls with CDN versions
|
|
|
|
css = grunt.file.read('dist/cdn/video-js.css');
|
2013-10-18 02:38:13 +03:00
|
|
|
css = css.replace(/font\//g, '../f/2/');
|
2013-05-09 00:12:22 +03:00
|
|
|
grunt.file.write('dist/cdn/video-js.css', css);
|
|
|
|
|
2013-06-12 01:14:36 +03:00
|
|
|
// Add CDN-specfic JS
|
|
|
|
jsmin = grunt.file.read('dist/cdn/video.js');
|
|
|
|
// GA Tracking Pixel (manually building the pixel URL)
|
|
|
|
cdnjs = uglify.minify('src/js/cdn.js').code.replace('v0.0.0', 'v'+version.full);
|
|
|
|
grunt.file.write('dist/cdn/video.js', jsmin + cdnjs);
|
2013-01-13 09:23:22 +03:00
|
|
|
});
|
2013-10-29 04:25:28 +03:00
|
|
|
|
2014-02-19 23:49:29 +03:00
|
|
|
grunt.registerTask('cdn-links', 'Update the version of CDN links in docs', function(){
|
|
|
|
var doc = grunt.file.read('docs/guides/setup.md');
|
|
|
|
var version = pkg.version;
|
|
|
|
|
|
|
|
// remove the patch version to point to the latest patch
|
|
|
|
version = version.replace(/(\d\.\d)\.\d/, '$1');
|
|
|
|
|
|
|
|
// update the version in http://vjs.zencdn.net/4.3/video.js
|
|
|
|
doc = doc.replace(/(\/\/vjs\.zencdn\.net\/)\d\.\d(\.\d)?/g, '$1'+version);
|
|
|
|
grunt.file.write('docs/guides/setup.md', doc);
|
|
|
|
});
|
|
|
|
|
2014-01-16 22:25:07 +03:00
|
|
|
grunt.registerTask('dist', 'Creating distribution', ['dist-copy', 'zip:dist']);
|
|
|
|
|
2014-03-06 00:41:26 +03:00
|
|
|
grunt.registerTask('next-issue', 'Get the next issue that needs a response', function(){
|
|
|
|
var done = this.async();
|
|
|
|
var GitHubApi = require('github');
|
|
|
|
var open = require('open');
|
|
|
|
|
|
|
|
var github = new GitHubApi({
|
|
|
|
// required
|
|
|
|
version: '3.0.0',
|
|
|
|
// optional
|
|
|
|
debug: true,
|
|
|
|
protocol: 'https',
|
|
|
|
// host: 'github.my-GHE-enabled-company.com',
|
|
|
|
// pathPrefix: '/api/v3', // for some GHEs
|
|
|
|
timeout: 5000
|
|
|
|
});
|
|
|
|
|
|
|
|
github.issues.repoIssues({
|
|
|
|
// optional:
|
|
|
|
// headers: {
|
|
|
|
// 'cookie': 'blahblah'
|
|
|
|
// },
|
|
|
|
user: 'videojs',
|
|
|
|
repo: 'video.js',
|
|
|
|
sort: 'updated',
|
|
|
|
direction: 'asc',
|
|
|
|
state: 'open',
|
|
|
|
per_page: 100
|
|
|
|
}, function(err, res) {
|
|
|
|
var issueToOpen;
|
|
|
|
var usersWithWrite = ['heff', 'mmcc'];
|
|
|
|
var categoryLabels = ['enhancement', 'bug', 'question', 'feature'];
|
|
|
|
|
|
|
|
console.log('Number of issues: '+res.length);
|
|
|
|
|
|
|
|
// TODO: Find the best way to exclude an issue where a question has been asked of the
|
|
|
|
// issue owner/submitter that hasn't been answerd yet.
|
|
|
|
// A stupid simple first step would be to check for the needs: more info label
|
|
|
|
// and exactly one comment (the question)
|
|
|
|
|
|
|
|
// find issues that need categorizing, no category labels
|
|
|
|
res.some(function(issue){
|
|
|
|
if (issue.labels.length === 0) {
|
|
|
|
return issueToOpen = issue; // break
|
|
|
|
}
|
|
|
|
// look for category labels
|
|
|
|
var categorized = issue.labels.some(function(label){
|
|
|
|
return categoryLabels.indexOf(label.name) >= 0;
|
|
|
|
});
|
|
|
|
if (!categorized) {
|
|
|
|
return issueToOpen = issue; // break
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (issueToOpen) {
|
|
|
|
open(issueToOpen.html_url);
|
|
|
|
return done();
|
|
|
|
}
|
|
|
|
|
|
|
|
// find issues that need confirming or answering
|
|
|
|
res.some(function(issue){
|
|
|
|
// look for confirmed label
|
|
|
|
var confirmed = issue.labels.some(function(label){
|
|
|
|
return label.name === 'confirmed';
|
|
|
|
});
|
|
|
|
// Was exluding questions, but that might leave a lot of people hanging
|
|
|
|
// var question = issue.labels.some(function(label){
|
|
|
|
// return label.name === 'question';
|
|
|
|
// });
|
|
|
|
if (!confirmed) { // && !question
|
|
|
|
return issueToOpen = issue; // break
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (issueToOpen) {
|
|
|
|
open(issueToOpen.html_url);
|
|
|
|
return done();
|
|
|
|
}
|
|
|
|
|
|
|
|
grunt.log.writeln('No next issue found');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-01-12 10:02:20 +03:00
|
|
|
};
|