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

Adding listGithubRepoContents() to lib #84

Merged
merged 3 commits into from
Feb 6, 2024
Merged

Conversation

TanyaScales
Copy link
Member

Description and Context

In order to support an addition to the CLI for listing out available modules in a repo for this issue - I've created a generic function that is going accept a repo and content path, as well as an additional option for filtering by the type of the asset returned in the array (either a file or directory based on the GH response).

This is completely additive and shouldn't affect other functionality in the lib.

@TanyaScales
Copy link
Member Author

TanyaScales commented Jan 24, 2024

Build failing due to third-party dep chokidar -- there's an issue up there discussing it: paulmillr/chokidar#1299

Comment on lines +253 to +263
const error = e as GenericError;
if (error?.response?.data?.message) {
throwErrorWithMessage(
`${i18nKey}.downloadGithubRepoContents.errors.fetchFail`,
{
errorMessage: error.response.data.message,
}
);
} else {
throwError(error);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing the error with message here based on the github error response for fetching. Using GenericError as the type -- I'm not sure if it is preferred that I make a new type of Error - GithubErrorContext with the shape of the response to match. Above this function the downloadGithubRepoContents method is using BaseError as the type, but I would expect the response shape of the errors to be the same between these two. However, the error.error.message property path doesn't exist on the fetch fail response from GH.

export async function listGithubRepoContents(
repoPath: RepoPath,
contentPath: string,
fileFilter?: 'file' | 'dir'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly typing the options here that are relevant to the response from fetching GitHub repo contents

@TanyaScales TanyaScales merged commit c2ee27b into main Feb 6, 2024
1 check passed
@TanyaScales TanyaScales deleted the ts/159-JSR-list-modules branch February 6, 2024 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant