Update build process

This commit is contained in:
Sam Potts
2019-02-19 01:05:59 +11:00
parent 522135adaf
commit 54110f8358
24 changed files with 1918 additions and 945 deletions
+46
View File
@@ -0,0 +1,46 @@
{
"js": {
"plyr.js": {
"src": "./src/js/plyr.js",
"dist": "./dist/",
"formats": ["es", "umd"],
"namespace": "Plyr"
},
"plyr.polyfilled.js": {
"src": "./src/js/plyr.polyfilled.js",
"dist": "./dist/",
"formats": ["es", "umd"],
"namespace": "Plyr"
},
"demo.js": {
"src": "./demo/src/js/demo.js",
"dist": "./demo/dist/",
"formats": ["iife"],
"namespace": "Demo"
}
},
"css": {
"plyr.css": {
"src": "./src/sass/plyr.scss",
"dist": "./dist/"
},
"demo.css": {
"src": "./demo/src/sass/bundles/demo.scss",
"dist": "./demo/dist/"
},
"error.css": {
"src": "./demo/src/sass/bundles/error.scss",
"dist": "./demo/dist/"
}
},
"sprite": {
"plyr.svg": {
"src": "./src/sprite/*.svg",
"dist": "./dist"
},
"demo.svg": {
"src": "./src/sprite/*.svg",
"dist": "./demo/dist"
}
}
}
-20
View File
@@ -1,20 +0,0 @@
{
"plyr": {
"sass": {
"plyr.css": "src/sass/plyr.scss"
},
"js": {
"plyr.js": "src/js/plyr.js",
"plyr.polyfilled.js": "src/js/plyr.polyfilled.js"
}
},
"demo": {
"sass": {
"demo.css": "demo/src/sass/bundles/demo.scss",
"error.css": "demo/src/sass/bundles/error.scss"
},
"js": {
"demo.js": "demo/src/js/demo.js"
}
}
}
+5 -11
View File
@@ -5911,7 +5911,7 @@ typeof navigator === "object" && (function () {
min: 0, min: 0,
max: 100, max: 100,
value: 0, value: 0,
role: 'presentation', role: 'progressbar',
'aria-hidden': true 'aria-hidden': true
}, attributes)); // Create the label inside }, attributes)); // Create the label inside
@@ -13004,17 +13004,12 @@ typeof navigator === "object" && (function () {
focused.classList.add(tabClassName); focused.classList.add(tabClassName);
}, 10); }, 10);
}); }); // Setup the player
var userType = 'annon';
var contentType = 'on-demand';
var cmsid = 2490180;
var vid = 3788;
var tagUrl = "https://pubads.g.doubleclick.net/gampad/live/ads?sz=640x360&iu=/21736521837/ovo/web&impl=s&gdfp_req=1&env=vp&output=vast&cust_params=usergroup%3D".concat(userType, "%26content-type%3D").concat(contentType, "&cmsid=").concat(cmsid, "&vid=").concat(vid); // Setup the player
var player = new Plyr(selector, { var player = new Plyr(selector, {
debug: true, debug: true,
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
iconUrl: 'dist/plyr.svg', iconUrl: 'dist/demo.svg',
keyboard: { keyboard: {
global: true global: true
}, },
@@ -13028,9 +13023,8 @@ typeof navigator === "object" && (function () {
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c' google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c'
}, },
ads: { ads: {
enabled: true, enabled: env.prod || env.dev,
// env.prod || env.dev, publisherId: '918848828995742'
tagUrl: tagUrl
}, },
previewThumbnails: { previewThumbnails: {
enabled: true, enabled: true,
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

+3 -10
View File
@@ -58,18 +58,11 @@ import Plyr from '../../../src/js/plyr';
}, 10); }, 10);
}); });
const userType = 'annon';
const contentType = 'on-demand';
const cmsid = 2490180;
const vid = 3788;
const tagUrl = `https://pubads.g.doubleclick.net/gampad/live/ads?sz=640x360&iu=/21736521837/ovo/web&impl=s&gdfp_req=1&env=vp&output=vast&cust_params=usergroup%3D${userType}%26content-type%3D${contentType}&cmsid=${cmsid}&vid=${vid}`;
// Setup the player // Setup the player
const player = new Plyr(selector, { const player = new Plyr(selector, {
debug: true, debug: true,
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
iconUrl: 'dist/plyr.svg', iconUrl: 'dist/demo.svg',
keyboard: { keyboard: {
global: true, global: true,
}, },
@@ -83,8 +76,8 @@ import Plyr from '../../../src/js/plyr';
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c', google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c',
}, },
ads: { ads: {
enabled: true, // env.prod || env.dev, enabled: env.prod || env.dev,
tagUrl, publisherId: '918848828995742',
}, },
previewThumbnails: { previewThumbnails: {
enabled: true, enabled: true,
+12
View File
@@ -0,0 +1,12 @@
{
"cdn": {
"bucket": "plyr",
"domain": "cdn.plyr.io",
"region": "us-east-1"
},
"demo": {
"bucket": "plyr.io",
"domain": "plyr.io",
"region": "us-west-1"
}
}
+1 -1
View File
@@ -1826,7 +1826,7 @@ typeof navigator === "object" && (function (global, factory) {
min: 0, min: 0,
max: 100, max: 100,
value: 0, value: 0,
role: 'presentation', role: 'progressbar',
'aria-hidden': true 'aria-hidden': true
}, attributes)); // Create the label inside }, attributes)); // Create the label inside
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1820,7 +1820,7 @@ var controls = {
min: 0, min: 0,
max: 100, max: 100,
value: 0, value: 0,
role: 'presentation', role: 'progressbar',
'aria-hidden': true 'aria-hidden': true
}, attributes)); // Create the label inside }, attributes)); // Create the label inside
+2 -2
View File
@@ -574,7 +574,7 @@ typeof navigator === "object" && (function (global, factory) {
}); });
var _core = createCommonjsModule(function (module) { var _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.6.4' }; var core = module.exports = { version: '2.6.5' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
}); });
var _core_1 = _core.version; var _core_1 = _core.version;
@@ -4892,7 +4892,7 @@ typeof navigator === "object" && (function (global, factory) {
min: 0, min: 0,
max: 100, max: 100,
value: 0, value: 0,
role: 'presentation', role: 'progressbar',
'aria-hidden': true 'aria-hidden': true
}, attributes)); // Create the label inside }, attributes)); // Create the label inside
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -568,7 +568,7 @@ if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
}); });
var _core = createCommonjsModule(function (module) { var _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.6.4' }; var core = module.exports = { version: '2.6.5' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
}); });
var _core_1 = _core.version; var _core_1 = _core.version;
@@ -4886,7 +4886,7 @@ var controls = {
min: 0, min: 0,
max: 100, max: 100,
value: 0, value: 0,
role: 'presentation', role: 'progressbar',
'aria-hidden': true 'aria-hidden': true
}, attributes)); // Create the label inside }, attributes)); // Create the label inside
+1 -1
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

