1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-28 08:58:46 +02:00

chore: generate a test example on netlify for PRs (#4912)

This commit is contained in:
Gary Katsevman 2018-01-30 11:17:41 -05:00 committed by GitHub
parent 41fd5cb4e6
commit 8b54737646
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 67 additions and 11 deletions

52
build/generate-example.js Normal file
View File

@ -0,0 +1,52 @@
import path from 'path';
import fs from 'fs';
import sh from 'shelljs';
import klawSync from 'klaw-sync';
import pkg from '../package.json';
const dest = 'docs/api/';
const vjsFlash = 'node_modules/videojs-flash';
const vjsSwf = 'node_modules/videojs-swf/';
const distDest = path.join(dest, 'dist');
const exampleDest = path.join(dest, 'test-example');
const vjsFlashDest = path.join(dest, vjsFlash, 'dist');
const swfDest = path.join(dest, vjsFlash, vjsSwf, 'dist');
export function cleanupExample() {
sh.rm('-rf', distDest);
sh.rm('-rf', exampleDest);
sh.rm('-rf', path.join(dest, 'node_modules'));
}
export default function generateExample({skipBuild} = {}) {
// run the build
if (!skipBuild) {
sh.exec('npm run build');
}
// make sure that the example, flash, and swf dests are available
sh.mkdir('-p', exampleDest);
sh.mkdir('-p', vjsFlashDest);
sh.mkdir('-p', swfDest);
// copy the `dist` dir
sh.cp('-R', 'dist', path.join(dest, 'dist'));
sh.rm(path.join(dest, 'dist', `video-js-${pkg.version}.zip`));
// copy videojs-flash
sh.cp(path.join(vjsFlash, 'dist', 'videojs-flash.js'), vjsFlashDest);
// copy videojs-swf
if (fs.existsSync(path.join(vjsFlash, vjsSwf, 'dist', 'video-js.swf'))) {
sh.cp(path.join(vjsFlash, vjsSwf, 'dist', 'video-js.swf'), swfDest);
} else {
sh.cp(path.join(vjsSwf, 'dist', 'video-js.swf'), swfDest);
}
const files = klawSync('sandbox/').filter((file) => path.extname(file.path) === '.example');
// copy the sandbox example files
files.forEach(function(file) {
const p = path.parse(file.path);
sh.cp(file.path, path.join(exampleDest, p.name));
});
}

View File

@ -151,7 +151,6 @@ module.exports = function(grunt) {
] ]
}, },
fonts: { cwd: 'node_modules/videojs-font/fonts/', src: ['*'], dest: 'build/temp/font/', expand: true, filter: 'isFile' }, fonts: { cwd: 'node_modules/videojs-font/fonts/', src: ['*'], dest: 'build/temp/font/', expand: true, filter: 'isFile' },
swf: { cwd: 'node_modules/videojs-swf/dist/', src: 'video-js.swf', dest: 'build/temp/', expand: true, filter: 'isFile' },
ie8: { cwd: 'node_modules/videojs-ie8/dist/', src: ['**/**'], dest: 'build/temp/ie8/', expand: true, filter: 'isFile' }, ie8: { cwd: 'node_modules/videojs-ie8/dist/', src: ['**/**'], dest: 'build/temp/ie8/', expand: true, filter: 'isFile' },
dist: { cwd: 'build/temp/', src: ['**/**', '!test*'], dest: 'dist/', 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 a11y: { src: 'sandbox/descriptions.html.example', dest: 'sandbox/descriptions.test-a11y.html' }, // Can only test a file with a .html or .htm extension
@ -449,7 +448,6 @@ module.exports = function(grunt) {
'cssmin', 'cssmin',
'copy:fonts', 'copy:fonts',
'copy:swf',
'copy:ie8', 'copy:ie8',
'vjslanguages' 'vjslanguages'
]); ]);

View File

@ -1,5 +1,6 @@
const sh = require('shelljs'); const sh = require('shelljs');
const semver = require('semver'); const semver = require('semver');
const generateExample = require('./generate-example.js').default;
const GIT_LOG = `git log --format=%B -n 1 ${process.env.COMMIT_REF}`; const GIT_LOG = `git log --format=%B -n 1 ${process.env.COMMIT_REF}`;
const output = sh.exec(GIT_LOG, {async: false, silent:true}).stdout; const output = sh.exec(GIT_LOG, {async: false, silent:true}).stdout;
@ -16,4 +17,9 @@ if (process.env.BRANCH === 'master' && semver.valid(output.trim()) === null) {
// copy the legacy docs over // copy the legacy docs over
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs'); sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
if (process.env.BRANCH !== 'master') {
// generate the example
generateExample();
}
} }

View File

@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script> <script src="../dist/ie8/videojs-ie8.js"></script>
<!-- Load the source files --> <!-- Load the source files -->
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script> <script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script>

View File

@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script> <script src="../dist/ie8/videojs-ie8.js"></script>
<!-- Load the source files --> <!-- Load the source files -->
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<!-- Set the location of the flash SWF --> <!-- Set the location of the flash SWF -->

View File

@ -6,13 +6,13 @@
<script src='../node_modules/es5-shim/es5-shim.js'></script> <script src='../node_modules/es5-shim/es5-shim.js'></script>
<script src='../node_modules/es6-shim/es6-shim.js'></script> <script src='../node_modules/es6-shim/es6-shim.js'></script>
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<script src='../node_modules/videojs-flash/dist/videojs-flash.js'></script> <script src='../node_modules/videojs-flash/dist/videojs-flash.js'></script>
<script src="https://unpkg.com/videojs-contrib-hls@latest/dist/videojs-contrib-hls.js"></script> <script src="https://unpkg.com/videojs-contrib-hls@latest/dist/videojs-contrib-hls.js"></script>
<script src="../build/temp/lang/es.js"></script> <script src="../dist/lang/es.js"></script>
<!-- Set the location of the flash SWF --> <!-- Set the location of the flash SWF -->
<script> <script>

View File

@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script> <script src="../dist/ie8/videojs-ie8.js"></script>
<!-- Load the source files --> <!-- Load the source files -->
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script> <script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Video.js Icons Sandbox</title> <title>Video.js Icons Sandbox</title>
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<style> <style>
.icon-list li span { font-size: 150% } .icon-list li span { font-size: 150% }

View File

@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script> <script src="../dist/ie8/videojs-ie8.js"></script>
<!-- Load the source files --> <!-- Load the source files -->
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script> <script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script>

View File

@ -9,7 +9,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script> <script src="../dist/ie8/videojs-ie8.js"></script>
<!-- Load the source files --> <!-- Load the source files -->
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<!-- Set the location of the flash SWF --> <!-- Set the location of the flash SWF -->

View File

@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script> <script src="../dist/ie8/videojs-ie8.js"></script>
<!-- Load the source files --> <!-- Load the source files -->
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css"> <link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script> <script src="../dist/video.js"></script>
<!-- Set the location of the flash SWF --> <!-- Set the location of the flash SWF -->