diff --git a/dist/octokit.d.ts b/dist/octokit.d.ts index d0bc258..83e2f6e 100644 --- a/dist/octokit.d.ts +++ b/dist/octokit.d.ts @@ -1,5 +1,5 @@ import { Octokit } from '@octokit/core'; declare const CustomOctokit: typeof Octokit & import("@octokit/core/dist-types/types").Constructor; export type CustomOctokit = InstanceType; -export declare function getOctokit(token: string): Octokit & import("@probot/octokit-plugin-config/dist-types/types").API; +export declare function getOctokit(token: string): CustomOctokit; export {}; diff --git a/dist/pull-request.js.map b/dist/pull-request.js.map index 7324f7c..ff393d6 100644 --- a/dist/pull-request.js.map +++ b/dist/pull-request.js.map @@ -1 +1 @@ -{"version":3,"file":"pull-request.js","sourceRoot":"","sources":["../src/pull-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,MAAM,OAAO,WAAW;IAGtB,YACW,EAAU,EACV,OAAsB,EAC/B,QAAkB;QAFT,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAe;QAG/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,SAAS;QACP,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;IAC1D,CAAC;IAED,oBAAoB,CAAC,SAAmB,EAAE,GAAY;QACpD,KAAK,CAAC,gCAAgC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC7C,IAAI,WAAW,KAAK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,CAAC,QAAQ,CAAC,SAAS;YAAE,OAAO;QAErC,KAAK,CAAC,6BAA6B,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QAE9D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CACzC,0DAA0D,kCAErD,OAAO,CAAC,IAAI,KACf,UAAU,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EACpC,IAAI,IAEP,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CACzB,EAAU,EACV,OAAsB;QAEtB,OAAO,IAAI,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;CACF"} \ No newline at end of file diff --git a/src/action.ts b/src/action.ts index 939a449..f812d1c 100644 --- a/src/action.ts +++ b/src/action.ts @@ -5,7 +5,7 @@ import { CustomOctokit } from './octokit'; import { PullRequest } from './pull-request'; import { Tag } from './tag'; -async function action(octokit: CustomOctokit) /*: Promise*/ { +async function action(octokit: CustomOctokit): Promise { const config = await Config.getConfig(octokit); const tag = new Tag(await Tag.getLatestTag()); diff --git a/src/config.ts b/src/config.ts index b63d9b4..37940c6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,7 +35,7 @@ export class Config { return new this(retrievedConfig); } - static isConfigEmpty(config: unknown) { + static isConfigEmpty(config: unknown): boolean { return config === null || config === undefined; } } diff --git a/src/metadata.ts b/src/metadata.ts index 2cf1975..1765e86 100644 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -42,7 +42,7 @@ export class Metadata { static readonly metadataFreezingTag = 'freezing-tag'; static readonly metadataCommentID = 'comment-id'; - async setMetadata() { + async setMetadata(): Promise { if (this.commentID !== undefined) { await this.controller.setMetadata( this.issueNumber, @@ -59,7 +59,7 @@ export class Metadata { ); } - static async getMetadata(issueNumber: number) { + static async getMetadata(issueNumber: number): Promise { const controller = new MetadataController('devel-freezer', { ...context.repo, headers: { diff --git a/src/octokit.ts b/src/octokit.ts index 1d2396f..3984f36 100644 --- a/src/octokit.ts +++ b/src/octokit.ts @@ -5,7 +5,7 @@ const CustomOctokit = Octokit.plugin(config); export type CustomOctokit = InstanceType; -export function getOctokit(token: string) { +export function getOctokit(token: string): CustomOctokit { return new CustomOctokit({ auth: token, }); diff --git a/src/pull-request.ts b/src/pull-request.ts index 5fa7705..d4036f9 100644 --- a/src/pull-request.ts +++ b/src/pull-request.ts @@ -19,11 +19,11 @@ export class PullRequest { return this._metadata; } - isFreezed() { + isFreezed(): boolean { return !!this.metadata.commentID && !!this.metadata.tag; } - isTagPolicyCompliant(tagPolicy: string[], tag?: string) { + isTagPolicyCompliant(tagPolicy: string[], tag?: string): boolean { debug(`Checking tag policy for PR: #${this.id}`); const freezingTag = tag ?? this.metadata.tag; if (freezingTag === undefined) false; @@ -33,7 +33,7 @@ export class PullRequest { ); } - async freeze(content: string, freezingTag: string) { + async freeze(content: string, freezingTag: string): Promise { debug(`Freezing PR: #${this.id}`); const id = await this.publishComment(content); @@ -42,7 +42,7 @@ export class PullRequest { await this.metadata.setMetadata(); } - async unfreeze(content: string) { + async unfreeze(content: string): Promise { debug(`Unfreezing PR: #${this.id}`); const id = await this.publishComment(content); @@ -50,7 +50,7 @@ export class PullRequest { await this.metadata.setMetadata(); } - async publishComment(content: string) { + async publishComment(content: string): Promise { if (this.metadata.commentID) { this.updateComment(content); return; @@ -100,7 +100,10 @@ export class PullRequest { return data; } - static async getPullRequest(id: number, octokit: CustomOctokit) { + static async getPullRequest( + id: number, + octokit: CustomOctokit + ): Promise { return new PullRequest(id, octokit, await Metadata.getMetadata(id)); } } diff --git a/src/tag.ts b/src/tag.ts index 1604b9d..44e16bc 100644 --- a/src/tag.ts +++ b/src/tag.ts @@ -16,7 +16,7 @@ export class Tag { return this._latest; } - isFreezed(tagPolicy: string[]) { + isFreezed(tagPolicy: string[]): boolean { if (this.latest === undefined) false; return tagPolicy.some(regex => @@ -24,7 +24,7 @@ export class Tag { ); } - static async getLatestTag() { + static async getLatestTag(): Promise { // Get latest tag sorted by date, currently impossible by using GitHub REST API const { stdout, stderr } = await promiseExec( // Get rid of new lines - it causes issues when regex is to explicit (including `$`)