Permalink
Browse files

chore: switch to videojs-generate-karma-config (#5528)

  • Loading branch information...
BrandonOCasey authored and gkatsev committed Oct 31, 2018
1 parent 607ed8b commit 2e704509c92e44a25e6861cc62a26f8293650141
Showing with 827 additions and 1,721 deletions.
  1. +1 −1 .gitignore
  2. +27 −146 build/grunt.js
  3. +0 −49 build/options-customizer.js
  4. +27 −0 index.html
  5. +729 −1,301 package-lock.json
  6. +7 −21 package.json
  7. +0 −18 test/index.html
  8. +36 −185 test/karma.conf.js
@@ -24,7 +24,7 @@ sandbox/*
*results.xml
*.log

test/coverage/*
test/dist/*
.coveralls.yml
.sass-cache

@@ -1,86 +1,26 @@
import {gruntCustomizer, gruntOptionsMaker} from './options-customizer.js';
import isDocsOnly from './docs-only.js';

module.exports = function(grunt) {
require('time-grunt')(grunt);

let _ = require('lodash');
let pkg = grunt.file.readJSON('package.json');
let license = grunt.file.read('build/license-header.txt');
let bannerCommonData = _.pick(pkg, ['version', 'copyright']);
let verParts = pkg.version.split('.');
let version = {
const pkg = grunt.file.readJSON('package.json');
const verParts = pkg.version.split('.');
const version = {
full: pkg.version,
major: verParts[0],
minor: verParts[1],
patch: verParts[2]
};

const browserifyGruntDefaults = {
browserifyOptions: {
standalone: 'videojs'
},
plugin: [
['bundle-collapser/plugin'],
['browserify-derequire']
]
};

/**
* Customizes _.merge behavior in `browserifyGruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
*
* @see https://lodash.com/docs#merge
* @function browserifyGruntCustomizer
* @private
* @param {Mixed} objectValue
* @param {Mixed} sourceValue
* @return {Object}
*/
const browserifyGruntCustomizer = gruntCustomizer;

/**
* Creates a unique object of Browserify Grunt task options.
*
* @function browserifyGruntOptions
* @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}
*/
const browserifyGruntOptions = gruntOptionsMaker(browserifyGruntDefaults, browserifyGruntCustomizer);

/**
* Creates processor functions for license banners.
*
* @function createLicenseProcessor
* @private
* @param {Object} data Custom data overriding `bannerCommonData`. Will
* not be mutated.
* @return {Function} A function which returns a processed grunt template
* using an object constructed from `bannerCommonData`
* and the `data` argument.
*/
function createLicenseProcessor(data) {
return () => {
return grunt.template.process(license, {
data: _.merge({}, bannerCommonData, data)
});
};
}

version.majorMinor = `${version.major}.${version.minor}`;
grunt.vjsVersion = version;

// Project configuration.
grunt.initConfig({
pkg,
clean: {
build: ['build/temp/*', 'es5'],
dist: ['dist/*']
build: ['build/temp/*', 'es5', 'test/dist'],
dist: ['dist/*', 'test/dist']
},
dist: {},
watch: {
@@ -89,55 +29,12 @@ module.exports = function(grunt) {
tasks: ['vjslanguages']
}
},
connect: {
dev: {
options: {
port: Number(process.env.VJS_CONNECT_PORT) || 9999,
livereload: true,
useAvailablePort: true
}
}
},
copy: {
fonts: { cwd: 'node_modules/videojs-font/fonts/', src: ['*'], dest: 'build/temp/font/', expand: true, filter: 'isFile' },
dist: { cwd: 'build/temp/', src: ['**/**', '!test*'], dest: 'dist/', expand: true, filter: 'isFile' },
a11y: { src: 'sandbox/descriptions.html.example', dest: 'sandbox/descriptions.test-a11y.html' }, // Can only test a file with a .html or .htm extension
examples: { cwd: 'docs/examples/', src: ['**/**'], dest: 'dist/examples/', expand: true, filter: 'isFile' }
},
karma: {
// this config file applies to all following configs except if overwritten
options: {
configFile: 'test/karma.conf.js'
},

defaults: {
detectBrowsers: {
enabled: !process.env.TRAVIS,
usePhantomJS: false
}
},

watch: {
autoWatch: true,
singleRun: false
},

// these are run locally on local browsers
dev: { browsers: ['Chrome', 'Firefox', 'Safari'] },
chromecanary: { browsers: ['ChromeCanary'] },
chrome: { browsers: ['Chrome'] },
firefox: { browsers: ['Firefox'] },
safari: { browsers: ['Safari'] },
ie: { browsers: ['IE'] },

// this only runs on PRs from the mainrepo on BrowserStack
browserstack: { browsers: ['chrome_bs'] },
chrome_bs: { browsers: ['chrome_bs'] },
firefox_bs: { browsers: ['firefox_bs'] },
safari_bs: { browsers: ['safari_bs'] },
edge_bs: { browsers: ['edge_bs'] },
ie11_bs: { browsers: ['ie11_bs'] }
},
vjslanguages: {
defaults: {
files: {
@@ -156,37 +53,14 @@ module.exports = function(grunt) {
dest: 'dist/video-js-' + version.full + '.zip'
}
},
browserify: {
tests: {
options: {
browserifyOptions: {
verbose: true,
standalone: false,
transform: ['babelify']
},
plugin: [
['proxyquireify/plugin', 'bundle-collapser/plugin']
],
banner: false,
watch: true,
keepAlive: true
},
files: {
'build/temp/tests.js': [
'test/globals-shim.js',
'test/unit/**/*.js'
]
}
}
},
coveralls: {
options: {
// warn instead of failing when coveralls errors
// we've seen coveralls 503 relatively frequently
force: true
},
all: {
src: 'test/coverage/lcov.info'
src: 'test/dist/coverage/lcov.info'
}
},
concurrent: {
@@ -195,30 +69,37 @@ module.exports = function(grunt) {
},
tests: [
'shell:babel',
'browserify:tests'
],
dev: [
'shell:sass',
'shell:babel',
'browserify:tests',
'watch:lang',
'copy:dist'
'copy:dist',
'shell:karma-server'
],
// Run multiple watch tasks in parallel
// Needed so watchify can cache intelligently
watchAll: [
'watch',
'browserify:watch',
'browserify:watchnovtt',
'browserify:tests',
'karma:watch'
'shell:karma-server'
],
watchSandbox: [
'watch',
'browserify:watch'
'watch'
]
},
shell: {
'karma-server': {
command: 'npm run karma-server',
options: {
preferLocal: true
}
},
'karma-run': {
command: 'npm run karma-run',
options: {
preferLocal: true
}
},
cssmin: {
command: 'npm run cssmin',
options: {
@@ -331,7 +212,7 @@ module.exports = function(grunt) {
'shell:noderequire',
'shell:browserify',
'shell:webpack',
'karma:defaults',
'shell:karma-run',
'test-a11y'
];

@@ -348,13 +229,13 @@ module.exports = function(grunt) {
});

// Run while developing
grunt.registerTask('dev', ['sandbox', 'connect:dev', 'concurrent:dev']);
grunt.registerTask('watchAll', ['build', 'connect:dev', 'concurrent:watchAll']);
grunt.registerTask('dev', ['sandbox', 'concurrent:dev']);
grunt.registerTask('watchAll', ['build', 'concurrent:watchAll']);
grunt.registerTask('test-a11y', ['copy:a11y', 'accessibility']);

// Pick your testing, or run both in different terminals
grunt.registerTask('test-ui', ['browserify:tests']);
grunt.registerTask('test-cli', ['karma:watch']);
grunt.registerTask('test-ui', ['shell:karma-server']);
grunt.registerTask('test-cli', ['shell:karma-server']);

// Load all the tasks in the tasks directory
grunt.loadTasks('build/tasks');

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Video.js Dev Server</title>
</head>
<body>
<h2>Navigation</h2>
<ul>
<li><a href="/test/debug.html">Run unit tests in browser.</a></li>
<li><a href="/sandbox/index.html">Simple Demo (also seen below)</a></li>
<li><a href="/sandbox/plugin.html">Plugin Demo</a></li>
<li><a href="/sandbox/responsive.html">Responsive Demo</a></li>
<li><a href="/sandbox/middleware-play.html">Middleware Play Demo</a></li>
<li><a href="/sandbox/icons.html">Icons Demo</a></li>
<li><a href="/sandbox/focus-visible.html">Focus Visible Demo</a></li>
<li><a href="/sandbox/flash.html">Flash Demo</a></li>
<li><a href="/sandbox/fake-live.html">Fake Live Demo</a></li>
<li><a href="/sandbox/embeds.html">Embeds Demo</a></li>
<li><a href="/sandbox/descriptions.html">Descriptions Demo</a></li>
<li><a href="/sandbox/combined-tracks.html">Combined Tracks Demo</a></li>
</ul>

<h2>Simple Demo (in an iframe)</h2>
<iframe src="/sandbox/index.html" width=700 height=500></iframe>
</body>
</html>
Oops, something went wrong.

0 comments on commit 2e70450

Please sign in to comment.