mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-06 06:29:45 -06:00
chore: add utility for purging urls from Cloudflare cache (#27923)
This commit is contained in:
@@ -285,6 +285,22 @@ const deploy = {
|
||||
return moveBinaries(args)
|
||||
},
|
||||
|
||||
// purge all URLs from Cloudflare cache from file
|
||||
'purge-urls' (args = process.argv) {
|
||||
console.log('#purge-urls')
|
||||
|
||||
const options = minimist(args, {
|
||||
string: 'filePath',
|
||||
alias: {
|
||||
filePath: 'f',
|
||||
},
|
||||
})
|
||||
|
||||
la(check.unemptyString(options.filePath), 'missing file path to url list', options)
|
||||
|
||||
return uploadUtils.purgeUrlsFromCloudflareCache(options.filePath)
|
||||
},
|
||||
|
||||
// purge all platforms of a desktop app for specific version
|
||||
'purge-version' (args = process.argv) {
|
||||
console.log('#purge-version')
|
||||
|
||||
@@ -6,6 +6,7 @@ const fse = require('fs-extra')
|
||||
const os = require('os')
|
||||
const Promise = require('bluebird')
|
||||
const { fromSSO, fromEnv } = require('@aws-sdk/credential-providers')
|
||||
const _ = require('lodash')
|
||||
|
||||
const { purgeCloudflareCache } = require('./purge-cloudflare-cache')
|
||||
|
||||
@@ -108,6 +109,15 @@ const purgeDesktopAppAllPlatforms = function (version, zipName) {
|
||||
return purgeDesktopAppFromCache({ version, platformArch, zipName })
|
||||
})
|
||||
}
|
||||
|
||||
// reads all lines in from a file as URLs and purges them from Cloudflare
|
||||
// see Slack conversation https://cypressio.slack.com/archives/C055U0SMV32/p1695851503262999?thread_ts=1695846392.723289&cid=C055U0SMV32
|
||||
const purgeUrlsFromCloudflareCache = async function (urlsFilePath) {
|
||||
const urls = (await fse.readFile(urlsFilePath)).toString().split('\n')
|
||||
|
||||
return Promise.map(_.compact(urls), purgeCloudflareCache, { concurrency: 5 })
|
||||
}
|
||||
|
||||
// simple check for platform-arch string
|
||||
// example: isValidPlatformArch("darwin") // FALSE
|
||||
const isValidPlatformArch = check.oneOf(validPlatformArchs)
|
||||
@@ -156,4 +166,5 @@ module.exports = {
|
||||
saveUrl,
|
||||
formHashFromEnvironment,
|
||||
getUploadUrl,
|
||||
purgeUrlsFromCloudflareCache,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user