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,682 @@
|
|
|
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
|
+
# GitLab CLI Helper Script
|
|
5
|
+
# Comprehensive GitLab management using GitLab CLI (glab)
|
|
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/gitlab-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_GLAB_NOT_INSTALLED="GitLab CLI (glab) is required but not installed"
|
|
34
|
+
readonly ERROR_NOT_LOGGED_IN="GitLab CLI is not authenticated. Run 'glab auth login'"
|
|
35
|
+
readonly ERROR_ACCOUNT_MISSING="Account configuration not found"
|
|
36
|
+
readonly ERROR_ARGS_MISSING="Missing required arguments"
|
|
37
|
+
readonly ERROR_API_FAILED="GitLab API request failed"
|
|
38
|
+
|
|
39
|
+
readonly ERROR_PROJECT_NOT_FOUND="Project not found"
|
|
40
|
+
readonly ERROR_INSTANCE_URL_NOT_CONFIGURED="Instance URL not configured for account"
|
|
41
|
+
readonly ERROR_FAILED_TO_READ_CONFIG="Failed to read configuration"
|
|
42
|
+
readonly ERROR_PROJECT_NAME_REQUIRED="Project name is required"
|
|
43
|
+
readonly ERROR_ISSUE_TITLE_REQUIRED="Issue title is required"
|
|
44
|
+
readonly ERROR_ISSUE_NUMBER_REQUIRED="Issue number is required"
|
|
45
|
+
readonly ERROR_MR_TITLE_REQUIRED="Merge request title is required"
|
|
46
|
+
readonly ERROR_MR_NUMBER_REQUIRED="Merge request number is required"
|
|
47
|
+
readonly ERROR_BRANCH_NAME_REQUIRED="Branch name is required"
|
|
48
|
+
|
|
49
|
+
# Success Messages
|
|
50
|
+
readonly SUCCESS_PROJECT_CREATED="Project created successfully"
|
|
51
|
+
readonly SUCCESS_ISSUE_CREATED="Issue created successfully"
|
|
52
|
+
readonly SUCCESS_MR_CREATED="Merge request created successfully"
|
|
53
|
+
readonly SUCCESS_BRANCH_CREATED="Branch created successfully"
|
|
54
|
+
readonly SUCCESS_ISSUE_CLOSED="Issue closed successfully"
|
|
55
|
+
readonly SUCCESS_MR_MERGED="Merge request merged successfully"
|
|
56
|
+
|
|
57
|
+
# Common constants
|
|
58
|
+
readonly CONTENT_TYPE_JSON="$CONTENT_TYPE_JSON"
|
|
59
|
+
readonly AUTH_HEADER_TOKEN="Authorization: token"
|
|
60
|
+
|
|
61
|
+
# ------------------------------------------------------------------------------
|
|
62
|
+
# UTILITY FUNCTIONS
|
|
63
|
+
# ------------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
print_info() {
|
|
66
|
+
local msg="$1"
|
|
67
|
+
echo -e "${BLUE}[INFO]${NC} $msg"
|
|
68
|
+
return 0
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
print_success() {
|
|
72
|
+
local msg="$1"
|
|
73
|
+
echo -e "${GREEN}[SUCCESS]${NC} $msg"
|
|
74
|
+
return 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
print_warning() {
|
|
78
|
+
local msg="$1"
|
|
79
|
+
echo -e "${YELLOW}[WARNING]${NC} $msg"
|
|
80
|
+
return 0
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
print_error() {
|
|
84
|
+
local msg="$1"
|
|
85
|
+
echo -e "${RED}[ERROR]${NC} $msg" >&2
|
|
86
|
+
return 0
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# ------------------------------------------------------------------------------
|
|
90
|
+
# DEPENDENCY CHECKING
|
|
91
|
+
# ------------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
check_dependencies() {
|
|
94
|
+
if ! command -v glab &> /dev/null; then
|
|
95
|
+
print_error "$ERROR_GLAB_NOT_INSTALLED"
|
|
96
|
+
print_info "Install GitLab CLI:"
|
|
97
|
+
print_info " macOS: brew install glab"
|
|
98
|
+
print_info " Ubuntu: sudo apt install glab"
|
|
99
|
+
print_info " Other: https://glab.readthedocs.io/en/latest/installation/"
|
|
100
|
+
exit 1
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
if ! glab auth status &> /dev/null; then
|
|
104
|
+
print_error "$ERROR_NOT_LOGGED_IN"
|
|
105
|
+
print_info "Authenticate with: glab auth login"
|
|
106
|
+
exit 1
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
if ! command -v jq &> /dev/null; then
|
|
110
|
+
print_error "jq is required but not installed"
|
|
111
|
+
print_info "Install: brew install jq (macOS) or sudo apt install jq (Ubuntu)"
|
|
112
|
+
exit 1
|
|
113
|
+
fi
|
|
114
|
+
return 0
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# ------------------------------------------------------------------------------
|
|
118
|
+
# CONFIGURATION LOADING
|
|
119
|
+
# ------------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
load_config() {
|
|
122
|
+
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
123
|
+
print_error "$ERROR_CONFIG_MISSING"
|
|
124
|
+
print_info "Create configuration: cp configs/gitlab-cli-config.json.txt $CONFIG_FILE"
|
|
125
|
+
return 1
|
|
126
|
+
fi
|
|
127
|
+
return 0
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get_account_config() {
|
|
131
|
+
local account_name="$1"
|
|
132
|
+
|
|
133
|
+
if [[ -z "$account_name" ]]; then
|
|
134
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
135
|
+
return 1
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
local config
|
|
139
|
+
if ! config=$(jq -r ".accounts.\"$account_name\"" "$CONFIG_FILE" 2>/dev/null); then
|
|
140
|
+
print_error "$ERROR_FAILED_TO_READ_CONFIG"
|
|
141
|
+
return 1
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
if [[ "$config" == "null" ]]; then
|
|
145
|
+
print_error "$ERROR_ACCOUNT_MISSING: $account_name"
|
|
146
|
+
return 1
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
echo "$config"
|
|
150
|
+
return 0
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get_project_info() {
|
|
154
|
+
local account_name="$1"
|
|
155
|
+
local project_identifier="$2"
|
|
156
|
+
local config
|
|
157
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
158
|
+
|
|
159
|
+
local instance_url
|
|
160
|
+
instance_url=$(echo "$config" | jq -r '.instance_url // "EMPTY"')
|
|
161
|
+
if [[ "$instance_url" == "EMPTY" || -z "$instance_url" ]]; then
|
|
162
|
+
print_error "Instance URL not configured for account: $account_name"
|
|
163
|
+
return 1
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
# Try to find project by name or ID
|
|
167
|
+
local project_info
|
|
168
|
+
if project_info=$(glab api "projects?search=$project_identifier" --jq ".[] | select(.name_with_namespace == \"$project_identifier\" or .path == \"$project_identifier\" or .id == ($project_identifier | tonumber?))" 2>/dev/null) && [[ -n "$project_info" ]]; then
|
|
169
|
+
echo "$project_info" | jq -r '.id'
|
|
170
|
+
return 0
|
|
171
|
+
fi
|
|
172
|
+
|
|
173
|
+
# If not found, try exact match
|
|
174
|
+
if project_info=$(glab api "projects?search=$project_identifier" --jq ".[] | select(.path_with_namespace == \"$project_identifier\") | .id" 2>/dev/null); then
|
|
175
|
+
echo "$project_info"
|
|
176
|
+
return 0
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
print_error "$ERROR_PROJECT_NOT_FOUND: $project_identifier"
|
|
180
|
+
return 1
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# ------------------------------------------------------------------------------
|
|
184
|
+
# PROJECT MANAGEMENT
|
|
185
|
+
# ------------------------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
list_projects() {
|
|
188
|
+
local account_name="$1"
|
|
189
|
+
local filter="${2:-}"
|
|
190
|
+
local visibility="${3:-}"
|
|
191
|
+
|
|
192
|
+
local config
|
|
193
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
194
|
+
|
|
195
|
+
local instance_url
|
|
196
|
+
instance_url=$(echo "$config" | jq -r '.instance_url // "EMPTY"')
|
|
197
|
+
if [[ "$instance_url" == "EMPTY" || -z "$instance_url" ]]; then
|
|
198
|
+
print_error "Instance URL not configured for account: $account_name"
|
|
199
|
+
return 1
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
print_info "Listing projects from $instance_url..."
|
|
203
|
+
|
|
204
|
+
local api_path="projects"
|
|
205
|
+
local query_params=""
|
|
206
|
+
|
|
207
|
+
if [[ -n "$filter" ]]; then
|
|
208
|
+
query_params="${query_params}&search=$filter"
|
|
209
|
+
fi
|
|
210
|
+
if [[ -n "$visibility" ]]; then
|
|
211
|
+
query_params="${query_params}&visibility=$visibility"
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
if [[ -n "$query_params" ]]; then
|
|
215
|
+
api_path="$api_path?${query_params#&}"
|
|
216
|
+
fi
|
|
217
|
+
|
|
218
|
+
if ! glab api "$api_path" --jq '.[] | "\(.id): \(.name_with_namespace) (\(.visibility))"'; then
|
|
219
|
+
print_error "$ERROR_API_FAILED"
|
|
220
|
+
return 1
|
|
221
|
+
fi
|
|
222
|
+
return 0
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
create_project() {
|
|
226
|
+
local account_name="$1"
|
|
227
|
+
local project_name="$2"
|
|
228
|
+
local project_description="${3:-}"
|
|
229
|
+
local visibility="${4:-public}"
|
|
230
|
+
local initialize_with_readme="${5:-false}"
|
|
231
|
+
|
|
232
|
+
if [[ -z "$project_name" ]]; then
|
|
233
|
+
print_error "$ERROR_PROJECT_NAME_REQUIRED"
|
|
234
|
+
print_info "Usage: gitlab-cli-helper.sh create-project <account> <name> [description] [visibility] [init]"
|
|
235
|
+
return 1
|
|
236
|
+
fi
|
|
237
|
+
|
|
238
|
+
local config
|
|
239
|
+
config=$(get_account_config "$account_name") || exit 1
|
|
240
|
+
|
|
241
|
+
local instance_url
|
|
242
|
+
instance_url=$(echo "$config" | jq -r '.instance_url // "EMPTY"')
|
|
243
|
+
if [[ "$instance_url" == "EMPTY" || -z "$instance_url" ]]; then
|
|
244
|
+
print_error "$ERROR_INSTANCE_URL_NOT_CONFIGURED: $account_name"
|
|
245
|
+
return 1
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
local group_path
|
|
249
|
+
group_path=$(echo "$config" | jq -r '.default_group // "EMPTY"')
|
|
250
|
+
|
|
251
|
+
print_info "Creating project: $project_name"
|
|
252
|
+
|
|
253
|
+
local project_data
|
|
254
|
+
project_data="{\"name\": \"$project_name\""
|
|
255
|
+
if [[ -n "$project_description" ]]; then
|
|
256
|
+
project_data="$project_data, \"description\": \"$project_description\""
|
|
257
|
+
fi
|
|
258
|
+
project_data="$project_data, \"visibility\": \"$visibility\""
|
|
259
|
+
if [[ "$initialize_with_readme" == "true" ]]; then
|
|
260
|
+
project_data="$project_data, \"initialize_with_readme\": true"
|
|
261
|
+
fi
|
|
262
|
+
|
|
263
|
+
local api_path="projects"
|
|
264
|
+
if [[ "$group_path" != "EMPTY" && -n "$group_path" ]]; then
|
|
265
|
+
api_path="groups/$group_path/projects"
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
local create_data
|
|
269
|
+
if create_data=$(glab api --method POST "$api_path" --field "$project_data" 2>/dev/null); then
|
|
270
|
+
local project_id
|
|
271
|
+
project_id=$(echo "$create_data" | jq -r '.id')
|
|
272
|
+
local project_path
|
|
273
|
+
project_path=$(echo "$create_data" | jq -r '.path_with_namespace')
|
|
274
|
+
print_success "$SUCCESS_PROJECT_CREATED: $project_path (ID: $project_id)"
|
|
275
|
+
|
|
276
|
+
# Add to configuration
|
|
277
|
+
jq --arg project_id "$project_id" --arg project_path "$project_path" --arg name "$project_name" \
|
|
278
|
+
'.projects[$project_id] = {id: $project_id, path: $project_path, name: $name, account: $account_name}' \
|
|
279
|
+
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
280
|
+
else
|
|
281
|
+
print_error "Failed to create project"
|
|
282
|
+
return 1
|
|
283
|
+
fi
|
|
284
|
+
return 0
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
delete_project() {
|
|
288
|
+
local account_name="$1"
|
|
289
|
+
local project_identifier="$2"
|
|
290
|
+
|
|
291
|
+
if [[ -z "$project_identifier" ]]; then
|
|
292
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
293
|
+
return 1
|
|
294
|
+
fi
|
|
295
|
+
|
|
296
|
+
local project_id
|
|
297
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
298
|
+
|
|
299
|
+
print_warning "This will permanently delete project (ID: $project_id)"
|
|
300
|
+
print_info "To confirm, type 'DELETE':"
|
|
301
|
+
read -r confirmation
|
|
302
|
+
|
|
303
|
+
if [[ "$confirmation" != "DELETE" ]]; then
|
|
304
|
+
print_info "Deletion cancelled"
|
|
305
|
+
return 0
|
|
306
|
+
fi
|
|
307
|
+
|
|
308
|
+
print_info "Deleting project ID: $project_id"
|
|
309
|
+
|
|
310
|
+
if glab api --method DELETE "projects/$project_id"; then
|
|
311
|
+
print_success "Project deleted successfully"
|
|
312
|
+
|
|
313
|
+
# Remove from configuration
|
|
314
|
+
jq --arg project_id "$project_id" 'del(.projects[$project_id])' \
|
|
315
|
+
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
316
|
+
else
|
|
317
|
+
print_error "Failed to delete project"
|
|
318
|
+
return 1
|
|
319
|
+
fi
|
|
320
|
+
return 0
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
get_project_details() {
|
|
324
|
+
local account_name="$1"
|
|
325
|
+
local project_identifier="$2"
|
|
326
|
+
|
|
327
|
+
if [[ -z "$project_identifier" ]]; then
|
|
328
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
329
|
+
return 1
|
|
330
|
+
fi
|
|
331
|
+
|
|
332
|
+
local project_id
|
|
333
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
334
|
+
|
|
335
|
+
print_info "Project details (ID: $project_id):"
|
|
336
|
+
glab api "projects/$project_id"
|
|
337
|
+
return 0
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
# ------------------------------------------------------------------------------
|
|
341
|
+
# ISSUE MANAGEMENT
|
|
342
|
+
# ------------------------------------------------------------------------------
|
|
343
|
+
|
|
344
|
+
list_issues() {
|
|
345
|
+
local account_name="$1"
|
|
346
|
+
local project_identifier="$2"
|
|
347
|
+
local state="${3:-opened}"
|
|
348
|
+
|
|
349
|
+
if [[ -z "$project_identifier" ]]; then
|
|
350
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
351
|
+
return 1
|
|
352
|
+
fi
|
|
353
|
+
|
|
354
|
+
local project_id
|
|
355
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
356
|
+
|
|
357
|
+
print_info "Listing issues for project (ID: $project_id) (state: $state)"
|
|
358
|
+
glab api "projects/$project_id/issues?state=$state" --jq '.[] | "##\(.iid): \(.title) (\(.state))"'
|
|
359
|
+
return 0
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
create_issue() {
|
|
363
|
+
local account_name="$1"
|
|
364
|
+
local project_identifier="$2"
|
|
365
|
+
local title="$3"
|
|
366
|
+
local description="${4:-}"
|
|
367
|
+
|
|
368
|
+
if [[ -z "$title" ]]; then
|
|
369
|
+
print_error "$ERROR_ISSUE_TITLE_REQUIRED"
|
|
370
|
+
return 1
|
|
371
|
+
fi
|
|
372
|
+
|
|
373
|
+
local project_id
|
|
374
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
375
|
+
|
|
376
|
+
print_info "Creating issue in project (ID: $project_id)"
|
|
377
|
+
|
|
378
|
+
if glab issue create --project "$project_id" --title "$title" --description "$description"; then
|
|
379
|
+
print_success "$SUCCESS_ISSUE_CREATED"
|
|
380
|
+
else
|
|
381
|
+
print_error "Failed to create issue"
|
|
382
|
+
return 1
|
|
383
|
+
fi
|
|
384
|
+
return 0
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
close_issue() {
|
|
388
|
+
local account_name="$1"
|
|
389
|
+
local project_identifier="$2"
|
|
390
|
+
local issue_number="$3"
|
|
391
|
+
|
|
392
|
+
if [[ -z "$issue_number" ]]; then
|
|
393
|
+
print_error "$ERROR_ISSUE_NUMBER_REQUIRED"
|
|
394
|
+
return 1
|
|
395
|
+
fi
|
|
396
|
+
|
|
397
|
+
local project_id
|
|
398
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
399
|
+
|
|
400
|
+
print_info "Closing issue #$issue_number in project (ID: $project_id)"
|
|
401
|
+
|
|
402
|
+
if glab issue update --project "$project_id" "$issue_number" --state-event close; then
|
|
403
|
+
print_success "$SUCCESS_ISSUE_CLOSED"
|
|
404
|
+
else
|
|
405
|
+
print_error "Failed to close issue"
|
|
406
|
+
return 1
|
|
407
|
+
fi
|
|
408
|
+
return 0
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
# ------------------------------------------------------------------------------
|
|
412
|
+
# MERGE REQUEST MANAGEMENT
|
|
413
|
+
# ------------------------------------------------------------------------------
|
|
414
|
+
|
|
415
|
+
list_merge_requests() {
|
|
416
|
+
local account_name="$1"
|
|
417
|
+
local project_identifier="$2"
|
|
418
|
+
local state="${3:-opened}"
|
|
419
|
+
|
|
420
|
+
if [[ -z "$project_identifier" ]]; then
|
|
421
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
422
|
+
return 1
|
|
423
|
+
fi
|
|
424
|
+
|
|
425
|
+
local project_id
|
|
426
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
427
|
+
|
|
428
|
+
print_info "Listing merge requests for project (ID: $project_id) (state: $state)"
|
|
429
|
+
glab api "projects/$project_id/merge_requests?state=$state" --jq '.[] | "!#\(.iid): \(.title) (\(.state))"'
|
|
430
|
+
return 0
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
create_merge_request() {
|
|
434
|
+
local account_name="$1"
|
|
435
|
+
local project_identifier="$2"
|
|
436
|
+
local title="$3"
|
|
437
|
+
local source_branch="${4:-}"
|
|
438
|
+
local target_branch="${5:-main}"
|
|
439
|
+
local description="${6:-}"
|
|
440
|
+
|
|
441
|
+
if [[ -z "$title" || -z "$source_branch" ]]; then
|
|
442
|
+
print_error "$ERROR_MR_TITLE_REQUIRED"
|
|
443
|
+
return 1
|
|
444
|
+
fi
|
|
445
|
+
|
|
446
|
+
local project_id
|
|
447
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
448
|
+
|
|
449
|
+
print_info "Creating merge request in project (ID: $project_id)"
|
|
450
|
+
|
|
451
|
+
if glab mr create --project "$project_id" --title "$title" --source-branch "$source_branch" --target-branch "$target_branch" --description "$description"; then
|
|
452
|
+
print_success "$SUCCESS_MR_CREATED"
|
|
453
|
+
else
|
|
454
|
+
print_error "Failed to create merge request"
|
|
455
|
+
return 1
|
|
456
|
+
fi
|
|
457
|
+
return 0
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
merge_merge_request() {
|
|
461
|
+
local account_name="$1"
|
|
462
|
+
local project_identifier="$2"
|
|
463
|
+
local mr_number="$3"
|
|
464
|
+
local merge_method="${4:-merge}"
|
|
465
|
+
|
|
466
|
+
if [[ -z "$mr_number" ]]; then
|
|
467
|
+
print_error "$ERROR_MR_NUMBER_REQUIRED"
|
|
468
|
+
return 1
|
|
469
|
+
fi
|
|
470
|
+
|
|
471
|
+
local project_id
|
|
472
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
473
|
+
|
|
474
|
+
print_info "Merging merge request !#$mr_number in project (ID: $project_id)"
|
|
475
|
+
|
|
476
|
+
if glab mr merge --project "$project_id" "$mr_number" --yes --"$merge_method"; then
|
|
477
|
+
print_success "$SUCCESS_MR_MERGED"
|
|
478
|
+
else
|
|
479
|
+
print_error "Failed to merge merge request"
|
|
480
|
+
return 1
|
|
481
|
+
fi
|
|
482
|
+
return 0
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
# ------------------------------------------------------------------------------
|
|
486
|
+
# BRANCH MANAGEMENT
|
|
487
|
+
# ------------------------------------------------------------------------------
|
|
488
|
+
|
|
489
|
+
list_branches() {
|
|
490
|
+
local account_name="$1"
|
|
491
|
+
local project_identifier="$2"
|
|
492
|
+
|
|
493
|
+
if [[ -z "$project_identifier" ]]; then
|
|
494
|
+
print_error "$ERROR_ARGS_MISSING"
|
|
495
|
+
return 1
|
|
496
|
+
fi
|
|
497
|
+
|
|
498
|
+
local project_id
|
|
499
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
500
|
+
|
|
501
|
+
print_info "Listing branches for project (ID: $project_id)"
|
|
502
|
+
glab api "projects/$project_id/repository/branches" --jq '.[] | .name'
|
|
503
|
+
return 0
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
create_branch() {
|
|
507
|
+
local account_name="$1"
|
|
508
|
+
local project_identifier="$2"
|
|
509
|
+
local branch_name="$3"
|
|
510
|
+
local source_branch="${4:-main}"
|
|
511
|
+
|
|
512
|
+
if [[ -z "$branch_name" ]]; then
|
|
513
|
+
print_error "$ERROR_BRANCH_NAME_REQUIRED"
|
|
514
|
+
return 1
|
|
515
|
+
fi
|
|
516
|
+
|
|
517
|
+
local project_id
|
|
518
|
+
project_id=$(get_project_info "$account_name" "$project_identifier") || exit 1
|
|
519
|
+
|
|
520
|
+
print_info "Creating branch '$branch_name' in project (ID: $project_id) from '$source_branch'"
|
|
521
|
+
|
|
522
|
+
local branch_data
|
|
523
|
+
branch_data="{\"branch\": \"$branch_name\", \"ref\": \"$source_branch\"}"
|
|
524
|
+
|
|
525
|
+
if glab api --method POST "projects/$project_id/repository/branches" --field "$branch_data"; then
|
|
526
|
+
print_success "$SUCCESS_BRANCH_CREATED"
|
|
527
|
+
else
|
|
528
|
+
print_error "Failed to create branch"
|
|
529
|
+
return 1
|
|
530
|
+
fi
|
|
531
|
+
return 0
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
# ------------------------------------------------------------------------------
|
|
535
|
+
# ACCOUNT MANAGEMENT
|
|
536
|
+
# ------------------------------------------------------------------------------
|
|
537
|
+
|
|
538
|
+
list_accounts() {
|
|
539
|
+
print_info "Configured GitLab accounts:"
|
|
540
|
+
if [[ -f "$CONFIG_FILE" ]]; then
|
|
541
|
+
jq -r '.accounts | keys[]' "$CONFIG_FILE" 2>/dev/null || print_warning "No accounts configured"
|
|
542
|
+
else
|
|
543
|
+
print_warning "Configuration file not found"
|
|
544
|
+
fi
|
|
545
|
+
return 0
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
show_help() {
|
|
549
|
+
cat << EOF
|
|
550
|
+
GitLab CLI Helper Script
|
|
551
|
+
Usage: $0 [command] [account] [arguments]
|
|
552
|
+
|
|
553
|
+
GitLab management using GitLab CLI (glab)
|
|
554
|
+
|
|
555
|
+
COMMANDS:
|
|
556
|
+
Project Management:
|
|
557
|
+
list-projects [account] [filter] [vis] - List projects
|
|
558
|
+
filter: search term
|
|
559
|
+
visibility: internal|private|public
|
|
560
|
+
create-project <account> <name> [desc] [vis] [init] - Create project
|
|
561
|
+
visibility: internal|private|public (default: public)
|
|
562
|
+
init: true|false to create README (default: false)
|
|
563
|
+
delete-project <account> <project_id> - Delete project (requires confirmation)
|
|
564
|
+
get-project <account> <identifier> - Get project details
|
|
565
|
+
|
|
566
|
+
Issue Management:
|
|
567
|
+
list-issues <account> <project> [state] - List issues (opened|closed|all)
|
|
568
|
+
create-issue <account> <project> <title> [desc] - Create issue
|
|
569
|
+
close-issue <account> <project> <number> - Close issue
|
|
570
|
+
|
|
571
|
+
Merge Request Management:
|
|
572
|
+
list-mrs <account> <project> [state] - List merge requests
|
|
573
|
+
create-mr <account> <project> <title> <source> [target] [desc] - Create MR
|
|
574
|
+
merge-mr <account> <project> <number> [method] - Merge MR (merge|squash|rebase)
|
|
575
|
+
|
|
576
|
+
Branch Management:
|
|
577
|
+
list-branches <account> <project> - List branches
|
|
578
|
+
create-branch <account> <project> <branch> [source] - Create branch
|
|
579
|
+
|
|
580
|
+
Account Management:
|
|
581
|
+
list-accounts - List configured accounts
|
|
582
|
+
help - $HELP_SHOW_MESSAGE
|
|
583
|
+
|
|
584
|
+
EXAMPLES:
|
|
585
|
+
$0 list-projects marcusquinn
|
|
586
|
+
$0 create-project marcusquinn new-project "My GitLab project" private true
|
|
587
|
+
$0 list-issues marcusquinn my-project opened
|
|
588
|
+
$0 create-issue marcusquinn my-project "Bug report" "Issue description"
|
|
589
|
+
$0 create-mr marcusquinn my-project "Fix feature" fix-branch main
|
|
590
|
+
|
|
591
|
+
CONFIGURATION:
|
|
592
|
+
File: configs/gitlab-cli-config.json
|
|
593
|
+
Example: cp configs/gitlab-cli-config.json.txt configs/gitlab-cli-config.json
|
|
594
|
+
|
|
595
|
+
REQUIREMENTS:
|
|
596
|
+
- GitLab CLI (glab) installed and authenticated
|
|
597
|
+
- jq JSON processor
|
|
598
|
+
- Valid GitLab access token
|
|
599
|
+
|
|
600
|
+
For more information, see the GitLab CLI documentation: https://glab.readthedocs.io/
|
|
601
|
+
EOF
|
|
602
|
+
return 0
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
# ------------------------------------------------------------------------------
|
|
606
|
+
# MAIN COMMAND HANDLER
|
|
607
|
+
# ------------------------------------------------------------------------------
|
|
608
|
+
|
|
609
|
+
main() {
|
|
610
|
+
local command="${1:-help}"
|
|
611
|
+
local account_name="$2"
|
|
612
|
+
local target="$3"
|
|
613
|
+
local options="$4"
|
|
614
|
+
|
|
615
|
+
case "$command" in
|
|
616
|
+
"list-projects")
|
|
617
|
+
list_projects "$account_name" "$target" "$options"
|
|
618
|
+
;;
|
|
619
|
+
"create-project")
|
|
620
|
+
local proj_desc="$options"
|
|
621
|
+
local proj_vis="$5"
|
|
622
|
+
local proj_init="$6"
|
|
623
|
+
create_project "$account_name" "$target" "$proj_desc" "$proj_vis" "$proj_init"
|
|
624
|
+
;;
|
|
625
|
+
"delete-project")
|
|
626
|
+
delete_project "$account_name" "$target"
|
|
627
|
+
;;
|
|
628
|
+
"get-project")
|
|
629
|
+
get_project_details "$account_name" "$target"
|
|
630
|
+
;;
|
|
631
|
+
"list-issues")
|
|
632
|
+
list_issues "$account_name" "$target" "$options"
|
|
633
|
+
;;
|
|
634
|
+
"create-issue")
|
|
635
|
+
local issue_desc="$5"
|
|
636
|
+
create_issue "$account_name" "$target" "$options" "$issue_desc"
|
|
637
|
+
;;
|
|
638
|
+
"close-issue")
|
|
639
|
+
close_issue "$account_name" "$target" "$options"
|
|
640
|
+
;;
|
|
641
|
+
"list-mrs")
|
|
642
|
+
list_merge_requests "$account_name" "$target" "$options"
|
|
643
|
+
;;
|
|
644
|
+
"create-mr")
|
|
645
|
+
local mr_src="$5"
|
|
646
|
+
local mr_tgt="$6"
|
|
647
|
+
local mr_desc="$7"
|
|
648
|
+
create_merge_request "$account_name" "$target" "$options" "$mr_src" "$mr_tgt" "$mr_desc"
|
|
649
|
+
;;
|
|
650
|
+
"merge-mr")
|
|
651
|
+
local mr_method="$5"
|
|
652
|
+
merge_merge_request "$account_name" "$target" "$options" "$mr_method"
|
|
653
|
+
;;
|
|
654
|
+
"list-branches")
|
|
655
|
+
list_branches "$account_name" "$target"
|
|
656
|
+
;;
|
|
657
|
+
"create-branch")
|
|
658
|
+
local branch_src="$5"
|
|
659
|
+
create_branch "$account_name" "$target" "$options" "$branch_src"
|
|
660
|
+
;;
|
|
661
|
+
"list-accounts")
|
|
662
|
+
list_accounts
|
|
663
|
+
;;
|
|
664
|
+
"help"|"-h"|"--help")
|
|
665
|
+
show_help
|
|
666
|
+
;;
|
|
667
|
+
*)
|
|
668
|
+
print_error "$ERROR_UNKNOWN_COMMAND $command"
|
|
669
|
+
print_info "Use '$0 help' for usage information"
|
|
670
|
+
exit 1
|
|
671
|
+
;;
|
|
672
|
+
esac
|
|
673
|
+
|
|
674
|
+
return 0
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
# Initialize
|
|
678
|
+
check_dependencies
|
|
679
|
+
load_config
|
|
680
|
+
|
|
681
|
+
# Execute main function
|
|
682
|
+
main "$@"
|