Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·267 lines (231 loc) · 8.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·267 lines (231 loc) · 8.3 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/bin/bash
#
# Makepad Skills Installer
# https://github.com/ZhangHanDong/makepad-skills
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/ZhangHanDong/makepad-skills/main/install.sh | bash
# curl -fsSL https://raw.githubusercontent.com/ZhangHanDong/makepad-skills/main/install.sh | bash -s -- --with-hooks
# curl -fsSL https://raw.githubusercontent.com/ZhangHanDong/makepad-skills/main/install.sh | bash -s -- --target /path/to/project
#
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Default values
REPO_URL="https://github.com/ZhangHanDong/makepad-skills"
BRANCH="main"
TARGET_DIR=""
WITH_HOOKS=false
TEMP_DIR=""
# Print colored message
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[OK]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
# Print banner
print_banner() {
echo ""
echo -e "${BLUE}╔══════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║${NC} ${GREEN}Makepad Skills Installer v2.1.1${NC} ${BLUE}║${NC}"
echo -e "${BLUE}║${NC} Claude Code Skills for Makepad ${BLUE}║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════════╝${NC}"
echo ""
}
# Show usage
usage() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --target DIR Install to specific directory (default: current directory)"
echo " --with-hooks Also install and configure hooks"
echo " --branch BRANCH Use specific branch (default: main)"
echo " --help Show this help message"
echo ""
echo "Examples:"
echo " # Install to current project"
echo " $0"
echo ""
echo " # Install with hooks enabled"
echo " $0 --with-hooks"
echo ""
echo " # Install to specific project"
echo " $0 --target /path/to/my-makepad-project"
echo ""
}
# Parse arguments
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
--target)
TARGET_DIR="$2"
shift 2
;;
--with-hooks)
WITH_HOOKS=true
shift
;;
--branch)
BRANCH="$2"
shift 2
;;
--help)
usage
exit 0
;;
*)
error "Unknown option: $1"
;;
esac
done
}
# Check dependencies
check_deps() {
info "Checking dependencies..."
# Need either curl or git
if ! command -v curl &> /dev/null && ! command -v git &> /dev/null; then
error "Either curl or git is required. Please install one of them first."
fi
# Need unzip if using curl
if command -v curl &> /dev/null && ! command -v unzip &> /dev/null; then
if ! command -v git &> /dev/null; then
error "unzip is required when using curl. Please install unzip or git."
fi
warn "unzip not found, will use git instead"
fi
success "Dependencies OK"
}
# Determine target directory
determine_target() {
if [[ -z "$TARGET_DIR" ]]; then
TARGET_DIR="$(pwd)"
fi
# Expand to absolute path
TARGET_DIR="$(cd "$TARGET_DIR" 2>/dev/null && pwd)" || error "Target directory does not exist: $TARGET_DIR"
info "Target directory: $TARGET_DIR"
# Check if it looks like a project directory
if [[ ! -f "$TARGET_DIR/Cargo.toml" ]]; then
warn "No Cargo.toml found. This may not be a Rust/Makepad project."
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
}
# Clone or download repository
download_skills() {
info "Downloading makepad-skills..."
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
# Try ZIP download first (no git required)
local ZIP_URL="https://github.com/ZhangHanDong/makepad-skills/archive/refs/heads/${BRANCH}.zip"
if command -v curl &> /dev/null; then
curl -fsSL "$ZIP_URL" -o "$TEMP_DIR/makepad-skills.zip" 2>/dev/null
if [[ $? -eq 0 && -f "$TEMP_DIR/makepad-skills.zip" ]]; then
unzip -q "$TEMP_DIR/makepad-skills.zip" -d "$TEMP_DIR" 2>/dev/null
mv "$TEMP_DIR/makepad-skills-${BRANCH}" "$TEMP_DIR/makepad-skills"
success "Downloaded via ZIP"
return
fi
fi
# Fallback to git clone
if command -v git &> /dev/null; then
git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$TEMP_DIR/makepad-skills" 2>/dev/null && \
success "Downloaded via git" && return
fi
error "Failed to download. Please check your internet connection."
}
# Install skills
install_skills() {
local SKILLS_DIR="$TARGET_DIR/.claude/skills"
info "Installing skills to $SKILLS_DIR..."
# Create .claude directory if needed
mkdir -p "$TARGET_DIR/.claude"
# Backup existing skills if present
if [[ -d "$SKILLS_DIR" ]]; then
local BACKUP_DIR="$SKILLS_DIR.backup.$(date +%Y%m%d%H%M%S)"
warn "Existing skills found. Backing up to $BACKUP_DIR"
mv "$SKILLS_DIR" "$BACKUP_DIR"
fi
# Copy skills
cp -r "$TEMP_DIR/makepad-skills/skills" "$SKILLS_DIR"
success "Skills installed"
}
# Install hooks
install_hooks() {
if [[ "$WITH_HOOKS" != true ]]; then
return
fi
local SKILLS_DIR="$TARGET_DIR/.claude/skills"
local HOOKS_SRC="$SKILLS_DIR/99-evolution/hooks"
local HOOKS_DST="$SKILLS_DIR/hooks"
info "Installing hooks..."
if [[ -d "$HOOKS_SRC" ]]; then
cp -r "$HOOKS_SRC" "$HOOKS_DST"
chmod +x "$HOOKS_DST"/*.sh
success "Hooks installed to $HOOKS_DST"
echo ""
warn "To enable hooks, add the following to your .claude/settings.json:"
echo ""
echo -e "${YELLOW}$(cat "$HOOKS_SRC/settings.example.json")${NC}"
echo ""
else
warn "Hooks source not found, skipping"
fi
}
# Print summary
print_summary() {
local SKILLS_DIR="$TARGET_DIR/.claude/skills"
echo ""
echo -e "${GREEN}════════════════════════════════════════════════${NC}"
echo -e "${GREEN} Installation Complete!${NC}"
echo -e "${GREEN}════════════════════════════════════════════════${NC}"
echo ""
echo " Skills installed to: $SKILLS_DIR"
echo ""
echo " Structure:"
echo " ├── 00-getting-started/ (Project setup)"
echo " ├── 01-core/ (Layout, widgets, events)"
echo " ├── 02-components/ (Widget gallery)"
echo " ├── 03-graphics/ (Shaders, animations)"
echo " │ ├── _base/ (Official skills)"
echo " │ └── community/ (Your contributions)"
echo " ├── 04-patterns/ (Production patterns)"
echo " │ ├── _base/ (Official patterns)"
echo " │ └── community/ (Your contributions)"
echo " ├── 05-deployment/ (Build & package)"
echo " ├── 06-reference/ (Troubleshooting)"
echo " └── 99-evolution/ (Self-improvement)"
echo ""
echo " Quick Start:"
echo " 1. Open your project with Claude Code"
echo " 2. Ask: \"Create a simple Makepad counter app\""
echo ""
if [[ "$WITH_HOOKS" == true ]]; then
echo -e " ${YELLOW}Hooks are installed but need manual configuration.${NC}"
echo " See the settings.json snippet above."
echo ""
else
echo " To enable auto-evolution hooks, run:"
echo " curl -fsSL https://raw.githubusercontent.com/ZhangHanDong/makepad-skills/main/install.sh | bash -s -- --with-hooks --target $TARGET_DIR"
echo ""
fi
echo " Documentation: https://github.com/ZhangHanDong/makepad-skills"
echo ""
}
# Main
main() {
print_banner
parse_args "$@"
check_deps
determine_target
download_skills
install_skills
install_hooks
print_summary
}
main "$@"