chore: remove fastly purging logic (#2173)

This commit is contained in:
Sam Potts 2021-04-18 17:41:58 +10:00 committed by GitHub
parent 951cccb6b0
commit 7d22c361d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 49 deletions

View File

@ -52,7 +52,6 @@
"del": "^6.0.0",
"eslint": "^7.23.0",
"fancy-log": "^1.3.3",
"fastly-purge": "^1.0.1",
"git-branch": "^2.0.1",
"gulp": "^4.0.2",
"gulp-awspublish": "^4.1.2",
@ -88,8 +87,7 @@
"stylelint-config-sass-guidelines": "^8.0.0",
"stylelint-order": "^4.1.0",
"stylelint-scss": "^3.19.0",
"stylelint-selector-bem-pattern": "^2.1.0",
"through2": "^4.0.2"
"stylelint-selector-bem-pattern": "^2.1.0"
},
"dependencies": {
"core-js": "^3.10.1",

View File

@ -14,11 +14,9 @@ const { green, cyan, bold } = require('colorette');
const log = require('fancy-log');
const open = require('gulp-open');
const size = require('gulp-size');
const through = require('through2');
// Deployment
const aws = require('aws-sdk');
const publish = require('gulp-awspublish');
const FastlyPurge = require('fastly-purge');
// Configs
const pkg = require('../package.json');
const deploy = require('../deploy.json');
@ -53,14 +51,6 @@ const paths = {
],
};
// Get credentials
let credentials = {};
try {
credentials = require('../credentials.json'); //eslint-disable-line
} catch (e) {
// Do nothing
}
// Get branch info
const branch = {
current: gitbranch.sync(),
@ -177,41 +167,6 @@ gulp.task('cdn', (done) => {
);
});
// Purge the fastly cache incase any 403/404 are cached
gulp.task('purge', () => {
if (!Object.keys(credentials).includes('fastly')) {
throw new Error('Fastly credentials required to purge cache.');
}
const { fastly } = credentials;
const list = [];
return gulp
.src(paths.upload)
.pipe(
through.obj((file, enc, cb) => {
const filename = file.path.split('/').pop();
list.push(`${versionPath}${filename.replace(minSuffix, '')}`);
cb(null);
}),
)
.on('end', () => {
const purge = new FastlyPurge(fastly.token);
list.forEach((url) => {
log(`Purging ${cyan(url)}...`);
purge.url(url, (error, result) => {
if (error) {
log.error(error);
} else if (result) {
log(result);
}
});
});
});
});
// Publish to demo bucket
gulp.task('demo', (done) => {
if (!canDeploy()) {
@ -271,4 +226,4 @@ gulp.task('open', () => {
});
// Do everything
gulp.task('deploy', gulp.series('cdn', 'demo', 'purge', 'open'));
gulp.task('deploy', gulp.series('cdn', 'demo', 'open'));