filesafe/scripts/cfpurge.js
Bobby Wibowo e55a04c156
Updates
Added cfpurge.js to scripts directory.
This can be used to purge cache of frontend pages and uploads.
Do "node scripts/cfpurge.js --help" for usage.

Removed "randver" from package.js/scripts.
I've installed randomstring globally instead and just simply do:
randomstring n
Back then I didn't know it could be used that way.
2019-01-06 13:27:17 +07:00

26 lines
840 B
JavaScript

const { stripIndents } = require('./_utils')
const utils = require('./../controllers/utilsController')
const config = require('./../config')
const cfpurge = {}
cfpurge.do = async () => {
const location = process.argv[1].replace(process.cwd() + '/', '')
const args = process.argv.slice(2)
if (args.includes('--help') || args.includes('-h'))
return console.log(stripIndents(`
Purge Cloudflare's cache.
Usage:\nnode ${location} [...filename]
filename:
File names (as in uploads) separated by space (will automatically include their thumbs if available).
If not provided, this will default to frontend pages listed in "pages" array in config.js.
`))
const filenames = args.length ? args : config.pages
return utils.purgeCloudflareCache(filenames, Boolean(args.length), true)
}
cfpurge.do()