From 9574bb4ad51746f4570a1acdfa7c3e84797f32ae Mon Sep 17 00:00:00 2001 From: Brandon Casey <2381475+brandonocasey@users.noreply.github.com> Date: Tue, 19 Jan 2021 18:47:48 -0500 Subject: [PATCH] chore: netlify ci demo and docs (#7045) --- .gitignore | 3 +++ build/generate-example.js | 42 --------------------------------------- build/netlify-docs.js | 16 ++------------- build/netlify.js | 35 ++++++++++++++++++++++++++++++++ index.html | 1 + package.json | 3 ++- 6 files changed, 43 insertions(+), 57 deletions(-) delete mode 100644 build/generate-example.js create mode 100644 build/netlify.js diff --git a/.gitignore b/.gitignore index a098cfc43..ae21c2bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ core.es.js # Ignore Chinese clones for now. lang/zh-Han*.json + +# netlify deploy +deploy/ diff --git a/build/generate-example.js b/build/generate-example.js deleted file mode 100644 index aa6f10e78..000000000 --- a/build/generate-example.js +++ /dev/null @@ -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 -}; diff --git a/build/netlify-docs.js b/build/netlify-docs.js index 3f163f369..a9578fee3 100644 --- a/build/netlify-docs.js +++ b/build/netlify-docs.js @@ -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'); - } diff --git a/build/netlify.js b/build/netlify.js new file mode 100644 index 000000000..e0b67ca10 --- /dev/null +++ b/build/netlify.js @@ -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`)); diff --git a/index.html b/index.html index 0da3bb90d..5ca5cf2b5 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@