Skip to content

Commit 1865c3b

Browse files
committed
[evals] Fix test run and typecheck for trpc - install modules scripts for client + server
1 parent 497eb36 commit 1865c3b

File tree

9 files changed

+115
-12
lines changed

9 files changed

+115
-12
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Common functions for DBX SDK eval scripts
4+
5+
install_dependencies() {
6+
if [ -f "package.json" ]; then
7+
if [ ! -d "node_modules" ]; then
8+
echo "Installing dependencies..." >&2
9+
npm install >&2 || { echo "❌ Failed to install dependencies" >&2; exit 1; }
10+
fi
11+
fi
12+
}

klaudbiusz/cli/eval/dbx-sdk/typecheck.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ set -e
44
# DBX SDK template typecheck script
55
# Runs TypeScript type checking using npm run check or tsc directly
66

7+
# Source common functions
8+
source "$(dirname "$0")/common.sh"
9+
10+
# Install dependencies if needed
11+
install_dependencies
12+
713
# Verify package.json exists
814
if [ ! -f "package.json" ]; then
915
echo "❌ Error: No package.json found" >&2
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Common functions for Docker eval scripts
4+
5+
install_dependencies() {
6+
echo "Ensuring dependencies are installed..." >&2
7+
8+
# Check if root package.json has install:all script (trpc style)
9+
if [ -f "package.json" ] && grep -q '"install:all"' package.json 2>/dev/null; then
10+
echo "Running npm run install:all..." >&2
11+
npm run install:all >&2 || { echo "❌ Failed to install dependencies" >&2; exit 1; }
12+
elif [ -f "package.json" ] && [ ! -d "node_modules" ]; then
13+
# Root-level app (dbx-sdk style)
14+
echo "Installing dependencies..." >&2
15+
npm install >&2 || { echo "❌ Failed to install dependencies" >&2; exit 1; }
16+
else
17+
# Install server/client separately if they exist
18+
if [ -d "server" ] && [ -f "server/package.json" ] && [ ! -d "server/node_modules" ]; then
19+
echo "Installing server dependencies..." >&2
20+
cd server && npm install >&2 && cd .. || { echo "❌ Failed to install server dependencies" >&2; exit 1; }
21+
fi
22+
23+
if [ -d "client" ] && [ -f "client/package.json" ] && [ ! -d "client/node_modules" ]; then
24+
echo "Installing client dependencies..." >&2
25+
cd client && npm install >&2 && cd .. || { echo "❌ Failed to install client dependencies" >&2; exit 1; }
26+
fi
27+
fi
28+
}

klaudbiusz/cli/eval/docker/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ set -e
55
# For Docker apps, we run tests before the Docker build
66
# Docker apps are typically built from dbx-sdk or trpc templates
77

8+
# Source common functions
9+
source "$(dirname "$0")/common.sh"
10+
11+
# Install dependencies if needed
12+
install_dependencies
13+
814
# Try root-level test (works for both dbx-sdk and trpc)
915
if [ -f "package.json" ] && grep -q '"test"' package.json 2>/dev/null; then
1016
# Check if test files exist

klaudbiusz/cli/eval/docker/typecheck.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ set -e
55
# For Docker apps, we check the source before the Docker build
66
# Docker apps are typically built from dbx-sdk or trpc templates
77

8+
# Source common functions
9+
source "$(dirname "$0")/common.sh"
10+
11+
# Install dependencies if needed
12+
install_dependencies
13+
814
# Try root-level check first (dbx-sdk style)
915
if [ -f "package.json" ] && grep -q '"check"' package.json 2>/dev/null; then
1016
exec npm run check
@@ -21,8 +27,9 @@ if [ -d "server" ] && [ -f "server/tsconfig.json" ]; then
2127
cd server && npx tsc --noEmit --skipLibCheck && cd ..
2228

2329
# Also check client if exists
24-
if [ -d "../client" ] && [ -f "../client/tsconfig.json" ]; then
25-
cd ../client && npx tsc --noEmit --skipLibCheck
30+
if [ -d "client" ] && [ -f "client/tsconfig.json" ]; then
31+
echo "Checking client types..." >&2
32+
cd client && npx tsc --noEmit --skipLibCheck
2633
fi
2734
exit 0
2835
fi

