aboutsummaryrefslogtreecommitdiffstats
path: root/gulpfile.js
diff options
context:
space:
mode:
authorSam Potts <me@sampotts.me>2018-01-09 20:25:46 +1100
committerSam Potts <me@sampotts.me>2018-01-09 20:25:46 +1100
commit6fd7b26bb2b0d1961a8b5844792f51adc6074cbc (patch)
tree23ac3c02de2f16c34774b208558c0bd1a5b8bbcb /gulpfile.js
parent1df79cf7f8d9d41aa2c26ce6fe879ad58ce658fc (diff)
downloadplyr-6fd7b26bb2b0d1961a8b5844792f51adc6074cbc.tar.lz
plyr-6fd7b26bb2b0d1961a8b5844792f51adc6074cbc.tar.xz
plyr-6fd7b26bb2b0d1961a8b5844792f51adc6074cbc.zip
Beta version up on https://plyr.io/beta and CDN
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js69
1 files changed, 36 insertions, 33 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 88d9cd15..6bb28ad1 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -221,34 +221,11 @@ gulp.task('default', () => {
// Publish a version to CDN and demo
// --------------------------------------------
-const { version } = pkg;
-const maxAge = 31536000; // 1 year
-const options = {
- cdn: {
- headers: {
- 'Cache-Control': `max-age=${maxAge}`,
- Vary: 'Accept-Encoding',
- },
- },
- demo: {
- headers: {
- 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
- Vary: 'Accept-Encoding',
- },
- },
- symlinks(ver, filename) {
- return {
- headers: {
- // http://stackoverflow.com/questions/2272835/amazon-s3-object-redirect
- 'x-amz-website-redirect-location': `/${ver}/${filename}`,
- 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
- },
- };
- },
-};
-
// If aws is setup
if (Object.keys(aws).includes('cdn') && Object.keys(aws).includes('demo')) {
+ const { version } = pkg;
+
+ // Get branch info
const branch = {
current: gitbranch.sync(),
master: 'master',
@@ -259,12 +236,36 @@ if (Object.keys(aws).includes('cdn') && Object.keys(aws).includes('demo')) {
branch.beta,
];
+ const maxAge = 31536000; // 1 year
+ const options = {
+ cdn: {
+ headers: {
+ 'Cache-Control': `max-age=${maxAge}`,
+ Vary: 'Accept-Encoding',
+ },
+ },
+ demo: {
+ uploadPath: branch.current === branch.beta ? 'beta/' : null,
+ headers: {
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
+ Vary: 'Accept-Encoding',
+ },
+ },
+ symlinks(ver, filename) {
+ return {
+ headers: {
+ // http://stackoverflow.com/questions/2272835/amazon-s3-object-redirect
+ 'x-amz-website-redirect-location': `/${ver}/${filename}`,
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
+ },
+ };
+ },
+ };
+
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\\-]+)*)?';
- const folder = branch.current === branch.beta ? '/beta' : '';
- const cdnpath = new RegExp(`${aws.cdn.domain}${folder}/${regex}`, 'gi');
const semver = new RegExp(`v${regex}`, 'gi');
const localPath = new RegExp('(../)?dist', 'gi');
- const versionPath = `https://${aws.cdn.domain}${folder}/${version}`;
+ const versionPath = `https://${aws.cdn.domain}/${version}`;
// Publish version to CDN bucket
gulp.task('cdn', () => {
@@ -273,7 +274,7 @@ if (Object.keys(aws).includes('cdn') && Object.keys(aws).includes('demo')) {
return null;
}
- console.log(`Uploading '${version}' to ${aws.cdn.domain}${folder}...`);
+ console.log(`Uploading '${version}' to ${aws.cdn.domain}...`);
// Upload to CDN
return gulp
@@ -301,19 +302,21 @@ if (Object.keys(aws).includes('cdn') && Object.keys(aws).includes('demo')) {
return null;
}
- console.log(`Uploading '${version}' demo to ${aws.demo.domain}${folder}...`);
+ console.log(`Uploading '${version}' demo to ${aws.demo.domain}...`);
+
+ const cdnpath = new RegExp(`${aws.cdn.domain}/${regex}/`, 'gi');
// Replace versioned files in readme.md
gulp
.src([`${root}/readme.md`])
- .pipe(replace(cdnpath, `${aws.cdn.domain}${folder}/${version}`))
+ .pipe(replace(cdnpath, `${aws.cdn.domain}/${version}/`))
.pipe(gulp.dest(root));
// Replace versioned files in plyr.js
gulp
.src(path.join(root, 'src/js/plyr.js'))
.pipe(replace(semver, `v${version}`))
- .pipe(replace(cdnpath, `${aws.cdn.domain}${folder}/${version}`))
+ .pipe(replace(cdnpath, `${aws.cdn.domain}/${version}/`))
.pipe(gulp.dest(path.join(root, 'src/js/')));
// Replace local file paths with remote paths in demo HTML