@cbs-consulting/generator-btp 1.2.7 → 1.2.9
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.
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
[alias]
|
|
2
|
-
|
|
2
|
+
# Helper aliases for ticket workflow
|
|
3
3
|
extract-branch-parts = "!f() { current_branch=$(git branch --show-current); case \"$current_branch\" in */*) prefix=\"${current_branch%%/*}\"; ticketRef=\"${current_branch#*/}\"; echo \"$prefix|$ticketRef\" ;; *) echo \"Error: Branch name must contain a prefix (e.g., feature/ABC-123)\" >&2; return 1 ;; esac; }; f"
|
|
4
4
|
capitalize-prefix = "!f() { first_char=$(printf '%s' \"$1\" | cut -c1 | tr '[:lower:]' '[:upper:]'); rest_chars=$(printf '%s' \"$1\" | cut -c2-); echo \"$first_char$rest_chars\"; }; f"
|
|
5
5
|
format-pr-url = "!f() { pr_id=\"$1\"; remote_url=$(git config --get remote.origin.url | sed 's|https://[^@]*@|https://|'); base_url=$(echo \"$remote_url\" | sed 's|\\.git$||'); echo \"${base_url}/pullrequest/${pr_id}\"; }; f"
|
|
6
|
-
get-commit-message = "!f() { provided_message=\"$1\"; default_branch=\"$2\"; current_branch=$(git branch --show-current); commit_count=$(git rev-list --count $default_branch..$current_branch 2>/dev/null
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
get-commit-message = "!f() { provided_message=\"$1\"; default_branch=\"$2\"; current_branch=$(git branch --show-current); remote=$(git config --get branch.$default_branch.remote); if [ -z \"$remote\" ]; then echo \"Error: No remote configured for branch $default_branch\" >&2; return 1; fi; commit_count=$(git rev-list --count $remote/$default_branch..$current_branch 2>/dev/null); if [ -z \"$commit_count\" ]; then echo \"Error: Failed to get commit count\" >&2; return 1; fi; if [ \"$commit_count\" -eq 1 ]; then if [ -z \"$provided_message\" ]; then git log -1 --pretty=%s; else echo \"$provided_message\"; fi; elif [ \"$commit_count\" -gt 1 ]; then if [ -z \"$provided_message\" ]; then echo \"Error: Multiple commits found. Please provide a message with -m <message>\" >&2; return 1; fi; echo \"$provided_message\"; else echo \"Error: No commits found on this branch\" >&2; return 1; fi; }; f"
|
|
7
|
+
get-merge-strategy = "!f() { repoName=$(basename -s .git \"$(git config --get remote.origin.url)\"); repoId=$(az repos list --query \"[?name=='$repoName'].id\" -o tsv 2>/dev/null); if [ -z \"$repoId\" ]; then return 0; fi; default_branch=$(git default-branch); if [ $? -ne 0 ]; then return 1; fi; policy=$(az repos policy list --repository-id \"$repoId\" --branch \"$default_branch\" --query \"[?type.displayName=='Require a merge strategy'].settings | [0]\" -o json 2>/dev/null); if [ -z \"$policy\" ] || [ \"$policy\" = \"null\" ]; then return 0; fi; if echo \"$policy\" | grep -q '\"allowSquash\": true'; then echo 'squash'; elif echo \"$policy\" | grep -q '\"allowNoFastForward\": true'; then echo 'noFastForward'; elif echo \"$policy\" | grep -q '\"allowRebase\": true'; then echo 'rebase'; elif echo \"$policy\" | grep -q '\"allowRebaseMerge\": true'; then echo 'rebaseMerge'; fi; }; f"
|
|
8
|
+
stash-if-dirty = "!f() { if ! git diff-index --quiet HEAD -- 2>/dev/null; then echo 'Stashing...' >&2; git stash >/dev/null 2>&1 && echo 'stashed'; fi; }; f"
|
|
9
|
+
unstash-if-needed = "!f() { if [ \"$1\" = \"stashed\" ]; then echo 'Restoring stash...' >&2; git stash pop >/dev/null 2>&1; fi; }; f"
|
|
10
|
+
revert-stash-if-needed = "!f() { if [ \"$1\" = \"stashed\" ]; then echo 'Reverting stash...' >&2; git stash pop >/dev/null 2>&1; fi; }; f"
|
|
10
11
|
open-ticket-help = "!f() { default_branch=$(git default-branch); echo ''; echo '----------------------------------------'; echo ''; echo 'Usage: git open-ticket [prefix] <ticketRef>'; echo ''; echo \"Creates a new feature branch from the default branch.\"; echo \"The default branch of this project is: $default_branch.\"; echo ''; echo 'Arguments:'; echo ' ticketRef Ticket reference (e.g., ABC-123)'; echo ' prefix Optional branch prefix (default: feature)'; echo ''; echo 'Options:'; echo ' -h Show this help message'; echo ''; echo 'Examples:'; echo ' git open-ticket ABC-123 # Creates feature/ABC-123'; echo ' git open-ticket bugfix ABC-123 # Creates bugfix/ABC-123'; echo ' git open-ticket hotfix XYZ-456 # Creates hotfix/XYZ-456'; }; f"
|
|
11
12
|
close-ticket-help = "!f() { default_branch=$(git default-branch); echo ''; echo '----------------------------------------'; echo ''; echo 'Usage: git close-ticket [OPTIONS]'; echo ''; echo \"Creates a pull request from the current branch to the default branch.\"; echo \"The default branch of this project is: $default_branch.\"; echo ''; echo \"The message is prefixed based on the branch name.\"; echo \"Example: feature/ABC-123 -> Feature ABC-123: <message>\"; echo ''; echo 'Options:'; echo ' --auto-complete Enable auto-complete and delete source branch after merge'; echo ' -m <message> Custom PR message (required if multiple commits exist)'; echo ' -h Show this help message'; echo ''; echo 'Examples:'; echo ' git close-ticket'; echo ' git close-ticket --auto-complete'; echo ' git close-ticket -m \"Add new feature\"'; echo ' git close-ticket --auto-complete -m \"Fix bug\"'; }; f"
|
|
12
13
|
|
|
13
14
|
# Main ticket workflow aliases
|
|
14
|
-
close-ticket = "!f() { message=\"\";
|
|
15
|
+
close-ticket = "!f() { message=\"\"; auto_complete_enabled=false; while [ $# -gt 0 ]; do case \"$1\" in -h) git close-ticket-help; return 0 ;; -m) if [ -z \"$2\" ]; then echo \"Error: -m requires a message\" >&2; return 1; fi; message=\"$2\"; shift 2 ;; --auto-complete) auto_complete_enabled=true; shift ;; *) echo \"Error: Unknown parameter '$1'. Usage: git close-ticket [--auto-complete] [-m <message>]\" >&2; return 1 ;; esac; done; parts=$(git extract-branch-parts) || return 1; prefix=$(echo \"$parts\" | cut -d'|' -f1); ticketRef=$(echo \"$parts\" | cut -d'|' -f2); git push || return 1; default_branch=$(git default-branch); message=$(git get-commit-message \"$message\" \"$default_branch\") || return 1; prefix_cap=$(git capitalize-prefix \"$prefix\"); pr_title=\"$prefix_cap $ticketRef: $message\"; echo \"Creating PR: $pr_title\"; auto_complete=\"\"; if [ \"$auto_complete_enabled\" = true ]; then merge_strategy=$(git get-merge-strategy); if [ \"$merge_strategy\" = \"squash\" ]; then auto_complete=\"--auto-complete true --delete-source-branch true --squash true\"; elif [ \"$merge_strategy\" = \"noFastForward\" ]; then auto_complete=\"--auto-complete true --delete-source-branch true\"; elif [ -n \"$merge_strategy\" ]; then echo \"Warning: Merge strategy '$merge_strategy' requires manual completion. Creating PR without auto-complete.\" >&2; else auto_complete=\"--auto-complete true --delete-source-branch true --squash true\"; fi; fi; pr_id=$(az repos pr create --title \"$pr_title\" --target-branch \"$default_branch\" --source-branch \"$(git branch --show-current)\" $auto_complete -o tsv --query \"pullRequestId\") || return 1; pr_url=$(git format-pr-url \"$pr_id\"); echo \"PR created: $pr_url\"; git switch $(git default-branch) && git pull && git cleanup-branches; }; f"
|
|
15
16
|
open-ticket = "!f() { if [ \"$1\" = \"-h\" ]; then git open-ticket-help; return 0; fi; if [ -z \"$1\" ]; then echo \"Error: Please provide a ticket name. Usage: git open-ticket [prefix] <ticketRef>\" >&2; return 1; fi; if [ -n \"$2\" ]; then prefix=\"$1/\"; ticket=\"$2\"; else prefix=\"feature/\"; ticket=\"$1\"; fi; case \"$ticket\" in */*) echo \"Error: Ticket name cannot contain '/'. Use separate prefix parameter instead. Example: git open-ticket feature ABC-123\" >&2; return 1 ;; esac; stash_status=$(git stash-if-dirty); if ! git switch $(git default-branch); then git revert-stash-if-needed \"$stash_status\"; return 1; fi; if ! git pull; then git revert-stash-if-needed \"$stash_status\"; return 1; fi; if ! git switch -c \"$prefix$ticket\"; then git revert-stash-if-needed \"$stash_status\"; return 1; fi; git unstash-if-needed \"$stash_status\"; }; f"
|
|
16
17
|
default-branch = "!f() { \n if ! az extension list --query \"[?name=='azure-devops'].name\" -o tsv 2>/dev/null | grep -q 'azure-devops'; then \n echo \"Error: azure-devops extension is not installed. Install it with: az extension add --name azure-devops\" >&2; \n return 1; \n fi; \n if ! az account show >/dev/null 2>&1; then \n echo \"Error: Not logged in to Azure. Login with: az login --allow-no-subscriptions\" >&2; \n return 1; \n fi; \n repoName=$(basename -s .git \"$(git config --get remote.origin.url)\"); \n remoteBranch=$(az repos show --query defaultBranch -o tsv -r \"$repoName\"); \n localBranch=$(git rev-parse --abbrev-ref \"$remoteBranch\"); \n echo \"$localBranch\"; \n}; f"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cbs-consulting/generator-btp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yeoman generator for bootstrapping CAP/UI5 projects with TypeScript, ESLint, and other essential configurations",
|
|
6
6
|
"main": "generators/app/index.js",
|