klaudbiusz/cli/eval/trpc/common.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Common functions for tRPC eval scripts
4+
5+
install_dependencies() {
6+
echo "Ensuring dependencies are installed..." >&2
7+
8+
# Check if root package.json has install:all script
9+
if [ -f "package.json" ] && grep -q '"install:all"' package.json 2>/dev/null; then
10+
echo "Running npm run install:all..." >&2
11+
npm run install:all >&2 || { echo "❌ Failed to install dependencies" >&2; exit 1; }
12+
else
13+
# Install server dependencies if needed
14+
if [ -d "server" ] && [ -f "server/package.json" ]; then
15+
if [ ! -d "server/node_modules" ]; then
16+
echo "Installing server dependencies..." >&2
17+
cd server && npm install >&2 && cd .. || { echo "❌ Failed to install server dependencies" >&2; exit 1; }
18+
fi
19+
fi
20+
21+
# Install client dependencies if needed (try both client/ and frontend/)
22+
if [ -d "client" ] && [ -f "client/package.json" ]; then
23+
if [ ! -d "client/node_modules" ]; then
24+
echo "Installing client dependencies..." >&2
25+
cd client && npm install >&2 && cd .. || { echo "❌ Failed to install client dependencies" >&2; exit 1; }
26+
fi
27+
elif [ -d "frontend" ] && [ -f "frontend/package.json" ]; then
28+
if [ ! -d "frontend/node_modules" ]; then
29+
echo "Installing frontend dependencies..." >&2
30+
cd frontend && npm install >&2 && cd .. || { echo "❌ Failed to install frontend dependencies" >&2; exit 1; }
31+
fi
32+
fi
33+
fi
34+
}

klaudbiusz/cli/eval/trpc/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ set -e
44
# tRPC template test script
55
# Runs tests using root-level npm test command
66

7+
# Source common functions
8+
source "$(dirname "$0")/common.sh"
9+
10+
# Install dependencies if needed
11+
install_dependencies
12+
713
# Check if package.json exists
814
if [ ! -f "package.json" ]; then
915
echo "❌ Error: No package.json found" >&2

klaudbiusz/cli/eval/trpc/typecheck.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ set -e
44
# tRPC template typecheck script
55
# Runs TypeScript type checking separately for server/ and client/
66

7+
# Source common functions
8+
source "$(dirname "$0")/common.sh"
9+
10+
# Install dependencies if needed
11+
install_dependencies
12+
713
# Check server directory
814
if [ -d "server" ] && [ -f "server/tsconfig.json" ]; then
915
echo "Checking server types..." >&2

klaudbiusz/cli/evaluate_app.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,13 @@ def check_type_safety(app_dir: Path, template: str = "unknown") -> bool:
429429
"""
430430
print(" [3/7] Checking type safety...")
431431

432-
# Determine which template script to use
433-
dockerfile = app_dir / "Dockerfile"
434-
if dockerfile.exists():
435-
script_dir = "docker"
436-
elif template == "dbx-sdk":
432+
# Determine which template script to use (prefer template-specific over docker)
433+
if template == "dbx-sdk":
437434
script_dir = "dbx-sdk"
438435
elif template == "trpc":
439436
script_dir = "trpc"
437+
elif (app_dir / "Dockerfile").exists():
438+
script_dir = "docker"
440439
else:
441440
# Unknown template - fail
442441
print(f" ⚠️ Unknown template: {template}")
@@ -465,14 +464,13 @@ def check_tests_pass(app_dir: Path, template: str = "unknown") -> tuple[bool, fl
465464
"""
466465
print(" [4/7] Checking tests pass...")
467466

468-
# Determine which template script to use
469-
dockerfile = app_dir / "Dockerfile"
470-
if dockerfile.exists():
471-
script_dir = "docker"
472-
elif template == "dbx-sdk":
467+
# Determine which template script to use (prefer template-specific over docker)
468+
if template == "dbx-sdk":
473469
script_dir = "dbx-sdk"
474470
elif template == "trpc":
475471
script_dir = "trpc"
472+
elif (app_dir / "Dockerfile").exists():
473+
script_dir = "docker"
476474
else:
477475
# Unknown template - fail
478476
return False, 0.0, False

0 commit comments

Comments
 (0)