-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·221 lines (197 loc) · 6.58 KB
/
bootstrap.sh
File metadata and controls
executable file
·221 lines (197 loc) · 6.58 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Candy Crash Bootstrap Script
# Checks for critical dependencies after cloning
#
# Usage:
# ./bootstrap.sh
#
# This script checks for:
# - Git (version control)
# - Just (task runner)
# - Podman (container engine)
# - Ruby (runtime)
#
# NOTE: Git doesn't support "pre-clone" hooks (hooks only exist after clone).
# Users should run this script immediately after cloning.
set -e
echo "🍬 Candy Crash Bootstrap"
echo "======================="
echo ""
echo "Checking critical dependencies..."
echo ""
# Track missing dependencies
missing=()
optional_missing=()
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check Git (should always be present if we got here)
echo -n "Checking Git... "
if command -v git &> /dev/null; then
version=$(git --version | awk '{print $3}')
echo -e "${GREEN}✓${NC} Found (v$version)"
else
echo -e "${RED}✗${NC} Missing (critical)"
missing+=("git")
fi
# Check Just (task runner - CRITICAL)
echo -n "Checking Just... "
if command -v just &> /dev/null; then
version=$(just --version | awk '{print $2}')
echo -e "${GREEN}✓${NC} Found (v$version)"
else
echo -e "${RED}✗${NC} Missing (critical)"
missing+=("just")
fi
# Check Podman (container engine - CRITICAL for production)
echo -n "Checking Podman... "
if command -v podman &> /dev/null; then
version=$(podman --version | awk '{print $3}')
echo -e "${GREEN}✓${NC} Found (v$version)"
else
echo -e "${YELLOW}✗${NC} Missing (required for containers)"
missing+=("podman")
fi
# Check Ruby (runtime - should be present for Rails)
echo -n "Checking Ruby... "
if command -v ruby &> /dev/null; then
version=$(ruby --version | awk '{print $2}')
echo -e "${GREEN}✓${NC} Found (v$version)"
# Check if it's the right version
required_version="3.3.6"
if [[ "$version" != "$required_version"* ]]; then
echo -e "${YELLOW}⚠${NC} Warning: Expected Ruby $required_version, found $version"
fi
else
echo -e "${RED}✗${NC} Missing (critical)"
missing+=("ruby")
fi
# Check Bundler (Ruby gem manager)
echo -n "Checking Bundler... "
if command -v bundle &> /dev/null; then
version=$(bundle --version | awk '{print $3}')
echo -e "${GREEN}✓${NC} Found (v$version)"
else
echo -e "${YELLOW}✗${NC} Missing (install with: gem install bundler)"
optional_missing+=("bundler")
fi
# Check Deno (JavaScript/TypeScript runtime)
echo -n "Checking Deno... "
if command -v deno &> /dev/null; then
version=$(deno --version | head -1 | awk '{print $2}')
echo -e "${GREEN}✓${NC} Found (v$version)"
else
echo -e "${YELLOW}✗${NC} Missing (JavaScript runtime)"
optional_missing+=("deno")
fi
echo ""
echo "======================="
echo ""
# If critical dependencies are missing, prompt for installation
if [ ${#missing[@]} -gt 0 ]; then
echo -e "${RED}⚠️ CRITICAL DEPENDENCIES MISSING${NC}"
echo ""
echo "The following tools are required to work on this project:"
echo ""
for dep in "${missing[@]}"; do
case $dep in
git)
echo -e "${BLUE}Git${NC} (version control)"
echo " Install: https://git-scm.com/downloads"
;;
just)
echo -e "${BLUE}Just${NC} (task runner)"
echo " Install: cargo install just"
echo " Or visit: https://github.com/casey/just#installation"
echo " Packages available for: brew, apt, pacman, cargo"
;;
podman)
echo -e "${BLUE}Podman${NC} (rootless container engine)"
echo " Install:"
echo " • Ubuntu/Debian: sudo apt-get install podman"
echo " • Fedora: sudo dnf install podman"
echo " • macOS: brew install podman"
echo " • Arch: sudo pacman -S podman"
echo " Or visit: https://podman.io/getting-started/installation"
;;
ruby)
echo -e "${BLUE}Ruby 3.3.6${NC} (runtime)"
echo " Install with rbenv:"
echo " rbenv install 3.3.6"
echo " rbenv global 3.3.6"
echo " Or visit: https://www.ruby-lang.org/en/downloads/"
;;
esac
echo ""
done
echo -e "${YELLOW}Without these tools, you will be severely limited in contributing to this project.${NC}"
echo ""
# Ask if they want to continue
read -p "Do you want to continue setup anyway? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Setup aborted. Please install missing dependencies and run ./bootstrap.sh again."
echo ""
exit 1
fi
echo ""
echo -e "${YELLOW}⚠️ Continuing with missing dependencies (not recommended)${NC}"
echo ""
fi
# Install Git hooks if Just is available
if command -v just &> /dev/null; then
echo "🔧 Setting up Git hooks..."
if ./.githooks/install.sh; then
echo -e "${GREEN}✓${NC} Git hooks installed"
else
echo -e "${YELLOW}⚠${NC} Could not install Git hooks"
fi
echo ""
fi
# Install Ruby dependencies if Bundler is available
if command -v bundle &> /dev/null; then
echo "📦 Installing Ruby dependencies..."
read -p "Run 'bundle install' now? (Y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Nn]$ ]]; then
bundle install
echo -e "${GREEN}✓${NC} Ruby dependencies installed"
else
echo "Skipped. Run 'bundle install' manually later."
fi
echo ""
fi
# Setup database if Rails is available
if command -v bundle &> /dev/null && [ -f "bin/rails" ]; then
echo "🗄️ Setting up database..."
read -p "Run 'rails db:setup' now? (Y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Nn]$ ]]; then
bundle exec rails db:setup
echo -e "${GREEN}✓${NC} Database setup complete"
else
echo "Skipped. Run 'rails db:setup' manually later."
fi
echo ""
fi
echo "======================="
echo ""
echo -e "${GREEN}✅ Bootstrap complete!${NC}"
echo ""
echo "Next steps:"
echo " 1. Review CONTRIBUTING.adoc for contribution guidelines"
echo " 2. Read CLAUDE.adoc for AI assistant instructions"
echo " 3. Run 'just --list' to see available commands"
echo " 4. Start development server: 'just serve'"
echo ""
echo "For help:"
echo " • Documentation: cat README.adoc"
echo " • Task runner: just --list"
echo " • Rails commands: bin/rails --help"
echo ""