-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Experimental compiler refactor #133
Conversation
fa3b405
to
0fe9387
Compare
Woohoo, it's aliveeeeee. Just need to do a bit more cleanup and it's good to go! |
2162ec9
to
5fb08b1
Compare
…d overlay being needed in app
…n bud and the app
…r. fix imhash tests after refactor.
2a11558
to
84c6a24
Compare
# main branch. See: https://github.com/golang/go/issues/53226 | ||
- name: Install bud binary into $PATH | ||
run: GOPRIVATE=* go install github.com/livebud/bud@main | ||
|
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.
No longer necessary! There's no more spawning of a v8server when using bud run
. Instead we've combined this with an internal local "bud server", that handles server-side rendering, hot reloads, and bundling client-side files.
This bud server is only run with bud run
, when you bud build
v8 is bundled, there's no hot reloads and all client-side files are pre-build and embedded.
@@ -50,7 +50,7 @@ example.hn.watch: | |||
# Go | |||
## | |||
|
|||
GO_SOURCE := ./internal/... ./package/... ./runtime/... | |||
GO_SOURCE := ./internal/... ./package/... ./framework/... |
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.
I wanted to combine internal/generator
and runtime/generator
into one package so that would put all the generators in one place. Framework felt like a better word for this because not all the packages in framework/
used at runtime, though I'm still tempted to change it to generator/
@@ -0,0 +1,45 @@ | |||
package app | |||
|
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.
app is the new entrypoint into the program. In the previous bud, there was a generated main
and program
. This was over-engineering at this point in bud's journey, so I opted to simplify things for the time being.
return err | ||
} | ||
// Inform bud that we're ready | ||
budClient.Publish("app:ready", nil) |
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.
The bud client talks to the server during bud run
and informs the server that the app is ready. This allows tests to be less flaky and fail faster.
@@ -5,8 +5,8 @@ import ( | |||
"net/http/httptest" | |||
"testing" | |||
|
|||
. "github.com/livebud/bud/framework/controller/controllerrt/request" |
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.
Not totally happy with controllerrt
, but it's short for "controller runtime"
} | ||
|
||
// Module finds the go.mod file for the application | ||
func Module(dir string) (*gomod.Module, error) { |
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.
internal/cli/bud contains some shared configuration, the root command and some helper functions that are used by the rest of the CLI
"github.com/livebud/bud/internal/cli/bud" | ||
) | ||
|
||
func New(bud *bud.Command, in *bud.Input) *Command { |
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.
Added some tools to inspect the generated files
} | ||
// Print the archive to stdout | ||
fmt.Fprintln(os.Stdout, string(txtar.Format(ar))) | ||
return nil |
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.
This one is going to be handy for reproing issues
"os/exec" | ||
|
||
"github.com/livebud/bud/internal/once" | ||
) |
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.
This package simplifies the previous exe package to consolidate how subprocesses are managed in bud. Instead of wrapping exec.Command, it can turn an exec.Cmd into a Process.
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.
Additionally, it can allow you to configure commands earlier with shared env / stdio / files etc. that can be spawned at a later time.
return fmt.Sprintf(format(message), args...) | ||
} | ||
|
||
func Errorf(message string, args ...interface{}) error { |
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.
Added a way to add multi-line errors more easily.
This PR concludes a large internal refactor I've been working on since launch. The goals of this PR:
In general, now that I'm starting to get a better understanding of what people are expecting from the framework, I can start moving the codebase more towards that. The results of this PR:
Since so much of the codebase has changed, I'm pretty sure there's going to be a few minor regressions, but we can address them as they pop up. The core workflows have remained unchanged. This PR pretty much wraps up v0.2. Have a look at the discussion to learn more about next steps. |
I'd like to take one more crack at the compiler refactor. It's important to get this process right because all the generators will fit within this overall process. Writing generators is the easy part.
The goal is to:
Additionally:
framework/
directoryThis will hopefully make the code base much easier to follow, without compromising on flexibility.