Permalink
Browse files

Update grunt build script.

  • Loading branch information...
heff committed Jan 13, 2013
1 parent e7c146b commit 0f0fccc3128d4d9747f8040f968c8f61e8945334
Showing with 337 additions and 1,495 deletions.
  1. +81 −91 Gruntfile.js
  2. +0 −10 Makefile
  3. +0 −20 build/release-files/youtube.html
  4. +4 −4 package.json
  5. +5 −0 src/js/component.js
  6. +6 −0 src/js/controls.js
  7. +4 −1 src/js/core.js
  8. +10 −5 src/js/events.js
  9. +11 −0 src/js/exports.js
  10. +2 −0 src/js/json.js
  11. +11 −7 src/js/lib.js
  12. +4 −0 src/js/media.flash.js
  13. +4 −0 src/js/media.html5.js
  14. +4 −0 src/js/media.js
  15. +4 −0 src/js/player.js
  16. +5 −0 src/js/setup.js
  17. +6 −0 src/js/tracks.js
  18. +0 −90 test/dev-compiled.html
  19. +59 −0 test/index.html
  20. +0 −42 test/integration.html
  21. +0 −304 test/integration/test.js
  22. +0 −22 test/phantom-logging.js
  23. +0 −63 test/phantom.js
  24. 0 test/{vendor → }/qunit/.gitignore
  25. 0 test/{vendor → }/qunit/README.md
  26. 0 test/{vendor → }/qunit/addons/canvas/README.md
  27. 0 test/{vendor → }/qunit/addons/canvas/canvas-test.js
  28. 0 test/{vendor → }/qunit/addons/canvas/canvas.html
  29. 0 test/{vendor → }/qunit/addons/canvas/qunit-canvas.js
  30. 0 test/{vendor → }/qunit/addons/close-enough/README.md
  31. 0 test/{vendor → }/qunit/addons/close-enough/close-enough-test.js
  32. 0 test/{vendor → }/qunit/addons/close-enough/close-enough.html
  33. 0 test/{vendor → }/qunit/addons/close-enough/qunit-close-enough.js
  34. 0 test/{vendor → }/qunit/addons/composite/README.md
  35. 0 test/{vendor → }/qunit/addons/composite/composite-demo-test.html
  36. 0 test/{vendor → }/qunit/addons/composite/composite-test.html
  37. 0 test/{vendor → }/qunit/addons/composite/composite-test.js
  38. 0 test/{vendor → }/qunit/addons/composite/dummy-qunit-test.html
  39. 0 test/{vendor → }/qunit/addons/composite/dummy-same-test.html
  40. 0 test/{vendor → }/qunit/addons/composite/index.html
  41. 0 test/{vendor → }/qunit/addons/composite/qunit-composite.css
  42. 0 test/{vendor → }/qunit/addons/composite/qunit-composite.js
  43. 0 test/{vendor → }/qunit/addons/step/README.md
  44. 0 test/{vendor → }/qunit/addons/step/qunit-step.js
  45. 0 test/{vendor → }/qunit/addons/step/step-test.js
  46. 0 test/{vendor → }/qunit/addons/step/step.html
  47. 0 test/{vendor → }/qunit/package.json
  48. 0 test/{ → qunit}/qunit-externs.js
  49. 0 test/{vendor → }/qunit/qunit/qunit.css
  50. 0 test/{vendor → }/qunit/qunit/qunit.js
  51. 0 test/{vendor → }/qunit/test/headless.html
  52. 0 test/{vendor → }/qunit/test/index.html
  53. 0 test/{vendor → }/qunit/test/logs.html
  54. 0 test/{vendor → }/qunit/test/logs.js
  55. 0 test/{vendor → }/qunit/test/same.js
  56. 0 test/{vendor → }/qunit/test/test.js
  57. +0 −14 test/server.js
  58. +0 −1 test/src
  59. +0 −29 test/unit-compiled.html
  60. +0 −49 test/unit.html
  61. +0 −646 test/unit.js
  62. +0 −97 test/video.compiled.js
  63. +117 −0 test/video.test.js
