-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathtypes.ts
53 lines (47 loc) · 1.69 KB
/
types.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
export interface MainCommandOptions {
published?: string
onlyChangesets?: string
}
// This type represents a couple of possible literal values for a string, but also
// allows any other string value. It's useful for environment variables that can
// have a default value, but can also be overridden by the user.
// The weird `string & {}` is to make sure that the type is not narrowed to `string`
// See: https://twitter.com/mattpocockuk/status/1671908303918473217
// eslint-disable-next-line @typescript-eslint/ban-types, sonar/no-useless-intersection
export type LooseString<T extends string> = T | (string & {})
export type Env = GitLabCIPredefinedVariables &
MergeRequestVariables & {
GITLAB_HOST: string
GITLAB_TOKEN: string
GITLAB_TOKEN_TYPE: LooseString<'job' | 'oauth'>
GITLAB_CI_USER_NAME?: string
GITLAB_CI_USER_EMAIL: string
GITLAB_COMMENT_TYPE: LooseString<'discussion' | 'note'>
GITLAB_ADD_CHANGESET_MESSAGE?: string
DEBUG_GITLAB_CREDENTIAL: LooseString<'1' | 'true'>
HOME: string
NPM_TOKEN?: string
}
type MergeRequestVariables =
| {
// this is used to be checked if the current job is a merge request job
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME: undefined
}
| {
CI_MERGE_REQUEST_IID: number
CI_MERGE_REQUEST_PROJECT_URL: string
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME: string
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA: string
CI_MERGE_REQUEST_TITLE: string
}
type GitLabCIPredefinedVariables = { GITLAB_USER_NAME: string } & (
| {
// this is used to be checked if the current job is in a CI environment
CI: undefined
}
| {
CI: 'true'
CI_PROJECT_PATH: string
CI_SERVER_URL: string
}
)