Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more JS Docs #34

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions utils/githubApi/fetchAllRepos.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import {
getOpenPRsForRepo,
} from "../renovate/dependencyDashboard.js";

/**
* Fetches all repos from the GitHub API.
* Each repo is enriched with data fetched through further API calls
* @returns {Promise<StoredRepo[]>}
*/
const fetchAllRepos = async () => {
const repos = [];

Expand All @@ -33,10 +38,17 @@ const fetchAllRepos = async () => {
return repos;
};

/**
* Fetches installation data for the app from the GitHub API
* @returns {Object}
*/
const installationOctokit = await OctokitApp.app.octokit.request(
"GET /app/installations"
);

/**
* Saves all repos to a JSON file
*/
const saveAllRepos = async () => {
console.info("Fetching all repos...");
const repos = await fetchAllRepos();
Expand Down
13 changes: 12 additions & 1 deletion utils/githubApi/fetchOpenPrs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
export const getOpenPRsForRepo = ({ octokit, repository }) => {
/**
* Requests the open PRs for a given repository
* @param {any} {octokit
* @param {any} repository}
* @returns {Promise<number>}
*/
export const getOpenPRsForRepo = async ({ octokit, repository }) => {
return octokit.request(repository.pulls_url).then(handlePrsApiResponse);
};

/**
* Returns the length of the PRs array or 0 if there are no PRs
* @param {any} {data}
* @returns {number}
*/
export const handlePrsApiResponse = ({ data }) => data?.length || 0;
Loading