mirror of
https://github.com/acaloiaro/frm
synced 2026-07-21 10:12:23 +00:00
chore: use reflex instead of air
This commit is contained in:
parent
5220c77358
commit
62d581f960
6 changed files with 246 additions and 529 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@
|
||||||
.pre-commit-config.yaml
|
.pre-commit-config.yaml
|
||||||
.env
|
.env
|
||||||
tmp
|
tmp
|
||||||
|
trigger_restart.go
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,9 @@ func main() {
|
||||||
logger.Info("frm dev server started")
|
logger.Info("frm dev server started")
|
||||||
chiRouter := chi.NewRouter()
|
chiRouter := chi.NewRouter()
|
||||||
chiRouter.Use(httplog.RequestLogger(requestLogger))
|
chiRouter.Use(httplog.RequestLogger(requestLogger))
|
||||||
|
chiRouter.Get("/ping", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
})
|
||||||
const workspaceParamName = "frm_workspace_id"
|
const workspaceParamName = "frm_workspace_id"
|
||||||
f, err := frm.New(frm.Args{
|
f, err := frm.New(frm.Args{
|
||||||
PostgresURL: os.Getenv("POSTGRES_URL"),
|
PostgresURL: os.Getenv("POSTGRES_URL"),
|
||||||
|
|
|
||||||
698
flake.lock
698
flake.lock
File diff suppressed because it is too large
Load diff
69
flake.nix
69
flake.nix
|
|
@ -8,11 +8,7 @@
|
||||||
url = "github:acaloiaro/ess/v2.13.0";
|
url = "github:acaloiaro/ess/v2.13.0";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
air = {
|
templ.url = "github:a-h/templ/v0.3.819";
|
||||||
url = "github:acaloiaro/air";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
templ.url = "github:a-h/templ/v0.2.793";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
|
|
@ -20,7 +16,6 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
devenv,
|
devenv,
|
||||||
systems,
|
systems,
|
||||||
air,
|
|
||||||
tailwindcss,
|
tailwindcss,
|
||||||
...
|
...
|
||||||
} @ inputs: let
|
} @ inputs: let
|
||||||
|
|
@ -49,9 +44,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
air.packages.${system}.default
|
|
||||||
go-migrate
|
go-migrate
|
||||||
nixpacks
|
nixpacks
|
||||||
|
reflex
|
||||||
sqlc
|
sqlc
|
||||||
postgresql
|
postgresql
|
||||||
pre-commit
|
pre-commit
|
||||||
|
|
@ -148,10 +143,10 @@
|
||||||
description = "Execute 'ess' with default parameters";
|
description = "Execute 'ess' with default parameters";
|
||||||
};
|
};
|
||||||
|
|
||||||
server = {
|
frm-server = {
|
||||||
description = "Run the development server";
|
description = "Run the development server";
|
||||||
exec = ''
|
exec = ''
|
||||||
tailwindcss -c ui/tailwind.config.js -i ./ui/css/tailwind.css -o ./static/css/styles.css && run-generate-models && go generate ./... && go build -o ./tmp/frm ./cmd/dev_server && ./tmp/frm
|
bash -c 'pkill ./tmp/frm; exit 0' && go generate ./... && go build -o ./tmp/frm ./cmd/dev_server && ./tmp/frm
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -166,17 +161,61 @@
|
||||||
${sqlc}/bin/sqlc generate && echo sqlc generate done
|
${sqlc}/bin/sqlc generate && echo sqlc generate done
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
processes.air = {
|
rebuild-tailwind = {
|
||||||
exec = ''
|
description = "rebuild tailwind's output and trigger a templ rebuild by touching a templ file";
|
||||||
${air.packages.${system}.default}/bin/air -c .air.toml -build.bin server
|
# When tailwind updates CSS, we need to trigger a rebuild of the go application, hence the modification to main.go
|
||||||
'';
|
exec = "tailwindcss -c ui/tailwind.config.js -i ./ui/css/tailwind.css -o ./static/css/styles.css && echo -e \"package frm\nimport \\x22fmt\\x22\nfunc main() { fmt.Println($(head -c2 /dev/urandom | od -An -vtu4)) }\" > ./trigger_restart.go";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
processes.templ = {
|
processes.templ = {
|
||||||
exec = ''
|
exec = ''
|
||||||
templ generate --watch --proxy="http://localhost:3000"
|
templ generate -cmd frm-server -watch -watch-pattern='(^(?:[^e]|e[^n]|en[^u]|enu[^m]|enum[^e]|enume[^r])*\.go$)|(.+\.templ$)|(.+_templ\.txt$)|(.+styles\.css$)' -proxy 'http://localhost:3000' -v trace
|
||||||
|
'';
|
||||||
|
process-compose = {
|
||||||
|
availability = {
|
||||||
|
restart = "on_failure";
|
||||||
|
};
|
||||||
|
readiness_probe = {
|
||||||
|
http_get = {
|
||||||
|
host = "127.0.0.1";
|
||||||
|
scheme = "http";
|
||||||
|
path = "/ping";
|
||||||
|
port = "3000";
|
||||||
|
initial_delay_seconds = 5;
|
||||||
|
period_seconds = 2;
|
||||||
|
timeout_seconds = 5;
|
||||||
|
success_threshold = 1;
|
||||||
|
failure_threshold = 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
depends_on = {
|
||||||
|
postgres = {
|
||||||
|
condition = "process_healthy";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
processes.tailwindcss = {
|
||||||
|
exec = ''
|
||||||
|
reflex \
|
||||||
|
-v \
|
||||||
|
--inverse-regex='\.devenv' \
|
||||||
|
--inverse-regex='\.direnv' \
|
||||||
|
--inverse-regex='.+trigger_rebuild.+' \
|
||||||
|
-r '.+tailwind\.css$|.+\.templ$' \
|
||||||
|
-- rebuild-tailwind
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
processes.sqlc = {
|
||||||
|
exec = ''
|
||||||
|
reflex \
|
||||||
|
-s -r '.+\.sql$' \
|
||||||
|
-- run-generate-models
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -3,7 +3,7 @@ module github.com/acaloiaro/frm
|
||||||
go 1.23.2
|
go 1.23.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/a-h/templ v0.2.793
|
github.com/a-h/templ v0.3.819
|
||||||
github.com/go-chi/chi/v5 v5.1.0
|
github.com/go-chi/chi/v5 v5.1.0
|
||||||
github.com/go-chi/httplog/v2 v2.1.1
|
github.com/go-chi/httplog/v2 v2.1.1
|
||||||
github.com/golang-migrate/migrate/v4 v4.18.0
|
github.com/golang-migrate/migrate/v4 v4.18.0
|
||||||
|
|
|
||||||
2
go.sum
2
go.sum
|
|
@ -4,6 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
|
||||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||||
github.com/a-h/templ v0.2.793 h1:Io+/ocnfGWYO4VHdR0zBbf39PQlnzVCVVD+wEEs6/qY=
|
github.com/a-h/templ v0.2.793 h1:Io+/ocnfGWYO4VHdR0zBbf39PQlnzVCVVD+wEEs6/qY=
|
||||||
github.com/a-h/templ v0.2.793/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
|
github.com/a-h/templ v0.2.793/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
|
||||||
|
github.com/a-h/templ v0.3.819 h1:KDJ5jTFN15FyJnmSmo2gNirIqt7hfvBD2VXVDTySckM=
|
||||||
|
github.com/a-h/templ v0.3.819/go.mod h1:iDJKJktpttVKdWoTkRNNLcllRI+BlpopJc+8au3gOUo=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue