-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
142 lines (125 loc) · 5.3 KB
/
Taskfile.yml
File metadata and controls
142 lines (125 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
version: '3'
# Project task runner. Reflects the current shape of the repo:
# - Binary is `schemaforge` (defined in crates/schema-forge-cli/Cargo.toml).
# - Default backend is `surrealdb`; alternate is `postgres` (mutually
# exclusive with the default — opt in by setting FEATURES=postgres).
# - The React admin/app surface lives in `site/`, scaffolded by
# `schemaforge site generate` and served by Vite. The legacy Tera +
# Tailwind `admin-ui` is gone; there is no embedded HTML template
# pipeline to compile any more.
vars:
# Override on the CLI to swap backends, e.g. `FEATURES=postgres task serve`.
# Empty by default → uses the crate's default features (surrealdb).
FEATURES: ""
PORT: 3000
ADMIN_PASSWORD: changeme
BASE_URL: "http://127.0.0.1:{{.PORT}}"
SITE_DIR: site
SCHEMA_DIR: schemas
SITE_DEV_PORT: 5173
tasks:
build:
desc: Build the schemaforge binary (debug)
cmds:
- cargo build -p schema-forge-cli {{if .FEATURES}}--no-default-features --features {{.FEATURES}}{{end}}
install:
desc: Build release binary and install to ~/.cargo/bin/schemaforge
cmds:
- cargo install --path crates/schema-forge-cli {{if .FEATURES}}--no-default-features --features {{.FEATURES}}{{end}}
serve:
desc: Start the SchemaForge server (Ctrl+C to stop)
cmds:
# Pass --config explicitly: acton-service's auto-discovery walks XDG +
# /etc but doesn't reliably pick up the project root's `config.toml`
# under all `cargo run` cwd contexts. Explicit beats implicit.
- >-
cargo run -p schema-forge-cli {{if .FEATURES}}--no-default-features --features {{.FEATURES}}{{end}} -- --config config.toml serve
--port {{.PORT}}
--schemas {{.SCHEMA_DIR}}
--admin-password {{.ADMIN_PASSWORD}}
--dev-cors
seed:
desc: Seed demo data (expects server already running on $BASE_URL)
cmds:
- bash scripts/seed-demo-data.sh
env:
BASE_URL: "{{.BASE_URL}}"
demo:
desc: Build, start server with in-memory DB, seed demo data, then keep running
cmds:
- |
set -euo pipefail
# Build the CLI
cargo build -p schema-forge-cli {{if .FEATURES}}--no-default-features --features {{.FEATURES}}{{end}}
# Start server in background with in-memory DB.
# `--config config.toml` is explicit so the project's [rate_limit]
# block applies; acton-service's auto-discovery doesn't always pick
# up the project root.
./target/debug/schemaforge --config config.toml serve \
--port {{.PORT}} \
--schemas {{.SCHEMA_DIR}} \
--admin-password {{.ADMIN_PASSWORD}} \
--db-url "mem://" \
--dev-cors &
SERVER_PID=$!
trap 'kill $SERVER_PID 2>/dev/null' EXIT
# Wait for health endpoint (30s timeout)
echo "Waiting for server to start..."
for i in $(seq 1 30); do
if curl -sf {{.BASE_URL}}/health > /dev/null 2>&1; then
echo "Server is ready."
break
fi
if [ "$i" -eq 30 ]; then
echo "ERROR: Server failed to start within 30 seconds."
exit 1
fi
sleep 1
done
# Seed demo data
BASE_URL="{{.BASE_URL}}" bash scripts/seed-demo-data.sh
echo ""
echo "============================================================"
echo " Demo backend running at {{.BASE_URL}}"
echo "============================================================"
echo ""
echo " Sign in:"
echo " username: admin"
echo " password: {{.ADMIN_PASSWORD}}"
echo ""
echo " Endpoints:"
echo " health: {{.BASE_URL}}/health"
echo " meta: {{.BASE_URL}}/api/v1/forge/meta"
echo " schemas: {{.BASE_URL}}/api/v1/forge/schemas"
echo ""
echo " Launch the React admin/app site:"
echo " task site:dev # regenerates site/ and starts Vite on :{{.SITE_DEV_PORT}}"
echo ""
echo " Press Ctrl+C to stop the backend."
echo "============================================================"
wait $SERVER_PID
site:
desc: Regenerate the React site scaffold from the schema directory
cmds:
- cargo run -p schema-forge-cli --quiet -- site generate --schema-dir {{.SCHEMA_DIR}} --out-dir {{.SITE_DIR}}
site:dev:
desc: Regenerate the React site and start the Vite dev server
cmds:
- cargo run -p schema-forge-cli --quiet -- site generate --schema-dir {{.SCHEMA_DIR}} --out-dir {{.SITE_DIR}}
- pnpm --dir {{.SITE_DIR}} install
- pnpm --dir {{.SITE_DIR}} dev --port {{.SITE_DEV_PORT}}
site:build:
desc: Type-check and bundle the React site for production
cmds:
- cargo run -p schema-forge-cli --quiet -- site generate --schema-dir {{.SCHEMA_DIR}} --out-dir {{.SITE_DIR}}
- pnpm --dir {{.SITE_DIR}} install
- pnpm --dir {{.SITE_DIR}} build
test:
desc: Run all workspace tests with cargo nextest
cmds:
- cargo nextest run --workspace {{if .FEATURES}}--no-default-features --features {{.FEATURES}}{{end}}
check:
desc: Run clippy and format checks
cmds:
- cargo clippy --workspace --all-targets {{if .FEATURES}}--no-default-features --features {{.FEATURES}}{{end}} -- -D warnings
- cargo fmt --all -- --check