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

chore: generate a test example on netlify on PRs #4912

Merged
merged 8 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from 7 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
52 changes: 52 additions & 0 deletions build/generate-example.js
Original file line number Diff line number Diff line change
@@ -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 link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need the zip file published here.


// 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));
});
}
2 changes: 0 additions & 2 deletions build/grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ module.exports = function(grunt) {
]
},
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' },
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
Expand Down Expand Up @@ -449,7 +448,6 @@ module.exports = function(grunt) {
'cssmin',

'copy:fonts',
'copy:swf',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our switch to node 8/npm 5 meant that packages were flattened, so, the swf snuck back into the dist folder.

'copy:ie8',
'vjslanguages'
]);
Expand Down
6 changes: 6 additions & 0 deletions build/netlify-docs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const sh = require('shelljs');
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 output = sh.exec(GIT_LOG, {async: false, silent:true}).stdout;
Expand All @@ -16,4 +17,9 @@ if (process.env.BRANCH === 'master' && semver.valid(output.trim()) === null) {

// copy the legacy docs over
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');

if (process.env.BRANCH !== 'master') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need or want to generate this in the master branch currently, I don't think.

// generate the example
generateExample();
}
}
2 changes: 1 addition & 1 deletion sandbox/combined-tracks.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script>

<!-- 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="../node_modules/videojs-flash/dist/videojs-flash.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion sandbox/descriptions.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script>

<!-- 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>

<!-- Set the location of the flash SWF -->
Expand Down
4 changes: 2 additions & 2 deletions sandbox/embeds.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<script src='../node_modules/es5-shim/es5-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='../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="../build/temp/lang/es.js"></script>
<script src="../dist/lang/es.js"></script>

<!-- Set the location of the flash SWF -->
<script>
Expand Down
2 changes: 1 addition & 1 deletion sandbox/flash.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script>

<!-- 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="../node_modules/videojs-flash/dist/videojs-flash.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion sandbox/icons.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<title>Video.js Icons Sandbox</title>

<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css">
<link href="../build/video-js.css" rel="stylesheet" type="text/css">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one intentionally using build instead of dist?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. Probably got confused about it, heh.


<style>
.icon-list li span { font-size: 150% }
Expand Down
2 changes: 1 addition & 1 deletion sandbox/index.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script>

<!-- 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="../node_modules/videojs-flash/dist/videojs-flash.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion sandbox/language.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script>

<!-- 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>

<!-- Set the location of the flash SWF -->
Expand Down
2 changes: 1 addition & 1 deletion sandbox/plugin.html.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="../dist/ie8/videojs-ie8.js"></script>

<!-- 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>

<!-- Set the location of the flash SWF -->
Expand Down