Compare commits

...

1 Commits

Author SHA1 Message Date
Nikhil Sonti
c02cdab095 fix: address balpha CLI dogfooding feedback 2026-04-27 15:39:39 -07:00
6 changed files with 36 additions and 8 deletions

View File

@@ -2,11 +2,15 @@ BINARY := balpha
SOURCES := $(shell find . -name '*.go') go.mod go.sum
PREFIX ?= $(HOME)/bin
all: build
build: $(BINARY)
$(BINARY): $(SOURCES)
@echo "[build] Compiling $(BINARY)..."
@go build -o $(BINARY) .
.PHONY: install test clean
.PHONY: all build install test clean
install: $(BINARY)
@mkdir -p $(PREFIX)

View File

@@ -119,7 +119,7 @@ func runEnvironment(cfg config.Config, agentRoot string) error {
Dir: serverDir,
Env: env,
Restart: true,
Cmd: []string{"bun", "--watch", "--env-file=.env.development", "src/index.ts"},
Cmd: serverCommand(),
}))
printSummary(cfg, agentRoot)
@@ -157,6 +157,10 @@ func runEnvironment(cfg config.Config, agentRoot string) error {
return nil
}
func serverCommand() []string {
return []string{"bun", "--env-file=.env.development", "src/index.ts"}
}
func exists(path string) bool {
_, err := os.Stat(path)
return err == nil

View File

@@ -0,0 +1,14 @@
package cmd
import (
"reflect"
"testing"
)
func TestServerCommandDoesNotWatchFiles(t *testing.T) {
got := serverCommand()
want := []string{"bun", "--env-file=.env.development", "src/index.ts"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("server command got %#v want %#v", got, want)
}
}

View File

@@ -195,7 +195,7 @@ func DefaultProductionEnv() ProductionEnv {
"R2_DOWNLOAD_PREFIX": "artifacts/vendor",
"R2_UPLOAD_PREFIX": "artifacts/server",
"NODE_ENV": "production",
"LOG_LEVEL": "info",
"LOG_LEVEL": "debug",
},
CLI: map[string]string{
"POSTHOG_API_KEY": "",
@@ -203,7 +203,7 @@ func DefaultProductionEnv() ProductionEnv {
"R2_ACCESS_KEY_ID": "",
"R2_SECRET_ACCESS_KEY": "",
"R2_BUCKET": "browseros",
"R2_UPLOAD_PREFIX": "cli",
"R2_UPLOAD_PREFIX": "",
},
}
}

View File

@@ -29,9 +29,15 @@ func TestDefaults(t *testing.T) {
if cfg.ProductionEnv.Server["BROWSEROS_CONFIG_URL"] == "" {
t.Fatalf("missing server production env defaults: %#v", cfg.ProductionEnv.Server)
}
if cfg.ProductionEnv.Server["LOG_LEVEL"] != "debug" {
t.Fatalf("server log level got %q want debug", cfg.ProductionEnv.Server["LOG_LEVEL"])
}
if cfg.ProductionEnv.CLI["R2_BUCKET"] != "browseros" {
t.Fatalf("missing cli production env defaults: %#v", cfg.ProductionEnv.CLI)
}
if cfg.ProductionEnv.CLI["R2_UPLOAD_PREFIX"] != "" {
t.Fatalf("cli upload prefix got %q want empty", cfg.ProductionEnv.CLI["R2_UPLOAD_PREFIX"])
}
}
func TestSaveLoadRoundTrip(t *testing.T) {

View File

@@ -15,11 +15,11 @@ func TestWriteProductionEnvFiles(t *testing.T) {
ProductionEnv: config.ProductionEnv{
Server: map[string]string{
"NODE_ENV": "production",
"LOG_LEVEL": "info",
"LOG_LEVEL": "debug",
},
CLI: map[string]string{
"R2_BUCKET": "browseros",
"R2_UPLOAD_PREFIX": "cli",
"R2_UPLOAD_PREFIX": "",
},
},
}
@@ -29,11 +29,11 @@ func TestWriteProductionEnvFiles(t *testing.T) {
assertMode(t, filepath.Join(root, "apps/server/.env.production"), 0600)
assertMode(t, filepath.Join(root, "apps/cli/.env.production"), 0600)
assertContains(t, filepath.Join(root, "apps/server/.env.production"), "BROWSEROS_CONFIG_URL=https://llm.browseros.com/api/browseros-server/config\n")
assertContains(t, filepath.Join(root, "apps/server/.env.production"), "LOG_LEVEL=info\n")
assertContains(t, filepath.Join(root, "apps/server/.env.production"), "LOG_LEVEL=debug\n")
assertContains(t, filepath.Join(root, "apps/server/.env.production"), "NODE_ENV=production\n")
assertContains(t, filepath.Join(root, "apps/cli/.env.production"), "POSTHOG_API_KEY=\n")
assertContains(t, filepath.Join(root, "apps/cli/.env.production"), "R2_BUCKET=browseros\n")
assertContains(t, filepath.Join(root, "apps/cli/.env.production"), "R2_UPLOAD_PREFIX=cli\n")
assertContains(t, filepath.Join(root, "apps/cli/.env.production"), "R2_UPLOAD_PREFIX=\n")
}
func TestWriteEnvFileQuotesUnsafeValues(t *testing.T) {