View
@@ -3,52 +3,37 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
- concat: {
- dist: {
- src: [
- 'src/js/goog.base.js',
- 'src/js/core.js',
- 'src/js/lib.js',
- 'src/js/events.js',
- 'src/js/component.js',
- 'src/js/player.js',
- 'src/js/media.js',
- 'src/js/media.html5.js',
- 'src/js/media.flash.js',
- 'src/js/controls.js',
- 'src/js/tracks.js',
- 'src/js/setup.js',
- 'src/js/json.js',
- 'src/js/exports.js'
- ],
- dest: 'dist/video.js'
- },
- test: {
- src: [
- 'test/unit/phantom-logging.js',
- 'test/unit/component.js',
- 'test/unit/core.js',
- 'test/unit/events.js',
- 'test/unit/lib.js',
- 'test/unit/media.html5.js',
- 'test/unit/player.js',
- 'test/unit/setup.js',
- ],
- dest: 'test/unit.js'
- }
+ build: {
+ dist:{}
},
// Current forEach issue: https://github.com/gruntjs/grunt/issues/610
// npm install https://github.com/gruntjs/grunt-contrib-jshint/archive/7fd70e86c5a8d489095fa81589d95dccb8eb3a46.tar.gz
jshint: {
- dist: {
- src: ["dist/video.js"],
+ src: {
+ src: ["src/js/*.js"],
options: {
jshintrc: ".jshintrc"
}
}
},
+ compile: {
+ dist:{
+ sourcelist: 'dist/sourcelist.txt',
+ externs: ['src/js/media.flash.externs.js'],
+ dest: 'dist/video.js'
+ },
+ test: {
+ sourcelist: 'dist/sourcelist.txt',
+ src: ['test/unit/*.js'],
+ externs: ['src/js/media.flash.externs.js', 'test/qunit-externs.js'],
+ dest: 'test/video.test.js'
+ }
+ },
+ dist: {
+ latest:{}
+ },
qunit: {
- all: ['test/unit.html']
+ all: ['test/index.html'],
},
watch: {
files: [ "src/**/*.js" ],
@@ -57,77 +42,80 @@ module.exports = function(grunt) {
});
- // Default task.
- // grunt.registerTask('default', 'lint:beforeconcat concat lint:afterconcat');
- // // Default task(s).
- // grunt.registerTask('default', ['uglify']);
-
- grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-contrib-watch");
- grunt.registerTask( "dev", [ "compile" ] ); // "build:*:*", "jshint"
- // compiled += grunt.file.read( filepath );
+ // Default task.
+ grunt.registerTask('default', ['build', 'jshint', 'compile', 'dist']);
+ // Development watch task
+ grunt.registerTask('dev', ['build', 'jshint']);
+
+ grunt.registerTask('test', ['build', 'jshint', 'qunit']);
- var exec = require('child_process').exec,
- fs = require('fs'),
+ var fs = require('fs'),
gzip = require('zlib').gzip;
grunt.registerMultiTask('build', 'Building Source', function(){
- grunt.log.writeln(this.target)
- if (this.target === 'latest') {
- var files = this.data.files;
- var dist = '';
-
- // for (prop in this.file) {
- // grunt.log.writeln(prop + ":" + this.file[prop])
- // }
-
- files.forEach(function(file){
- dist += grunt.file.read('src/js/' + file)
- });
-
- grunt.file.write('dist/video.js', dist);
- } else if (this.target === 'test') {
- grunt.task.run('build:latest');
- }
+ var calcdeps = require('calcdeps').calcdeps;
+ // caclcdeps is async
+ var done = this.async();
+ // In current version of calcdeps, not supplying certain
+ // options that should have defaults causes errors
+ // so we have all options listed here with their defaults.
+ calcdeps({
+ input: ['src/js/exports.js'],
+ path:['src/js/'],
+ dep:[],
+ exclude:[],
+ output_mode:'list',
+ }, function(err,results){
+ if (err) {
+ grunt.warn({ message: err })
+ grunt.log.writeln(err);
+ done(false);
+ }
+
+ if (results) {
+ grunt.file.write('dist/sourcelist.txt', results.join(','));
+ grunt.file.write('dist/sourcelist.js', 'var sourcelist = ["' + results.join('","') + '"]');
+ }
+
+ done();
+ });
});
- grunt.registerTask('compile', 'Minify JS files using Closure Compiler.', function() {
+ grunt.registerMultiTask('compile', 'Minify JS files using Closure Compiler.', function() {
var done = this.async();
+ var exec = require('child_process').exec;
- var command = 'java -jar build/compiler/compiler.jar';
- command += ' --compilation_level ADVANCED_OPTIMIZATIONS';
-
- var files = [
- 'goog.base.js',
- 'core.js',
- 'lib.js',
- 'events.js',
- 'component.js',
- 'player.js',
- 'media.js',
- 'media.html5.js',
- 'media.flash.js',
- 'controls.js',
- 'tracks.js',
- 'setup.js',
- 'json.js',
- 'exports.js'
- ];
+ var externs = this.file.externs || [];
+ var dest = this.file.dest;
+ var files = [];
+ if (this.data.sourcelist) {
+ files = files.concat(grunt.file.read(this.data.sourcelist).split(','))
+ }
+ if (this.file.src) {
+ files = files.concat(this.file.src);
+ }
+
+ 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'
+ + ' --output_wrapper "(function() {%output%})();//@ sourceMappingURL=video.js.map"';
files.forEach(function(file){
- command += ' --js=src/js/'+file;
+ command += ' --js='+file;
});
- command += ' --externs src/js/media.flash.externs.js';
- // command += ' --formatting=pretty_print';
- command += ' --js_output_file=test/video.compiled.js';
- command += ' --create_source_map test/video.compiled.js.map --source_map_format=V3';
- // command += ' --externs test/qunit-externs.js';
- command += ' --output_wrapper "(function() {%output%})();//@ sourceMappingURL=video.compiled.js.map"';
+ externs.forEach(function(extern){
+ command += ' --externs='+extern;
+ });
+
+ // grunt.log.writeln(command)
exec(command, { maxBuffer: 500*1024 }, function(err, stdout, stderr){
@@ -140,9 +128,11 @@ module.exports = function(grunt) {
grunt.log.writeln(stdout);
}
- grunt.log.writeln("done!")
done();
});
});
+ grunt.registerMultiTask('dist', 'Creating distribution', function(){
+
+ });
};
View
@@ -1,10 +0,0 @@
-# Using makefile temporarily to run tests on Travis CI
-
-test:
- jshint src/*.js --config .jshintrc
- node test/server.js &
- phantomjs test/phantom.js "http://localhost:3000/test/unit.html"
- kill -9 `cat test/pid.txt`
- rm test/pid.txt
-
-.PHONY: test
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Video.js | HTML5 Video Player | YouTube Demo</title>
-
- <!-- Change URLs to wherever Video.js files will be hosted -->
- <link href="video-js.css" rel="stylesheet" type="text/css">
- <!-- video.js must be in the <head> for older IEs to work. -->
- <script src="video.js"></script>
-
-</head>
-<body>
-
- <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="360"
- data-setup='{"techOrder":["youtube","html5"],"ytcontrols":false}'>
- <source src="http://www.youtube.com/watch?v=qWjzVHG9T1I" type='video/youtube' />
- </video>
-
-</body>
-</html>
View
@@ -11,7 +11,7 @@
"homepage": "http://videojs.com",
"author": "Steve Heffernan",
"scripts": {
- "test": "grunt qunit"
+ "test": "grunt test"
},
"repository": {
"type": "git",
@@ -20,14 +20,14 @@
"devDependencies": {
"grunt-cli": "~0.1.0",
"grunt": "0.4.0rc4",
- "grunt-contrib-jshint": "~0.1.0",
+ "grunt-contrib-jshint": "https://github.com/gruntjs/grunt-contrib-jshint/archive/7fd70e86c5a8d489095fa81589d95dccb8eb3a46.tar.gz",
"grunt-contrib-nodeunit": "~0.1.0",
"jshint": "0.6.1",
"connect": "2.1.3",
"grunt-contrib-uglify": "~0.1.0",
"grunt-closure-compiler": "0.0.13",
"grunt-contrib-watch": "~0.1.4",
- "grunt-contrib-concat": "~0.1.1",
- "grunt-contrib-qunit": "~0.1.0"
+ "grunt-contrib-qunit": "~0.1.0",
+ "calcdeps": "~0.1.7"
}
}
View
@@ -3,6 +3,11 @@
*
*/
+goog.provide('vjs.Component');
+
+goog.require('vjs.events');
+goog.require('vjs.dom');
+
/**
* Base UI Component class
* @param {Object} player Main Player
View
@@ -2,6 +2,12 @@
* @fileoverview Controls classes for Video.js buttons, sliders, etc.
*/
+goog.provide('vjs.Control');
+goog.provide('vjs.Menu');
+goog.provide('vjs.MenuItem');
+
+goog.require('vjs.Player');
+
/**
* Base class for all control elements
* @param {vjs.Player|Object} player
View
@@ -1,7 +1,10 @@
/**
- * @fileoverview Main function src. First file after goog.base.
+ * @fileoverview Main function src.
*/
+goog.provide('vjs');
+goog.provide('videojs');
+
// HTML5 Shiv. Must be in <head> to support older browsers.
document.createElement('video');document.createElement('audio');
View
@@ -1,8 +1,13 @@
-// Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
-// (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
-//
-// This should work very similarly to jQuery's events, however it's based off the book version which isn't as
-// robust as jquery's, so there's probably some differences.
+/**
+ * @fileoverview Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
+ * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
+ * This should work very similarly to jQuery's events, however it's based off the book version which isn't as
+ * robust as jquery's, so there's probably some differences.
+ */
+
+goog.provide('vjs.events');
+
+goog.require('vjs');
/**
* Add an event listener to element
View
@@ -5,6 +5,15 @@
* be renamed by closure compiler.
*/
+goog.require('vjs');
+goog.require('vjs.Component');
+goog.require('vjs.Player');
+goog.require('vjs.Control');
+goog.require('vjs.Html5');
+goog.require('vjs.Flash');
+goog.require('vjs.TextTrack');
+goog.require('vjs.autoSetup');
+
/**
* vjs (internal only) = videojs = _V_ (external only)
*
@@ -118,3 +127,5 @@ goog.exportProperty(vjs.TextTrack.prototype, 'label', vjs.TextTrack.prototype.la
goog.exportSymbol('videojs.CaptionsTrack', vjs.CaptionsTrack);
goog.exportSymbol('videojs.SubtitlesTrack', vjs.SubtitlesTrack);
goog.exportSymbol('videojs.ChaptersTrack', vjs.ChaptersTrack);
+
+goog.exportSymbol('videojs.autoSetup', vjs.autoSetup);
View
@@ -1,3 +1,5 @@
+goog.provide('vjs.JSON');
+
/**
* Javascript JSON implementation
* (Parse Method Only)
Oops, something went wrong.

0 comments on commit 0f0fccc

Please sign in to comment.