Files
GDevelop/newIDE/web-app/scripts/deploy-purge-cache.js
Florian Rival d8a241502e Update urls of cache purge for the web-app
Don't show in changelog
2022-02-22 11:38:37 +00:00

50 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const shell = require('shelljs');
const axios = require('axios');
const args = require('minimist')(process.argv.slice(2));
if (!args['cf-zoneid'] || !args['cf-token']) {
shell.echo(
'❌ You must pass --cf-zoneid, --cf-token to purge the CloudFare cache.'
);
shell.exit(1);
}
shell.echo('️ Purging Cloudflare cache...');
const zoneId = args['cf-zoneid'];
const purgeCacheUrl = `https://api.cloudflare.com/client/v4/zones/${zoneId}/purge_cache`;
axios
.post(
purgeCacheUrl,
{
files: [
// Update index.html:
'https://editor.gdevelop.io/',
'https://editor.gdevelop.io/index.html',
// Purge service worker (otherwise old service worker will serve the old index.html):
'https://editor.gdevelop.io/service-worker.js',
// Purge libGD.js to avoid incompatibilities:
'https://editor.gdevelop.io/libGD.js',
'https://editor.gdevelop.io/libGD.mem',
// Purge other files:
'https://editor.gdevelop.io/manifest.json',
],
},
{
headers: {
Authorization: `Bearer ${args['cf-token']}`,
'Content-Type': 'application/json',
},
}
)
.then(response => response.data)
.then(() => {
shell.echo('✅ Cache purge done.');
})
.catch(error => {
shell.echo('❌ Error while requesting cache purge (are your identifiers correct?)');
shell.echo(error.message || '(unknown error)');
shell.exit(1);
});