aidevops 2.52.1
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/.agent/AGENTS.md +614 -0
- package/.agent/accounts.md +65 -0
- package/.agent/aidevops/add-new-mcp-to-aidevops.md +456 -0
- package/.agent/aidevops/api-integrations.md +335 -0
- package/.agent/aidevops/architecture.md +510 -0
- package/.agent/aidevops/configs.md +274 -0
- package/.agent/aidevops/docs.md +244 -0
- package/.agent/aidevops/extension.md +311 -0
- package/.agent/aidevops/mcp-integrations.md +340 -0
- package/.agent/aidevops/mcp-troubleshooting.md +162 -0
- package/.agent/aidevops/memory-patterns.md +172 -0
- package/.agent/aidevops/providers.md +217 -0
- package/.agent/aidevops/recommendations.md +321 -0
- package/.agent/aidevops/requirements.md +301 -0
- package/.agent/aidevops/resources.md +214 -0
- package/.agent/aidevops/security-requirements.md +174 -0
- package/.agent/aidevops/security.md +350 -0
- package/.agent/aidevops/service-links.md +400 -0
- package/.agent/aidevops/services.md +357 -0
- package/.agent/aidevops/setup.md +153 -0
- package/.agent/aidevops/troubleshooting.md +389 -0
- package/.agent/aidevops.md +124 -0
- package/.agent/build-plus.md +244 -0
- package/.agent/content/guidelines.md +109 -0
- package/.agent/content.md +87 -0
- package/.agent/health.md +59 -0
- package/.agent/legal.md +59 -0
- package/.agent/loop-state/full-loop.local.md +16 -0
- package/.agent/loop-state/ralph-loop.local.md +10 -0
- package/.agent/marketing.md +440 -0
- package/.agent/memory/README.md +260 -0
- package/.agent/onboarding.md +796 -0
- package/.agent/plan-plus.md +245 -0
- package/.agent/research.md +100 -0
- package/.agent/sales.md +333 -0
- package/.agent/scripts/101domains-helper.sh +701 -0
- package/.agent/scripts/add-missing-returns.sh +140 -0
- package/.agent/scripts/agent-browser-helper.sh +311 -0
- package/.agent/scripts/agno-setup.sh +712 -0
- package/.agent/scripts/ahrefs-mcp-wrapper.js +168 -0
- package/.agent/scripts/aidevops-update-check.sh +71 -0
- package/.agent/scripts/ampcode-cli.sh +522 -0
- package/.agent/scripts/auto-version-bump.sh +156 -0
- package/.agent/scripts/autogen-helper.sh +512 -0
- package/.agent/scripts/beads-sync-helper.sh +596 -0
- package/.agent/scripts/closte-helper.sh +5 -0
- package/.agent/scripts/cloudron-helper.sh +321 -0
- package/.agent/scripts/codacy-cli-chunked.sh +581 -0
- package/.agent/scripts/codacy-cli.sh +442 -0
- package/.agent/scripts/code-audit-helper.sh +5 -0
- package/.agent/scripts/coderabbit-cli.sh +417 -0
- package/.agent/scripts/coderabbit-pro-analysis.sh +238 -0
- package/.agent/scripts/commands/code-simplifier.md +86 -0
- package/.agent/scripts/commands/full-loop.md +246 -0
- package/.agent/scripts/commands/postflight-loop.md +103 -0
- package/.agent/scripts/commands/recall.md +182 -0
- package/.agent/scripts/commands/remember.md +132 -0
- package/.agent/scripts/commands/save-todo.md +175 -0
- package/.agent/scripts/commands/session-review.md +154 -0
- package/.agent/scripts/comprehensive-quality-fix.sh +106 -0
- package/.agent/scripts/context-builder-helper.sh +522 -0
- package/.agent/scripts/coolify-cli-helper.sh +674 -0
- package/.agent/scripts/coolify-helper.sh +380 -0
- package/.agent/scripts/crawl4ai-examples.sh +401 -0
- package/.agent/scripts/crawl4ai-helper.sh +1078 -0
- package/.agent/scripts/crewai-helper.sh +681 -0
- package/.agent/scripts/dev-browser-helper.sh +513 -0
- package/.agent/scripts/dns-helper.sh +396 -0
- package/.agent/scripts/domain-research-helper.sh +917 -0
- package/.agent/scripts/dspy-helper.sh +285 -0
- package/.agent/scripts/dspyground-helper.sh +291 -0
- package/.agent/scripts/eeat-score-helper.sh +1242 -0
- package/.agent/scripts/efficient-return-fix.sh +92 -0
- package/.agent/scripts/extract-opencode-prompts.sh +128 -0
- package/.agent/scripts/find-missing-returns.sh +113 -0
- package/.agent/scripts/fix-auth-headers.sh +104 -0
- package/.agent/scripts/fix-common-strings.sh +254 -0
- package/.agent/scripts/fix-content-type.sh +100 -0
- package/.agent/scripts/fix-error-messages.sh +130 -0
- package/.agent/scripts/fix-misplaced-returns.sh +74 -0
- package/.agent/scripts/fix-remaining-literals.sh +152 -0
- package/.agent/scripts/fix-return-statements.sh +41 -0
- package/.agent/scripts/fix-s131-default-cases.sh +249 -0
- package/.agent/scripts/fix-sc2155-simple.sh +102 -0
- package/.agent/scripts/fix-shellcheck-critical.sh +187 -0
- package/.agent/scripts/fix-string-literals.sh +273 -0
- package/.agent/scripts/full-loop-helper.sh +773 -0
- package/.agent/scripts/generate-opencode-agents.sh +497 -0
- package/.agent/scripts/generate-opencode-commands.sh +1629 -0
- package/.agent/scripts/generate-skills.sh +366 -0
- package/.agent/scripts/git-platforms-helper.sh +640 -0
- package/.agent/scripts/gitea-cli-helper.sh +743 -0
- package/.agent/scripts/github-cli-helper.sh +702 -0
- package/.agent/scripts/gitlab-cli-helper.sh +682 -0
- package/.agent/scripts/gsc-add-user-helper.sh +325 -0
- package/.agent/scripts/gsc-sitemap-helper.sh +678 -0
- package/.agent/scripts/hetzner-helper.sh +485 -0
- package/.agent/scripts/hostinger-helper.sh +229 -0
- package/.agent/scripts/keyword-research-helper.sh +1815 -0
- package/.agent/scripts/langflow-helper.sh +544 -0
- package/.agent/scripts/linkedin-automation.py +241 -0
- package/.agent/scripts/linter-manager.sh +599 -0
- package/.agent/scripts/linters-local.sh +434 -0
- package/.agent/scripts/list-keys-helper.sh +488 -0
- package/.agent/scripts/local-browser-automation.py +339 -0
- package/.agent/scripts/localhost-helper.sh +744 -0
- package/.agent/scripts/loop-common.sh +806 -0
- package/.agent/scripts/mainwp-helper.sh +728 -0
- package/.agent/scripts/markdown-formatter.sh +338 -0
- package/.agent/scripts/markdown-lint-fix.sh +311 -0
- package/.agent/scripts/mass-fix-returns.sh +58 -0
- package/.agent/scripts/mcp-diagnose.sh +167 -0
- package/.agent/scripts/mcp-inspector-helper.sh +449 -0
- package/.agent/scripts/memory-helper.sh +650 -0
- package/.agent/scripts/monitor-code-review.sh +255 -0
- package/.agent/scripts/onboarding-helper.sh +706 -0
- package/.agent/scripts/opencode-github-setup-helper.sh +797 -0
- package/.agent/scripts/opencode-test-helper.sh +213 -0
- package/.agent/scripts/pagespeed-helper.sh +464 -0
- package/.agent/scripts/pandoc-helper.sh +362 -0
- package/.agent/scripts/postflight-check.sh +555 -0
- package/.agent/scripts/pre-commit-hook.sh +259 -0
- package/.agent/scripts/pre-edit-check.sh +169 -0
- package/.agent/scripts/qlty-cli.sh +356 -0
- package/.agent/scripts/quality-cli-manager.sh +525 -0
- package/.agent/scripts/quality-feedback-helper.sh +462 -0
- package/.agent/scripts/quality-fix.sh +263 -0
- package/.agent/scripts/quality-loop-helper.sh +1108 -0
- package/.agent/scripts/ralph-loop-helper.sh +836 -0
- package/.agent/scripts/ralph-upstream-check.sh +341 -0
- package/.agent/scripts/secretlint-helper.sh +847 -0
- package/.agent/scripts/servers-helper.sh +241 -0
- package/.agent/scripts/ses-helper.sh +619 -0
- package/.agent/scripts/session-review-helper.sh +404 -0
- package/.agent/scripts/setup-linters-wizard.sh +379 -0
- package/.agent/scripts/setup-local-api-keys.sh +330 -0
- package/.agent/scripts/setup-mcp-integrations.sh +472 -0
- package/.agent/scripts/shared-constants.sh +246 -0
- package/.agent/scripts/site-crawler-helper.sh +1487 -0
- package/.agent/scripts/snyk-helper.sh +940 -0
- package/.agent/scripts/sonarcloud-autofix.sh +193 -0
- package/.agent/scripts/sonarcloud-cli.sh +191 -0
- package/.agent/scripts/sonarscanner-cli.sh +455 -0
- package/.agent/scripts/spaceship-helper.sh +747 -0
- package/.agent/scripts/stagehand-helper.sh +321 -0
- package/.agent/scripts/stagehand-python-helper.sh +321 -0
- package/.agent/scripts/stagehand-python-setup.sh +441 -0
- package/.agent/scripts/stagehand-setup.sh +439 -0
- package/.agent/scripts/system-cleanup.sh +340 -0
- package/.agent/scripts/terminal-title-helper.sh +388 -0
- package/.agent/scripts/terminal-title-setup.sh +549 -0
- package/.agent/scripts/test-stagehand-both-integration.sh +317 -0
- package/.agent/scripts/test-stagehand-integration.sh +309 -0
- package/.agent/scripts/test-stagehand-python-integration.sh +341 -0
- package/.agent/scripts/todo-ready.sh +263 -0
- package/.agent/scripts/tool-version-check.sh +362 -0
- package/.agent/scripts/toon-helper.sh +469 -0
- package/.agent/scripts/twilio-helper.sh +917 -0
- package/.agent/scripts/updown-helper.sh +279 -0
- package/.agent/scripts/validate-mcp-integrations.sh +250 -0
- package/.agent/scripts/validate-version-consistency.sh +131 -0
- package/.agent/scripts/vaultwarden-helper.sh +597 -0
- package/.agent/scripts/vercel-cli-helper.sh +816 -0
- package/.agent/scripts/verify-mirrors.sh +169 -0
- package/.agent/scripts/version-manager.sh +831 -0
- package/.agent/scripts/webhosting-helper.sh +471 -0
- package/.agent/scripts/webhosting-verify.sh +238 -0
- package/.agent/scripts/wordpress-mcp-helper.sh +508 -0
- package/.agent/scripts/worktree-helper.sh +595 -0
- package/.agent/scripts/worktree-sessions.sh +577 -0
- package/.agent/seo/dataforseo.md +215 -0
- package/.agent/seo/domain-research.md +532 -0
- package/.agent/seo/eeat-score.md +659 -0
- package/.agent/seo/google-search-console.md +366 -0
- package/.agent/seo/gsc-sitemaps.md +282 -0
- package/.agent/seo/keyword-research.md +521 -0
- package/.agent/seo/serper.md +278 -0
- package/.agent/seo/site-crawler.md +387 -0
- package/.agent/seo.md +236 -0
- package/.agent/services/accounting/quickfile.md +159 -0
- package/.agent/services/communications/telfon.md +470 -0
- package/.agent/services/communications/twilio.md +569 -0
- package/.agent/services/crm/fluentcrm.md +449 -0
- package/.agent/services/email/ses.md +399 -0
- package/.agent/services/hosting/101domains.md +378 -0
- package/.agent/services/hosting/closte.md +177 -0
- package/.agent/services/hosting/cloudflare.md +251 -0
- package/.agent/services/hosting/cloudron.md +478 -0
- package/.agent/services/hosting/dns-providers.md +335 -0
- package/.agent/services/hosting/domain-purchasing.md +344 -0
- package/.agent/services/hosting/hetzner.md +327 -0
- package/.agent/services/hosting/hostinger.md +287 -0
- package/.agent/services/hosting/localhost.md +419 -0
- package/.agent/services/hosting/spaceship.md +353 -0
- package/.agent/services/hosting/webhosting.md +330 -0
- package/.agent/social-media.md +69 -0
- package/.agent/templates/plans-template.md +114 -0
- package/.agent/templates/prd-template.md +129 -0
- package/.agent/templates/tasks-template.md +108 -0
- package/.agent/templates/todo-template.md +89 -0
- package/.agent/tools/ai-assistants/agno.md +471 -0
- package/.agent/tools/ai-assistants/capsolver.md +326 -0
- package/.agent/tools/ai-assistants/configuration.md +221 -0
- package/.agent/tools/ai-assistants/overview.md +209 -0
- package/.agent/tools/ai-assistants/status.md +171 -0
- package/.agent/tools/ai-assistants/windsurf.md +193 -0
- package/.agent/tools/ai-orchestration/autogen.md +406 -0
- package/.agent/tools/ai-orchestration/crewai.md +445 -0
- package/.agent/tools/ai-orchestration/langflow.md +405 -0
- package/.agent/tools/ai-orchestration/openprose.md +487 -0
- package/.agent/tools/ai-orchestration/overview.md +362 -0
- package/.agent/tools/ai-orchestration/packaging.md +647 -0
- package/.agent/tools/browser/agent-browser.md +464 -0
- package/.agent/tools/browser/browser-automation.md +400 -0
- package/.agent/tools/browser/chrome-devtools.md +282 -0
- package/.agent/tools/browser/crawl4ai-integration.md +422 -0
- package/.agent/tools/browser/crawl4ai-resources.md +277 -0
- package/.agent/tools/browser/crawl4ai-usage.md +416 -0
- package/.agent/tools/browser/crawl4ai.md +585 -0
- package/.agent/tools/browser/dev-browser.md +341 -0
- package/.agent/tools/browser/pagespeed.md +260 -0
- package/.agent/tools/browser/playwright.md +266 -0
- package/.agent/tools/browser/playwriter.md +310 -0
- package/.agent/tools/browser/stagehand-examples.md +456 -0
- package/.agent/tools/browser/stagehand-python.md +483 -0
- package/.agent/tools/browser/stagehand.md +421 -0
- package/.agent/tools/build-agent/agent-review.md +224 -0
- package/.agent/tools/build-agent/build-agent.md +784 -0
- package/.agent/tools/build-mcp/aidevops-plugin.md +476 -0
- package/.agent/tools/build-mcp/api-wrapper.md +445 -0
- package/.agent/tools/build-mcp/build-mcp.md +240 -0
- package/.agent/tools/build-mcp/deployment.md +401 -0
- package/.agent/tools/build-mcp/server-patterns.md +632 -0
- package/.agent/tools/build-mcp/transports.md +366 -0
- package/.agent/tools/code-review/auditing.md +383 -0
- package/.agent/tools/code-review/automation.md +219 -0
- package/.agent/tools/code-review/best-practices.md +203 -0
- package/.agent/tools/code-review/codacy.md +151 -0
- package/.agent/tools/code-review/code-simplifier.md +174 -0
- package/.agent/tools/code-review/code-standards.md +309 -0
- package/.agent/tools/code-review/coderabbit.md +101 -0
- package/.agent/tools/code-review/management.md +155 -0
- package/.agent/tools/code-review/qlty.md +248 -0
- package/.agent/tools/code-review/secretlint.md +565 -0
- package/.agent/tools/code-review/setup.md +250 -0
- package/.agent/tools/code-review/snyk.md +563 -0
- package/.agent/tools/code-review/tools.md +230 -0
- package/.agent/tools/content/summarize.md +353 -0
- package/.agent/tools/context/augment-context-engine.md +468 -0
- package/.agent/tools/context/context-builder-agent.md +76 -0
- package/.agent/tools/context/context-builder.md +375 -0
- package/.agent/tools/context/context7.md +371 -0
- package/.agent/tools/context/dspy.md +302 -0
- package/.agent/tools/context/dspyground.md +374 -0
- package/.agent/tools/context/llm-tldr.md +219 -0
- package/.agent/tools/context/osgrep.md +488 -0
- package/.agent/tools/context/prompt-optimization.md +338 -0
- package/.agent/tools/context/toon.md +292 -0
- package/.agent/tools/conversion/pandoc.md +304 -0
- package/.agent/tools/credentials/api-key-management.md +154 -0
- package/.agent/tools/credentials/api-key-setup.md +224 -0
- package/.agent/tools/credentials/environment-variables.md +180 -0
- package/.agent/tools/credentials/vaultwarden.md +382 -0
- package/.agent/tools/data-extraction/outscraper.md +974 -0
- package/.agent/tools/deployment/coolify-cli.md +388 -0
- package/.agent/tools/deployment/coolify-setup.md +353 -0
- package/.agent/tools/deployment/coolify.md +345 -0
- package/.agent/tools/deployment/vercel.md +390 -0
- package/.agent/tools/git/authentication.md +132 -0
- package/.agent/tools/git/gitea-cli.md +193 -0
- package/.agent/tools/git/github-actions.md +207 -0
- package/.agent/tools/git/github-cli.md +223 -0
- package/.agent/tools/git/gitlab-cli.md +190 -0
- package/.agent/tools/git/opencode-github-security.md +350 -0
- package/.agent/tools/git/opencode-github.md +328 -0
- package/.agent/tools/git/opencode-gitlab.md +252 -0
- package/.agent/tools/git/security.md +196 -0
- package/.agent/tools/git.md +207 -0
- package/.agent/tools/opencode/oh-my-opencode.md +375 -0
- package/.agent/tools/opencode/opencode-anthropic-auth.md +446 -0
- package/.agent/tools/opencode/opencode.md +651 -0
- package/.agent/tools/social-media/bird.md +437 -0
- package/.agent/tools/task-management/beads.md +336 -0
- package/.agent/tools/terminal/terminal-title.md +251 -0
- package/.agent/tools/ui/shadcn.md +196 -0
- package/.agent/tools/ui/ui-skills.md +115 -0
- package/.agent/tools/wordpress/localwp.md +311 -0
- package/.agent/tools/wordpress/mainwp.md +391 -0
- package/.agent/tools/wordpress/scf.md +527 -0
- package/.agent/tools/wordpress/wp-admin.md +729 -0
- package/.agent/tools/wordpress/wp-dev.md +940 -0
- package/.agent/tools/wordpress/wp-preferred.md +398 -0
- package/.agent/tools/wordpress.md +95 -0
- package/.agent/workflows/branch/bugfix.md +63 -0
- package/.agent/workflows/branch/chore.md +95 -0
- package/.agent/workflows/branch/experiment.md +115 -0
- package/.agent/workflows/branch/feature.md +59 -0
- package/.agent/workflows/branch/hotfix.md +98 -0
- package/.agent/workflows/branch/refactor.md +92 -0
- package/.agent/workflows/branch/release.md +96 -0
- package/.agent/workflows/branch.md +347 -0
- package/.agent/workflows/bug-fixing.md +267 -0
- package/.agent/workflows/changelog.md +129 -0
- package/.agent/workflows/code-audit-remote.md +279 -0
- package/.agent/workflows/conversation-starter.md +69 -0
- package/.agent/workflows/error-feedback.md +578 -0
- package/.agent/workflows/feature-development.md +355 -0
- package/.agent/workflows/git-workflow.md +702 -0
- package/.agent/workflows/multi-repo-workspace.md +268 -0
- package/.agent/workflows/plans.md +709 -0
- package/.agent/workflows/postflight.md +604 -0
- package/.agent/workflows/pr.md +571 -0
- package/.agent/workflows/preflight.md +278 -0
- package/.agent/workflows/ralph-loop.md +773 -0
- package/.agent/workflows/release.md +498 -0
- package/.agent/workflows/session-manager.md +254 -0
- package/.agent/workflows/session-review.md +311 -0
- package/.agent/workflows/sql-migrations.md +631 -0
- package/.agent/workflows/version-bump.md +283 -0
- package/.agent/workflows/wiki-update.md +333 -0
- package/.agent/workflows/worktree.md +477 -0
- package/LICENSE +21 -0
- package/README.md +1446 -0
- package/VERSION +1 -0
- package/aidevops.sh +1746 -0
- package/bin/aidevops +21 -0
- package/package.json +75 -0
- package/scripts/npm-postinstall.js +60 -0
- package/setup.sh +2366 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
+
|
|
4
|
+
# GitHub CLI Helper Script
|
|
5
|
+
# Comprehensive GitHub management using GitHub CLI (gh)
|
|
6
|
+
# Managed by AI DevOps Framework
|
|
7
|
+
|
|
8
|
+
# Set strict mode
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
# ------------------------------------------------------------------------------
|
|
12
|
+
# CONFIGURATION & CONSTANTS
|
|
13
|
+
# ------------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit
|
|
16
|
+
readonly SCRIPT_DIR="$script_dir"
|
|
17
|
+
|
|
18
|
+
repo_root="$(dirname "$SCRIPT_DIR")"
|
|
19
|
+
readonly REPO_ROOT="$repo_root"
|
|
20
|
+
readonly CONFIG_FILE="$REPO_ROOT/configs/github-cli-config.json"
|
|
21
|
+
|
|
22
|
+
# Colors
|
|
23
|
+
readonly BLUE='\033[0;34m'
|
|
24
|
+
readonly GREEN='\033[0;32m'
|
|
25
|
+
readonly YELLOW='\033[1;33m'
|
|
26
|
+
readonly RED='\033[0;31m'
|
|
27
|
+
readonly NC='\033[0m'
|
|
28
|
+
|
|
29
|
+
# Common constants
|
|
30
|
+
readonly ERROR_UNKNOWN_COMMAND="Unknown command:"
|
|
31
|
+
# Error Messages
|
|
32
|
+
readonly ERROR_CONFIG_MISSING="Configuration file not found at $CONFIG_FILE"
|
|
33
|
+
readonly ERROR_GH_NOT_INSTALLED="GitHub CLI (gh) is required but not installed"
|
|
34
|
+
readonly ERROR_NOT_LOGGED_IN="GitHub CLI is not authenticated. Run 'gh auth login'"
|
|
35
|
+
readonly ERROR_ACCOUNT_MISSING="Account configuration not found"
|
|
36
|
+
readonly ERROR_ARGS_MISSING="Missing required arguments"
|
|
37
|
+
readonly ERROR_API_FAILED="GitHub API request failed"
|
|
38
|
+
|
|
39
|
+
readonly ERROR_REPO_NAME_REQUIRED="Repository name is required"
|
|
40
|
+
readonly ERROR_ISSUE_TITLE_REQUIRED="Issue title is required"
|
|
41
|
+
readonly ERROR_ISSUE_NUMBER_REQUIRED="Issue number is required"
|
|
42
|
+
readonly ERROR_PR_TITLE_REQUIRED="Pull request title is required"
|
|
43
|
+
readonly ERROR_PR_NUMBER_REQUIRED="Pull request number is required"
|
|
44
|
+
readonly ERROR_BRANCH_NAME_REQUIRED="Branch name is required"
|
|
45
|
+
readonly ERROR_OWNER_NOT_CONFIGURED="Owner not configured for account"
|
|
46
|
+
readonly ERROR_FAILED_TO_READ_CONFIG="Failed to read configuration"
|
|
47
|
+
|
|
48
|
+
# Success Messages
|
|
49
|
+
readonly SUCCESS_REPO_CREATED="Repository created successfully"
|
|
50
|
+
readonly SUCCESS_ISSUE_CREATED="Issue created successfully"
|
|
51
|
+
readonly SUCCESS_PR_CREATED="Pull request created successfully"
|
|
52
|
+
readonly SUCCESS_BRANCH_CREATED="Branch created successfully"
|
|
53
|
+
readonly SUCCESS_ISSUE_CLOSED="Issue closed successfully"
|
|
54
|
+
readonly SUCCESS_PR_MERGED="Pull request merged successfully"
|
|
55
|
+
|
|
56
|
+
# Common constants
|
|
57
|
+
readonly CONTENT_TYPE_JSON="$CONTENT_TYPE_JSON"
|
|
58
|
+
readonly AUTH_HEADER_TOKEN="Authorization: token"
|
|
59
|
+
|
|
60
|
+
# ------------------------------------------------------------------------------
|
|
61
|
+
# UTILITY FUNCTIONS
|
|
62
|
+
# ------------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
print_info() {
|
|
65
|
+
local msg="$1"
|
|
66
|
+
echo -e "${BLUE}[INFO]${NC} $msg"
|
|
67
|
+
return 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
print_success() {
|
|
71
|
+
local msg="$1"
|
|
72
|
+
echo -e "${GREEN}[SUCCESS]${NC} $msg"
|
|
73
|
+
return 0
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
print_warning() {
|
|
77
|
+
local msg="$1"
|
|
78
|
+
echo -e "${YELLOW}[WARNING]${NC} $msg"
|
|
79
|
+
return 0
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
print_error() {
|
|
83
|
+
local msg="$1"
|
|
84
|
+
echo -e "${RED}[ERROR]${NC} $msg" >&2
|
|
85
|
+
return 0
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# ------------------------------------------------------------------------------
|
|
89
|
+
# DEPENDENCY CHECKING
|
|
90
|
+
# ------------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
check_dependencies() {
|
|
93
|
+
if ! command -v gh &> /dev/null; then
|
|
94
|
+
print_error "$ERROR_GH_NOT_INSTALLED"
|
|
95
|
+
print_info "Install GitHub CLI:"
|
|
96
|
+
print_info " macOS: brew install gh"
|
|
97
|
+
print_info " Ubuntu: sudo apt install gh"
|
|
98
|
+
print_info " Other: https://cli.github.com/manual/installation"
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
if ! gh auth status &> /dev/null; then
|
|
103
|
+
print_error "$ERROR_NOT_LOGGED_IN"
|
|
104
|
+
print_info "Authenticate with: gh auth login"
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
if ! command -v jq &> /dev/null; then
|
|
109
|
+
print_error "jq is required but not installed"
|
|
110
|
+
print_info "Install: brew install jq (macOS) or sudo apt install jq (Ubuntu)"
|
|
111
|
+
exit 1
|
|
112
|
+
fi
|
|
113
|
+
return 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# ------------------------------------------------------------------------------
|
|
117
|
+
# CONFIGURATION LOADING
|
|
118
|
+
# ------------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
load_config() {
|
|
121
|
+
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
122
|
+
print_error "$ERROR_CONFIG_MISSING"
|
|
123
|
+
print_info "Create configuration: cp configs/github-cli-config.json.txt $CONFIG_FILE"
|
|
124
|
+
return 1
|
|
125
|
+
fi
|
|
126
|
+
return 0
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get_account_config() {
|
|
130
|
+
local account_name="$1"
|
|
131
|
+
|
|
132
|
+
if [[ -z "$account_name" ]]; then
|
|
133
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
134
|
+
return 1
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
local config
|
|
138
|
+
if ! config=$(jq -r ".accounts.\"$account_name\"" "$CONFIG_FILE" 2>/dev/null); then
|
|
139
|
+
print_error "$ERROR_FAILED_TO_READ_CONFIG"
|
|
140
|
+
return 1
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
if [[ "$config" == "null" ]]; then
|
|
144
|
+
print_error "$ERROR_ACCOUNT_MISSING: $account_name"
|
|
145
|
+
return 1
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
echo "$config"
|
|
149
|
+
return 0
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# ------------------------------------------------------------------------------
|
|
153
|
+
# REPOSITORY MANAGEMENT
|
|
154
|
+
# ------------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
list_repos() {
|
|
157
|
+
local account_name="$1"
|
|
158
|
+
local filter="${2:-}"
|
|
159
|
+
|
|
160
|
+
local config
|
|
161
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
162
|
+
|
|
163
|
+
local owner
|
|
164
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
165
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
166
|
+
print_error "Owner not configured for account: $account_name"
|
|
167
|
+
return 1
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
print_info "Listing repositories for $owner..."
|
|
171
|
+
|
|
172
|
+
local query="owner:$owner"
|
|
173
|
+
if [[ -n "$filter" ]]; then
|
|
174
|
+
query="$query $filter"
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
if ! gh repo list "$owner" --limit 50 --search "$query"; then
|
|
178
|
+
print_error "$ERROR_API_FAILED"
|
|
179
|
+
return 1
|
|
180
|
+
fi
|
|
181
|
+
return 0
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
create_repo() {
|
|
185
|
+
local account_name="$1"
|
|
186
|
+
local repo_name="$2"
|
|
187
|
+
local repo_description="${3:-}"
|
|
188
|
+
local visibility="${4:-public}"
|
|
189
|
+
local auto_init="${5:-false}"
|
|
190
|
+
|
|
191
|
+
if [[ -z "$repo_name" ]]; then
|
|
192
|
+
print_error "$ERROR_REPO_NAME_REQUIRED"
|
|
193
|
+
print_info "Usage: github-cli-helper.sh create-repo <account> <repo-name> [description] [visibility]"
|
|
194
|
+
return 1
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
local config
|
|
198
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
199
|
+
|
|
200
|
+
local owner
|
|
201
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
202
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
203
|
+
print_error "$ERROR_OWNER_NOT_CONFIGURED: $account_name"
|
|
204
|
+
return 1
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
print_info "Creating repository: $owner/$repo_name"
|
|
208
|
+
|
|
209
|
+
local gh_args=("$owner/$repo_name" --description "$repo_description" --visibility "$visibility")
|
|
210
|
+
if [[ "$auto_init" == "true" ]]; then
|
|
211
|
+
gh_args+=(--auto-init)
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
if gh repo create "${gh_args[@]}"; then
|
|
215
|
+
print_success "$SUCCESS_REPO_CREATED: $owner/$repo_name"
|
|
216
|
+
|
|
217
|
+
# Add to configuration if not exists
|
|
218
|
+
if ! jq -e ".repos.\"$owner/$repo_name\"" "$CONFIG_FILE" &>/dev/null; then
|
|
219
|
+
jq --arg repo "$owner/$repo_name" --arg owner "$owner" --arg name "$repo_name" \
|
|
220
|
+
'.repos[$repo] = {owner: $owner, name: $name, account: $account_name}' \
|
|
221
|
+
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
222
|
+
fi
|
|
223
|
+
else
|
|
224
|
+
print_error "Failed to create repository"
|
|
225
|
+
return 1
|
|
226
|
+
fi
|
|
227
|
+
return 0
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
delete_repo() {
|
|
231
|
+
local account_name="$1"
|
|
232
|
+
local repo_name="$2"
|
|
233
|
+
|
|
234
|
+
if [[ -z "$repo_name" ]]; then
|
|
235
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
236
|
+
return 1
|
|
237
|
+
fi
|
|
238
|
+
|
|
239
|
+
local config
|
|
240
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
241
|
+
|
|
242
|
+
local owner
|
|
243
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
244
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
245
|
+
print_error "Owner not configured for account: $account_name"
|
|
246
|
+
return 1
|
|
247
|
+
fi
|
|
248
|
+
|
|
249
|
+
print_warning "This will permanently delete repository: $owner/$repo_name"
|
|
250
|
+
print_info "To confirm, type 'DELETE':"
|
|
251
|
+
read -r confirmation
|
|
252
|
+
|
|
253
|
+
if [[ "$confirmation" != "DELETE" ]]; then
|
|
254
|
+
print_info "Deletion cancelled"
|
|
255
|
+
return 0
|
|
256
|
+
fi
|
|
257
|
+
|
|
258
|
+
print_info "Deleting repository: $owner/$repo_name"
|
|
259
|
+
|
|
260
|
+
if gh repo delete "$owner/$repo_name" --confirm; then
|
|
261
|
+
print_success "Repository deleted successfully"
|
|
262
|
+
|
|
263
|
+
# Remove from configuration
|
|
264
|
+
jq --arg repo "$owner/$repo_name" 'del(.repos[$repo])' \
|
|
265
|
+
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
266
|
+
else
|
|
267
|
+
print_error "Failed to delete repository"
|
|
268
|
+
return 1
|
|
269
|
+
fi
|
|
270
|
+
return 0
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
get_repo_info() {
|
|
274
|
+
local account_name="$1"
|
|
275
|
+
local repo_name="$2"
|
|
276
|
+
|
|
277
|
+
if [[ -z "$repo_name" ]]; then
|
|
278
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
279
|
+
return 1
|
|
280
|
+
fi
|
|
281
|
+
|
|
282
|
+
local config
|
|
283
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
284
|
+
|
|
285
|
+
local owner
|
|
286
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
287
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
288
|
+
print_error "Owner not configured for account: $account_name"
|
|
289
|
+
return 1
|
|
290
|
+
fi
|
|
291
|
+
|
|
292
|
+
print_info "Repository information for $owner/$repo_name:"
|
|
293
|
+
gh repo view "$owner/$repo_name"
|
|
294
|
+
return 0
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
# ------------------------------------------------------------------------------
|
|
298
|
+
# ISSUE MANAGEMENT
|
|
299
|
+
# ------------------------------------------------------------------------------
|
|
300
|
+
|
|
301
|
+
list_issues() {
|
|
302
|
+
local account_name="$1"
|
|
303
|
+
local repo_name="$2"
|
|
304
|
+
local state="${3:-open}"
|
|
305
|
+
|
|
306
|
+
if [[ -z "$repo_name" ]]; then
|
|
307
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
308
|
+
return 1
|
|
309
|
+
fi
|
|
310
|
+
|
|
311
|
+
local config
|
|
312
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
313
|
+
|
|
314
|
+
local owner
|
|
315
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
316
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
317
|
+
print_error "Owner not configured for account: $account_name"
|
|
318
|
+
return 1
|
|
319
|
+
fi
|
|
320
|
+
|
|
321
|
+
print_info "Listing issues for $owner/$repo_name (state: $state)"
|
|
322
|
+
gh issue list --repo "$owner/$repo_name" --limit 50 --state "$state"
|
|
323
|
+
return 0
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
create_issue() {
|
|
327
|
+
local account_name="$1"
|
|
328
|
+
local repo_name="$2"
|
|
329
|
+
local title="$3"
|
|
330
|
+
local body="${4:-}"
|
|
331
|
+
|
|
332
|
+
if [[ -z "$title" ]]; then
|
|
333
|
+
print_error "$ERROR_ISSUE_TITLE_REQUIRED"
|
|
334
|
+
return 1
|
|
335
|
+
fi
|
|
336
|
+
|
|
337
|
+
local config
|
|
338
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
339
|
+
|
|
340
|
+
local owner
|
|
341
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
342
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
343
|
+
print_error "$ERROR_OWNER_NOT_CONFIGURED: $account_name"
|
|
344
|
+
return 1
|
|
345
|
+
fi
|
|
346
|
+
|
|
347
|
+
print_info "Creating issue in $owner/$repo_name"
|
|
348
|
+
|
|
349
|
+
if gh issue create --repo "$owner/$repo_name" --title "$title" --body "$body"; then
|
|
350
|
+
print_success "$SUCCESS_ISSUE_CREATED"
|
|
351
|
+
else
|
|
352
|
+
print_error "Failed to create issue"
|
|
353
|
+
return 1
|
|
354
|
+
fi
|
|
355
|
+
return 0
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
close_issue() {
|
|
359
|
+
local account_name="$1"
|
|
360
|
+
local repo_name="$2"
|
|
361
|
+
local issue_number="$3"
|
|
362
|
+
|
|
363
|
+
if [[ -z "$issue_number" ]]; then
|
|
364
|
+
print_error "$ERROR_ISSUE_NUMBER_REQUIRED"
|
|
365
|
+
return 1
|
|
366
|
+
fi
|
|
367
|
+
|
|
368
|
+
local config
|
|
369
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
370
|
+
|
|
371
|
+
local owner
|
|
372
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
373
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
374
|
+
print_error "$ERROR_OWNER_NOT_CONFIGURED: $account_name"
|
|
375
|
+
return 1
|
|
376
|
+
fi
|
|
377
|
+
|
|
378
|
+
print_info "Closing issue #$issue_number in $owner/$repo_name"
|
|
379
|
+
|
|
380
|
+
if gh issue close --repo "$owner/$repo_name" "$issue_number"; then
|
|
381
|
+
print_success "$SUCCESS_ISSUE_CLOSED"
|
|
382
|
+
else
|
|
383
|
+
print_error "Failed to close issue"
|
|
384
|
+
return 1
|
|
385
|
+
fi
|
|
386
|
+
return 0
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
# ------------------------------------------------------------------------------
|
|
390
|
+
# PULL REQUEST MANAGEMENT
|
|
391
|
+
# ------------------------------------------------------------------------------
|
|
392
|
+
|
|
393
|
+
list_prs() {
|
|
394
|
+
local account_name="$1"
|
|
395
|
+
local repo_name="$2"
|
|
396
|
+
local state="${3:-open}"
|
|
397
|
+
|
|
398
|
+
if [[ -z "$repo_name" ]]; then
|
|
399
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
400
|
+
return 1
|
|
401
|
+
fi
|
|
402
|
+
|
|
403
|
+
local config
|
|
404
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
405
|
+
|
|
406
|
+
local owner
|
|
407
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
408
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
409
|
+
print_error "Owner not configured for account: $account_name"
|
|
410
|
+
return 1
|
|
411
|
+
fi
|
|
412
|
+
|
|
413
|
+
print_info "Listing pull requests for $owner/$repo_name (state: $state)"
|
|
414
|
+
gh pr list --repo "$owner/$repo_name" --limit 50 --state "$state"
|
|
415
|
+
return 0
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
create_pr() {
|
|
419
|
+
local account_name="$1"
|
|
420
|
+
local repo_name="$2"
|
|
421
|
+
local title="$3"
|
|
422
|
+
local base_branch="${4:-main}"
|
|
423
|
+
local head_branch="${5:-}"
|
|
424
|
+
local body="${6:-}"
|
|
425
|
+
|
|
426
|
+
if [[ -z "$title" ]]; then
|
|
427
|
+
print_error "$ERROR_PR_TITLE_REQUIRED"
|
|
428
|
+
return 1
|
|
429
|
+
fi
|
|
430
|
+
|
|
431
|
+
local config
|
|
432
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
433
|
+
|
|
434
|
+
local owner
|
|
435
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
436
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
437
|
+
print_error "$ERROR_OWNER_NOT_CONFIGURED: $account_name"
|
|
438
|
+
return 1
|
|
439
|
+
fi
|
|
440
|
+
|
|
441
|
+
print_info "Creating pull request in $owner/$repo_name"
|
|
442
|
+
|
|
443
|
+
local gh_args=("--repo" "$owner/$repo_name" "--title" "$title" "--base" "$base_branch")
|
|
444
|
+
if [[ -n "$head_branch" ]]; then
|
|
445
|
+
gh_args+=("--head" "$head_branch")
|
|
446
|
+
fi
|
|
447
|
+
if [[ -n "$body" ]]; then
|
|
448
|
+
gh_args+=("--body" "$body")
|
|
449
|
+
fi
|
|
450
|
+
|
|
451
|
+
if gh pr create "${gh_args[@]}"; then
|
|
452
|
+
print_success "$SUCCESS_PR_CREATED"
|
|
453
|
+
else
|
|
454
|
+
print_error "Failed to create pull request"
|
|
455
|
+
return 1
|
|
456
|
+
fi
|
|
457
|
+
return 0
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
merge_pr() {
|
|
461
|
+
local account_name="$1"
|
|
462
|
+
local repo_name="$2"
|
|
463
|
+
local pr_number="$3"
|
|
464
|
+
local merge_method="${4:-merge}"
|
|
465
|
+
|
|
466
|
+
if [[ -z "$pr_number" ]]; then
|
|
467
|
+
print_error "$ERROR_PR_NUMBER_REQUIRED"
|
|
468
|
+
return 1
|
|
469
|
+
fi
|
|
470
|
+
|
|
471
|
+
local config
|
|
472
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
473
|
+
|
|
474
|
+
local owner
|
|
475
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
476
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
477
|
+
print_error "$ERROR_OWNER_NOT_CONFIGURED: $account_name"
|
|
478
|
+
return 1
|
|
479
|
+
fi
|
|
480
|
+
|
|
481
|
+
print_info "Merging pull request #$pr_number in $owner/$repo_name"
|
|
482
|
+
|
|
483
|
+
if gh pr merge --repo "$owner/$repo_name" "$pr_number" --"$merge_method"; then
|
|
484
|
+
print_success "$SUCCESS_PR_MERGED"
|
|
485
|
+
else
|
|
486
|
+
print_error "Failed to merge pull request"
|
|
487
|
+
return 1
|
|
488
|
+
fi
|
|
489
|
+
return 0
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
# ------------------------------------------------------------------------------
|
|
493
|
+
# BRANCH MANAGEMENT
|
|
494
|
+
# ------------------------------------------------------------------------------
|
|
495
|
+
|
|
496
|
+
list_branches() {
|
|
497
|
+
local account_name="$1"
|
|
498
|
+
local repo_name="$2"
|
|
499
|
+
|
|
500
|
+
if [[ -z "$repo_name" ]]; then
|
|
501
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
502
|
+
return 1
|
|
503
|
+
fi
|
|
504
|
+
|
|
505
|
+
local config
|
|
506
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
507
|
+
|
|
508
|
+
local owner
|
|
509
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
510
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
511
|
+
print_error "Owner not configured for account: $account_name"
|
|
512
|
+
return 1
|
|
513
|
+
fi
|
|
514
|
+
|
|
515
|
+
print_info "Listing branches for $owner/$repo_name"
|
|
516
|
+
gh repo list "$owner" --limit 1 "--json" "nameWithOwner" | jq -r '.[0].nameWithOwner' | \
|
|
517
|
+
xargs -I {} gh api "repos/{}/branches" --jq '.[] | .name'
|
|
518
|
+
return 0
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
create_branch() {
|
|
522
|
+
local account_name="$1"
|
|
523
|
+
local repo_name="$2"
|
|
524
|
+
local branch_name="$3"
|
|
525
|
+
local source_branch="${4:-main}"
|
|
526
|
+
|
|
527
|
+
if [[ -z "$branch_name" ]]; then
|
|
528
|
+
print_error "$ERROR_BRANCH_NAME_REQUIRED"
|
|
529
|
+
return 1
|
|
530
|
+
fi
|
|
531
|
+
|
|
532
|
+
local config
|
|
533
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
534
|
+
|
|
535
|
+
local owner
|
|
536
|
+
owner=$(echo "$config" | jq -r '.owner // "EMPTY"')
|
|
537
|
+
if [[ "$owner" == "EMPTY" || -z "$owner" ]]; then
|
|
538
|
+
print_error "$ERROR_OWNER_NOT_CONFIGURED: $account_name"
|
|
539
|
+
return 1
|
|
540
|
+
fi
|
|
541
|
+
|
|
542
|
+
print_info "Creating branch '$branch_name' in $owner/$repo_name from '$source_branch'"
|
|
543
|
+
|
|
544
|
+
# Use API to create branch reference
|
|
545
|
+
if gh api "repos/$owner/$repo_name/git/refs/heads/$source_branch" --jq '.object.sha' | \
|
|
546
|
+
xargs -I {} gh api --method POST "repos/$owner/$repo_name/git/refs" \
|
|
547
|
+
--field "ref=refs/heads/$branch_name" --field "sha={}"; then
|
|
548
|
+
print_success "$SUCCESS_BRANCH_CREATED"
|
|
549
|
+
else
|
|
550
|
+
print_error "Failed to create branch"
|
|
551
|
+
return 1
|
|
552
|
+
fi
|
|
553
|
+
return 0
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
# ------------------------------------------------------------------------------
|
|
557
|
+
# ACCOUNT MANAGEMENT
|
|
558
|
+
# ------------------------------------------------------------------------------
|
|
559
|
+
|
|
560
|
+
list_accounts() {
|
|
561
|
+
print_info "Configured GitHub accounts:"
|
|
562
|
+
if [[ -f "$CONFIG_FILE" ]]; then
|
|
563
|
+
jq -r '.accounts | keys[]' "$CONFIG_FILE" 2>/dev/null || print_warning "No accounts configured"
|
|
564
|
+
else
|
|
565
|
+
print_warning "Configuration file not found"
|
|
566
|
+
fi
|
|
567
|
+
return 0
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
show_help() {
|
|
571
|
+
cat << EOF
|
|
572
|
+
GitHub CLI Helper Script
|
|
573
|
+
Usage: $0 [command] [account] [arguments]
|
|
574
|
+
|
|
575
|
+
GitHub management using GitHub CLI (gh)
|
|
576
|
+
|
|
577
|
+
COMMANDS:
|
|
578
|
+
Repository Management:
|
|
579
|
+
list-repos [account] [filter] - List repositories (can filter by name)
|
|
580
|
+
create-repo <account> <name> [desc] [vis] [init] - Create repository
|
|
581
|
+
visibility: public|private (default: public)
|
|
582
|
+
auto_init: true|false (default: false)
|
|
583
|
+
delete-repo <account> <name> - Delete repository (requires confirmation)
|
|
584
|
+
get-repo <account> <name> - Get repository information
|
|
585
|
+
|
|
586
|
+
Issue Management:
|
|
587
|
+
list-issues <account> <repo> [state] - List issues (open|closed|all)
|
|
588
|
+
create-issue <account> <repo> <title> [body] - Create issue
|
|
589
|
+
close-issue <account> <repo> <number> - Close issue
|
|
590
|
+
|
|
591
|
+
Pull Request Management:
|
|
592
|
+
list-prs <account> <repo> [state] - List pull requests
|
|
593
|
+
create-pr <account> <repo> <title> [base] [head] [body] - Create PR
|
|
594
|
+
merge-pr <account> <repo> <number> [method] - Merge PR (merge|squash|rebase)
|
|
595
|
+
|
|
596
|
+
Branch Management:
|
|
597
|
+
list-branches <account> <repo> - List branches
|
|
598
|
+
create-branch <account> <repo> <branch> [source] - Create branch
|
|
599
|
+
|
|
600
|
+
Account Management:
|
|
601
|
+
list-accounts - List configured accounts
|
|
602
|
+
help - $HELP_SHOW_MESSAGE
|
|
603
|
+
|
|
604
|
+
EXAMPLES:
|
|
605
|
+
$0 list-repos marcusquinn
|
|
606
|
+
$0 create-repo marcusquinn my-new-project "My awesome project" public true
|
|
607
|
+
$0 list-issues marcusquinn my-repo open
|
|
608
|
+
$0 create-issue marcusquinn my-repo "Bug report" "Describe the issue here"
|
|
609
|
+
$0 create-pr marcusquinn my-repo "Fix bug" main bugfix
|
|
610
|
+
|
|
611
|
+
CONFIGURATION:
|
|
612
|
+
File: configs/github-cli-config.json
|
|
613
|
+
Example: cp configs/github-cli-config.json.txt configs/github-cli-config.json
|
|
614
|
+
|
|
615
|
+
REQUIREMENTS:
|
|
616
|
+
- GitHub CLI (gh) installed and authenticated
|
|
617
|
+
- jq JSON processor
|
|
618
|
+
- Valid GitHub authentication token
|
|
619
|
+
|
|
620
|
+
For more information, see the GitHub CLI documentation: https://cli.github.com/manual/
|
|
621
|
+
EOF
|
|
622
|
+
return 0
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
# ------------------------------------------------------------------------------
|
|
626
|
+
# MAIN COMMAND HANDLER
|
|
627
|
+
# ------------------------------------------------------------------------------
|
|
628
|
+
|
|
629
|
+
main() {
|
|
630
|
+
local command="${1:-help}"
|
|
631
|
+
local account_name="$2"
|
|
632
|
+
local target="$3"
|
|
633
|
+
local options="$4"
|
|
634
|
+
|
|
635
|
+
case "$command" in
|
|
636
|
+
"list-repos")
|
|
637
|
+
list_repos "$account_name" "$target"
|
|
638
|
+
;;
|
|
639
|
+
"create-repo")
|
|
640
|
+
local repo_desc="$options"
|
|
641
|
+
local repo_vis="$5"
|
|
642
|
+
local repo_init="$6"
|
|
643
|
+
create_repo "$account_name" "$target" "$repo_desc" "$repo_vis" "$repo_init"
|
|
644
|
+
;;
|
|
645
|
+
"delete-repo")
|
|
646
|
+
delete_repo "$account_name" "$target"
|
|
647
|
+
;;
|
|
648
|
+
"get-repo")
|
|
649
|
+
get_repo_info "$account_name" "$target"
|
|
650
|
+
;;
|
|
651
|
+
"list-issues")
|
|
652
|
+
list_issues "$account_name" "$target" "$options"
|
|
653
|
+
;;
|
|
654
|
+
"create-issue")
|
|
655
|
+
local issue_body="$5"
|
|
656
|
+
create_issue "$account_name" "$target" "$options" "$issue_body"
|
|
657
|
+
;;
|
|
658
|
+
"close-issue")
|
|
659
|
+
close_issue "$account_name" "$target" "$options"
|
|
660
|
+
;;
|
|
661
|
+
"list-prs")
|
|
662
|
+
list_prs "$account_name" "$target" "$options"
|
|
663
|
+
;;
|
|
664
|
+
"create-pr")
|
|
665
|
+
local pr_base="$5"
|
|
666
|
+
local pr_head="$6"
|
|
667
|
+
local pr_body="$7"
|
|
668
|
+
create_pr "$account_name" "$target" "$options" "$pr_base" "$pr_head" "$pr_body"
|
|
669
|
+
;;
|
|
670
|
+
"merge-pr")
|
|
671
|
+
local merge_method="$5"
|
|
672
|
+
merge_pr "$account_name" "$target" "$options" "$merge_method"
|
|
673
|
+
;;
|
|
674
|
+
"list-branches")
|
|
675
|
+
list_branches "$account_name" "$target"
|
|
676
|
+
;;
|
|
677
|
+
"create-branch")
|
|
678
|
+
local source_branch="$5"
|
|
679
|
+
create_branch "$account_name" "$target" "$options" "$source_branch"
|
|
680
|
+
;;
|
|
681
|
+
"list-accounts")
|
|
682
|
+
list_accounts
|
|
683
|
+
;;
|
|
684
|
+
"help"|"-h"|"--help")
|
|
685
|
+
show_help
|
|
686
|
+
;;
|
|
687
|
+
*)
|
|
688
|
+
print_error "$ERROR_UNKNOWN_COMMAND $command"
|
|
689
|
+
print_info "Use '$0 help' for usage information"
|
|
690
|
+
exit 1
|
|
691
|
+
;;
|
|
692
|
+
esac
|
|
693
|
+
|
|
694
|
+
return 0
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
# Initialize
|
|
698
|
+
check_dependencies
|
|
699
|
+
load_config
|
|
700
|
+
|
|
701
|
+
# Execute main function
|
|
702
|
+
main "$@"
|