mirror of
https://github.com/videojs/video.js.git
synced 2024-12-25 02:42:10 +02:00
chore: netlify ci demo and docs (#7045)
This commit is contained in:
parent
e240396f5a
commit
9574bb4ad5
3
.gitignore
vendored
3
.gitignore
vendored
@ -38,3 +38,6 @@ core.es.js
|
|||||||
|
|
||||||
# Ignore Chinese clones for now.
|
# Ignore Chinese clones for now.
|
||||||
lang/zh-Han*.json
|
lang/zh-Han*.json
|
||||||
|
|
||||||
|
# netlify deploy
|
||||||
|
deploy/
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
const sh = require('shelljs');
|
|
||||||
const pkg = require('../package.json');
|
|
||||||
|
|
||||||
const dest = path.join(__dirname, '..', 'docs', 'api');
|
|
||||||
const distDest = path.join(dest, 'dist');
|
|
||||||
const exampleDest = path.join(dest, 'test-example');
|
|
||||||
|
|
||||||
const cleanupExample = function() {
|
|
||||||
sh.rm('-rf', distDest);
|
|
||||||
sh.rm('-rf', exampleDest);
|
|
||||||
sh.rm('-rf', path.join(dest, 'node_modules'));
|
|
||||||
};
|
|
||||||
|
|
||||||
const generateExample = function({skipBuild} = {}) {
|
|
||||||
// run the build
|
|
||||||
if (!skipBuild) {
|
|
||||||
sh.exec('npm run build');
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure that the example dest is available
|
|
||||||
sh.mkdir('-p', exampleDest);
|
|
||||||
|
|
||||||
// copy the `dist` dir
|
|
||||||
sh.cp('-R', 'dist', path.join(dest, 'dist'));
|
|
||||||
sh.rm(path.join(dest, 'dist', `video-js-${pkg.version}.zip`));
|
|
||||||
|
|
||||||
const filepaths = sh.find(path.join(__dirname, '..', 'sandbox', '**', '*.*'))
|
|
||||||
.filter((filepath) => path.extname(filepath) === '.example');
|
|
||||||
|
|
||||||
// copy the sandbox example files
|
|
||||||
filepaths.forEach(function(filepath) {
|
|
||||||
const p = path.parse(filepath);
|
|
||||||
|
|
||||||
sh.cp(filepath, path.join(exampleDest, p.name));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
cleanupExample,
|
|
||||||
generateExample
|
|
||||||
};
|
|
@ -1,26 +1,14 @@
|
|||||||
const sh = require('shelljs');
|
const sh = require('shelljs');
|
||||||
const semver = require('semver');
|
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 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;
|
||||||
|
|
||||||
// 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
|
// 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);
|
process.exit(1);
|
||||||
|
|
||||||
// if we're on any other branch, we can regenerate docs
|
|
||||||
} else {
|
} else {
|
||||||
if (process.env.BRANCH !== 'master') {
|
|
||||||
// generate the example
|
|
||||||
generateExample();
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate the docs
|
|
||||||
sh.exec('npm run docs:api');
|
sh.exec('npm run docs:api');
|
||||||
|
|
||||||
// copy the legacy docs over
|
|
||||||
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
|
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
35
build/netlify.js
Normal file
35
build/netlify.js
Normal file
@ -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`));
|
@ -8,6 +8,7 @@
|
|||||||
<h2>Navigation</h2>
|
<h2>Navigation</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="test/debug.html">Run unit tests in browser.</a></li>
|
<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/index.html">Simple Demo (also seen below)</a></li>
|
||||||
<li><a href="sandbox/plugin.html">Plugin Demo</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/responsive.html">Responsive Demo</a></li>
|
||||||
|
@ -70,7 +70,8 @@
|
|||||||
"docs:lint": "remark -- './{,!(node_modules)/**/}!(CHANGELOG)*.md'",
|
"docs:lint": "remark -- './{,!(node_modules)/**/}!(CHANGELOG)*.md'",
|
||||||
"docs:fix": "remark --output -- './{,!(node_modules)/**/}!(CHANGELOG)*.md'",
|
"docs:fix": "remark --output -- './{,!(node_modules)/**/}!(CHANGELOG)*.md'",
|
||||||
"docs:lang": "node build/translations.js",
|
"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",
|
"prepublishOnly": "run-p build",
|
||||||
"publish": "node build/gh-release.js",
|
"publish": "node build/gh-release.js",
|
||||||
"version": "is-prerelease || npm run changelog && git add CHANGELOG.md",
|
"version": "is-prerelease || npm run changelog && git add CHANGELOG.md",
|
||||||
|
Loading…
Reference in New Issue
Block a user