-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
161 lines (143 loc) · 4.54 KB
/
Taskfile.yml
File metadata and controls
161 lines (143 loc) · 4.54 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# https://taskfile.dev
version: '3'
tasks:
dev:
desc: Run web apps, Go, and Rust together (graceful Ctrl+C)
cmds:
- |
bash <<'SCRIPT'
set -e
trap 'echo; echo "🛑 Stopping all dev tasks..."; kill 0' INT TERM
task dev:web &
task dev:go &
task dev:rs &
wait
SCRIPT
# ----- Web apps -----
dev:web:
desc: Run all web apps under ./apps/web
dir: .
cmds:
- |
bash <<'SCRIPT'
set -euo pipefail
shopt -s nullglob
echo "DEBUG: Starting dev:web task"
echo "DEBUG: Current directory: $(pwd)"
echo "DEBUG: Checking for npm..."
if ! command -v npm >/dev/null 2>&1; then
echo "❌ npm not found in PATH"
exit 1
fi
echo "DEBUG: npm found at $(which npm)"
echo "DEBUG: Looking for apps in ./apps/web/*"
apps=(./apps/web/*)
echo "DEBUG: Found ${#apps[@]} entries"
filtered=()
for app in "${apps[@]}"; do
echo "DEBUG: Checking $app"
if [ -d "$app" ]; then
echo "DEBUG: $app is a directory"
filtered+=("$app")
fi
done
echo "DEBUG: Filtered to ${#filtered[@]} directories"
if [ "${#filtered[@]}" -eq 0 ]; then
echo "ℹ️ No web apps found under ./apps/web/*"
exit 0
fi
echo "🚀 Starting web apps under ./apps/web:"
for app in "${filtered[@]}"; do
(
cd "$app"
name="$(basename "$app")"
echo "DEBUG: Processing $name in $(pwd)"
if [ -f package.json ]; then
echo "📦 [$name] npm install…"
npm install --no-fund --no-audit
echo "🏃 [$name] npm run dev…"
npm run dev
else
echo "⏭️ [$name] skipped (no package.json)"
fi
) &
done
wait
echo "✅ All web apps exited"
SCRIPT
# ----- Go services -----
dev:go:
desc: Run all Go services under ./services/go
cmds:
- |
echo "🚀 Starting all Go services..."
if [ -d "./services/go" ]; then
for svc in ./services/go/*; do
if [ -d "$svc" ]; then
(
cd "$svc"
echo "▶️ Running $(basename "$svc")"
go run .
) &
fi
done
wait
else
echo "ℹ️ No ./services/go directory yet"
fi
echo "✅ All Go services exited"
# ----- Rust services -----
dev:rs:
desc: Run all Rust services under ./services/rs
cmds:
- |
echo "🚀 Starting all Rust services..."
if [ -d "./services/rs" ]; then
for svc in ./services/rs/*; do
if [ -d "$svc" ]; then
(
cd "$svc"
name="$(basename "$svc")"
echo "▶️ Running $name"
cargo run
) &
fi
done
wait
else
echo "ℹ️ No ./services/rs directory yet"
fi
echo "✅ All Rust services exited"
# =========================
# Scaffolding commands
# =========================
# Apps
new:app-web:
desc: Create a new React Router app inside ./apps/web
vars:
appname: '{{.appname | default "new-web-app"}}'
cmds:
- mkdir -p ./apps/web
- cd ./apps/web && npx create-react-router@latest {{.appname}}
- echo "✅ Created web app at ./apps/web/{{.appname}}"
# Services
new:service-go:
desc: Create a new Go HTTP service inside ./services/go
vars:
appname: '{{.appname | default "new-service"}}'
port: '{{.port | default "8080"}}'
cmds:
- mkdir -p ./services/go/{{.appname}}
- cd ./services/go/{{.appname}} && go mod init {{.appname}}
- gomplate -c appname={{.appname}} -c port={{.port}} -f templates/go-service.go.tmpl -o ./services/go/{{.appname}}/main.go
- echo "✅ Created Go service at ./services/go/{{.appname}}"
new:service-rs:
desc: Create a new Rust service inside ./services/rs
vars:
appname: '{{.appname | default "new-rs-service"}}'
port: '{{.port | default "8082"}}'
cmds:
- mkdir -p ./services/rs
- cd ./services/rs && cargo new {{.appname}} --bin
- gomplate -d vars=<(echo '{"appname":"{{.appname}}","port":"{{.port}}"}') -f templates/rust-service.rs.tmpl -o ./services/rs/{{.appname}}/src/main.rs
- echo "✅ Created Rust service at ./services/rs/{{.appname}}"