filesafe/scripts/cf-purge.js
Bobby Wibowo 02e2e402c3
!!! MASSIVE OVERHAUL !!!
As the title says, this commit is a massive overhaul.
I've rewritten/restrucuted almost everything in the controller scripts.
Because of that, there's a considerable possibility that I've broken
something somewhere.

Notable changes:

Added temporary uploads.

Removed file name length changer from dashboard,
in favor of an equivalent in homepage config tab.
This allows non-registered users to also set file name length.

A bunch of other undocmented stuff.
I don't know, I'm too tired to remember them all.
2019-09-08 08:56:29 +07:00

32 lines
935 B
JavaScript

const { stripIndents } = require('./_utils')
const utils = require('./../controllers/utilsController')
;(async () => {
const location = process.argv[1].replace(process.cwd() + '/', '')
const args = process.argv.slice(2)
if (!args.length || args.includes('--help') || args.includes('-h'))
return console.log(stripIndents(`
Purge Cloudflare's cache.
Usage:
node ${location} ...filename
filename:
Upload names separated by space (will automatically include their thumbs if available).
`))
const results = await utils.purgeCloudflareCache(args, true, true)
for (const result of results)
if (result.errors.length)
result.errors.forEach(error => console.error(`CF: ${error}`))
else
console.log(`URLs:\n${result.files.join('\n')}\n\nSuccess: ${result.success}`)
})()
.then(() => process.exit(0))
.catch(error => {
console.error(error)
process.exit(1)
})