feat(01-03): add summer dev watch rebuild loop
- Watch app sources with fsnotify, debounce, and one serialized build.App - Restart the child only after a successful build and print rebuild latency - Ignore generated app files and reap the child on cancellation
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"git.golem15.com/golem15/summercms/bonfire"
|
||||
"git.golem15.com/golem15/summercms/internal/build"
|
||||
"git.golem15.com/golem15/summercms/internal/dev"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -27,6 +28,7 @@ func toolCommands() []bonfire.Command {
|
||||
buildCommand(),
|
||||
makePluginCommand(),
|
||||
addPluginCommand(),
|
||||
devCommand(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +74,20 @@ func makePluginCommand() bonfire.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func devCommand() bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "dev",
|
||||
Description: "Watch sources and rebuild the app binary",
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return dev.Watch(ctx, dir, out)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func addPluginCommand() bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "plugin:add",
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestToolCommandNames(t *testing.T) {
|
||||
for _, c := range toolCommands() {
|
||||
names = append(names, c.Name)
|
||||
}
|
||||
for _, want := range []string{"build", "make:plugin", "plugin:add"} {
|
||||
for _, want := range []string{"build", "make:plugin", "plugin:add", "dev"} {
|
||||
if !slices.Contains(names, want) {
|
||||
t.Fatalf("missing %s in %v", want, names)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user