-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
📦 Adds support for Swift Package plugin command #1093
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this 🙇
@pol-piella I agree with 3rd option sounding the most reasonable |
Amazing! I will get that done and let you know when it’s ready to be reviewed again. So excited to get this into Sourcery ❤️ |
@krzysztofzablocki Updated with the changes suggested to provide a default cache path 👍 Let me know if you're happy with the changes and we can get it merged 🚀 |
lgtm, you can go ahead and merge 👏 |
Following a conversation with @krzysztofzablocki and the creation of issue #1090, this PR starts the work to add support for Swift Package Plugins for
Sourcery
At the moment, this PR only includes support for Swift Package command plugins but not for build plugins yet, I'll be investigating those next as there are a set of challenges which must be overcome.
This PR also updates to using
swift-tools
version 5.6 to be able to make use of SPM plugins.Discussion
I have left the
--disableCache
flag in this PR as I wanted to hear your opinion on how we can tackle the issue. From what I can see, sincecacheBasePath
is only an argument on config and not a cli argument, we have a few options:--disableCache
parameter and not do anything else. The client will have to provide acacheBasePath
in the configuration file that is within the package directory. It might be a bit misleading and the plugin won't work out of the box..sourcery.yml
to always provide acacheBasePath
that is in thepluginWorkDirectory
. This could be done only when the key isn't present on the.sourcery.yml
file?cacheBasePath
a command line argument which can be used only when the config key isn't present. This allows the package to provide a 'default value' that works while allowing the user to modify it?I think my preferred option is the last one, but keen to hear your thoughts as you might have a different opinion on it 👍
How to test the plugin
I have create a small repo called sourcery-plugins-playground which will help with the testing. There are two folders:
swift-package-playground
Command Line
cd
intoswift-package-playground
.swift package plugin --list
and verify thatsourcery-command
is part of the list.swift package --allow-writing-to-package-directory sourcery-command
.AutoMockable.generated.swift
is generated in the right directory.Xcode 14
cd
intoswift-package-playground
.Package.swift
swift-package-playground
packagesorcery-command
from the list.xcodeproj-playground
Xcode 14
cd
intoxcodeproj-playground
.SourceryPluginSampleProj.xcodeproj