go-gin-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/git-manager.sh ADDED
@@ -0,0 +1,495 @@
1
+ #!/bin/bash
2
+
3
+ # Git Manager - Modern Git Management Script
4
+ # Author: Cascade AI
5
+ # Version: 1.0.0
6
+ # Description: A modern, quick, and easy-to-use Git management tool
7
+
8
+ set -e
9
+
10
+ # Colors for output
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ BLUE='\033[0;34m'
15
+ PURPLE='\033[0;35m'
16
+ CYAN='\033[0;36m'
17
+ WHITE='\033[1;37m'
18
+ NC='\033[0m' # No Color
19
+
20
+ # Emojis for better UX
21
+ ROCKET="🚀"
22
+ CHECK="✅"
23
+ CROSS="❌"
24
+ WARNING="âš ī¸"
25
+ INFO="â„šī¸"
26
+ BRANCH="đŸŒŋ"
27
+ COMMIT="📝"
28
+ PUSH="âŦ†ī¸"
29
+ PULL="âŦ‡ī¸"
30
+ MERGE="🔀"
31
+ TAG="đŸˇī¸"
32
+
33
+ # Print colored output
34
+ print_color() {
35
+ printf "${1}${2}${NC}\n"
36
+ }
37
+
38
+ # Print header
39
+ print_header() {
40
+ echo ""
41
+ print_color $CYAN "╔══════════════════════════════════════════════════════════════╗"
42
+ print_color $CYAN "║ ${ROCKET} GIT MANAGER ${ROCKET} ║"
43
+ print_color $CYAN "║ Modern Git Management Made Easy ║"
44
+ print_color $CYAN "╚══════════════════════════════════════════════════════════════╝"
45
+ echo ""
46
+ }
47
+
48
+ # Check if we're in a git repository
49
+ check_git_repo() {
50
+ if ! git rev-parse --git-dir > /dev/null 2>&1; then
51
+ print_color $RED "${CROSS} Not a git repository!"
52
+ echo "Run 'git init' to initialize a new repository or navigate to an existing one."
53
+ exit 1
54
+ fi
55
+ }
56
+
57
+ # Get current branch name
58
+ get_current_branch() {
59
+ git branch --show-current
60
+ }
61
+
62
+ # Get repository status
63
+ get_repo_status() {
64
+ local current_branch=$(get_current_branch)
65
+ local status_output=$(git status --porcelain)
66
+ local ahead_behind=$(git rev-list --left-right --count origin/$current_branch...$current_branch 2>/dev/null || echo "0 0")
67
+ local behind=$(echo $ahead_behind | cut -f1)
68
+ local ahead=$(echo $ahead_behind | cut -f2)
69
+
70
+ echo "Branch: $current_branch"
71
+ if [ ! -z "$status_output" ]; then
72
+ echo "Status: Changes detected"
73
+ else
74
+ echo "Status: Clean"
75
+ fi
76
+ echo "Ahead: $ahead commits | Behind: $behind commits"
77
+ }
78
+
79
+ # Show main menu
80
+ show_menu() {
81
+ print_header
82
+
83
+ # Show current repository status
84
+ print_color $BLUE "${INFO} Repository Status:"
85
+ get_repo_status
86
+ echo ""
87
+
88
+ print_color $WHITE "Choose an option:"
89
+ echo ""
90
+ print_color $GREEN " 1. ${COMMIT} Quick Commit (add all + commit + push)"
91
+ print_color $GREEN " 2. ${COMMIT} Smart Commit (interactive staging)"
92
+ print_color $YELLOW " 3. ${BRANCH} Branch Management"
93
+ print_color $BLUE " 4. ${PULL} Pull Latest Changes"
94
+ print_color $PURPLE " 5. ${PUSH} Push Current Branch"
95
+ print_color $CYAN " 6. ${MERGE} Merge Operations"
96
+ print_color $WHITE " 7. ${TAG} Tag Management"
97
+ print_color $YELLOW " 8. ${INFO} Repository Info"
98
+ print_color $GREEN " 9. 🔧 Git Utilities"
99
+ print_color $RED " 0. Exit"
100
+ echo ""
101
+ printf "Enter your choice [0-9]: "
102
+ }
103
+
104
+ # Quick commit function
105
+ quick_commit() {
106
+ print_color $CYAN "${ROCKET} Quick Commit Process"
107
+ echo ""
108
+
109
+ # Check for changes
110
+ if [ -z "$(git status --porcelain)" ]; then
111
+ print_color $YELLOW "${WARNING} No changes to commit!"
112
+ return
113
+ fi
114
+
115
+ # Show what will be committed
116
+ print_color $BLUE "Files to be committed:"
117
+ git status --short
118
+ echo ""
119
+
120
+ # Get commit message
121
+ printf "Enter commit message: "
122
+ read commit_message
123
+
124
+ if [ -z "$commit_message" ]; then
125
+ print_color $RED "${CROSS} Commit message cannot be empty!"
126
+ return
127
+ fi
128
+
129
+ # Add all files
130
+ print_color $YELLOW "Adding all files..."
131
+ git add .
132
+
133
+ # Commit
134
+ print_color $YELLOW "Committing changes..."
135
+ git commit -m "$commit_message"
136
+
137
+ # Push
138
+ printf "Push to remote? (y/N): "
139
+ read push_confirm
140
+ if [[ $push_confirm =~ ^[Yy]$ ]]; then
141
+ print_color $YELLOW "Pushing to remote..."
142
+ git push origin $(get_current_branch)
143
+ print_color $GREEN "${CHECK} Successfully committed and pushed!"
144
+ else
145
+ print_color $GREEN "${CHECK} Successfully committed!"
146
+ fi
147
+ }
148
+
149
+ # Smart commit function
150
+ smart_commit() {
151
+ print_color $CYAN "${ROCKET} Smart Commit Process"
152
+ echo ""
153
+
154
+ # Check for changes
155
+ if [ -z "$(git status --porcelain)" ]; then
156
+ print_color $YELLOW "${WARNING} No changes to commit!"
157
+ return
158
+ fi
159
+
160
+ # Interactive staging
161
+ print_color $BLUE "Current changes:"
162
+ git status --short
163
+ echo ""
164
+
165
+ printf "Use interactive staging? (y/N): "
166
+ read interactive
167
+
168
+ if [[ $interactive =~ ^[Yy]$ ]]; then
169
+ git add -i
170
+ else
171
+ printf "Add all files? (Y/n): "
172
+ read add_all
173
+ if [[ ! $add_all =~ ^[Nn]$ ]]; then
174
+ git add .
175
+ else
176
+ printf "Enter files to add (space-separated): "
177
+ read files_to_add
178
+ git add $files_to_add
179
+ fi
180
+ fi
181
+
182
+ # Show staged changes
183
+ echo ""
184
+ print_color $BLUE "Staged changes:"
185
+ git diff --cached --name-only
186
+ echo ""
187
+
188
+ # Get commit message
189
+ printf "Enter commit message: "
190
+ read commit_message
191
+
192
+ if [ -z "$commit_message" ]; then
193
+ print_color $RED "${CROSS} Commit message cannot be empty!"
194
+ return
195
+ fi
196
+
197
+ # Commit
198
+ git commit -m "$commit_message"
199
+ print_color $GREEN "${CHECK} Successfully committed!"
200
+
201
+ # Push option
202
+ printf "Push to remote? (y/N): "
203
+ read push_confirm
204
+ if [[ $push_confirm =~ ^[Yy]$ ]]; then
205
+ git push origin $(get_current_branch)
206
+ print_color $GREEN "${CHECK} Successfully pushed!"
207
+ fi
208
+ }
209
+
210
+ # Branch management
211
+ branch_management() {
212
+ print_color $CYAN "${BRANCH} Branch Management"
213
+ echo ""
214
+
215
+ print_color $WHITE "Choose an option:"
216
+ echo " 1. List all branches"
217
+ echo " 2. Create new branch"
218
+ echo " 3. Switch branch"
219
+ echo " 4. Delete branch"
220
+ echo " 5. Rename current branch"
221
+ echo " 0. Back to main menu"
222
+ echo ""
223
+ printf "Enter your choice [0-5]: "
224
+ read branch_choice
225
+
226
+ case $branch_choice in
227
+ 1)
228
+ print_color $BLUE "All branches:"
229
+ git branch -a
230
+ ;;
231
+ 2)
232
+ printf "Enter new branch name: "
233
+ read new_branch
234
+ if [ ! -z "$new_branch" ]; then
235
+ git checkout -b "$new_branch"
236
+ print_color $GREEN "${CHECK} Created and switched to branch: $new_branch"
237
+ fi
238
+ ;;
239
+ 3)
240
+ print_color $BLUE "Available branches:"
241
+ git branch
242
+ echo ""
243
+ printf "Enter branch name to switch to: "
244
+ read switch_branch
245
+ if [ ! -z "$switch_branch" ]; then
246
+ git checkout "$switch_branch"
247
+ print_color $GREEN "${CHECK} Switched to branch: $switch_branch"
248
+ fi
249
+ ;;
250
+ 4)
251
+ print_color $BLUE "Local branches:"
252
+ git branch
253
+ echo ""
254
+ printf "Enter branch name to delete: "
255
+ read delete_branch
256
+ if [ ! -z "$delete_branch" ]; then
257
+ printf "Are you sure? This cannot be undone (y/N): "
258
+ read confirm_delete
259
+ if [[ $confirm_delete =~ ^[Yy]$ ]]; then
260
+ git branch -D "$delete_branch"
261
+ print_color $GREEN "${CHECK} Deleted branch: $delete_branch"
262
+ fi
263
+ fi
264
+ ;;
265
+ 5)
266
+ printf "Enter new name for current branch: "
267
+ read new_name
268
+ if [ ! -z "$new_name" ]; then
269
+ git branch -m "$new_name"
270
+ print_color $GREEN "${CHECK} Renamed branch to: $new_name"
271
+ fi
272
+ ;;
273
+ 0)
274
+ return
275
+ ;;
276
+ *)
277
+ print_color $RED "${CROSS} Invalid option!"
278
+ ;;
279
+ esac
280
+
281
+ printf "\nPress Enter to continue..."
282
+ read
283
+ }
284
+
285
+ # Pull latest changes
286
+ pull_changes() {
287
+ print_color $CYAN "${PULL} Pulling Latest Changes"
288
+ echo ""
289
+
290
+ local current_branch=$(get_current_branch)
291
+ print_color $BLUE "Pulling changes for branch: $current_branch"
292
+
293
+ # Check for uncommitted changes
294
+ if [ ! -z "$(git status --porcelain)" ]; then
295
+ print_color $YELLOW "${WARNING} You have uncommitted changes!"
296
+ printf "Stash changes before pulling? (Y/n): "
297
+ read stash_confirm
298
+ if [[ ! $stash_confirm =~ ^[Nn]$ ]]; then
299
+ git stash push -m "Auto-stash before pull $(date)"
300
+ print_color $GREEN "${CHECK} Changes stashed"
301
+ fi
302
+ fi
303
+
304
+ # Pull changes
305
+ git pull origin "$current_branch"
306
+ print_color $GREEN "${CHECK} Successfully pulled latest changes!"
307
+
308
+ # Check if there are stashed changes
309
+ if git stash list | grep -q "Auto-stash before pull"; then
310
+ printf "Apply stashed changes? (Y/n): "
311
+ read apply_stash
312
+ if [[ ! $apply_stash =~ ^[Nn]$ ]]; then
313
+ git stash pop
314
+ print_color $GREEN "${CHECK} Stashed changes applied!"
315
+ fi
316
+ fi
317
+ }
318
+
319
+ # Push current branch
320
+ push_branch() {
321
+ print_color $CYAN "${PUSH} Pushing Current Branch"
322
+ echo ""
323
+
324
+ local current_branch=$(get_current_branch)
325
+ print_color $BLUE "Pushing branch: $current_branch"
326
+
327
+ # Check if branch exists on remote
328
+ if ! git ls-remote --heads origin "$current_branch" | grep -q "$current_branch"; then
329
+ printf "Branch doesn't exist on remote. Create it? (Y/n): "
330
+ read create_remote
331
+ if [[ ! $create_remote =~ ^[Nn]$ ]]; then
332
+ git push -u origin "$current_branch"
333
+ print_color $GREEN "${CHECK} Branch created and pushed to remote!"
334
+ fi
335
+ else
336
+ git push origin "$current_branch"
337
+ print_color $GREEN "${CHECK} Successfully pushed to remote!"
338
+ fi
339
+ }
340
+
341
+ # Repository info
342
+ repo_info() {
343
+ print_color $CYAN "${INFO} Repository Information"
344
+ echo ""
345
+
346
+ print_color $BLUE "Repository Details:"
347
+ echo "Remote URL: $(git remote get-url origin 2>/dev/null || echo 'No remote configured')"
348
+ echo "Current Branch: $(get_current_branch)"
349
+ echo "Total Commits: $(git rev-list --count HEAD 2>/dev/null || echo '0')"
350
+ echo "Contributors: $(git shortlog -sn | wc -l)"
351
+ echo ""
352
+
353
+ print_color $BLUE "Recent Commits:"
354
+ git log --oneline -10
355
+ echo ""
356
+
357
+ print_color $BLUE "Branch Status:"
358
+ git status --short
359
+
360
+ printf "\nPress Enter to continue..."
361
+ read
362
+ }
363
+
364
+ # Git utilities
365
+ git_utilities() {
366
+ print_color $CYAN "🔧 Git Utilities"
367
+ echo ""
368
+
369
+ print_color $WHITE "Choose a utility:"
370
+ echo " 1. Clean up merged branches"
371
+ echo " 2. Reset to last commit (soft)"
372
+ echo " 3. Reset to last commit (hard)"
373
+ echo " 4. View commit history (graph)"
374
+ echo " 5. Search commits"
375
+ echo " 6. Show file history"
376
+ echo " 0. Back to main menu"
377
+ echo ""
378
+ printf "Enter your choice [0-6]: "
379
+ read util_choice
380
+
381
+ case $util_choice in
382
+ 1)
383
+ print_color $YELLOW "Cleaning up merged branches..."
384
+ git branch --merged | grep -v "\*\|main\|master\|develop" | xargs -n 1 git branch -d 2>/dev/null || true
385
+ print_color $GREEN "${CHECK} Cleaned up merged branches!"
386
+ ;;
387
+ 2)
388
+ printf "Are you sure you want to soft reset to last commit? (y/N): "
389
+ read confirm_soft
390
+ if [[ $confirm_soft =~ ^[Yy]$ ]]; then
391
+ git reset --soft HEAD~1
392
+ print_color $GREEN "${CHECK} Soft reset completed!"
393
+ fi
394
+ ;;
395
+ 3)
396
+ printf "âš ī¸ This will permanently lose uncommitted changes! Continue? (y/N): "
397
+ read confirm_hard
398
+ if [[ $confirm_hard =~ ^[Yy]$ ]]; then
399
+ git reset --hard HEAD~1
400
+ print_color $GREEN "${CHECK} Hard reset completed!"
401
+ fi
402
+ ;;
403
+ 4)
404
+ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -20
405
+ ;;
406
+ 5)
407
+ printf "Enter search term: "
408
+ read search_term
409
+ if [ ! -z "$search_term" ]; then
410
+ git log --grep="$search_term" --oneline
411
+ fi
412
+ ;;
413
+ 6)
414
+ printf "Enter file path: "
415
+ read file_path
416
+ if [ ! -z "$file_path" ]; then
417
+ git log --follow --patch -- "$file_path"
418
+ fi
419
+ ;;
420
+ 0)
421
+ return
422
+ ;;
423
+ *)
424
+ print_color $RED "${CROSS} Invalid option!"
425
+ ;;
426
+ esac
427
+
428
+ printf "\nPress Enter to continue..."
429
+ read
430
+ }
431
+
432
+ # Main function
433
+ main() {
434
+ # Check if we're in a git repository
435
+ check_git_repo
436
+
437
+ while true; do
438
+ show_menu
439
+ read choice
440
+
441
+ case $choice in
442
+ 1)
443
+ quick_commit
444
+ printf "\nPress Enter to continue..."
445
+ read
446
+ ;;
447
+ 2)
448
+ smart_commit
449
+ printf "\nPress Enter to continue..."
450
+ read
451
+ ;;
452
+ 3)
453
+ branch_management
454
+ ;;
455
+ 4)
456
+ pull_changes
457
+ printf "\nPress Enter to continue..."
458
+ read
459
+ ;;
460
+ 5)
461
+ push_branch
462
+ printf "\nPress Enter to continue..."
463
+ read
464
+ ;;
465
+ 6)
466
+ print_color $YELLOW "${WARNING} Merge operations coming in next version!"
467
+ printf "\nPress Enter to continue..."
468
+ read
469
+ ;;
470
+ 7)
471
+ print_color $YELLOW "${WARNING} Tag management coming in next version!"
472
+ printf "\nPress Enter to continue..."
473
+ read
474
+ ;;
475
+ 8)
476
+ repo_info
477
+ ;;
478
+ 9)
479
+ git_utilities
480
+ ;;
481
+ 0)
482
+ print_color $GREEN "${CHECK} Thanks for using Git Manager!"
483
+ exit 0
484
+ ;;
485
+ *)
486
+ print_color $RED "${CROSS} Invalid option! Please try again."
487
+ printf "\nPress Enter to continue..."
488
+ read
489
+ ;;
490
+ esac
491
+ done
492
+ }
493
+
494
+ # Run the script
495
+ main "$@"
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "go-gin-cli",
3
+ "version": "1.0.0",
4
+ "main": "src/bin/index.js",
5
+ "bin": {
6
+ "gcg": "./src/bin/index.js"
7
+ },
8
+ "scripts": {
9
+ "gcg": "node ./src/bin/index.js"
10
+ },
11
+ "author": "",
12
+ "license": "MIT",
13
+ "description": "A CLI tool to generate Go/Gin clean architecture projects and modules",
14
+ "keywords": [
15
+ "golang",
16
+ "go",
17
+ "gin",
18
+ "gin-gonic",
19
+ "clean-architecture",
20
+ "module-generator",
21
+ "cli",
22
+ "gorm",
23
+ "postgresql",
24
+ "rest-api"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": ""
29
+ },
30
+ "engines": {
31
+ "node": ">=14.0.0"
32
+ },
33
+ "dependencies": {
34
+ "prompts": "^2.4.2"
35
+ }
36
+ }
package/prompt.md ADDED
@@ -0,0 +1,6 @@
1
+ covert and modify this package to golang package cli with npm
2
+ 1. Adjust the package based on current popular golang packages.
3
+ 2. base structure is by nestjs clean architecture like my nestjs project.
4
+ 3. use golang best practices.
5
+ 4. use gin-gonic for framework.
6
+ and etc...