-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgithub-push.sh
More file actions
executable file
·450 lines (380 loc) · 12.9 KB
/
Copy pathgithub-push.sh
File metadata and controls
executable file
·450 lines (380 loc) · 12.9 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
#!/bin/bash
# ===================================================================
# DevelopmentTranslation Bridge 3.0 - GitHub Push Automation Script
# ===================================================================
#
# Purpose: Automates the process of pushing your WordPress Bootstrap
# Claude 3.0 repository to GitHub with proper validation
# and error handling.
#
# Usage: ./github-push.sh
#
# Features:
# - Validates git configuration
# - Checks remote repository
# - Verifies branch name
# - Shows preview of changes
# - Confirms before pushing
# - Handles errors gracefully
# - Provides next steps
#
# Author: DevelopmentTranslation Bridge Team
# Version: 1.0.0
# ===================================================================
# Color definitions for beautiful output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
# Emoji support (works on most terminals)
CHECK="✅"
CROSS="❌"
ROCKET="🚀"
WARNING="⚠️"
INFO="ℹ️"
GEAR="⚙️"
SPARKLES="✨"
# Configuration
REPO_URL="https://github.com/coryhubbell/development-translation-bridge.git"
DEFAULT_BRANCH="main"
COMMIT_MESSAGE="🚀 Release: DevelopmentTranslation Bridge 3.0 - Translation Bridge™
Revolutionary WordPress development framework with Translation Bridge™
Features:
- World's first framework translator (Bootstrap ↔ DIVI ↔ Elementor)
- Claude AI integration for 10x productivity
- Complete component libraries for all frameworks
- Advanced WordPress Loop system
- Plugin conversion toolkit
This release includes:
- Translation Bridge™ core engine
- Universal translator class (9,000+ lines)
- Bootstrap, DIVI, and Elementor mappings
- Claude Code integration
- CLI tools and REST API
- Comprehensive documentation
Version: 3.0.0
Status: Production Ready
🌉 Translation Bridge™ - The framework that changes everything"
# ===================================================================
# Helper Functions
# ===================================================================
# Print a section header
print_header() {
echo ""
echo -e "${CYAN}═══════════════════════════════════════════════════════${NC}"
echo -e "${WHITE}$1${NC}"
echo -e "${CYAN}═══════════════════════════════════════════════════════${NC}"
echo ""
}
# Print success message
print_success() {
echo -e "${GREEN}${CHECK} $1${NC}"
}
# Print error message
print_error() {
echo -e "${RED}${CROSS} $1${NC}"
}
# Print warning message
print_warning() {
echo -e "${YELLOW}${WARNING} $1${NC}"
}
# Print info message
print_info() {
echo -e "${BLUE}${INFO} $1${NC}"
}
# Print step message
print_step() {
echo -e "${PURPLE}${GEAR} $1${NC}"
}
# Ask for confirmation
confirm() {
local prompt="$1"
local default="${2:-n}"
if [[ $default == "y" ]]; then
prompt="$prompt [Y/n]: "
else
prompt="$prompt [y/N]: "
fi
while true; do
read -p "$(echo -e ${YELLOW}${prompt}${NC})" yn
yn=${yn:-$default}
case $yn in
[Yy]* ) return 0;;
[Nn]* ) return 1;;
* ) echo "Please answer yes or no.";;
esac
done
}
# ===================================================================
# Validation Functions
# ===================================================================
# Check if git is installed
check_git_installed() {
print_step "Checking if git is installed..."
if ! command -v git &> /dev/null; then
print_error "Git is not installed!"
echo ""
echo "Please install git first:"
echo " macOS: brew install git"
echo " Ubuntu: sudo apt-get install git"
echo " Windows: https://git-scm.com/download/win"
echo ""
exit 1
fi
local git_version=$(git --version)
print_success "Git is installed: $git_version"
}
# Check if we're in a git repository
check_git_repo() {
print_step "Checking if this is a git repository..."
if ! git rev-parse --git-dir &> /dev/null; then
print_error "This is not a git repository!"
echo ""
if confirm "Would you like to initialize it now?"; then
git init
print_success "Git repository initialized"
else
print_error "Cannot continue without git repository"
exit 1
fi
else
print_success "Git repository found"
fi
}
# Check git configuration
check_git_config() {
print_step "Checking git configuration..."
local user_name=$(git config user.name)
local user_email=$(git config user.email)
if [[ -z "$user_name" ]] || [[ -z "$user_email" ]]; then
print_warning "Git user configuration is incomplete"
echo ""
echo "Current configuration:"
echo " Name: ${user_name:-<not set>}"
echo " Email: ${user_email:-<not set>}"
echo ""
if confirm "Would you like to configure it now?"; then
read -p "Enter your name: " user_name
read -p "Enter your email: " user_email
git config user.name "$user_name"
git config user.email "$user_email"
print_success "Git configuration updated"
else
print_warning "Continuing without complete git configuration"
fi
else
print_success "Git user: $user_name <$user_email>"
fi
}
# Check remote repository
check_remote() {
print_step "Checking remote repository..."
local current_remote=$(git remote get-url origin 2>/dev/null)
if [[ -z "$current_remote" ]]; then
print_warning "No remote repository configured"
echo ""
if confirm "Would you like to add the remote now?"; then
git remote add origin "$REPO_URL"
print_success "Remote added: $REPO_URL"
else
print_error "Cannot push without remote repository"
exit 1
fi
elif [[ "$current_remote" != "$REPO_URL" ]]; then
print_warning "Remote URL mismatch!"
echo ""
echo "Current: $current_remote"
echo "Expected: $REPO_URL"
echo ""
if confirm "Would you like to update the remote URL?"; then
git remote set-url origin "$REPO_URL"
print_success "Remote URL updated"
else
print_warning "Continuing with current remote: $current_remote"
fi
else
print_success "Remote configured: $REPO_URL"
fi
}
# Check current branch
check_branch() {
print_step "Checking current branch..."
local current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ -z "$current_branch" ]]; then
print_warning "No commits yet, branch will be created on first commit"
current_branch="$DEFAULT_BRANCH"
elif [[ "$current_branch" != "$DEFAULT_BRANCH" ]] && [[ "$current_branch" != "master" ]]; then
print_warning "Current branch: $current_branch"
echo ""
if confirm "Would you like to switch to $DEFAULT_BRANCH branch?"; then
git checkout -b "$DEFAULT_BRANCH" 2>/dev/null || git checkout "$DEFAULT_BRANCH"
print_success "Switched to $DEFAULT_BRANCH branch"
current_branch="$DEFAULT_BRANCH"
fi
elif [[ "$current_branch" == "master" ]]; then
print_warning "Current branch is 'master'"
echo ""
if confirm "Would you like to rename it to 'main'?"; then
git branch -m master main
print_success "Branch renamed to 'main'"
current_branch="main"
fi
else
print_success "Current branch: $current_branch"
fi
echo "$current_branch"
}
# ===================================================================
# Main Push Functions
# ===================================================================
# Show what will be pushed
show_changes() {
print_header "Preview of Changes"
print_step "Files to be committed:"
echo ""
# Show status
git status --short
echo ""
print_step "Commit statistics:"
echo ""
# Count files
local total_files=$(git ls-files | wc -l | tr -d ' ')
local new_files=$(git ls-files --others --exclude-standard | wc -l | tr -d ' ')
local modified_files=$(git diff --name-only | wc -l | tr -d ' ')
echo " Total files in repo: $total_files"
echo " New files: $new_files"
echo " Modified files: $modified_files"
echo ""
}
# Stage all files
stage_files() {
print_step "Staging all files..."
git add -A
if [[ $? -eq 0 ]]; then
print_success "All files staged"
else
print_error "Failed to stage files"
exit 1
fi
}
# Create commit
create_commit() {
print_step "Creating commit..."
git commit -m "$COMMIT_MESSAGE"
if [[ $? -eq 0 ]]; then
print_success "Commit created"
else
print_warning "Commit may have failed or there are no changes"
fi
}
# Push to GitHub
push_to_github() {
local branch="$1"
print_step "Pushing to GitHub..."
echo ""
git push -u origin "$branch"
if [[ $? -eq 0 ]]; then
print_success "Successfully pushed to GitHub!"
return 0
else
print_error "Failed to push to GitHub"
echo ""
echo "Common issues:"
echo " 1. Authentication failed - use Personal Access Token"
echo " 2. Repository doesn't exist - create it on GitHub first"
echo " 3. Push rejected - try: git pull --rebase origin $branch"
echo ""
return 1
fi
}
# ===================================================================
# Main Script
# ===================================================================
main() {
# Print welcome banner
echo ""
echo -e "${PURPLE}${SPARKLES}════════════════════════════════════════════════════════${SPARKLES}${NC}"
echo -e "${WHITE} DevelopmentTranslation Bridge 3.0 - GitHub Push ${NC}"
echo -e "${PURPLE}${SPARKLES}════════════════════════════════════════════════════════${SPARKLES}${NC}"
echo ""
# Run validation checks
print_header "Step 1: Validation"
check_git_installed
check_git_repo
check_git_config
check_remote
local branch=$(check_branch)
# Show what will be pushed
print_header "Step 2: Preview"
show_changes
# Confirm push
print_header "Step 3: Confirmation"
echo ""
echo "You are about to:"
echo " 1. Stage all files"
echo " 2. Create a commit with the v3.0 release message"
echo " 3. Push to: $REPO_URL"
echo " 4. Branch: $branch"
echo ""
if ! confirm "Do you want to continue?" "y"; then
print_warning "Push cancelled by user"
exit 0
fi
# Execute push
print_header "Step 4: Pushing to GitHub"
stage_files
create_commit
if push_to_github "$branch"; then
# Success!
print_header "🎉 Success!"
echo ""
echo -e "${GREEN}${ROCKET} Your DevelopmentTranslation Bridge 3.0 is now on GitHub!${NC}"
echo ""
echo "Next steps:"
echo ""
echo " 1. Visit your repository:"
echo " ${CYAN}https://github.com/coryhubbell/development-translation-bridge${NC}"
echo ""
echo " 2. Create a release:"
echo " - Go to Releases → New Release"
echo " - Tag: v3.0.0"
echo " - Title: Translation Bridge™ - World's First Framework Translator"
echo " - Copy release notes from RELEASE_NOTES.md"
echo ""
echo " 3. Share with the community:"
echo " - Twitter/X, Reddit r/wordpress, LinkedIn"
echo " - Use hashtags: #WordPress #WebDev #AI"
echo ""
echo -e "${PURPLE}${SPARKLES} The WordPress community is waiting! ${SPARKLES}${NC}"
echo ""
else
print_header "Push Failed"
echo ""
echo "Don't worry! Try these solutions:"
echo ""
echo " 1. Check authentication:"
echo " - Use Personal Access Token instead of password"
echo " - Or setup SSH keys (see .claude-code/SETUP_GUIDE.md)"
echo ""
echo " 2. Create repository on GitHub first:"
echo " - Go to https://github.com/new"
echo " - Name: development-translation-bridge"
echo " - Don't initialize with README"
echo ""
echo " 3. Try manual push:"
echo " git push -u origin $branch"
echo ""
echo "For detailed help, see:"
echo " - .claude-code/SETUP_GUIDE.md"
echo " - TERMINAL_COMMANDS.md"
echo ""
exit 1
fi
}
# Run main function
main
exit 0