-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·143 lines (118 loc) · 4 KB
/
bootstrap
File metadata and controls
executable file
·143 lines (118 loc) · 4 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
#!/usr/bin/env bash
# Stratos Development Environment Bootstrap Script
# This script initializes a fresh Stratos checkout by building required dependencies
# in the correct order before running bun install.
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print colored output
print_status() { echo -e "${BLUE}==>${NC} $1"; }
print_success() { echo -e "${GREEN}✓${NC} $1"; }
print_error() { echo -e "${RED}✗${NC} $1"; }
print_warning() { echo -e "${YELLOW}⚠${NC} $1"; }
print_status "Stratos Development Environment Bootstrap"
echo ""
# Check prerequisites
print_status "Checking prerequisites..."
# Check Node.js
if ! command -v node &> /dev/null; then
print_error "Node.js is not installed. Please install Node.js 24 or later."
exit 1
fi
NODE_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 24 ]; then
print_warning "Node.js version is $NODE_VERSION. Version 24 or later is recommended."
else
print_success "Node.js $(node --version) found"
fi
# Check Bun
if ! command -v bun &> /dev/null; then
print_error "Bun is not installed. Please install Bun: https://bun.sh"
exit 1
fi
print_success "Bun $(bun --version) found"
# Check Go
if ! command -v go &> /dev/null; then
print_error "Go is not installed. Please install Go 1.21 or later."
exit 1
fi
print_success "Go $(go version | awk '{print $3}') found"
echo ""
# Step 1: Build devkit package
print_status "Step 1/4: Building devkit package..."
if [ ! -d "src/frontend/packages/devkit" ]; then
print_error "Devkit package directory not found. Are you in the Stratos root directory?"
exit 1
fi
cd src/frontend/packages/devkit
# Remove old lockfile if it exists (it's incompatible with modern npm/bun)
if [ -f "package-lock.json" ]; then
print_warning "Removing old package-lock.json from devkit"
rm package-lock.json
fi
# Use npm for devkit build to avoid circular dependency with bun
print_status "Installing devkit dependencies..."
npm install --legacy-peer-deps > /dev/null 2>&1
print_status "Building devkit..."
npm run build > /dev/null 2>&1
cd ../../../..
if [ -d "dist-devkit" ]; then
print_success "Devkit built successfully"
else
print_error "Devkit build failed - dist-devkit directory not created"
exit 1
fi
# Step 2: Generate extension module
print_status "Step 2/4: Generating extension imports..."
if [ ! -f "build/extension-generator.mjs" ]; then
print_error "extension-generator.mjs not found"
exit 1
fi
node build/extension-generator.mjs
if [ -f "src/frontend/packages/core/src/_custom-import.module.ts" ]; then
print_success "Extension module generated"
else
print_error "Extension module generation failed"
exit 1
fi
# Step 3: Setup development configuration
print_status "Step 3/4: Setting up development configuration..."
if [ ! -f "build/dev-setup.js" ]; then
print_error "dev-setup.js not found"
exit 1
fi
# Run dev-setup as CommonJS (temporarily rename to .cjs)
mv build/dev-setup.js build/dev-setup.cjs 2>/dev/null || true
if [ -f "build/dev-setup.cjs" ]; then
node build/dev-setup.cjs
mv build/dev-setup.cjs build/dev-setup.js
else
node build/dev-setup.js
fi
if [ -f "proxy.conf.js" ]; then
print_success "Development configuration created"
else
print_warning "proxy.conf.js not created (may already exist)"
fi
# Step 4: Clean up any stray node_modules in workspace packages
print_status "Step 4/4: Cleaning workspace..."
find src/frontend/packages -type d -name "node_modules" -maxdepth 2 2>/dev/null | while read dir; do
print_warning "Removing unexpected node_modules: $dir"
rm -rf "$dir"
done
print_success "Workspace cleaned"
echo ""
print_success "Bootstrap complete!"
echo ""
print_status "Next steps:"
echo " 1. Run: bun install"
echo " 2. Run: make dev-frontend (for development)"
echo " OR: make build (for production build)"
echo ""
print_status "For backend development, also run:"
echo " make build-backend"
echo ""