-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
common.ts
236 lines (219 loc) · 6.12 KB
/
common.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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import got from 'got';
import Git from 'simple-git/promise';
import { RenovateConfig } from '../config/common';
import {
BranchStatus,
VulnerabilityAlert as _VulnerabilityAlert,
} from '../types';
export type VulnerabilityAlert = _VulnerabilityAlert;
/**
* File to commit to branch
*/
export interface File {
/**
* Relative file path
*/
name: string;
/**
* file contents
*/
contents: string | Buffer;
}
export type CommitFilesConfig = {
branchName: string;
files: File[];
message: string;
};
export interface GotApiOptions {
useCache?: boolean;
hostType?: string;
body?: any;
}
export type GotResponse<T extends object = any> = got.Response<T>;
export interface GotApi<TOptions extends object = any> {
get<T extends object = any>(
url: string,
options?: GotApiOptions & TOptions
): Promise<GotResponse<T>>;
post<T extends object = any>(
url: string,
options?: GotApiOptions & TOptions
): Promise<GotResponse<T>>;
put<T extends object = any>(
url: string,
options?: GotApiOptions & TOptions
): Promise<GotResponse<T>>;
patch<T extends object = any>(
url: string,
options?: GotApiOptions & TOptions
): Promise<GotResponse<T>>;
head<T extends object = any>(
url: string,
options?: GotApiOptions & TOptions
): Promise<GotResponse<T>>;
delete<T extends object = any>(
url: string,
options?: GotApiOptions & TOptions
): Promise<GotResponse<T>>;
reset(): void;
setBaseUrl(endpoint: string): void;
}
export interface PlatformConfig {
endpoint: string;
renovateUsername?: any;
gitAuthor?: any;
}
export interface RepoConfig {
baseBranch: string;
endpoint?: string;
renovateUsername?: any;
gitAuthor?: any;
isFork: boolean;
}
export interface RepoParams {
azureWorkItemId?: number; // shouldn't this be configurable within a renovate.json?
bbUseDefaultReviewers?: boolean; // shouldn't this be configurable within a renovate.json?
localDir: string;
optimizeForDisabled: boolean;
repository: string;
endpoint?: string;
forkMode?: string;
forkToken?: string;
includeForks?: boolean;
renovateUsername?: string;
}
/**
*
*/
export interface Pr {
body?: string;
branchName: string;
canMerge?: boolean;
canMergeReason?: string;
createdAt?: string;
displayNumber?: string;
isConflicted?: boolean;
isModified?: boolean;
isStale?: boolean;
labels?: string[];
number?: number;
reviewers?: string[];
sha?: string;
sourceRepo?: string;
state: string;
targetBranch?: string;
title: string;
}
/**
* TODO: Proper typing
*/
export interface Issue {
body?: string;
number?: number;
state?: string;
title?: string;
}
export type PlatformPrOptions = {
azureAutoComplete?: boolean;
statusCheckVerify?: boolean;
gitLabAutomerge?: boolean;
};
export interface CreatePRConfig {
branchName: string;
prTitle: string;
prBody: string;
labels?: string[] | null;
useDefaultBranch?: boolean;
platformOptions?: PlatformPrOptions;
}
export interface EnsureIssueConfig {
title: string;
body: string;
once?: boolean;
shouldReOpen?: boolean;
}
export interface BranchStatusConfig {
branchName: string;
context: string;
description: string;
state: BranchStatus;
url?: string;
}
export interface FindPRConfig {
branchName: string;
prTitle?: string | null;
state?: 'open' | 'closed' | '!open' | 'all';
refreshCache?: boolean;
}
export interface EnsureCommentConfig {
number: number;
topic: string;
content: string;
}
export interface EnsureCommentRemovalConfigByTopic {
number: number;
topic: string;
}
export interface EnsureCommentRemovalConfigByContent {
number: number;
content: string;
}
export interface EnsureCommentRemovalConfig {
number: number;
content?: string;
topic?: string;
}
export type EnsureIssueResult = 'updated' | 'created';
export interface Platform {
findIssue(title: string): Promise<Issue | null>;
getIssueList(): Promise<Issue[]>;
getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]>;
getCommitMessages(): Promise<string[]>;
setBranchPrefix(branchPrefix: string): Promise<void>;
initRepo(config: RepoParams): Promise<RepoConfig>;
cleanRepo(): Promise<void>;
getPrList(): Promise<Pr[]>;
getAllRenovateBranches(branchPrefix: string): Promise<string[]>;
ensureIssueClosing(title: string): Promise<void>;
getFileList(): Promise<string[]>;
ensureIssue(
issueConfig: EnsureIssueConfig
): Promise<EnsureIssueResult | null>;
getPrBody(prBody: string): string;
updatePr(number: number, prTitle: string, prBody?: string): Promise<void>;
mergePr(number: number, branchName: string): Promise<boolean>;
addReviewers(number: number, reviewers: string[]): Promise<void>;
addAssignees(number: number, assignees: string[]): Promise<void>;
createPr(prConfig: CreatePRConfig): Promise<Pr>;
getBranchLastCommitTime(branchName: string): Promise<Date>;
getRepos(): Promise<string[]>;
isBranchStale(branchName: string): Promise<boolean>;
getRepoForceRebase(): Promise<boolean>;
deleteLabel(number: number, label: string): Promise<void>;
setBranchStatus(branchStatusConfig: BranchStatusConfig): Promise<void>;
getBranchStatusCheck(
branchName: string,
context: string
): Promise<BranchStatus | null>;
ensureCommentRemoval(
ensureCommentRemoval:
| EnsureCommentRemovalConfigByTopic
| EnsureCommentRemovalConfigByContent
): Promise<void>;
deleteBranch(branchName: string, closePr?: boolean): Promise<void>;
ensureComment(ensureComment: EnsureCommentConfig): Promise<boolean>;
branchExists(branchName: string): Promise<boolean>;
setBaseBranch(baseBranch?: string): Promise<string>;
commitFiles(commitFile: CommitFilesConfig): Promise<string | null>;
getPr(number: number): Promise<Pr>;
findPr(findPRConfig: FindPRConfig): Promise<Pr>;
mergeBranch(branchName: string): Promise<void>;
getBranchStatus(
branchName: string,
requiredStatusChecks?: string[] | null
): Promise<BranchStatus>;
getBranchPr(branchName: string): Promise<Pr | null>;
getRepoStatus(): Promise<Git.StatusResult>;
getFile(lockFileName: string, branchName?: string): Promise<string>;
initPlatform(config: RenovateConfig): Promise<PlatformConfig>;
}