This PR adds support for custom generators. Custom generators allow you to define application-specific code generators that hook into the rest of the code generators. There was a first attempt at doing this in https://github.com/livebud/bud/pull/236, but it was subsequently removed in https://github.com/livebud/bud/pull/276 because the implementation had some tradeoffs so I looked for a better solution.
You can add a custom generator to you application by creating packages inside the generator/ directory. For example, you can define the following package in generator/tailwind/tailwind.go
Bud will then be able to find and run the function for preflight.css at bud/internal/generator/tailwind/preflight.css. Custom generators use the same budfs package that core generators like controller and view use.
While this PR introduces the ability to define your own custom generators, they're not exposed anywhere yet. The next step is to update other generators like public and web to look for custom generators and pull them into the build when they're in a certain directory. This will come in a follow-up PR.
Remaining todos for this PR:
[x] Fix removing a file generator breaking the build (budfs should be able to remove paths too)
This PR adds support for custom generators. Custom generators allow you to define application-specific code generators that hook into the rest of the code generators. There was a first attempt at doing this in https://github.com/livebud/bud/pull/236, but it was subsequently removed in https://github.com/livebud/bud/pull/276 because the implementation had some tradeoffs so I looked for a better solution.
You can add a custom generator to you application by creating packages inside the
generator/
directory. For example, you can define the following package ingenerator/tailwind/tailwind.go
Bud will then be able to find and run the function for
preflight.css
atbud/internal/generator/tailwind/preflight.css
. Custom generators use the samebudfs
package that core generators likecontroller
andview
use.While this PR introduces the ability to define your own custom generators, they're not exposed anywhere yet. The next step is to update other generators like
public
andweb
to look for custom generators and pull them into the build when they're in a certain directory. This will come in a follow-up PR.Remaining todos for this PR: