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

feat: Support self-hosted/custom git providers #138

Merged
merged 12 commits into from
May 29, 2024
Merged

feat: Support self-hosted/custom git providers #138

merged 12 commits into from
May 29, 2024

Conversation

noxify
Copy link
Contributor

@noxify noxify commented May 27, 2024

Previously only github.com, gitlab.com and bitbucket.org were supported as git provider.
This merge request adds the functionality to set the git provider manually.

fixes #137

Copy link

changeset-bot bot commented May 27, 2024

🦋 Changeset detected

Latest commit: 598d3af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mdxts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 27, 2024

@noxify is attempting to deploy a commit to the souporserious Team on Vercel.

A member of the Team first needs to authorize it.

@noxify noxify marked this pull request as draft May 27, 2024 10:37
@noxify
Copy link
Contributor Author

noxify commented May 27, 2024

Updated the getGitFileUrl function and added also some unit tests.
I hope it's ok that I have updated the logic inside the function and using path.join() isn't a problem to build the url path.

Reason why I did this change: While creating the unit tests I got some errors with the expected vs. received url.
This was based on the filePath.
Now it doesn't matter if you have a leading slash or not.

Also updated the input for the switch case block.

Let me know that you think about these changes @souporserious.

@noxify
Copy link
Contributor Author

noxify commented May 27, 2024

Based on the amount of arguments for getGitFileUrl, maybe it makes sense to use an object input.
This would introduce a breaking change, but makes it easier to configure.

Example

// old
getGitFileUrl({
        '/directory-name/file-name',
        undefined,
        undefined,
        'https://self-hosted.git.company.tld/owner-name/repo-name',
        undefined,
        'bitbucket'
})

// new
getGitFileUrl({
  filePath: '/directory-name/file-name',
  gitSource: 'https://self-hosted.git.company.tld/owner-name/repo-name',
  gitProvider: 'bitbucket'
})

@noxify
Copy link
Contributor Author

noxify commented May 27, 2024

Updated the relevant parts and added also a new example.

But while running

pnpm build --filter=@examples/custom-git-provider

I get the same error - Added temporary some debug prints and it seems that the gitProvider value isn't passed down to the getGitFileUrl.

I assumed that process.env.MDXTS_GIT_PROVIDER will be used as fallback in the getSourcePath function, but it's currently undefined.

Any idea how to solve this ?

@noxify
Copy link
Contributor Author

noxify commented May 27, 2024

Ok, got it - added the gitProvider prop where it was required ( = where getSourcePath was called ) - Now the build is working

@noxify
Copy link
Contributor Author

noxify commented May 27, 2024

Ok - for me it looks good, if I have missed something, please let me know.

@noxify noxify marked this pull request as ready for review May 27, 2024 12:39
Copy link
Owner

@souporserious souporserious left a comment

Choose a reason for hiding this comment

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

This looks great 🎉 thank you for adding tests!

packages/mdxts/src/utils/get-git-file-url.ts Show resolved Hide resolved
@souporserious souporserious merged commit 5e3a2b8 into souporserious:main May 29, 2024
0 of 2 checks passed
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.

Build error with custom/private/self-hosted git server
2 participants