mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-29 05:04:46 +01:00
89 lines
2.7 KiB
JavaScript
89 lines
2.7 KiB
JavaScript
const providers = [
|
|
["APPVEYOR"],
|
|
["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
|
|
["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
|
|
["APPCIRCLE", "AC_APPCIRCLE"],
|
|
["BAMBOO", "bamboo_planKey"],
|
|
["BITBUCKET", "BITBUCKET_COMMIT"],
|
|
["BITRISE", "BITRISE_IO"],
|
|
["BUDDY", "BUDDY_WORKSPACE_ID"],
|
|
["BUILDKITE"],
|
|
["CIRCLE", "CIRCLECI"],
|
|
["CIRRUS", "CIRRUS_CI"],
|
|
["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }],
|
|
["CODEBUILD", "CODEBUILD_BUILD_ARN"],
|
|
["CODEFRESH", "CF_BUILD_ID"],
|
|
["DRONE"],
|
|
["DRONE", "DRONE_BUILD_EVENT"],
|
|
["DSARI"],
|
|
["GITHUB_ACTIONS"],
|
|
["GITLAB", "GITLAB_CI"],
|
|
["GITLAB", "CI_MERGE_REQUEST_ID"],
|
|
["GOCD", "GO_PIPELINE_LABEL"],
|
|
["LAYERCI"],
|
|
["HUDSON", "HUDSON_URL"],
|
|
["JENKINS", "JENKINS_URL"],
|
|
["MAGNUM"],
|
|
["NETLIFY"],
|
|
["NETLIFY", "NETLIFY_LOCAL", { ci: false }],
|
|
["NEVERCODE"],
|
|
["RENDER"],
|
|
["SAIL", "SAILCI"],
|
|
["SEMAPHORE"],
|
|
["SCREWDRIVER"],
|
|
["SHIPPABLE"],
|
|
["SOLANO", "TDDIUM"],
|
|
["STRIDER"],
|
|
["TEAMCITY", "TEAMCITY_VERSION"],
|
|
["TRAVIS"],
|
|
["VERCEL", "NOW_BUILDER"],
|
|
["APPCENTER", "APPCENTER_BUILD_ID"],
|
|
["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }],
|
|
["STACKBLITZ"],
|
|
["STORMKIT"],
|
|
["CLEAVR"]
|
|
];
|
|
function detectProvider(env) {
|
|
for (const provider of providers) {
|
|
const envName = provider[1] || provider[0];
|
|
if (env[envName]) {
|
|
return {
|
|
name: provider[0].toLowerCase(),
|
|
...provider[2]
|
|
};
|
|
}
|
|
}
|
|
if (env.SHELL && env.SHELL === "/bin/jsh") {
|
|
return {
|
|
name: "stackblitz",
|
|
ci: false
|
|
};
|
|
}
|
|
return {
|
|
name: "",
|
|
ci: false
|
|
};
|
|
}
|
|
|
|
const processShim = typeof process !== "undefined" ? process : {};
|
|
const envShim = processShim.env || {};
|
|
const providerInfo = detectProvider(envShim);
|
|
const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
|
|
const platform = processShim.platform;
|
|
const provider = providerInfo.name;
|
|
const isCI = toBoolean(envShim.CI) || providerInfo.ci !== false;
|
|
const hasTTY = toBoolean(processShim.stdout && processShim.stdout.isTTY);
|
|
const hasWindow = typeof window !== "undefined";
|
|
const isDebug = toBoolean(envShim.DEBUG);
|
|
const isTest = nodeENV === "test" || toBoolean(envShim.TEST);
|
|
const isProduction = nodeENV === "production";
|
|
const isDevelopment = nodeENV === "dev" || nodeENV === "development";
|
|
const isMinimal = toBoolean(envShim.MINIMAL) || isCI || isTest || !hasTTY;
|
|
const isWindows = /^win/i.test(platform);
|
|
const isLinux = /^linux/i.test(platform);
|
|
const isMacOS = /^darwin/i.test(platform);
|
|
function toBoolean(val) {
|
|
return val ? val !== "false" : false;
|
|
}
|
|
|
|
export { hasTTY, hasWindow, isCI, isDebug, isDevelopment, isLinux, isMacOS, isMinimal, isProduction, isTest, isWindows, platform, provider };
|