forked from promptfoo/promptfoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconductor-setup.sh
More file actions
executable file
·86 lines (70 loc) · 2.38 KB
/
conductor-setup.sh
File metadata and controls
executable file
·86 lines (70 loc) · 2.38 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
#!/bin/bash
set -e # Exit on error
echo "🚀 Setting up Promptfoo workspace..."
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
echo "❌ Error: package.json not found. Are you in the right directory?"
exit 1
fi
# Check Node.js version
REQUIRED_NODE_VERSION=$(cat .nvmrc 2>/dev/null | sed 's/v//' || echo "20.0.0")
CURRENT_NODE_VERSION=$(node --version | sed 's/v//')
echo "📦 Checking Node.js version..."
echo " Required: v${REQUIRED_NODE_VERSION}"
echo " Current: v${CURRENT_NODE_VERSION}"
# Compare versions (simple major version check)
REQUIRED_MAJOR=$(echo $REQUIRED_NODE_VERSION | cut -d. -f1)
CURRENT_MAJOR=$(echo $CURRENT_NODE_VERSION | cut -d. -f1)
if [ "$CURRENT_MAJOR" -lt "$REQUIRED_MAJOR" ]; then
echo "❌ Error: Node.js version ${REQUIRED_NODE_VERSION} or higher is required"
echo " Current version: ${CURRENT_NODE_VERSION}"
echo " Please install Node.js ${REQUIRED_NODE_VERSION} or use nvm:"
echo " nvm install ${REQUIRED_NODE_VERSION}"
echo " nvm use ${REQUIRED_NODE_VERSION}"
exit 1
fi
# Check if npm is available
if ! command -v npm &>/dev/null; then
echo "❌ Error: npm is not installed"
echo " Please install npm (it comes with Node.js)"
exit 1
fi
echo "✅ Node.js version OK"
# Check for .env file in base repo and offer to symlink it
if [ -n "$CONDUCTOR_ROOT_PATH" ] && [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then
echo "📄 Found .env file in base repo"
if [ ! -f ".env" ]; then
echo " Creating symlink to .env..."
ln -s "$CONDUCTOR_ROOT_PATH/.env" ".env"
echo "✅ .env symlinked successfully"
else
echo " .env already exists in workspace"
fi
else
echo "ℹ️ No .env file found in base repo"
echo " If you need API keys for testing, create a .env file in:"
echo " $CONDUCTOR_ROOT_PATH/.env"
fi
# Install dependencies
echo "📦 Installing npm dependencies..."
npm install
if [ $? -ne 0 ]; then
echo "❌ Error: npm install failed"
exit 1
fi
echo "✅ Dependencies installed successfully"
# Build the project
echo "🔨 Building project..."
npm run build
if [ $? -ne 0 ]; then
echo "❌ Error: Build failed"
exit 1
fi
echo "✅ Build completed successfully"
echo ""
echo "🎉 Workspace setup complete!"
echo ""
echo "Next steps:"
echo " • Click 'Run' to start the development server (npm run dev)"
echo " • Or run commands manually: npm test, npm run local, etc."
echo ""