UNPKG

2.65 kBTypeScriptView Raw
1import { HandlerContext } from "../../HandlerContext";
2import { Project } from "../../project/Project";
3import { EditResult, ProjectEditor } from "./projectEditor";
4/**
5 * Used to determine EditMode on a per project basis,
6 * for example if we want to use a different branch name on different repos
7 */
8export declare type EditModeFactory = (p: Project) => EditMode;
9export declare function toEditModeFactory(em: EditMode | EditModeFactory): EditModeFactory;
10/**
11 * Root interface for information on how to apply an edit:
12 * E.g via a PR or commit to a branch (including master)
13 */
14export interface EditMode {
15 message: string;
16 /**
17 * Optional method to perform any additional actions on the project after
18 * applying the edit to persistent store--for example, setting a GitHub status
19 * @param {Project} p
20 * @param ctx HandlerContext for the current edit operation
21 * @return {Promise<any>}
22 */
23 afterPersist?(p: Project, ctx: HandlerContext): Promise<any>;
24}
25export declare function isEditMode(em: any): em is EditMode;
26/**
27 * Merge method to use when auto merging the branches
28 */
29export declare enum AutoMergeMethod {
30 Merge = "[auto-merge-method:merge]",
31 Rebase = "[auto-merge-method:rebase]",
32 Squash = "[auto-merge-method:squash]"
33}
34/**
35 * Trigger for branch auto merge
36 */
37export declare enum AutoMergeMode {
38 ApprovedReview = "[auto-merge:on-approve]",
39 SuccessfulCheck = "[auto-merge:on-check-success]"
40}
41/**
42 * Represents a commit to a project on a branch
43 */
44export interface BranchCommit extends EditMode {
45 branch: string;
46 autoMerge?: {
47 mode: AutoMergeMode | string;
48 method?: AutoMergeMethod;
49 };
50}
51/**
52 * Return a commit to master branch with the given message. Use with care!
53 */
54export declare function commitToMaster(message: string): BranchCommit;
55export declare function isBranchCommit(em: EditMode): em is BranchCommit;
56/**
57 * Captures extra steps that must go into raising a PR
58 */
59export declare class PullRequest implements BranchCommit {
60 branch: string;
61 title: string;
62 body: string;
63 message: string;
64 constructor(branch: string, title: string, body?: string, message?: string);
65}
66export declare function isPullRequest(em: EditMode): em is PullRequest;
67/**
68 * Use for edit modes that require custom persistence
69 */
70export interface CustomExecutionEditMode extends EditMode {
71 edit<P>(p: Project, action: ProjectEditor<P>, context: HandlerContext, parameters: P): Promise<EditResult>;
72}
73export declare function isCustomExecutionEditMode(ei: EditMode): ei is CustomExecutionEditMode;
74//# sourceMappingURL=editModes.d.ts.map
\No newline at end of file