-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathproviders.ts
More file actions
186 lines (174 loc) · 4.35 KB
/
providers.ts
File metadata and controls
186 lines (174 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// Reference: https://github.com/watson/ci-info/blob/v3.2.0/vendors.json
import { env, process } from "./env.ts";
/**
* Represents the name of a CI/CD or Deployment provider.
*/
export type ProviderName =
| (string & {})
| "appveyor"
| "aws_amplify"
| "azure_pipelines"
| "azure_static"
| "appcircle"
| "bamboo"
| "bitbucket"
| "bitrise"
| "buddy"
| "buildkite"
| "circle"
| "cirrus"
| "cloudflare_pages"
| "cloudflare_workers"
| "google_cloudrun"
| "google_cloudrun_job"
| "codebuild"
| "codefresh"
| "drone"
| "drone"
| "dsari"
| "github_actions"
| "gitlab"
| "gocd"
| "layerci"
| "hudson"
| "jenkins"
| "magnum"
| "netlify"
| "nevercode"
| "render"
| "sail"
| "semaphore"
| "screwdriver"
| "shippable"
| "solano"
| "strider"
| "teamcity"
| "travis"
| "vercel"
| "appcenter"
| "codesandbox"
| "stackblitz"
| "stormkit"
| "cleavr"
| "zeabur"
| "codesphere"
| "railway"
| "deno-deploy"
| "firebase_app_hosting";
type InternalProvider = [
providerName: Uppercase<ProviderName>,
envName?: string,
meta?: Record<string, any>,
];
const providers: InternalProvider[] = [
["APPVEYOR"],
["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }],
["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 }],
["CLOUDFLARE_WORKERS", "WORKERS_CI", { ci: true }],
["GOOGLE_CLOUDRUN", "K_SERVICE"],
["GOOGLE_CLOUDRUN_JOB", "CLOUD_RUN_JOB"],
["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"],
// Jenkins must be validated before Hudson
["JENKINS", "JENKINS_URL"],
["HUDSON", "HUDSON_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"],
["VERCEL", "VERCEL", { ci: false }],
["VERCEL", "VERCEL_ENV", { ci: false }],
["APPCENTER", "APPCENTER_BUILD_ID"],
["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }],
["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }],
["STACKBLITZ"],
["STORMKIT"],
["CLEAVR"],
["ZEABUR"],
["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }],
["RAILWAY", "RAILWAY_PROJECT_ID"],
["RAILWAY", "RAILWAY_SERVICE_ID"],
["DENO-DEPLOY", "DENO_DEPLOY"],
["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }],
];
/**
* Provides information about a CI/CD or Deployment provider, including its name and possibly other metadata.
*/
export type ProviderInfo = {
/**
* The name of the CI/CD or Deployment provider. See {@link ProviderName} for possible values.
*/
name: ProviderName;
/**
* If is set to `true`, the environment is recognised as a CI/CD provider.
*/
ci?: boolean;
/**
* Arbitrary metadata associated with the provider.
*/
[meta: string]: any;
};
/**
* Detects the current CI/CD or Deployment provider from environment variables.
*/
export function detectProvider(): ProviderInfo {
// Based on env
for (const provider of providers) {
const envName = provider[1] || provider[0];
if (env[envName]) {
return {
name: provider[0].toLowerCase(),
...(provider[2] as any),
};
}
}
// Stackblitz / Webcontainer
if (env.SHELL === "/bin/jsh" && process.versions?.webcontainer) {
return {
name: "stackblitz",
ci: false,
};
}
return {
name: "",
ci: false,
};
}
/**
* The detected provider information for the current execution context.
* This value is evaluated once at module initialisation.
*/
export const providerInfo: ProviderInfo = /* #__PURE__ */ detectProvider();
/**
* Name of the detected provider, defaults to an empty string if no provider is detected.
*/
export const provider: ProviderName = providerInfo.name;