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 Swift Plugin support #544

Closed
csjones opened this issue Sep 2, 2023 · 5 comments · Fixed by #556
Closed

Add Swift Plugin support #544

csjones opened this issue Sep 2, 2023 · 5 comments · Fixed by #556
Labels
feature request A new lefthook feature description

Comments

@csjones
Copy link
Contributor

csjones commented Sep 2, 2023

⚡ Summary

Thank you for making such an exceptional tool. While I primarily develop in Swift, I've recently created a wrapper plugin for Lefthook that can be included in Swift packages.

https://github.com/csjones/lefthook

Value

Direct Swift Package Manager support instead of relying on installation methods like go get, brew, npm, or gem.

Behavior and configuration changes

At minimum, the primary change would be in the hooks.tmpl file:

  elif swift package plugin lefthook >/dev/null 2>&1
  then
    swift package --disable-sandbox plugin lefthook $@
  else

Additional changes are dependent on whether it makes sense for a Swift plugin to live along side npm and rubygems implementations in this repository. This would include a Package.swift manifest file in the root of the repository and CI additions to create a lefthook.artifactbundle.zip file.

Alternatively, I could create a wrapper plugin package that downloads the Lefthook release binaries and implements all the swift details in a separate repository.

@csjones csjones added the feature request A new lefthook feature description label Sep 2, 2023
@csjones
Copy link
Contributor Author

csjones commented Sep 18, 2023

I've investigated and implemented the wrapper plugin approach here: https://github.com/csjones/lefthook-plugin

So far, the lefthook swift plugin is working well on macOS and Linux.

@mrexox
Copy link
Member

mrexox commented Sep 19, 2023

Hey @csjones, this is amazing! Do you want to keep your plugin in your repo or integrate it into lefthook repo?

@csjones
Copy link
Contributor Author

csjones commented Sep 21, 2023

Hey @mrexox, now having tried both approaches, I'm leaning more towards the plugin in the repo I created than the lefthook repo. Should I open a PR for the changes to hooks.tmpl?

@mrexox
Copy link
Member

mrexox commented Sep 21, 2023

@csjones , yes, that will be great. It would be also good to add a note into docs/installation.md and reference your repo there

@csjones
Copy link
Contributor Author

csjones commented Sep 24, 2023

@mrexox done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants