bbk-cli 1.0.0 → 1.1.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +11 -5
- package/dist/cli/wrapper.d.ts.map +1 -1
- package/dist/cli/wrapper.js +20 -25
- package/dist/cli/wrapper.js.map +1 -1
- package/dist/commands/helpers.js +1 -1
- package/dist/commands/runner.d.ts.map +1 -1
- package/dist/commands/runner.js +20 -24
- package/dist/commands/runner.js.map +1 -1
- package/dist/utils/bitbucket-client.d.ts +22 -22
- package/dist/utils/bitbucket-client.d.ts.map +1 -1
- package/dist/utils/bitbucket-client.js +11 -11
- package/dist/utils/bitbucket-client.js.map +1 -1
- package/dist/utils/bitbucket-utils.d.ts +94 -14
- package/dist/utils/bitbucket-utils.d.ts.map +1 -1
- package/dist/utils/bitbucket-utils.js +125 -13
- package/dist/utils/bitbucket-utils.js.map +1 -1
- package/dist/utils/config-loader.d.ts +1 -0
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js.map +1 -1
- package/package.json +1 -1
- package/tests/unit/cli/wrapper.test.ts +4 -8
- package/tests/unit/commands/runner.test.ts +5 -11
- package/.claude/bitbucket-config.local.md.example +0 -58
- package/.eslintcache +0 -1
|
@@ -21,7 +21,7 @@ async function initBitbucket() {
|
|
|
21
21
|
/**
|
|
22
22
|
* List all repositories in a workspace
|
|
23
23
|
* @param profile - Bitbucket profile name
|
|
24
|
-
* @param workspace - Workspace ID or slug
|
|
24
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
25
25
|
* @param format - Output format (json, toon)
|
|
26
26
|
*/
|
|
27
27
|
export async function listRepositories(profile, workspace, format = 'json') {
|
|
@@ -31,7 +31,7 @@ export async function listRepositories(profile, workspace, format = 'json') {
|
|
|
31
31
|
/**
|
|
32
32
|
* Get repository details
|
|
33
33
|
* @param profile - Bitbucket profile name
|
|
34
|
-
* @param workspace - Workspace ID or slug
|
|
34
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
35
35
|
* @param repoSlug - Repository slug
|
|
36
36
|
* @param format - Output format (json, toon)
|
|
37
37
|
*/
|
|
@@ -42,7 +42,7 @@ export async function getRepository(profile, workspace, repoSlug, format = 'json
|
|
|
42
42
|
/**
|
|
43
43
|
* List pull requests in a repository
|
|
44
44
|
* @param profile - Bitbucket profile name
|
|
45
|
-
* @param workspace - Workspace ID or slug
|
|
45
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
46
46
|
* @param repoSlug - Repository slug
|
|
47
47
|
* @param state - Pull request state (optional)
|
|
48
48
|
* @param format - Output format (json, toon)
|
|
@@ -54,7 +54,7 @@ export async function listPullRequests(profile, workspace, repoSlug, state, form
|
|
|
54
54
|
/**
|
|
55
55
|
* Get pull request details
|
|
56
56
|
* @param profile - Bitbucket profile name
|
|
57
|
-
* @param workspace - Workspace ID or slug
|
|
57
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
58
58
|
* @param repoSlug - Repository slug
|
|
59
59
|
* @param pullRequestId - Pull request ID
|
|
60
60
|
* @param format - Output format (json, toon)
|
|
@@ -66,7 +66,7 @@ export async function getPullRequest(profile, workspace, repoSlug, pullRequestId
|
|
|
66
66
|
/**
|
|
67
67
|
* Create a new pull request
|
|
68
68
|
* @param profile - Bitbucket profile name
|
|
69
|
-
* @param workspace - Workspace ID or slug
|
|
69
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
70
70
|
* @param repoSlug - Repository slug
|
|
71
71
|
* @param title - Pull request title
|
|
72
72
|
* @param sourceBranch - Source branch name
|
|
@@ -81,7 +81,7 @@ export async function createPullRequest(profile, workspace, repoSlug, title, sou
|
|
|
81
81
|
/**
|
|
82
82
|
* List branches in a repository
|
|
83
83
|
* @param profile - Bitbucket profile name
|
|
84
|
-
* @param workspace - Workspace ID or slug
|
|
84
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
85
85
|
* @param repoSlug - Repository slug
|
|
86
86
|
* @param q - Query string to filter branches
|
|
87
87
|
* @param sort - Sort field
|
|
@@ -94,7 +94,7 @@ export async function listBranches(profile, workspace, repoSlug, q, sort, format
|
|
|
94
94
|
/**
|
|
95
95
|
* List commits in a repository
|
|
96
96
|
* @param profile - Bitbucket profile name
|
|
97
|
-
* @param workspace - Workspace ID or slug
|
|
97
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
98
98
|
* @param repoSlug - Repository slug
|
|
99
99
|
* @param branch - Branch name (optional)
|
|
100
100
|
* @param format - Output format (json, toon)
|
|
@@ -106,7 +106,7 @@ export async function listCommits(profile, workspace, repoSlug, branch, format =
|
|
|
106
106
|
/**
|
|
107
107
|
* List issues in a repository
|
|
108
108
|
* @param profile - Bitbucket profile name
|
|
109
|
-
* @param workspace - Workspace ID or slug
|
|
109
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
110
110
|
* @param repoSlug - Repository slug
|
|
111
111
|
* @param format - Output format (json, toon)
|
|
112
112
|
*/
|
|
@@ -117,7 +117,7 @@ export async function listIssues(profile, workspace, repoSlug, format = 'json')
|
|
|
117
117
|
/**
|
|
118
118
|
* Get issue details
|
|
119
119
|
* @param profile - Bitbucket profile name
|
|
120
|
-
* @param workspace - Workspace ID or slug
|
|
120
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
121
121
|
* @param repoSlug - Repository slug
|
|
122
122
|
* @param issueId - Issue ID
|
|
123
123
|
* @param format - Output format (json, toon)
|
|
@@ -129,7 +129,7 @@ export async function getIssue(profile, workspace, repoSlug, issueId, format = '
|
|
|
129
129
|
/**
|
|
130
130
|
* Create a new issue
|
|
131
131
|
* @param profile - Bitbucket profile name
|
|
132
|
-
* @param workspace - Workspace ID or slug
|
|
132
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
133
133
|
* @param repoSlug - Repository slug
|
|
134
134
|
* @param title - Issue title
|
|
135
135
|
* @param content - Issue content/description (optional)
|
|
@@ -144,7 +144,7 @@ export async function createIssue(profile, workspace, repoSlug, title, content,
|
|
|
144
144
|
/**
|
|
145
145
|
* List pipelines in a repository
|
|
146
146
|
* @param profile - Bitbucket profile name
|
|
147
|
-
* @param workspace - Workspace ID or slug
|
|
147
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
148
148
|
* @param repoSlug - Repository slug
|
|
149
149
|
* @param format - Output format (json, toon)
|
|
150
150
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitbucket-client.js","sourceRoot":"","sources":["../../src/utils/bitbucket-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAErE,IAAI,aAAa,GAAyB,IAAI,CAAC;AAE/C;;GAEG;AACH,KAAK,UAAU,aAAa;IAC1B,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC;IAExC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QACvC,aAAa,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,0CAA0C,YAAY,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UA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AAE,CAAC;IACxC,OAAO,MAAM,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC3G,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,SAA6B,EAC7B,QAAgB,EAChB,SAA0B,MAAM;IAEhC,MAAM,SAAS,GAAG,MAAM,aAAa,EAAE,CAAC;IACxC,OAAO,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,OAAe,EACf,QAAiB,EACjB,SAA0B,MAAM;IAEhC,MAAM,SAAS,GAAG,MAAM,aAAa,EAAE,CAAC;IACxC,OAAO,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,SAAS,GAAG,MAAM,aAAa,EAAE,CAAC;IACxC,OAAO,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,YAAY,EAAE,CAAC;QAC7B,aAAa,GAAG,IAAI,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -27,6 +27,13 @@ export declare class BitbucketUtil {
|
|
|
27
27
|
* Get authentication for a profile
|
|
28
28
|
*/
|
|
29
29
|
getAuth(profileName: string): BitbucketClientAuth;
|
|
30
|
+
/**
|
|
31
|
+
* Get the default workspace for a profile
|
|
32
|
+
* @param profileName - Name of the profile to get the default workspace for
|
|
33
|
+
* @returns The default workspace string configured for the profile
|
|
34
|
+
* @throws Error if profile is not found or defaultWorkspace is not configured
|
|
35
|
+
*/
|
|
36
|
+
getDefaultWorkspace(profileName: string): string;
|
|
30
37
|
/**
|
|
31
38
|
* Make authenticated request to Bitbucket API
|
|
32
39
|
*/
|
|
@@ -45,54 +52,127 @@ export declare class BitbucketUtil {
|
|
|
45
52
|
formatResult(data: unknown, format?: 'json' | 'toon'): string;
|
|
46
53
|
/**
|
|
47
54
|
* List all repositories in a workspace
|
|
55
|
+
* @param profileName - Bitbucket profile name
|
|
56
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
57
|
+
* @param format - Output format (json, toon)
|
|
58
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
48
59
|
*/
|
|
49
|
-
listRepositories(profileName: string, workspace
|
|
60
|
+
listRepositories(profileName: string, workspace?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
50
61
|
/**
|
|
51
62
|
* Get repository details
|
|
63
|
+
* @param profileName - Bitbucket profile name
|
|
64
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
65
|
+
* @param repoSlug - Repository slug identifier
|
|
66
|
+
* @param format - Output format (json, toon)
|
|
67
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
52
68
|
*/
|
|
53
|
-
getRepository(profileName: string, workspace: string, repoSlug: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
69
|
+
getRepository(profileName: string, workspace: string | undefined, repoSlug: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
54
70
|
/**
|
|
55
71
|
* List pull requests in a repository
|
|
72
|
+
* @param profileName - Bitbucket profile name
|
|
73
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
74
|
+
* @param repoSlug - Repository slug identifier
|
|
75
|
+
* @param state - Filter by state (OPEN, MERGED, DECLINED, SUPERSEDED)
|
|
76
|
+
* @param format - Output format (json, toon)
|
|
77
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
56
78
|
*/
|
|
57
|
-
listPullRequests(profileName: string, workspace: string, repoSlug: string, state?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
79
|
+
listPullRequests(profileName: string, workspace: string | undefined, repoSlug: string, state?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
58
80
|
/**
|
|
59
81
|
* Get pull request details
|
|
82
|
+
* @param profileName - Bitbucket profile name
|
|
83
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
84
|
+
* @param repoSlug - Repository slug identifier
|
|
85
|
+
* @param pullRequestId - Pull request ID
|
|
86
|
+
* @param format - Output format (json, toon)
|
|
87
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
60
88
|
*/
|
|
61
|
-
getPullRequest(profileName: string, workspace: string, repoSlug: string, pullRequestId: number, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
89
|
+
getPullRequest(profileName: string, workspace: string | undefined, repoSlug: string, pullRequestId: number, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
62
90
|
/**
|
|
63
91
|
* Get default reviewers for a repository
|
|
92
|
+
* @param profileName - Bitbucket profile name
|
|
93
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
94
|
+
* @param repoSlug - Repository slug identifier
|
|
95
|
+
* @returns Array of reviewer UUIDs
|
|
96
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
64
97
|
*/
|
|
65
|
-
getDefaultReviewers(profileName: string, workspace: string, repoSlug: string): Promise<Array<{
|
|
98
|
+
getDefaultReviewers(profileName: string, workspace: string | undefined, repoSlug: string): Promise<Array<{
|
|
66
99
|
uuid: string;
|
|
67
100
|
}>>;
|
|
68
101
|
/**
|
|
69
102
|
* Create a new pull request
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
* @param profileName - Bitbucket profile name
|
|
104
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
105
|
+
* @param repoSlug - Repository slug identifier
|
|
106
|
+
* @param title - Pull request title
|
|
107
|
+
* @param sourceBranch - Source branch name
|
|
108
|
+
* @param destinationBranch - Destination branch name
|
|
109
|
+
* @param description - Pull request description (optional)
|
|
110
|
+
* @param format - Output format (json, toon)
|
|
111
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
112
|
+
*/
|
|
113
|
+
createPullRequest(profileName: string, workspace: string | undefined, repoSlug: string, title: string, sourceBranch: string, destinationBranch: string, description?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
72
114
|
/**
|
|
73
115
|
* List branches in a repository
|
|
116
|
+
* @param profileName - Bitbucket profile name
|
|
117
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
118
|
+
* @param repoSlug - Repository slug identifier
|
|
119
|
+
* @param q - Query filter for branch names (optional)
|
|
120
|
+
* @param sort - Sort order (optional)
|
|
121
|
+
* @param format - Output format (json, toon)
|
|
122
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
74
123
|
*/
|
|
75
|
-
listBranches(profileName: string, workspace: string, repoSlug: string, q?: string, sort?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
124
|
+
listBranches(profileName: string, workspace: string | undefined, repoSlug: string, q?: string, sort?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
76
125
|
/**
|
|
77
126
|
* List commits in a repository
|
|
127
|
+
* @param profileName - Bitbucket profile name
|
|
128
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
129
|
+
* @param repoSlug - Repository slug identifier
|
|
130
|
+
* @param branch - Branch name to limit commits to (optional)
|
|
131
|
+
* @param format - Output format (json, toon)
|
|
132
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
78
133
|
*/
|
|
79
|
-
listCommits(profileName: string, workspace: string, repoSlug: string, branch?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
134
|
+
listCommits(profileName: string, workspace: string | undefined, repoSlug: string, branch?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
80
135
|
/**
|
|
81
136
|
* List issues in a repository
|
|
137
|
+
* @param profileName - Bitbucket profile name
|
|
138
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
139
|
+
* @param repoSlug - Repository slug identifier
|
|
140
|
+
* @param format - Output format (json, toon)
|
|
141
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
82
142
|
*/
|
|
83
|
-
listIssues(profileName: string, workspace: string, repoSlug: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
143
|
+
listIssues(profileName: string, workspace: string | undefined, repoSlug: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
84
144
|
/**
|
|
85
145
|
* Get issue details
|
|
146
|
+
* @param profileName - Bitbucket profile name
|
|
147
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
148
|
+
* @param repoSlug - Repository slug identifier
|
|
149
|
+
* @param issueId - Issue ID
|
|
150
|
+
* @param format - Output format (json, toon)
|
|
151
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
86
152
|
*/
|
|
87
|
-
getIssue(profileName: string, workspace: string, repoSlug: string, issueId: number, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
153
|
+
getIssue(profileName: string, workspace: string | undefined, repoSlug: string, issueId: number, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
88
154
|
/**
|
|
89
155
|
* Create a new issue
|
|
90
|
-
|
|
91
|
-
|
|
156
|
+
* @param profileName - Bitbucket profile name
|
|
157
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
158
|
+
* @param repoSlug - Repository slug identifier
|
|
159
|
+
* @param title - Issue title
|
|
160
|
+
* @param content - Issue content/description (optional)
|
|
161
|
+
* @param kind - Issue kind (bug, enhancement, proposal, task) (optional)
|
|
162
|
+
* @param priority - Issue priority (trivial, minor, major, critical, blocker) (optional)
|
|
163
|
+
* @param format - Output format (json, toon)
|
|
164
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
165
|
+
*/
|
|
166
|
+
createIssue(profileName: string, workspace: string | undefined, repoSlug: string, title: string, content?: string, kind?: string, priority?: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
92
167
|
/**
|
|
93
168
|
* List pipelines in a repository
|
|
169
|
+
* @param profileName - Bitbucket profile name
|
|
170
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
171
|
+
* @param repoSlug - Repository slug identifier
|
|
172
|
+
* @param format - Output format (json, toon)
|
|
173
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
94
174
|
*/
|
|
95
|
-
listPipelines(profileName: string, workspace: string, repoSlug: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
175
|
+
listPipelines(profileName: string, workspace: string | undefined, repoSlug: string, format?: 'json' | 'toon'): Promise<ApiResult>;
|
|
96
176
|
/**
|
|
97
177
|
* Get user information
|
|
98
178
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitbucket-utils.d.ts","sourceRoot":"","sources":["../../src/utils/bitbucket-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkGD;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO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ACjB,MAAM,GAAE,MAAM,GAAG,MAAe,GAC/B,OAAO,CAAC,SAAS,CAAC;IAqCrB;;;;;;;OAOG;IACG,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAM,GAAG,MAAe,GAC/B,OAAO,CAAC,SAAS,CAAC;IAiCrB;;OAEG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,MAAe,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B3G;;OAEG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAmB7D;;OAEG;IACH,YAAY,IAAI,IAAI;CAGrB"}
|
|
@@ -30,6 +30,22 @@ export class BitbucketUtil {
|
|
|
30
30
|
this.authPool.set(profileName, auth);
|
|
31
31
|
return auth;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the default workspace for a profile
|
|
35
|
+
* @param profileName - Name of the profile to get the default workspace for
|
|
36
|
+
* @returns The default workspace string configured for the profile
|
|
37
|
+
* @throws Error if profile is not found or defaultWorkspace is not configured
|
|
38
|
+
*/
|
|
39
|
+
getDefaultWorkspace(profileName) {
|
|
40
|
+
const profile = this.config.profiles[profileName];
|
|
41
|
+
if (!profile) {
|
|
42
|
+
throw new Error(`Profile "${profileName}" not found`);
|
|
43
|
+
}
|
|
44
|
+
if (!profile.defaultWorkspace) {
|
|
45
|
+
throw new Error(`No default workspace configured for profile "${profileName}". Please provide a workspace parameter or set defaultWorkspace in your profile configuration.`);
|
|
46
|
+
}
|
|
47
|
+
return profile.defaultWorkspace;
|
|
48
|
+
}
|
|
33
49
|
/**
|
|
34
50
|
* Make authenticated request to Bitbucket API
|
|
35
51
|
*/
|
|
@@ -83,10 +99,16 @@ export class BitbucketUtil {
|
|
|
83
99
|
}
|
|
84
100
|
/**
|
|
85
101
|
* List all repositories in a workspace
|
|
102
|
+
* @param profileName - Bitbucket profile name
|
|
103
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
104
|
+
* @param format - Output format (json, toon)
|
|
105
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
86
106
|
*/
|
|
87
107
|
async listRepositories(profileName, workspace, format = 'json') {
|
|
88
108
|
try {
|
|
89
|
-
|
|
109
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
110
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
111
|
+
const response = (await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}`));
|
|
90
112
|
// Simplify repository data for display
|
|
91
113
|
const repos = response.values || [];
|
|
92
114
|
const simplifiedRepos = repos.map(r => ({
|
|
@@ -114,10 +136,17 @@ export class BitbucketUtil {
|
|
|
114
136
|
}
|
|
115
137
|
/**
|
|
116
138
|
* Get repository details
|
|
139
|
+
* @param profileName - Bitbucket profile name
|
|
140
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
141
|
+
* @param repoSlug - Repository slug identifier
|
|
142
|
+
* @param format - Output format (json, toon)
|
|
143
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
117
144
|
*/
|
|
118
145
|
async getRepository(profileName, workspace, repoSlug, format = 'json') {
|
|
119
146
|
try {
|
|
120
|
-
|
|
147
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
148
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
149
|
+
const response = await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}`);
|
|
121
150
|
return {
|
|
122
151
|
success: true,
|
|
123
152
|
data: response,
|
|
@@ -134,10 +163,18 @@ export class BitbucketUtil {
|
|
|
134
163
|
}
|
|
135
164
|
/**
|
|
136
165
|
* List pull requests in a repository
|
|
166
|
+
* @param profileName - Bitbucket profile name
|
|
167
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
168
|
+
* @param repoSlug - Repository slug identifier
|
|
169
|
+
* @param state - Filter by state (OPEN, MERGED, DECLINED, SUPERSEDED)
|
|
170
|
+
* @param format - Output format (json, toon)
|
|
171
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
137
172
|
*/
|
|
138
173
|
async listPullRequests(profileName, workspace, repoSlug, state, format = 'json') {
|
|
139
174
|
try {
|
|
140
|
-
|
|
175
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
176
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
177
|
+
let endpoint = `/repositories/${resolvedWorkspace}/${repoSlug}/pullrequests`;
|
|
141
178
|
if (state) {
|
|
142
179
|
endpoint += `?state=${state}`;
|
|
143
180
|
}
|
|
@@ -170,10 +207,18 @@ export class BitbucketUtil {
|
|
|
170
207
|
}
|
|
171
208
|
/**
|
|
172
209
|
* Get pull request details
|
|
210
|
+
* @param profileName - Bitbucket profile name
|
|
211
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
212
|
+
* @param repoSlug - Repository slug identifier
|
|
213
|
+
* @param pullRequestId - Pull request ID
|
|
214
|
+
* @param format - Output format (json, toon)
|
|
215
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
173
216
|
*/
|
|
174
217
|
async getPullRequest(profileName, workspace, repoSlug, pullRequestId, format = 'json') {
|
|
175
218
|
try {
|
|
176
|
-
|
|
219
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
220
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
221
|
+
const response = await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/pullrequests/${pullRequestId}`);
|
|
177
222
|
return {
|
|
178
223
|
success: true,
|
|
179
224
|
data: response,
|
|
@@ -190,10 +235,16 @@ export class BitbucketUtil {
|
|
|
190
235
|
}
|
|
191
236
|
/**
|
|
192
237
|
* Get default reviewers for a repository
|
|
238
|
+
* @param profileName - Bitbucket profile name
|
|
239
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
240
|
+
* @param repoSlug - Repository slug identifier
|
|
241
|
+
* @returns Array of reviewer UUIDs
|
|
242
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
193
243
|
*/
|
|
194
244
|
async getDefaultReviewers(profileName, workspace, repoSlug) {
|
|
195
245
|
try {
|
|
196
|
-
const
|
|
246
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
247
|
+
const response = (await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/effective-default-reviewers`));
|
|
197
248
|
// Extract user UUIDs from the response
|
|
198
249
|
const reviewers = response.values || [];
|
|
199
250
|
return reviewers.map(reviewer => ({
|
|
@@ -207,13 +258,24 @@ export class BitbucketUtil {
|
|
|
207
258
|
}
|
|
208
259
|
/**
|
|
209
260
|
* Create a new pull request
|
|
261
|
+
* @param profileName - Bitbucket profile name
|
|
262
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
263
|
+
* @param repoSlug - Repository slug identifier
|
|
264
|
+
* @param title - Pull request title
|
|
265
|
+
* @param sourceBranch - Source branch name
|
|
266
|
+
* @param destinationBranch - Destination branch name
|
|
267
|
+
* @param description - Pull request description (optional)
|
|
268
|
+
* @param format - Output format (json, toon)
|
|
269
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
210
270
|
*/
|
|
211
271
|
async createPullRequest(profileName, workspace, repoSlug, title, sourceBranch, destinationBranch, description, format = 'json') {
|
|
212
272
|
try {
|
|
273
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
274
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
213
275
|
// Fetch the current authenticated user and default reviewers in parallel
|
|
214
276
|
const [currentUserResponse, defaultReviewers] = await Promise.all([
|
|
215
277
|
this.makeRequest(profileName, '/user'),
|
|
216
|
-
this.getDefaultReviewers(profileName,
|
|
278
|
+
this.getDefaultReviewers(profileName, resolvedWorkspace, repoSlug),
|
|
217
279
|
]);
|
|
218
280
|
const currentUserUuid = currentUserResponse.uuid;
|
|
219
281
|
// Filter out the current user from reviewers (author cannot be a reviewer)
|
|
@@ -237,7 +299,7 @@ export class BitbucketUtil {
|
|
|
237
299
|
if (filteredReviewers.length > 0) {
|
|
238
300
|
body.reviewers = filteredReviewers;
|
|
239
301
|
}
|
|
240
|
-
const response = await this.makeRequest(profileName, `/repositories/${
|
|
302
|
+
const response = await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/pullrequests`, 'POST', body);
|
|
241
303
|
return {
|
|
242
304
|
success: true,
|
|
243
305
|
data: response,
|
|
@@ -254,10 +316,19 @@ export class BitbucketUtil {
|
|
|
254
316
|
}
|
|
255
317
|
/**
|
|
256
318
|
* List branches in a repository
|
|
319
|
+
* @param profileName - Bitbucket profile name
|
|
320
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
321
|
+
* @param repoSlug - Repository slug identifier
|
|
322
|
+
* @param q - Query filter for branch names (optional)
|
|
323
|
+
* @param sort - Sort order (optional)
|
|
324
|
+
* @param format - Output format (json, toon)
|
|
325
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
257
326
|
*/
|
|
258
327
|
async listBranches(profileName, workspace, repoSlug, q, sort, format = 'json') {
|
|
259
328
|
try {
|
|
260
|
-
|
|
329
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
330
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
331
|
+
let endpoint = `/repositories/${resolvedWorkspace}/${repoSlug}/refs/branches`;
|
|
261
332
|
const params = [];
|
|
262
333
|
if (q && q.trim() !== '') {
|
|
263
334
|
params.push(`q=${encodeURIComponent(q)}`);
|
|
@@ -294,10 +365,18 @@ export class BitbucketUtil {
|
|
|
294
365
|
}
|
|
295
366
|
/**
|
|
296
367
|
* List commits in a repository
|
|
368
|
+
* @param profileName - Bitbucket profile name
|
|
369
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
370
|
+
* @param repoSlug - Repository slug identifier
|
|
371
|
+
* @param branch - Branch name to limit commits to (optional)
|
|
372
|
+
* @param format - Output format (json, toon)
|
|
373
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
297
374
|
*/
|
|
298
375
|
async listCommits(profileName, workspace, repoSlug, branch, format = 'json') {
|
|
299
376
|
try {
|
|
300
|
-
|
|
377
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
378
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
379
|
+
let endpoint = `/repositories/${resolvedWorkspace}/${repoSlug}/commits`;
|
|
301
380
|
if (branch) {
|
|
302
381
|
endpoint += `/${branch}`;
|
|
303
382
|
}
|
|
@@ -325,10 +404,17 @@ export class BitbucketUtil {
|
|
|
325
404
|
}
|
|
326
405
|
/**
|
|
327
406
|
* List issues in a repository
|
|
407
|
+
* @param profileName - Bitbucket profile name
|
|
408
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
409
|
+
* @param repoSlug - Repository slug identifier
|
|
410
|
+
* @param format - Output format (json, toon)
|
|
411
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
328
412
|
*/
|
|
329
413
|
async listIssues(profileName, workspace, repoSlug, format = 'json') {
|
|
330
414
|
try {
|
|
331
|
-
|
|
415
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
416
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
417
|
+
const response = (await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/issues`));
|
|
332
418
|
const issues = response.values || [];
|
|
333
419
|
const simplifiedIssues = issues.map(i => ({
|
|
334
420
|
id: i.id,
|
|
@@ -355,10 +441,18 @@ export class BitbucketUtil {
|
|
|
355
441
|
}
|
|
356
442
|
/**
|
|
357
443
|
* Get issue details
|
|
444
|
+
* @param profileName - Bitbucket profile name
|
|
445
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
446
|
+
* @param repoSlug - Repository slug identifier
|
|
447
|
+
* @param issueId - Issue ID
|
|
448
|
+
* @param format - Output format (json, toon)
|
|
449
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
358
450
|
*/
|
|
359
451
|
async getIssue(profileName, workspace, repoSlug, issueId, format = 'json') {
|
|
360
452
|
try {
|
|
361
|
-
|
|
453
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
454
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
455
|
+
const response = await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/issues/${issueId}`);
|
|
362
456
|
return {
|
|
363
457
|
success: true,
|
|
364
458
|
data: response,
|
|
@@ -375,9 +469,20 @@ export class BitbucketUtil {
|
|
|
375
469
|
}
|
|
376
470
|
/**
|
|
377
471
|
* Create a new issue
|
|
472
|
+
* @param profileName - Bitbucket profile name
|
|
473
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
474
|
+
* @param repoSlug - Repository slug identifier
|
|
475
|
+
* @param title - Issue title
|
|
476
|
+
* @param content - Issue content/description (optional)
|
|
477
|
+
* @param kind - Issue kind (bug, enhancement, proposal, task) (optional)
|
|
478
|
+
* @param priority - Issue priority (trivial, minor, major, critical, blocker) (optional)
|
|
479
|
+
* @param format - Output format (json, toon)
|
|
480
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
378
481
|
*/
|
|
379
482
|
async createIssue(profileName, workspace, repoSlug, title, content, kind, priority, format = 'json') {
|
|
380
483
|
try {
|
|
484
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
485
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
381
486
|
const issueData = { title };
|
|
382
487
|
if (content) {
|
|
383
488
|
issueData.content = { raw: content };
|
|
@@ -388,7 +493,7 @@ export class BitbucketUtil {
|
|
|
388
493
|
if (priority) {
|
|
389
494
|
issueData.priority = priority;
|
|
390
495
|
}
|
|
391
|
-
const response = await this.makeRequest(profileName, `/repositories/${
|
|
496
|
+
const response = await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/issues`, 'POST', issueData);
|
|
392
497
|
return {
|
|
393
498
|
success: true,
|
|
394
499
|
data: response,
|
|
@@ -405,10 +510,17 @@ export class BitbucketUtil {
|
|
|
405
510
|
}
|
|
406
511
|
/**
|
|
407
512
|
* List pipelines in a repository
|
|
513
|
+
* @param profileName - Bitbucket profile name
|
|
514
|
+
* @param workspace - Workspace ID or slug (optional, uses profile default if not provided)
|
|
515
|
+
* @param repoSlug - Repository slug identifier
|
|
516
|
+
* @param format - Output format (json, toon)
|
|
517
|
+
* @throws Error if neither workspace parameter nor profile defaultWorkspace is configured
|
|
408
518
|
*/
|
|
409
519
|
async listPipelines(profileName, workspace, repoSlug, format = 'json') {
|
|
410
520
|
try {
|
|
411
|
-
|
|
521
|
+
// Resolve workspace: use provided parameter or fall back to profile's default workspace
|
|
522
|
+
const resolvedWorkspace = workspace || this.getDefaultWorkspace(profileName);
|
|
523
|
+
const response = (await this.makeRequest(profileName, `/repositories/${resolvedWorkspace}/${repoSlug}/pipelines/`));
|
|
412
524
|
const pipelines = response.values || [];
|
|
413
525
|
const simplifiedPipelines = pipelines.map(p => ({
|
|
414
526
|
uuid: p.uuid,
|