-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@ijsblokje/utils", | ||
"version": "0.0.0", | ||
"author": "ijsKoud <[email protected]>", | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
"./types.js": "./dist/types.js", | ||
"./constants.js": "./dist/constants.js", | ||
"./RequestWithPagination.js": "./dist/RequestWithPagination.js" | ||
}, | ||
"scripts": { | ||
"build": "tsc --build", | ||
"build:watch": "tsc --watch > /dev/null", | ||
"lint": "TIMING=1 eslint" | ||
}, | ||
"dependencies": { | ||
"lru-cache": "^10.0.0", | ||
"probot": "12.3.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.16.18", | ||
"eslint": "^8.43.0", | ||
"prettier": "^2.8.8", | ||
"typescript": "5.1.3" | ||
}, | ||
"engines": { | ||
"node": ">= v18.16.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Handle the pagination of an Octokit request | ||
* @param request The function to call everytime we need to fetch more data | ||
* @param check The function to check if we reached the desired amount or not | ||
* @returns | ||
*/ | ||
async function requestWithPagination<R>(request: RequestWithPaginationRequest<R>, check: RequestWithPaginationCheck<R>): Promise<R[]> { | ||
const data: R[] = []; | ||
let page = 1; | ||
|
||
let response = await request(page); | ||
data.push(response); | ||
|
||
while (check(response)) { | ||
response = await request(page); | ||
data.push(response); | ||
page++; | ||
} | ||
|
||
return data; | ||
} | ||
|
||
export type RequestWithPaginationRequest<R> = (page: number) => Promise<R>; | ||
export type RequestWithPaginationCheck<R> = (response: R) => boolean; | ||
|
||
export default requestWithPagination; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const README_TEMPLATE_LOCATION = "config/readme.md"; | ||
export const LABEL_CONFIG_LOCATION = "config/labels.json"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export interface GitHubRepoContext { | ||
/** The owner of the repository */ | ||
owner: string; | ||
|
||
/** The repository name */ | ||
repo: string; | ||
} | ||
|
||
export interface Label { | ||
/** The name of the label */ | ||
name: string; | ||
|
||
/** The label description */ | ||
description: string; | ||
|
||
/** The label color in hex format */ | ||
color: string; | ||
} | ||
|
||
export interface OctokitAuthOptions { | ||
/** The id of the GitHub application */ | ||
appId: number; | ||
|
||
/** The GitHub private key for signing data */ | ||
privateKey: string; | ||
|
||
/** The GitHub client id */ | ||
clientId: string; | ||
|
||
/** The GitHub client secret */ | ||
clientSecret: string; | ||
|
||
/** The installation id */ | ||
installationId?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["./src/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src/**/*.ts"], | ||
"compilerOptions": { "outDir": "./dist" } | ||
} |