Add support for renamed icons & Lucide-prefixed, add auto-updater #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5.
Context
The plugin replaces imports via a mechanism of regular expressions and string manipulation. It does not do any syntax analysis. As such, it cannot detect incorrect imports.
Extensive testing is done to ensure that the replacements work by constantly testing against the latest versions of
lucide-sveltein the CI, independently from the other dependencies upgrades workflow.However, aliases were not tested. I initially thought it wasn’t possible to do it in a way as extensive as for the regular imports, but I was wrong.
*Icon-suffixed icons were correctly handled, though.Solution
Immediate fix
The immediate solution is to first add tests against aliases imports to make sure they’re working properly. But how to actually make the tests pass?
Well, the only idea that came to my mind is to hardcode a map of alias names and their corresponding icon paths in the source code itself. It's dirty, but it does fix the issue. The main question remains how to maintain this mapping over time?
Long-term solution
As I was thinking through possible solutions, I realized I could make the maintenance process 100% automated. I know when a new breaking release happens (Renovate PR's CI), and I know what to do (get the new map of bindings, update it, and release a new version). What's left is just to fill in the gap.
The idea is the following:
srcdirectory (so that it's not affecting the real source code, it isn't anyway) that reads this test report file and spits out an updated map of renamed packagespackage.jsonand the updated version oflucide-svelte, after running Prettier, of course. This commit will indirectly close the Renovate PR as Lucide will now be up-to-date.This CI game should do the trick just fine and publish fixes entirely automatically and very quickly, thanks to Renovate scanning for updates frequently.
TODO
Lucide*-prefixed icons were a thing, they're now supported and coveredmain.ymlCI to update the mapping and push it on the master branch on test failure