+200 -181
View File
@@ -4,38 +4,65 @@
/* global require, __dirname */ /* global require, __dirname */
/* eslint no-console: "off" */ /* eslint no-console: "off" */
const del = require('del');
const path = require('path'); const path = require('path');
const gulp = require('gulp'); const gulp = require('gulp');
const gutil = require('gulp-util');
const concat = require('gulp-concat'); // JavaScript
const filter = require('gulp-filter'); const terser = require('gulp-terser');
const sass = require('gulp-sass');
const cleancss = require('gulp-clean-css');
const header = require('gulp-header');
const prefix = require('gulp-autoprefixer');
const gitbranch = require('git-branch');
const svgstore = require('gulp-svgstore');
const svgmin = require('gulp-svgmin');
const rename = require('gulp-rename');
const s3 = require('gulp-s3');
const replace = require('gulp-replace');
const open = require('gulp-open');
const size = require('gulp-size');
const rollup = require('gulp-better-rollup'); const rollup = require('gulp-better-rollup');
const babel = require('rollup-plugin-babel'); const babel = require('rollup-plugin-babel');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify-es').default;
const commonjs = require('rollup-plugin-commonjs'); const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve'); const resolve = require('rollup-plugin-node-resolve');
const FastlyPurge = require('fastly-purge');
// CSS
const sass = require('gulp-sass');
const clean = require('gulp-clean-css');
const prefix = require('gulp-autoprefixer');
// Images
const svgstore = require('gulp-svgstore');
const imagemin = require('gulp-imagemin');
// Utils
const del = require('del');
const filter = require('gulp-filter');
const header = require('gulp-header');
const gitbranch = require('git-branch');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const log = require('fancy-log');
const open = require('gulp-open');
const plumber = require('gulp-plumber');
const size = require('gulp-size');
const sourcemaps = require('gulp-sourcemaps');
const through = require('through2'); const through = require('through2');
const bundles = require('./bundles.json'); // Deployment
const aws = require('aws-sdk');
const publish = require('gulp-awspublish');
const FastlyPurge = require('fastly-purge');
const pkg = require('./package.json'); const pkg = require('./package.json');
const build = require('./build.json');
const deploy = require('./deploy.json');
const { browserslist: browsers, version } = pkg;
const minSuffix = '.min'; const minSuffix = '.min';
// Get AWS config
Object.values(deploy).forEach(target => {
Object.assign(target, {
publisher: publish.create({
region: target.region,
params: {
Bucket: target.bucket,
},
credentials: new aws.SharedIniFileCredentials({ profile: 'plyr' }),
}),
});
});
// Paths // Paths
const paths = { const paths = {
plyr: { plyr: {
@@ -73,7 +100,7 @@ const paths = {
// Task arrays // Task arrays
const tasks = { const tasks = {
sass: [], css: [],
js: [], js: [],
sprite: [], sprite: [],
clean: ['clean'], clean: ['clean'],
@@ -82,9 +109,6 @@ const tasks = {
// Size plugin // Size plugin
const sizeOptions = { showFiles: true, gzip: true }; const sizeOptions = { showFiles: true, gzip: true };
// Browserlist
const browsers = ['> 1%'];
// Babel config // Babel config
const babelrc = (polyfill = false) => ({ const babelrc = (polyfill = false) => ({
presets: [ presets: [
@@ -115,95 +139,91 @@ gulp.task('clean', done => {
done(); done();
}); });
const build = { // JAvaScript
js(files, bundle, options) {
Object.keys(files).forEach(key => {
const { format } = options;
const name = `js:${key}:${format}`;
tasks.js.push(name);
const { output } = paths[bundle];
const polyfill = name.includes('polyfilled');
const extension = format === 'es' ? '.mjs' : '.js';
return gulp.task(name, () => const namespace = 'Plyr';
gulp
.src(bundles[bundle].js[key]) Object.entries(build.js).forEach(([filename, entry]) => {
entry.formats.forEach(format => {
const name = `js:${filename}:${format}`;
tasks.js.push(name);
const polyfill = filename.includes('polyfilled');
const extension = format === 'es' ? 'mjs' : 'js';
gulp.task(name, () => {
return gulp
.src(entry.src)
.pipe(plumber())
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(concat(key))
.pipe( .pipe(
rollup( rollup(
{ {
plugins: [resolve(), commonjs(), babel(babelrc(polyfill))], plugins: [resolve(), commonjs(), babel(babelrc(polyfill))],
}, },
options, {
name: namespace,
// exports: 'named',
format,
},
), ),
) )
.pipe(header('typeof navigator === "object" && ')) // "Support" SSR (#935) .pipe(header('typeof navigator === "object" && ')) // "Support" SSR (#935)
.pipe(rename({ extname: extension }))
.pipe(gulp.dest(output))
.pipe(filter(`**/*${extension}`))
.pipe(uglify())
.pipe(size(sizeOptions))
.pipe(rename({ suffix: minSuffix }))
.pipe(sourcemaps.write(''))
.pipe(gulp.dest(output)),
);
});
},
sass(files, bundle) {
Object.keys(files).forEach(key => {
const name = `sass:${key}`;
tasks.sass.push(name);
return gulp.task(name, () =>
gulp
.src(bundles[bundle].sass[key])
.pipe(sass())
.on('error', gutil.log)
.pipe(concat(key))
.pipe(prefix(browsers, { cascade: false }))
.pipe(cleancss())
.pipe(size(sizeOptions))
.pipe(gulp.dest(paths[bundle].output)),
);
});
},
sprite(bundle) {
const name = `svg:sprite:${bundle}`;
tasks.sprite.push(name);
// Process Icons
return gulp.task(name, () =>
gulp
.src(paths[bundle].src.sprite)
.pipe( .pipe(
svgmin({ rename({
plugins: [ extname: `.${extension}`,
{
removeDesc: true,
},
],
}), }),
) )
.pipe(svgstore())
.pipe(rename({ basename: bundle }))
.pipe(size(sizeOptions)) .pipe(size(sizeOptions))
.pipe(gulp.dest(paths[bundle].output)) .pipe(gulp.dest(entry.dist))
.pipe(gulp.dest(paths.demo.output)), .pipe(filter(`**/*${extension}`))
); .pipe(terser())
}, .pipe(rename({ suffix: minSuffix }))
}; .pipe(size(sizeOptions))
.pipe(sourcemaps.write(''))
.pipe(gulp.dest(entry.dist));
});
});
});
// Plyr core files // CSS
const namespace = 'Plyr'; Object.entries(build.css).forEach(([filename, entry]) => {
build.js(bundles.plyr.js, 'plyr', { name: namespace, format: 'umd' }); const name = `css:${filename}`;
build.js(bundles.plyr.js, 'plyr', { name: namespace, format: 'es' }); tasks.css.push(name);
build.sass(bundles.plyr.sass, 'plyr');
build.sprite('plyr');
// Demo files gulp.task(name, () => {
build.sass(bundles.demo.sass, 'demo'); return gulp
build.js(bundles.demo.js, 'demo', { format: 'iife' }); .src(entry.src)
.pipe(plumber())
.pipe(sass())
.pipe(
prefix(browsers, {
cascade: false,
}),
)
.pipe(clean())
.pipe(size(sizeOptions))
.pipe(gulp.dest(entry.dist));
});
});
// SVG Sprites
Object.entries(build.sprite).forEach(([filename, entry]) => {
const name = `sprite:${filename}`;
tasks.sprite.push(name);
log(path.basename(filename));
gulp.task(name, () => {
return gulp
.src(entry.src)
.pipe(plumber())
.pipe(imagemin())
.pipe(svgstore())
.pipe(rename({ basename: path.parse(filename).name }))
.pipe(size(sizeOptions))
.pipe(gulp.dest(entry.dist));
});
});
// Build all JS // Build all JS
gulp.task('js', () => gulp.parallel(...tasks.js)); gulp.task('js', () => gulp.parallel(...tasks.js));
@@ -212,16 +232,16 @@ gulp.task('js', () => gulp.parallel(...tasks.js));
gulp.task('watch', () => { gulp.task('watch', () => {
// Plyr core // Plyr core
gulp.watch(paths.plyr.src.js, gulp.parallel(...tasks.js)); gulp.watch(paths.plyr.src.js, gulp.parallel(...tasks.js));
gulp.watch(paths.plyr.src.sass, gulp.parallel(...tasks.sass)); gulp.watch(paths.plyr.src.sass, gulp.parallel(...tasks.css));
gulp.watch(paths.plyr.src.sprite, gulp.parallel(...tasks.sprite)); gulp.watch(paths.plyr.src.sprite, gulp.parallel(...tasks.sprite));
// Demo // Demo
gulp.watch(paths.demo.src.js, gulp.parallel(...tasks.js)); gulp.watch(paths.demo.src.js, gulp.parallel(...tasks.js));
gulp.watch(paths.demo.src.sass, gulp.parallel(...tasks.sass)); gulp.watch(paths.demo.src.sass, gulp.parallel(...tasks.css));
}); });
// Build distribution // Build distribution
gulp.task('build', gulp.series(tasks.clean, gulp.parallel(...tasks.js, ...tasks.sass, ...tasks.sprite))); gulp.task('build', gulp.series(tasks.clean, gulp.parallel(...tasks.js, ...tasks.css, ...tasks.sprite)));
// Default gulp task // Default gulp task
gulp.task('default', gulp.series('build', 'watch')); gulp.task('default', gulp.series('build', 'watch'));
@@ -236,21 +256,15 @@ try {
// Do nothing // Do nothing
} }
// If deployment is setup // Get branch info
// TODO: Use gulp-awspublish and use AWS CLI credentials const branch = {
if (Object.keys(credentials).includes('aws') && Object.keys(credentials).includes('fastly')) {
const { version } = pkg;
const { aws, fastly } = credentials;
// Get branch info
const branch = {
current: gitbranch.sync(), current: gitbranch.sync(),
master: 'master', master: 'master',
beta: 'beta', beta: 'beta',
}; };
const maxAge = 31536000; // 1 year const maxAge = 31536000; // 1 year
const options = { const options = {
cdn: { cdn: {
headers: { headers: {
'Cache-Control': `max-age=${maxAge}`, 'Cache-Control': `max-age=${maxAge}`,
@@ -273,22 +287,22 @@ if (Object.keys(credentials).includes('aws') && Object.keys(credentials).include
}, },
}; };
}, },
}; };
const regex = const regex =
'(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*).(?:0|[1-9][0-9]*)(?:-[\\da-z\\-]+(?:.[\\da-z\\-]+)*)?(?:\\+[\\da-z\\-]+(?:.[\\da-z\\-]+)*)?'; '(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*).(?:0|[1-9][0-9]*)(?:-[\\da-z\\-]+(?:.[\\da-z\\-]+)*)?(?:\\+[\\da-z\\-]+(?:.[\\da-z\\-]+)*)?';
const semver = new RegExp(`v${regex}`, 'gi'); const semver = new RegExp(`v${regex}`, 'gi');
const localPath = new RegExp('(../)?dist', 'gi'); const localPath = new RegExp('(../)?dist', 'gi');
const versionPath = `https://${aws.cdn.domain}/${version}`; const versionPath = `https://${deploy.cdn.domain}/${version}`;
const cdnpath = new RegExp(`${aws.cdn.domain}/${regex}/`, 'gi'); const cdnpath = new RegExp(`${deploy.cdn.domain}/${regex}/`, 'gi');
const renameFile = rename(p => { const renameFile = rename(p => {
p.basename = p.basename.replace(minSuffix, ''); // eslint-disable-line p.basename = p.basename.replace(minSuffix, ''); // eslint-disable-line
p.dirname = p.dirname.replace('.', version); // eslint-disable-line p.dirname = p.dirname.replace('.', version); // eslint-disable-line
}); });
// Check we're on the correct branch to deploy // Check we're on the correct branch to deploy
const canDeploy = () => { const canDeploy = () => {
const allowed = [branch.master, branch.beta]; const allowed = [branch.master, branch.beta];
if (!allowed.includes(branch.current)) { if (!allowed.includes(branch.current)) {
@@ -298,14 +312,16 @@ if (Object.keys(credentials).includes('aws') && Object.keys(credentials).include
} }
return true; return true;
}; };
gulp.task('version', done => { gulp.task('version', done => {
if (!canDeploy()) { if (!canDeploy()) {
done(); done();
return null; return null;
} }
const { domain } = deploy.cdn;
console.log(`Updating versions to '${version}'...`); console.log(`Updating versions to '${version}'...`);
// Replace versioned URLs in source // Replace versioned URLs in source
@@ -314,18 +330,24 @@ if (Object.keys(credentials).includes('aws') && Object.keys(credentials).include
return gulp return gulp
.src(files.map(file => path.join(__dirname, `src/js/${file}`)), { base: '.' }) .src(files.map(file => path.join(__dirname, `src/js/${file}`)), { base: '.' })
.pipe(replace(semver, `v${version}`)) .pipe(replace(semver, `v${version}`))
.pipe(replace(cdnpath, `${aws.cdn.domain}/${version}/`)) .pipe(replace(cdnpath, `${domain}/${version}/`))
.pipe(gulp.dest('./')); .pipe(gulp.dest('./'));
}); });
// Publish version to CDN bucket // Publish version to CDN bucket
gulp.task('cdn', done => { gulp.task('cdn', done => {
if (!canDeploy()) { if (!canDeploy()) {
done(); done();
return null; return null;
} }
console.log(`Uploading '${version}' to ${aws.cdn.domain}...`); const { domain, publisher } = deploy.cdn;
if (!publisher) {
throw new Error('No publisher instance. Check AWS configuration.');
}
console.log(`Uploading '${version}' to ${domain}...`);
// Upload to CDN // Upload to CDN
return ( return (
@@ -339,19 +361,20 @@ if (Object.keys(credentials).includes('aws') && Object.keys(credentials).include
(match, filename) => `sourceMappingURL=${filename.replace(minSuffix, '')}`, (match, filename) => `sourceMappingURL=${filename.replace(minSuffix, '')}`,
), ),
) )
.pipe( .pipe(size(sizeOptions))
size({
showFiles: true,
gzip: true,
}),
)
.pipe(replace(localPath, versionPath)) .pipe(replace(localPath, versionPath))
.pipe(s3(aws.cdn, options.cdn)) .pipe(publisher.publish(options.cdn.headers))
.pipe(publish.reporter())
); );
}); });
// Purge the fastly cache incase any 403/404 are cached // Purge the fastly cache incase any 403/404 are cached
gulp.task('purge', () => { gulp.task('purge', () => {
if (!Object.keys(credentials).includes('fastly')) {
throw new Error('Fastly credentials required to purge cache.');
}
const { fastly } = credentials;
const list = []; const list = [];
return gulp return gulp
@@ -378,92 +401,88 @@ if (Object.keys(credentials).includes('aws') && Object.keys(credentials).include
}); });
}); });
}); });
}); });
// Publish to demo bucket // Publish to demo bucket
gulp.task('demo', done => { gulp.task('demo', done => {
if (!canDeploy()) { if (!canDeploy()) {
done(); done();
return null; return null;
} }
console.log(`Uploading '${version}' demo to ${aws.demo.domain}...`); const { publisher } = deploy.demo;
const { domain } = deploy.cdn;
if (!publisher) {
throw new Error('No publisher instance. Check AWS configuration.');
}
console.log(`Uploading '${version}' demo to ${deploy.demo.domain}...`);
// Replace versioned files in readme.md // Replace versioned files in readme.md
gulp.src([`${__dirname}/readme.md`]) gulp.src([`${__dirname}/readme.md`])
.pipe(replace(cdnpath, `${aws.cdn.domain}/${version}/`)) .pipe(replace(cdnpath, `${domain}/${version}/`))
.pipe(gulp.dest(__dirname)); .pipe(gulp.dest(__dirname));
// Replace local file paths with remote paths in demo HTML // Replace local file paths with remote paths in demo HTML
// e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js" // e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
const index = `${paths.demo.root}index.html`; const index = `${paths.demo.root}index.html`;
const error = `${paths.demo.root}error.html`; const error = `${paths.demo.root}error.html`;
const pages = [index]; const pages = [index, error];
if (branch.current === branch.master) { if (branch.current === branch.master) {
pages.push(error); pages.push(error);
} }
gulp.src(pages) return gulp
.src(pages)
.pipe(replace(localPath, versionPath)) .pipe(replace(localPath, versionPath))
.pipe(s3(aws.demo, options.demo)); .pipe(publisher.publish(options.demo.headers))
.pipe(publish.reporter());
});
gulp.task('error', done => {
// Only update CDN for master (prod) // Only update CDN for master (prod)
if (branch.current !== branch.master) { if (!canDeploy() || branch.current !== branch.master) {
done(); done();
return null; return null;
} }
// Upload error.html to cdn (as well as demo site) const { publisher } = deploy.cdn;
return gulp
.src([error])
.pipe(replace(localPath, versionPath))
.pipe(s3(aws.cdn, options.demo));
});
// Update symlinks for latest if (!publisher) {
/* gulp.task("symlinks", function () { throw new Error('No publisher instance. Check AWS configuration.');
console.log("Updating symlinks...");
return gulp.src(paths.upload)
.pipe(through.obj(function (chunk, enc, callback) {
if (chunk.stat.isFile()) {
// Get the filename
var filename = chunk.path.split("/").reverse()[0];
// Create the 0 byte redirect files to upload
createFile(filename, "")
.pipe(rename(function (path) {
path.dirname = path.dirname.replace(".", "latest");
}))
// Upload to S3 with correct headers
.pipe(s3(aws.cdn, options.symlinks(version, filename)));
} }
callback(null, chunk); // Replace local file paths with remote paths in demo HTML
})); // e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
}); */ // Upload error.html to cdn
return gulp
.src(`${paths.demo.root}error.html`)
.pipe(replace(localPath, versionPath))
.pipe(publisher.publish(options.demo.headers))
.pipe(publish.reporter());
});
// Open the demo site to check it's ok // Open the demo site to check it's ok
gulp.task('open', () => { gulp.task('open', () => {
return gulp.src(__filename).pipe( return gulp.src(__filename).pipe(
open({ open({
uri: `https://${aws.demo.domain}/${branch.current === branch.beta ? 'beta' : ''}`, uri: `https://${aws.demo.domain}/${branch.current === branch.beta ? 'beta' : ''}`,
}), }),
); );
}); });
// Do everything // Do everything
gulp.task( gulp.task(
'deploy', 'deploy',
gulp.series( gulp.series(
'version', 'version',
tasks.clean, tasks.clean,
gulp.parallel(...tasks.js, ...tasks.sass, ...tasks.sprite), gulp.parallel(...tasks.js, ...tasks.css, ...tasks.sprite),
'cdn', 'cdn',
'demo', 'demo',
'purge', 'purge',
'open', 'open',
), ),
); );
}
+15 -12
View File
@@ -27,45 +27,48 @@
"bugs": { "bugs": {
"url": "https://github.com/sampotts/plyr/issues" "url": "https://github.com/sampotts/plyr/issues"
}, },
"directories": { "browserslist": [
"doc": "readme.md" "> 1%",
}, "not dead"
],
"scripts": { "scripts": {
"build": "gulp build", "build": "gulp build",
"lint": "eslint src/js && npm run-script remark", "lint": "eslint src/js && npm run-script remark",
"remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'", "remark": "remark -f --use 'validate-links=repository:\"sampotts/plyr\"' '{,!(node_modules),.?**/}*.md'",
"test": "echo \"Error: no test specified\" && exit 1" "deploy": "yarn lint && gulp deploy"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.2.2", "aws-sdk": "^2.404.0",
"babel-eslint": "^10.0.1", "@babel/core": "^7.3.3",
"@babel/preset-env": "^7.3.1", "@babel/preset-env": "^7.3.1",
"babel-eslint": "^10.0.1",
"babel-preset-minify": "^0.5.0",
"del": "^3.0.0", "del": "^3.0.0",
"eslint": "^5.13.0", "eslint": "^5.14.0",
"eslint-config-airbnb-base": "^13.1.0", "eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^4.0.0", "eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0", "eslint-plugin-import": "^2.16.0",
"fancy-log": "^1.3.3",
"fastly-purge": "^1.0.1", "fastly-purge": "^1.0.1",
"git-branch": "^2.0.1", "git-branch": "^2.0.1",
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-autoprefixer": "^6.0.0", "gulp-autoprefixer": "^6.0.0",
"gulp-awspublish": "^4.0.0",
"gulp-better-rollup": "^3.4.0", "gulp-better-rollup": "^3.4.0",
"gulp-clean-css": "^4.0.0", "gulp-clean-css": "^4.0.0",
"gulp-concat": "^2.6.1",
"gulp-filter": "^5.1.0", "gulp-filter": "^5.1.0",
"gulp-header": "^2.0.7", "gulp-header": "^2.0.7",
"gulp-imagemin": "^5.0.3",
"gulp-open": "^3.0.1", "gulp-open": "^3.0.1",
"gulp-plumber": "^1.2.1",
"gulp-postcss": "^8.0.0", "gulp-postcss": "^8.0.0",
"gulp-rename": "^1.4.0", "gulp-rename": "^1.4.0",
"gulp-replace": "^1.0.0", "gulp-replace": "^1.0.0",
"gulp-s3": "^0.11.0",
"gulp-sass": "^4.0.2", "gulp-sass": "^4.0.2",
"gulp-size": "^3.0.0", "gulp-size": "^3.0.0",
"gulp-sourcemaps": "^2.6.4", "gulp-sourcemaps": "^2.6.4",
"gulp-svgmin": "^2.1.0",
"gulp-svgstore": "^7.0.1", "gulp-svgstore": "^7.0.1",
"gulp-uglify-es": "^1.0.4", "gulp-terser": "^1.1.7",
"gulp-util": "^3.0.8",
"postcss-custom-properties": "^8.0.9", "postcss-custom-properties": "^8.0.9",
"prettier-eslint": "^8.8.2", "prettier-eslint": "^8.8.2",
"prettier-stylelint": "^0.4.2", "prettier-stylelint": "^0.4.2",
+1503 -577
View File
File diff suppressed because it is too large Load Diff