mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 07:34:00 -05:00
use Cloudflare env variables or file
This commit is contained in:
@@ -58,6 +58,26 @@ module.exports = {
|
||||
console.log("target directory %s", dirName)
|
||||
dirName
|
||||
|
||||
hasCloudflareEnvironmentVars: () ->
|
||||
check.unemptyString(process.env.CF_TOKEN) &&
|
||||
check.unemptyString(process.env.CF_EMAIL) &&
|
||||
check.unemptyString(process.env.CF_DOMAIN)
|
||||
|
||||
# depends on the credentials file or environment variables
|
||||
makeCloudflarePurgeCommand: (url) ->
|
||||
configFile = path.resolve(__dirname, "support", ".cfcli.yml")
|
||||
if fs.existsSync(configFile)
|
||||
console.log("using CF credentials file")
|
||||
return "cfcli purgefile -c #{configFile} #{url}"
|
||||
else if @hasCloudflareEnvironmentVars()
|
||||
console.log("using CF environment variables")
|
||||
token = process.env.CF_TOKEN
|
||||
email = process.env.CF_EMAIL
|
||||
domain = process.env.CF_DOMAIN
|
||||
return "cfcli purgefile -e #{email} -k #{token} -d #{domain} #{url}"
|
||||
else
|
||||
throw new Error("Cannot form Cloudflare purge command without credentials")
|
||||
|
||||
purgeCache: ({version, platform}) ->
|
||||
la(check.unemptyString(platform), "missing platform", platform)
|
||||
la(check.unemptyString(zipName), "missing zip filename")
|
||||
@@ -69,8 +89,8 @@ module.exports = {
|
||||
|
||||
url = [konfig("cdn_url"), "desktop", version, osName, zipName].join("/")
|
||||
console.log("purging url", url)
|
||||
configFile = path.resolve(__dirname, "support", ".cfcli.yml")
|
||||
cp.exec "cfcli purgefile -c #{configFile} #{url}", (err, stdout, stderr) ->
|
||||
purgeCommand = @makeCloudflarePurgeCommand(url)
|
||||
cp.exec purgeCommand, (err, stdout, stderr) ->
|
||||
if err
|
||||
console.error("Could not purge #{url}")
|
||||
console.error(err.message)
|
||||
|
||||
Reference in New Issue
Block a user