chore: add mise.toml for tool versions and tasks, thin Makefile shim
This commit is contained in:
34
Makefile
34
Makefile
@@ -1,34 +0,0 @@
|
|||||||
.PHONY: build build-web build-go dev test clean
|
|
||||||
|
|
||||||
# Build the production single binary (embeds the Svelte SPA)
|
|
||||||
build: build-web build-go
|
|
||||||
|
|
||||||
build-web:
|
|
||||||
@echo "==> Building Svelte frontend..."
|
|
||||||
cd web && npm run build
|
|
||||||
|
|
||||||
build-go:
|
|
||||||
@echo "==> Building Go binary (production, embeds web/build)..."
|
|
||||||
go build -tags production -o wotra ./cmd/wotra
|
|
||||||
|
|
||||||
# Development mode: run Go server + Vite dev server concurrently
|
|
||||||
dev:
|
|
||||||
@echo "==> Starting development servers..."
|
|
||||||
@echo " Go API: http://localhost:8080"
|
|
||||||
@echo " Vite UI: http://localhost:5173"
|
|
||||||
@trap 'kill 0' INT; \
|
|
||||||
AUTH_TOKEN=$${AUTH_TOKEN:-devtoken} go run ./cmd/wotra & \
|
|
||||||
cd web && npm run dev
|
|
||||||
|
|
||||||
# Run all Go tests
|
|
||||||
test:
|
|
||||||
go test ./...
|
|
||||||
|
|
||||||
# Install frontend dependencies
|
|
||||||
web/node_modules:
|
|
||||||
cd web && npm install
|
|
||||||
|
|
||||||
# Remove build artifacts
|
|
||||||
clean:
|
|
||||||
rm -f wotra
|
|
||||||
rm -rf web/build web/.svelte-kit
|
|
||||||
29
README.md
29
README.md
@@ -15,30 +15,47 @@ A self-hosted working time tracker with a Go backend and a Svelte PWA frontend.
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
|
Tool versions are declared in `mise.toml`. Install [mise](https://mise.jdx.dev) and run `mise install` once to get the correct Go and Node versions.
|
||||||
|
|
||||||
### Development
|
### Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Set your auth token
|
# Install frontend dependencies (first time only)
|
||||||
export AUTH_TOKEN=mysecrettoken
|
mise run install
|
||||||
|
|
||||||
# 2. Start both servers
|
# Start both servers (Go API + Vite dev server)
|
||||||
make dev
|
mise run dev
|
||||||
# Go API: http://localhost:8080
|
# Go API: http://localhost:8080
|
||||||
# Vite UI: http://localhost:5173 (with /api proxy)
|
# Vite UI: http://localhost:5173 (with /api proxy)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`AUTH_TOKEN` defaults to `devtoken` in `mise.toml`. Override it by setting the variable in your environment before running.
|
||||||
|
|
||||||
Open `http://localhost:5173`, go to **Settings**, enter your token.
|
Open `http://localhost:5173`, go to **Settings**, enter your token.
|
||||||
|
|
||||||
### Production (single binary)
|
### Production (single binary)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build # builds web/ then embeds it in the Go binary
|
mise run build # builds web/ then embeds it in the Go binary
|
||||||
|
|
||||||
# Run
|
|
||||||
AUTH_TOKEN=mysecrettoken ./wotra
|
AUTH_TOKEN=mysecrettoken ./wotra
|
||||||
# open http://localhost:8080
|
# open http://localhost:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### All tasks
|
||||||
|
|
||||||
|
| Task | Description |
|
||||||
|
|---------------|--------------------------------------------------|
|
||||||
|
| `mise run build` | Build production binary (web + Go) |
|
||||||
|
| `mise run build:web` | Build Svelte frontend only |
|
||||||
|
| `mise run build:go` | Build Go binary only |
|
||||||
|
| `mise run dev` | Start API + UI dev servers concurrently |
|
||||||
|
| `mise run dev:api` | Start Go API server only |
|
||||||
|
| `mise run dev:ui` | Start Vite dev server only |
|
||||||
|
| `mise run test` | Run all Go tests |
|
||||||
|
| `mise run install` | Install frontend npm dependencies |
|
||||||
|
| `mise run clean` | Remove build artifacts |
|
||||||
|
|
||||||
## Configuration (environment variables)
|
## Configuration (environment variables)
|
||||||
|
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
|
|||||||
57
mise.toml
Normal file
57
mise.toml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
[tools]
|
||||||
|
go = "1.26.2"
|
||||||
|
node = "24.14.0"
|
||||||
|
npm = "latest"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
AUTH_TOKEN = "devtoken"
|
||||||
|
PORT = "8080"
|
||||||
|
DB_PATH = "wotra.db"
|
||||||
|
TZ = "UTC"
|
||||||
|
|
||||||
|
[tasks.build]
|
||||||
|
description = "Build production single binary (web + Go)"
|
||||||
|
depends = ["build:web", "build:go"]
|
||||||
|
|
||||||
|
[tasks."build:web"]
|
||||||
|
description = "Build Svelte frontend"
|
||||||
|
dir = "web"
|
||||||
|
run = "npm run build"
|
||||||
|
|
||||||
|
[tasks."build:go"]
|
||||||
|
description = "Build Go binary with embedded web assets"
|
||||||
|
run = "go build -tags production -o wotra ./cmd/wotra"
|
||||||
|
|
||||||
|
[tasks.dev]
|
||||||
|
description = "Start Go API and Vite dev server concurrently"
|
||||||
|
run = """
|
||||||
|
echo "Go API: http://localhost:${PORT}"
|
||||||
|
echo "Vite UI: http://localhost:5173"
|
||||||
|
mise run dev:api & mise run dev:ui
|
||||||
|
wait
|
||||||
|
"""
|
||||||
|
|
||||||
|
[tasks."dev:api"]
|
||||||
|
description = "Start Go API server"
|
||||||
|
run = "go run ./cmd/wotra"
|
||||||
|
|
||||||
|
[tasks."dev:ui"]
|
||||||
|
description = "Start Vite dev server"
|
||||||
|
dir = "web"
|
||||||
|
run = "npm run dev"
|
||||||
|
|
||||||
|
[tasks.test]
|
||||||
|
description = "Run all Go tests"
|
||||||
|
run = "go test ./..."
|
||||||
|
|
||||||
|
[tasks.install]
|
||||||
|
description = "Install frontend npm dependencies"
|
||||||
|
dir = "web"
|
||||||
|
run = "npm install"
|
||||||
|
|
||||||
|
[tasks.clean]
|
||||||
|
description = "Remove build artifacts"
|
||||||
|
run = """
|
||||||
|
rm -f wotra
|
||||||
|
rm -rf web/build web/.svelte-kit
|
||||||
|
"""
|
||||||
Reference in New Issue
Block a user