generated from NatoBoram/gigachad.ts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathenv.ts
55 lines (45 loc) · 1.82 KB
/
env.ts
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
import { envBool, envString, envUrl, loadEnv } from "@natoboram/load_env"
/**
* @see https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production
* @see https://vitest.dev/guide/migration.html#envs
*/
type NodeEnv = (typeof NodeEnv)[keyof typeof NodeEnv]
function isNodeEnv(value: unknown): value is NodeEnv {
return Object.values<unknown>(NodeEnv).includes(value)
}
function toNodeEnv(value: unknown): NodeEnv {
if (isNodeEnv(value)) return value
return NodeEnv.development
}
const NodeEnv = {
development: "development",
production: "production",
/**
* Vitest sets `NODE_ENV` to `test` if it wasn't set before.
* @see https://vitest.dev/guide/migration.html#envs
*/
test: "test",
} as const
const parsed = loadEnv()
export const NODE_ENV = toNodeEnv(parsed.NODE_ENV)
export const BITBUCKET_CLOUD_URL = envUrl("BITBUCKET_CLOUD_URL")
export const BITBUCKET_CLOUD_USERNAME = envString("BITBUCKET_CLOUD_USERNAME")
export const BITBUCKET_CLOUD_APP_PASSWORD = envString(
"BITBUCKET_CLOUD_APP_PASSWORD",
)
export const BITBUCKET_SERVER_URL = envUrl("BITBUCKET_SERVER_URL")
export const BITBUCKET_SERVER_TOKEN = envString("BITBUCKET_SERVER_TOKEN")
export const BITBUCKET_SERVER_TEST_PROJECT_KEY = envString(
"BITBUCKET_SERVER_TEST_PROJECT_KEY",
)
export const BITBUCKET_SERVER_TEST_PROJECT_NAME = envString(
"BITBUCKET_SERVER_TEST_PROJECT_NAME",
)
export const SKIP_BITBUCKET_CLOUD = envBool("SKIP_BITBUCKET_CLOUD")
/** Considering that single instance for a single user costs 2300 USD annually,
* most people aren't going to have a Bitbucket Data Center instance to test on.
* Therefore, end-to-end tests for Bitbucket Data Center are skipped by default.
*
* @see https://www.atlassian.com/software/bitbucket/enterprise
*/
export const SKIP_BITBUCKET_SERVER = envBool("SKIP_BITBUCKET_SERVER")