Build server prototype (integration with GitHub / NuGet / etc)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
micro-build-server/BuildServer/lib/github-wrapper.ts

52 lines
1.3 KiB

"use strict";
import * as RawGithub from "github";
import { Settings } from "./types";
interface IHttpError extends Error {
readonly message: string;
readonly code: number;
readonly status: any;
readonly headers: any;
}
type ICallback<T> = (error: IHttpError, result?: { data: T }) => void;
interface IIssueData {
readonly id: number;
readonly number: number;
readonly state: "open" | "closed";
readonly title: string;
readonly pull_request?: {
readonly url: string;
};
}
interface IReleaseData {
readonly id: number;
}
interface IStatusData {
readonly id: number;
}
interface IGithub {
readonly issues: {
createComment(params: RawGithub.IssuesCreateCommentParams, callback: ICallback<never>): void;
edit(params: RawGithub.IssuesEditParams, callback: ICallback<never>): void;
get(params: RawGithub.IssuesGetParams, callback: ICallback<IIssueData>): void;
};
readonly repos: {
createStatus(params: RawGithub.ReposCreateStatusParams, callback: ICallback<IStatusData>): void;
getReleases(params: RawGithub.ReposGetReleasesParams, callback: ICallback<IReleaseData[]>): void;
};
}
const createGithub = (settings: Settings, repoOwner: string) => settings.createGithub(repoOwner) as IGithub;
export {
IGithub,
createGithub,
};