import got from 'got'; import Git from 'simple-git/promise'; import { RenovateConfig } from '../config/common'; import { CommitFilesConfig } from './git/storage'; export interface FileData { name: string; contents: string | Buffer; } export interface GotApiOptions { useCache?: boolean; hostType?: string; body?: any; } export type GotResponse = got.Response; export interface GotApi { get( url: string, options?: GotApiOptions & TOptions ): Promise>; post( url: string, options?: GotApiOptions & TOptions ): Promise>; put( url: string, options?: GotApiOptions & TOptions ): Promise>; patch( url: string, options?: GotApiOptions & TOptions ): Promise>; head( url: string, options?: GotApiOptions & TOptions ): Promise>; delete( url: string, options?: GotApiOptions & TOptions ): Promise>; 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? gitPrivateKey?: string; localDir: string; optimizeForDisabled: boolean; repository: string; endpoint?: string; forkMode?: string; forkToken?: string; includeForks?: boolean; renovateUsername?: string; } /** * TODO: Proper typing */ export type Pr = { branchName: string; title: string; state: string; isConflicted?: boolean; isModified?: boolean; } & Record; /** * TODO: Proper typing */ export interface Issue { body?: string; number?: number; state?: string; title?: string; } export type BranchStatus = | 'pending' | 'success' | 'failed' | 'running' | 'failure'; 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: string | null; 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; } /** * TODO: Proper typing */ export type VulnerabilityAlert = any; export interface Platform { findIssue(title: string): Promise; getIssueList(): Promise; getVulnerabilityAlerts(): Promise; getCommitMessages(): Promise; setBranchPrefix(branchPrefix: string): Promise; initRepo(config: RepoParams): Promise; cleanRepo(): Promise; getPrFiles(prNo: number): Promise; getPrList(): Promise; getAllRenovateBranches(branchPrefix: string): Promise; ensureIssueClosing(title: string): Promise; getFileList(): Promise; ensureIssue( issueConfig: EnsureIssueConfig ): Promise<'updated' | 'created' | null>; getPrBody(prBody: string): string; updatePr(number: number, prTitle: string, prBody?: string): Promise; mergePr(number: number, branchName: string): Promise; addReviewers(number: number, reviewers: string[]): Promise; addAssignees(number: number, assignees: string[]): Promise; createPr(prConfig: CreatePRConfig): Promise; getBranchLastCommitTime(branchName: string): Promise; getRepos(): Promise; isBranchStale(branchName: string): Promise; getRepoForceRebase(): Promise; deleteLabel(number: number, label: string): Promise; setBranchStatus(branchStatusConfig: BranchStatusConfig): Promise; getBranchStatusCheck(branchName: string, context: string): Promise; ensureCommentRemoval(number: number, subject: string): Promise; deleteBranch(branchName: string, closePr?: boolean): Promise; ensureComment(ensureComment: EnsureCommentConfig): Promise; branchExists(branchName: string): Promise; setBaseBranch(baseBranch?: string): Promise; commitFilesToBranch(commitFile: CommitFilesConfig): Promise; getPr(number: number): Promise; findPr(findPRConfig: FindPRConfig): Promise; mergeBranch(branchName: string): Promise; getBranchStatus( branchName: string, requiredStatusChecks?: string[] | null ): Promise; getBranchPr(branchName: string): Promise; getRepoStatus(): Promise; getFile(lockFileName: string, branchName?: string): Promise; initPlatform(config: RenovateConfig): Promise; }