thrivekit 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ralph/init.sh +93 -4
package/package.json
CHANGED
package/ralph/init.sh
CHANGED
|
@@ -188,16 +188,54 @@ auto_configure_project() {
|
|
|
188
188
|
|
|
189
189
|
# 2. Detect testUrlBase from common patterns
|
|
190
190
|
local base_url=""
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
|
|
192
|
+
# Check docker-compose.yml for frontend/web service port mappings
|
|
193
|
+
for compose_file in "docker-compose.yml" "docker-compose.yaml" "compose.yml" "compose.yaml"; do
|
|
194
|
+
if [[ -f "$compose_file" && -z "$base_url" ]]; then
|
|
195
|
+
# Look for web/frontend service port mapping
|
|
196
|
+
local web_port
|
|
197
|
+
web_port=$(grep -A 20 -E '^\s*(web|frontend|client|ui):' "$compose_file" 2>/dev/null | \
|
|
198
|
+
grep -E '^\s*-\s*"?[0-9]+:[0-9]+"?' | head -1 | \
|
|
199
|
+
grep -oE '[0-9]+:' | head -1 | tr -d ':')
|
|
200
|
+
if [[ -n "$web_port" ]]; then
|
|
201
|
+
base_url="http://localhost:$web_port"
|
|
202
|
+
fi
|
|
203
|
+
fi
|
|
204
|
+
done
|
|
205
|
+
|
|
206
|
+
# Check for Vite config (uses port 5173 by default)
|
|
207
|
+
if [[ -z "$base_url" ]]; then
|
|
208
|
+
for vite_config in "vite.config.ts" "vite.config.js" "apps/web/vite.config.ts" "apps/web/vite.config.js" \
|
|
209
|
+
"apps/frontend/vite.config.ts" "frontend/vite.config.ts"; do
|
|
210
|
+
if [[ -f "$vite_config" ]]; then
|
|
211
|
+
base_url="http://localhost:5173"
|
|
212
|
+
break
|
|
213
|
+
fi
|
|
214
|
+
done
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
# Check for Next.js (uses port 3000 by default)
|
|
218
|
+
if [[ -z "$base_url" ]]; then
|
|
219
|
+
for next_config in "next.config.js" "next.config.ts" "next.config.mjs" \
|
|
220
|
+
"apps/web/next.config.js" "apps/web/next.config.mjs"; do
|
|
221
|
+
if [[ -f "$next_config" ]]; then
|
|
222
|
+
base_url="http://localhost:3000"
|
|
223
|
+
break
|
|
224
|
+
fi
|
|
225
|
+
done
|
|
226
|
+
fi
|
|
227
|
+
|
|
228
|
+
# Fallback: Check package.json scripts for dev server port
|
|
229
|
+
if [[ -z "$base_url" && -f "package.json" ]]; then
|
|
193
230
|
if grep -q '"dev".*:3000' package.json 2>/dev/null; then
|
|
194
231
|
base_url="http://localhost:3000"
|
|
195
232
|
elif grep -q '"dev".*:5173' package.json 2>/dev/null; then
|
|
196
|
-
base_url="http://localhost:5173"
|
|
233
|
+
base_url="http://localhost:5173"
|
|
197
234
|
elif grep -q '"dev".*:8080' package.json 2>/dev/null; then
|
|
198
235
|
base_url="http://localhost:8080"
|
|
199
236
|
fi
|
|
200
237
|
fi
|
|
238
|
+
|
|
201
239
|
# Check for monorepo frontend
|
|
202
240
|
for fe_pkg in "apps/web/package.json" "apps/frontend/package.json" "frontend/package.json"; do
|
|
203
241
|
if [[ -f "$fe_pkg" && -z "$base_url" ]]; then
|
|
@@ -254,7 +292,58 @@ auto_configure_project() {
|
|
|
254
292
|
fi
|
|
255
293
|
fi
|
|
256
294
|
|
|
257
|
-
# 4. Detect
|
|
295
|
+
# 4. Detect API baseUrl based on backend type
|
|
296
|
+
local api_url=""
|
|
297
|
+
|
|
298
|
+
# Check docker-compose.yml for API service port mappings (most common)
|
|
299
|
+
for compose_file in "docker-compose.yml" "docker-compose.yaml" "compose.yml" "compose.yaml"; do
|
|
300
|
+
if [[ -f "$compose_file" && -z "$api_url" ]]; then
|
|
301
|
+
# Look for api/backend service port mapping like "8000:8000" or "3001:3000"
|
|
302
|
+
local api_port
|
|
303
|
+
api_port=$(grep -A 20 -E '^\s*(api|backend|server|app):' "$compose_file" 2>/dev/null | \
|
|
304
|
+
grep -E '^\s*-\s*"?[0-9]+:[0-9]+"?' | head -1 | \
|
|
305
|
+
grep -oE '[0-9]+:' | head -1 | tr -d ':')
|
|
306
|
+
if [[ -n "$api_port" ]]; then
|
|
307
|
+
api_url="http://localhost:$api_port"
|
|
308
|
+
fi
|
|
309
|
+
fi
|
|
310
|
+
done
|
|
311
|
+
|
|
312
|
+
if [[ -n "$backend_dir" && -z "$api_url" ]]; then
|
|
313
|
+
# Check Dockerfile for EXPOSE directive
|
|
314
|
+
if [[ -f "$backend_dir/Dockerfile" ]]; then
|
|
315
|
+
local docker_port
|
|
316
|
+
docker_port=$(grep -i "^EXPOSE" "$backend_dir/Dockerfile" 2>/dev/null | head -1 | grep -oE '[0-9]+' | head -1)
|
|
317
|
+
if [[ -n "$docker_port" ]]; then
|
|
318
|
+
api_url="http://localhost:$docker_port"
|
|
319
|
+
fi
|
|
320
|
+
fi
|
|
321
|
+
# Python backends (FastAPI/Django) typically use port 8000
|
|
322
|
+
if [[ -z "$api_url" ]] && { [[ -f "$backend_dir/pyproject.toml" ]] || [[ -f "$backend_dir/requirements.txt" ]] || [[ -f "$backend_dir/main.py" ]]; }; then
|
|
323
|
+
api_url="http://localhost:8000"
|
|
324
|
+
# Node backends - check for port in package.json or default to 3001
|
|
325
|
+
elif [[ -z "$api_url" && -f "$backend_dir/package.json" ]]; then
|
|
326
|
+
if grep -q ':3001' "$backend_dir/package.json" 2>/dev/null; then
|
|
327
|
+
api_url="http://localhost:3001"
|
|
328
|
+
elif grep -q ':4000' "$backend_dir/package.json" 2>/dev/null; then
|
|
329
|
+
api_url="http://localhost:4000"
|
|
330
|
+
else
|
|
331
|
+
api_url="http://localhost:3001"
|
|
332
|
+
fi
|
|
333
|
+
fi
|
|
334
|
+
fi
|
|
335
|
+
|
|
336
|
+
if [[ -n "$api_url" ]]; then
|
|
337
|
+
if jq -e '.api.baseUrl' "$tmpfile" >/dev/null 2>&1 && [[ "$(jq -r '.api.baseUrl' "$tmpfile")" != "" ]]; then
|
|
338
|
+
: # Already set
|
|
339
|
+
else
|
|
340
|
+
jq --arg url "$api_url" '.api.baseUrl = $url' "$tmpfile" > "${tmpfile}.new" && mv "${tmpfile}.new" "$tmpfile"
|
|
341
|
+
echo " Auto-detected api.baseUrl: $api_url"
|
|
342
|
+
updated=true
|
|
343
|
+
fi
|
|
344
|
+
fi
|
|
345
|
+
|
|
346
|
+
# 5. Detect package manager
|
|
258
347
|
local pkg_manager="npm"
|
|
259
348
|
if [[ -f "pnpm-lock.yaml" ]]; then
|
|
260
349
|
pkg_manager="pnpm"
|