mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 00:16:21 +00:00
e55a04c156
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.
26 lines
840 B
JavaScript
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()
|