Skip to content

Commit

Permalink
chore: netlify ci demo and docs (#7045)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jan 19, 2021
1 parent e240396 commit 9574bb4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ core.es.js

# Ignore Chinese clones for now.
lang/zh-Han*.json

# netlify deploy
deploy/
42 changes: 0 additions & 42 deletions build/generate-example.js

This file was deleted.

16 changes: 2 additions & 14 deletions build/netlify-docs.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
const sh = require('shelljs');
const semver = require('semver');
const generateExample = require('./generate-example.js').generateExample;

const GIT_LOG = `git log --format=%B -n 1 ${process.env.COMMIT_REF}`;
const output = sh.exec(GIT_LOG, {async: false, silent: true}).stdout;

// if we're on master branch and not on a tagged commit,
// if we're on main branch and not on a tagged commit,
// error the build so it doesn't redeploy the docs
if (process.env.BRANCH === 'master' && semver.valid(output.trim()) === null) {
if (process.env.BRANCH === 'main' && semver.valid(output.trim()) === null) {
process.exit(1);

// if we're on any other branch, we can regenerate docs
} else {
if (process.env.BRANCH !== 'master') {
// generate the example
generateExample();
}

// generate the docs
sh.exec('npm run docs:api');

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

}
35 changes: 35 additions & 0 deletions build/netlify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const pkg = require('../package.json');
const path = require('path');
const sh = require('shelljs');

process.env.CI = true;
// run build steps
sh.exec('npm run build');
sh.exec('npm run sandbox');
sh.exec('npm run docs:api');

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

const deployDir = 'deploy';
const files = [
'node_modules/es5-shim/es5-shim.js',
'node_modules/es6-shim/es6-shim.js'
];

// cleanup previous deploy
sh.rm('-rf', deployDir);
// make sure the directory exists
sh.mkdir('-p', deployDir);

// create nested directories
files
.map((file) => path.dirname(file))
.forEach((dir) => sh.mkdir('-p', path.join(deployDir, dir)));

// copy files/folders to deploy dir
files
.concat('dist', 'index.html', 'sandbox', 'docs')
.forEach((file) => sh.cp('-r', file, path.join(deployDir, file)));

sh.rm(path.join(deployDir, 'dist', `video-js-${pkg.version}.zip`));
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<h2>Navigation</h2>
<ul>
<li><a href="test/debug.html">Run unit tests in browser.</a></li>
<li><a href="docs/api/">view api docs</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>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"docs:lint": "remark -- './{,!(node_modules)/**/}!(CHANGELOG)*.md'",
"docs:fix": "remark --output -- './{,!(node_modules)/**/}!(CHANGELOG)*.md'",
"docs:lang": "node build/translations.js",
"netlify": "node ./build/netlify-docs.js",
"netlify": "node ./build/netlify.js",
"netlify-docs": "node ./build/netlify-docs.js",
"prepublishOnly": "run-p build",
"publish": "node build/gh-release.js",
"version": "is-prerelease || npm run changelog && git add CHANGELOG.md",
Expand Down

0 comments on commit 9574bb4

Please sign in to comment.