bitbucketdc-cli 1.0.16 → 1.0.18
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/README.md +39 -7
- package/dist/index.js +216 -72
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# bitbucketdc-cli
|
|
2
2
|
|
|
3
|
-
Command-line interface for [Bitbucket Data Center](https://developer.atlassian.com/server/bitbucket/rest/v819/intro/).
|
|
3
|
+
Command-line interface for [Bitbucket Data Center](https://developer.atlassian.com/server/bitbucket/rest/v819/intro/). Covers pull requests, commits, files, branches, tags, projects, repos, and comparisons.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -26,8 +26,7 @@ All commands output JSON. Add `--pretty` to pretty-print.
|
|
|
26
26
|
| `bitbucketdc pr inbox` | List pull requests in your reviewer inbox |
|
|
27
27
|
| `bitbucketdc pr get <project> <repo> <prId>` | Get pull request details |
|
|
28
28
|
| `bitbucketdc pr changes <project> <repo> <prId>` | List changed files |
|
|
29
|
-
| `bitbucketdc pr diff <project> <repo> <prId>` | Get full diff (`--format`: text/json, `--whitespace`: show/ignore-all, `--context-lines`) |
|
|
30
|
-
| `bitbucketdc pr file-diff <project> <repo> <prId> <path>` | Get diff for a specific file |
|
|
29
|
+
| `bitbucketdc pr diff <project> <repo> <prId>` | Get full diff (`--format`: text/json, `--path` to filter, `--whitespace`: show/ignore-all, `--context-lines`) |
|
|
31
30
|
| `bitbucketdc pr activities <project> <repo> <prId>` | List activities/events on a PR |
|
|
32
31
|
| `bitbucketdc pr create <project> <repo>` | Create a PR (auto-fetches default reviewers) |
|
|
33
32
|
| `bitbucketdc pr comment <project> <repo> <prId>` | Add a general comment |
|
|
@@ -48,8 +47,10 @@ All commands output JSON. Add `--pretty` to pretty-print.
|
|
|
48
47
|
|
|
49
48
|
| Command | Description |
|
|
50
49
|
|---------|-------------|
|
|
51
|
-
| `bitbucketdc commit
|
|
52
|
-
| `bitbucketdc commit
|
|
50
|
+
| `bitbucketdc commit list` | List commit history on a ref, optionally scoped by path or range |
|
|
51
|
+
| `bitbucketdc commit get` | Get metadata for a single commit |
|
|
52
|
+
| `bitbucketdc commit changes` | List changed files in a commit (`--commit <ref>`) |
|
|
53
|
+
| `bitbucketdc commit diff` | Get diff for a commit (`--commit <ref>`, `--path` to filter) |
|
|
53
54
|
|
|
54
55
|
### compare
|
|
55
56
|
|
|
@@ -65,6 +66,18 @@ All commands output JSON. Add `--pretty` to pretty-print.
|
|
|
65
66
|
| `bitbucketdc file list <project> <repo>` | List files and directories (`--path`, `--at` ref) |
|
|
66
67
|
| `bitbucketdc file show <project> <repo> <path>` | Show file content (`--at` ref) |
|
|
67
68
|
|
|
69
|
+
### branch
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---------|-------------|
|
|
73
|
+
| `bitbucketdc branch list` | List branches with optional filters (`--filter`, `--order-by`, `--details`, `--base`) |
|
|
74
|
+
|
|
75
|
+
### tag
|
|
76
|
+
|
|
77
|
+
| Command | Description |
|
|
78
|
+
|---------|-------------|
|
|
79
|
+
| `bitbucketdc tag list` | List tags with optional filters (`--filter`, `--order-by`) |
|
|
80
|
+
|
|
68
81
|
### project
|
|
69
82
|
|
|
70
83
|
| Command | Description |
|
|
@@ -76,6 +89,8 @@ All commands output JSON. Add `--pretty` to pretty-print.
|
|
|
76
89
|
| Command | Description |
|
|
77
90
|
|---------|-------------|
|
|
78
91
|
| `bitbucketdc repo list` | List repositories (`--project`, `--name` filter) |
|
|
92
|
+
| `bitbucketdc repo get` | Get full repository metadata (includes defaultBranch, project, links) |
|
|
93
|
+
| `bitbucketdc repo default-branch` | Read the default branch configured for a repository |
|
|
79
94
|
| `bitbucketdc repo clone <project> <repo>` | Clone a repository |
|
|
80
95
|
| `bitbucketdc repo attachment download <project> <repo> <path>` | Download a repo attachment |
|
|
81
96
|
|
|
@@ -95,8 +110,8 @@ bitbucketdc pr get AI my-repo 42
|
|
|
95
110
|
# Review the diff
|
|
96
111
|
bitbucketdc pr diff AI my-repo 42 --context-lines 5
|
|
97
112
|
|
|
98
|
-
# Diff a single file
|
|
99
|
-
bitbucketdc pr
|
|
113
|
+
# Diff a single file within a PR
|
|
114
|
+
bitbucketdc pr diff AI my-repo 42 --path src/index.ts --format json
|
|
100
115
|
|
|
101
116
|
# Approve a PR
|
|
102
117
|
bitbucketdc pr review AI my-repo 42 APPROVED
|
|
@@ -118,4 +133,21 @@ bitbucketdc file show AI my-repo src/config.ts --at main
|
|
|
118
133
|
|
|
119
134
|
# Search repos by name within a project
|
|
120
135
|
bitbucketdc repo list --project AI --name "tool"
|
|
136
|
+
|
|
137
|
+
# Inspect repo metadata and default branch
|
|
138
|
+
bitbucketdc repo get --project AI --repo delivery
|
|
139
|
+
bitbucketdc repo default-branch --project AI --repo delivery
|
|
140
|
+
|
|
141
|
+
# List release branches
|
|
142
|
+
bitbucketdc branch list --project AI --repo delivery --filter operator-release/
|
|
143
|
+
|
|
144
|
+
# Walk recent commit history
|
|
145
|
+
bitbucketdc commit list --project AI --repo delivery --until main --limit 10
|
|
121
146
|
```
|
|
147
|
+
|
|
148
|
+
## Breaking changes in this release
|
|
149
|
+
|
|
150
|
+
- `repo list --project-key` renamed to `--project` (matches the flag naming used across every other command).
|
|
151
|
+
- `file list` / `file show` — the `--branch` alias has been removed. Use `--at <ref>` instead.
|
|
152
|
+
- `pr file-diff` has been removed. Use `pr diff --path <path> --format json` to get the JSON diff for a single file within a PR.
|
|
153
|
+
- `commit get` now takes `--commit <ref>` (consistent with `commit changes` and `commit diff`) instead of a positional argument.
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,10 @@ import { readFileSync } from "fs";
|
|
|
5
5
|
import { dirname, join } from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
import { styleText } from "util";
|
|
8
|
-
import { Command as
|
|
8
|
+
import { Command as Command12 } from "commander";
|
|
9
|
+
|
|
10
|
+
// src/commands/branch/list.ts
|
|
11
|
+
import { Option } from "commander";
|
|
9
12
|
|
|
10
13
|
// src/utils/cli.ts
|
|
11
14
|
import { InvalidArgumentError } from "commander";
|
|
@@ -177,6 +180,42 @@ function handleError(err) {
|
|
|
177
180
|
process.exit(1);
|
|
178
181
|
}
|
|
179
182
|
|
|
183
|
+
// src/commands/branch/list.ts
|
|
184
|
+
var ORDER_BY_MODES = ["ALPHABETICAL", "MODIFICATION"];
|
|
185
|
+
function list(parent) {
|
|
186
|
+
parent.command("list").description("List branches in a repository with optional filters").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").option("--filter <text>", "Prefix-match on branch name").addOption(new Option("--order-by <mode>", "Sort order").choices(ORDER_BY_MODES)).option("--details", "Include branch metadata (ahead/behind, latest commit)").option("--base <ref>", "Compare metadata against this ref").option("--boost-matches", "Rank exact matches above prefix matches").option("--start <n>", "Starting index for pagination", nonNegativeInt).option("--limit <n>", "Maximum results to return (1-1000)", intInRange(1, 1e3), 25).addHelpText(
|
|
187
|
+
"after",
|
|
188
|
+
`
|
|
189
|
+
Examples:
|
|
190
|
+
bitbucketdc branch list --project AI --repo delivery
|
|
191
|
+
bitbucketdc branch list --project AI --repo delivery --filter operator-release/
|
|
192
|
+
bitbucketdc branch list --project AI --repo delivery --order-by MODIFICATION --limit 10
|
|
193
|
+
bitbucketdc branch list --project AI --repo delivery --details`
|
|
194
|
+
).action(
|
|
195
|
+
async (opts) => {
|
|
196
|
+
const client = getClient();
|
|
197
|
+
const result = await client.branches.list({
|
|
198
|
+
projectKey: opts.project,
|
|
199
|
+
repositorySlug: opts.repo,
|
|
200
|
+
filterText: opts.filter,
|
|
201
|
+
orderBy: opts.orderBy,
|
|
202
|
+
details: opts.details,
|
|
203
|
+
base: opts.base,
|
|
204
|
+
boostMatches: opts.boostMatches,
|
|
205
|
+
start: opts.start,
|
|
206
|
+
limit: opts.limit
|
|
207
|
+
});
|
|
208
|
+
output(result);
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/commands/branch/index.ts
|
|
214
|
+
function registerBranchCommands(program2) {
|
|
215
|
+
const branch = program2.command("branch").description("Branch operations");
|
|
216
|
+
list(branch);
|
|
217
|
+
}
|
|
218
|
+
|
|
180
219
|
// src/commands/commit/changes.ts
|
|
181
220
|
function changes(parent) {
|
|
182
221
|
parent.command("changes").description("List files changed in a specific commit").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--commit <hash>", "Commit hash").option("--limit <n>", "Number of items to return (1-1000)", intInRange(1, 1e3), 25).option("--start <n>", "Start index for pagination", nonNegativeInt).addHelpText(
|
|
@@ -187,7 +226,7 @@ Examples:
|
|
|
187
226
|
bitbucketdc commit changes --project AI --repo my-app --commit abc123 --limit 100`
|
|
188
227
|
).action(async (opts) => {
|
|
189
228
|
const client = getClient();
|
|
190
|
-
const result = await client.
|
|
229
|
+
const result = await client.commits.getChanges({
|
|
191
230
|
projectKey: opts.project,
|
|
192
231
|
repositorySlug: opts.repo,
|
|
193
232
|
commitId: opts.commit,
|
|
@@ -199,11 +238,11 @@ Examples:
|
|
|
199
238
|
}
|
|
200
239
|
|
|
201
240
|
// src/commands/commit/diff.ts
|
|
202
|
-
import { Option } from "commander";
|
|
241
|
+
import { Option as Option2 } from "commander";
|
|
203
242
|
var WHITESPACE_MODES = ["show", "ignore-all"];
|
|
204
243
|
var DIFF_FORMATS = ["text", "json"];
|
|
205
244
|
function diff(parent) {
|
|
206
|
-
parent.command("diff").description("Get diff for a specific commit").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--commit <hash>", "Commit hash").option("--path <path>", "Scope diff to a single file").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500)).addOption(new
|
|
245
|
+
parent.command("diff").description("Get diff for a specific commit").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--commit <hash>", "Commit hash").option("--path <path>", "Scope diff to a single file").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500)).addOption(new Option2("--whitespace <mode>", "Whitespace handling").choices(WHITESPACE_MODES)).addOption(new Option2("--format <fmt>", "Response format").choices(DIFF_FORMATS).default("text")).addHelpText(
|
|
207
246
|
"after",
|
|
208
247
|
`
|
|
209
248
|
Examples:
|
|
@@ -213,7 +252,7 @@ Examples:
|
|
|
213
252
|
).action(
|
|
214
253
|
async (opts) => {
|
|
215
254
|
const client = getClient();
|
|
216
|
-
const result = await client.
|
|
255
|
+
const result = await client.commits.getDiff({
|
|
217
256
|
projectKey: opts.project,
|
|
218
257
|
repositorySlug: opts.repo,
|
|
219
258
|
commitId: opts.commit,
|
|
@@ -231,17 +270,75 @@ Examples:
|
|
|
231
270
|
);
|
|
232
271
|
}
|
|
233
272
|
|
|
273
|
+
// src/commands/commit/get.ts
|
|
274
|
+
function get(parent) {
|
|
275
|
+
parent.command("get").description("Get metadata for a single commit").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--commit <ref>", "Commit hash or any ref (branch, tag)").option("--path <p>", "Filter to changes touching this path").addHelpText(
|
|
276
|
+
"after",
|
|
277
|
+
`
|
|
278
|
+
Examples:
|
|
279
|
+
bitbucketdc commit get --project AI --repo delivery --commit 8165d8f
|
|
280
|
+
bitbucketdc commit get --project AI --repo delivery --commit main
|
|
281
|
+
bitbucketdc commit get --project AI --repo delivery --commit main --path src/index.ts`
|
|
282
|
+
).action(async (opts) => {
|
|
283
|
+
const client = getClient();
|
|
284
|
+
const result = await client.commits.get({
|
|
285
|
+
projectKey: opts.project,
|
|
286
|
+
repositorySlug: opts.repo,
|
|
287
|
+
commitId: opts.commit,
|
|
288
|
+
path: opts.path
|
|
289
|
+
});
|
|
290
|
+
output(result);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/commands/commit/list.ts
|
|
295
|
+
import { Option as Option3 } from "commander";
|
|
296
|
+
var MERGES_MODES = ["include", "exclude", "only"];
|
|
297
|
+
function list2(parent) {
|
|
298
|
+
parent.command("list").description("List commit history on a ref, optionally scoped by path or range").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").option("--path <p>", "Restrict to commits touching this path").option("--since <ref>", "Range start (commit ID or ref), exclusive").option("--until <ref>", "Range end (commit ID or ref). Alone, lists commits reachable from this ref.").addOption(new Option3("--merges <mode>", "Merge commit handling").choices(MERGES_MODES)).option("--follow-renames", "Track file renames (only meaningful with --path)").option("--ignore-missing", "Tolerate missing --since/--until refs instead of 404").option("--with-counts", "Include commit/author totals in response").option("--start <n>", "Starting index for pagination", nonNegativeInt).option("--limit <n>", "Maximum results to return (1-1000)", intInRange(1, 1e3), 25).addHelpText(
|
|
299
|
+
"after",
|
|
300
|
+
`
|
|
301
|
+
Examples:
|
|
302
|
+
bitbucketdc commit list --project AI --repo delivery
|
|
303
|
+
bitbucketdc commit list --project AI --repo delivery --until main --limit 10
|
|
304
|
+
bitbucketdc commit list --project AI --repo delivery --since operator-release/5.1.6 --until operator-release/5.1.7
|
|
305
|
+
bitbucketdc commit list --project AI --repo delivery --path package.json --follow-renames`
|
|
306
|
+
).action(
|
|
307
|
+
async (opts) => {
|
|
308
|
+
const client = getClient();
|
|
309
|
+
const result = await client.commits.list({
|
|
310
|
+
projectKey: opts.project,
|
|
311
|
+
repositorySlug: opts.repo,
|
|
312
|
+
path: opts.path,
|
|
313
|
+
since: opts.since,
|
|
314
|
+
until: opts.until,
|
|
315
|
+
merges: opts.merges,
|
|
316
|
+
followRenames: opts.followRenames,
|
|
317
|
+
ignoreMissing: opts.ignoreMissing,
|
|
318
|
+
withCounts: opts.withCounts,
|
|
319
|
+
start: opts.start,
|
|
320
|
+
limit: opts.limit
|
|
321
|
+
});
|
|
322
|
+
output(result);
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
234
327
|
// src/commands/commit/index.ts
|
|
235
328
|
function registerCommitCommands(program2) {
|
|
236
329
|
const commit = program2.command("commit").description("Commit inspection operations").addHelpText(
|
|
237
330
|
"after",
|
|
238
331
|
`
|
|
239
332
|
Examples:
|
|
333
|
+
$ bitbucketdc commit list --project AI --repo my-app --limit 10
|
|
334
|
+
$ bitbucketdc commit get --project AI --repo my-app --commit abc123
|
|
240
335
|
$ bitbucketdc commit changes --project AI --repo my-app --commit abc123
|
|
241
336
|
$ bitbucketdc commit diff --project AI --repo my-app --commit abc123
|
|
242
337
|
$ bitbucketdc commit diff --project AI --repo my-app --commit abc123 --path src/main.ts
|
|
243
338
|
`
|
|
244
339
|
);
|
|
340
|
+
list2(commit);
|
|
341
|
+
get(commit);
|
|
245
342
|
changes(commit);
|
|
246
343
|
diff(commit);
|
|
247
344
|
}
|
|
@@ -258,7 +355,7 @@ Examples:
|
|
|
258
355
|
).action(
|
|
259
356
|
async (opts) => {
|
|
260
357
|
const client = getClient();
|
|
261
|
-
const result = await client.
|
|
358
|
+
const result = await client.compare.getChanges({
|
|
262
359
|
projectKey: opts.project,
|
|
263
360
|
repositorySlug: opts.repo,
|
|
264
361
|
from: opts.from,
|
|
@@ -272,10 +369,10 @@ Examples:
|
|
|
272
369
|
}
|
|
273
370
|
|
|
274
371
|
// src/commands/compare/diff.ts
|
|
275
|
-
import { Option as
|
|
372
|
+
import { Option as Option4 } from "commander";
|
|
276
373
|
var WHITESPACE_MODES2 = ["show", "ignore-all"];
|
|
277
374
|
function diff2(parent) {
|
|
278
|
-
parent.command("diff").description("Get diff between two refs (structured JSON)").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--from <ref>", "Source ref (branch, tag, or commit)").requiredOption("--to <ref>", "Target ref (branch, tag, or commit)").option("--path <path>", "Scope diff to a single file").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500)).addOption(new
|
|
375
|
+
parent.command("diff").description("Get diff between two refs (structured JSON)").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--from <ref>", "Source ref (branch, tag, or commit)").requiredOption("--to <ref>", "Target ref (branch, tag, or commit)").option("--path <path>", "Scope diff to a single file").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500)).addOption(new Option4("--whitespace <mode>", "Whitespace handling").choices(WHITESPACE_MODES2)).addHelpText(
|
|
279
376
|
"after",
|
|
280
377
|
`
|
|
281
378
|
Examples:
|
|
@@ -284,7 +381,7 @@ Examples:
|
|
|
284
381
|
).action(
|
|
285
382
|
async (opts) => {
|
|
286
383
|
const client = getClient();
|
|
287
|
-
const result = await client.
|
|
384
|
+
const result = await client.compare.getDiff({
|
|
288
385
|
projectKey: opts.project,
|
|
289
386
|
repositorySlug: opts.repo,
|
|
290
387
|
from: opts.from,
|
|
@@ -314,8 +411,8 @@ Examples:
|
|
|
314
411
|
}
|
|
315
412
|
|
|
316
413
|
// src/commands/file/list.ts
|
|
317
|
-
function
|
|
318
|
-
parent.command("list").description("List directory contents in a repository").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").option("--path <path>", "Directory path (defaults to root)").option("--at <ref>", "Branch, tag, or commit hash").option("--
|
|
414
|
+
function list3(parent) {
|
|
415
|
+
parent.command("list").description("List directory contents in a repository").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").option("--path <path>", "Directory path (defaults to root)").option("--at <ref>", "Branch, tag, or commit hash").option("--limit <n>", "Number of items to return (1-1000)", intInRange(1, 1e3), 25).option("--start <n>", "Start index for pagination", nonNegativeInt).addHelpText(
|
|
319
416
|
"after",
|
|
320
417
|
`
|
|
321
418
|
Examples:
|
|
@@ -325,12 +422,11 @@ Examples:
|
|
|
325
422
|
).action(
|
|
326
423
|
async (opts) => {
|
|
327
424
|
const client = getClient();
|
|
328
|
-
const
|
|
329
|
-
const result = await client.repositories.browse({
|
|
425
|
+
const result = await client.files.browse({
|
|
330
426
|
projectKey: opts.project,
|
|
331
427
|
repositorySlug: opts.repo,
|
|
332
428
|
path: opts.path,
|
|
333
|
-
at:
|
|
429
|
+
at: opts.at,
|
|
334
430
|
limit: opts.limit,
|
|
335
431
|
start: opts.start
|
|
336
432
|
});
|
|
@@ -341,7 +437,7 @@ Examples:
|
|
|
341
437
|
|
|
342
438
|
// src/commands/file/show.ts
|
|
343
439
|
function show(parent) {
|
|
344
|
-
parent.command("show").description("Show raw file content from a repository").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--path <path>", "File path").option("--at <ref>", "Branch, tag, or commit hash").
|
|
440
|
+
parent.command("show").description("Show raw file content from a repository").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--path <path>", "File path").option("--at <ref>", "Branch, tag, or commit hash").addHelpText(
|
|
345
441
|
"after",
|
|
346
442
|
`
|
|
347
443
|
Examples:
|
|
@@ -349,12 +445,11 @@ Examples:
|
|
|
349
445
|
bitbucketdc file show --project PROJ --repo my-app --path config/settings.yaml --at release/2.0`
|
|
350
446
|
).action(async (opts) => {
|
|
351
447
|
const client = getClient();
|
|
352
|
-
const
|
|
353
|
-
const result = await client.repositories.getRawContent({
|
|
448
|
+
const result = await client.files.getRawContent({
|
|
354
449
|
projectKey: opts.project,
|
|
355
450
|
repositorySlug: opts.repo,
|
|
356
451
|
path: opts.path,
|
|
357
|
-
at:
|
|
452
|
+
at: opts.at
|
|
358
453
|
});
|
|
359
454
|
process.stdout.write(result);
|
|
360
455
|
});
|
|
@@ -371,7 +466,7 @@ Examples:
|
|
|
371
466
|
$ bitbucketdc file show --project PROJ --repo my-app --path README.md
|
|
372
467
|
`
|
|
373
468
|
);
|
|
374
|
-
|
|
469
|
+
list3(file);
|
|
375
470
|
show(file);
|
|
376
471
|
}
|
|
377
472
|
|
|
@@ -552,11 +647,11 @@ function deletePr(parent) {
|
|
|
552
647
|
}
|
|
553
648
|
|
|
554
649
|
// src/commands/pr/diff.ts
|
|
555
|
-
import { Option as
|
|
650
|
+
import { Option as Option5 } from "commander";
|
|
556
651
|
var WHITESPACE_MODES3 = ["show", "ignore-all"];
|
|
557
652
|
var DIFF_FORMATS2 = ["text", "json"];
|
|
558
653
|
function diff3(parent) {
|
|
559
|
-
parent.command("diff").description("Get diff for a pull request").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).option("--path <path>", "File path (omit for full PR diff)").option("--since <hash>", "Since commit hash").option("--until <hash>", "Until commit hash").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500), 10).addOption(new
|
|
654
|
+
parent.command("diff").description("Get diff for a pull request").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).option("--path <path>", "File path (omit for full PR diff)").option("--since <hash>", "Since commit hash").option("--until <hash>", "Until commit hash").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500), 10).addOption(new Option5("--whitespace <mode>", "Whitespace handling").choices(WHITESPACE_MODES3).default("show")).addOption(new Option5("--format <fmt>", "Response format").choices(DIFF_FORMATS2).default("text")).addHelpText(
|
|
560
655
|
"after",
|
|
561
656
|
`
|
|
562
657
|
Examples:
|
|
@@ -630,26 +725,8 @@ function fileComment(parent) {
|
|
|
630
725
|
});
|
|
631
726
|
}
|
|
632
727
|
|
|
633
|
-
// src/commands/pr/file-diff.ts
|
|
634
|
-
function fileDiff(parent) {
|
|
635
|
-
parent.command("file-diff").description("Get structured line-by-line diff for a specific file").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).requiredOption("--path <path>", "File path (e.g., src/main.ts)").option("--context <n>", "Number of context lines around changes (0-500)", intInRange(0, 500), 10).addHelpText(
|
|
636
|
-
"after",
|
|
637
|
-
"\nExamples:\n bitbucketdc pr file-diff --project PROJ --repo my-repo --id 42 --path src/main.ts\n bitbucketdc pr file-diff --project PROJ --repo my-repo --id 42 --path src/main.ts --context 5"
|
|
638
|
-
).action(async (opts) => {
|
|
639
|
-
const client = getClient();
|
|
640
|
-
const result = await client.pullRequests.getFileDiff({
|
|
641
|
-
projectKey: opts.project,
|
|
642
|
-
repositorySlug: opts.repo,
|
|
643
|
-
pullRequestId: opts.id,
|
|
644
|
-
path: opts.path,
|
|
645
|
-
contextLines: opts.context
|
|
646
|
-
});
|
|
647
|
-
output(result);
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
|
|
651
728
|
// src/commands/pr/get.ts
|
|
652
|
-
function
|
|
729
|
+
function get2(parent) {
|
|
653
730
|
parent.command("get").description("Get pull request details").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).addHelpText("after", "\nExamples:\n bitbucketdc pr get --project PROJ --repo my-repo --id 42").action(async (opts) => {
|
|
654
731
|
const client = getClient();
|
|
655
732
|
const result = await client.pullRequests.get({
|
|
@@ -677,12 +754,12 @@ function inbox(parent) {
|
|
|
677
754
|
}
|
|
678
755
|
|
|
679
756
|
// src/commands/pr/line-comment.ts
|
|
680
|
-
import { Option as
|
|
757
|
+
import { Option as Option6 } from "commander";
|
|
681
758
|
var LINE_TYPES = ["ADDED", "REMOVED", "CONTEXT"];
|
|
682
759
|
var FILE_TYPES = ["FROM", "TO"];
|
|
683
760
|
function lineComment(parent) {
|
|
684
|
-
parent.command("line-comment").description("Add an inline comment to a specific line in a pull request").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).requiredOption("--text <text>", "Comment text").requiredOption("--path <path>", "File path (e.g., src/main.ts)").requiredOption("--line <n>", "Line number to comment on", positiveInt).addOption(new
|
|
685
|
-
new
|
|
761
|
+
parent.command("line-comment").description("Add an inline comment to a specific line in a pull request").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).requiredOption("--text <text>", "Comment text").requiredOption("--path <path>", "File path (e.g., src/main.ts)").requiredOption("--line <n>", "Line number to comment on", positiveInt).addOption(new Option6("--line-type <type>", "Type of line").choices(LINE_TYPES).makeOptionMandatory()).addOption(
|
|
762
|
+
new Option6("--file-type <type>", "Side of diff: FROM (source/old) or TO (destination/new)").choices(FILE_TYPES).makeOptionMandatory()
|
|
686
763
|
).addHelpText(
|
|
687
764
|
"after",
|
|
688
765
|
`
|
|
@@ -730,10 +807,10 @@ Examples:
|
|
|
730
807
|
}
|
|
731
808
|
|
|
732
809
|
// src/commands/pr/reaction-add.ts
|
|
733
|
-
import { Option as
|
|
810
|
+
import { Option as Option7 } from "commander";
|
|
734
811
|
function reactionAdd(parent) {
|
|
735
812
|
parent.command("reaction-add").description("Add an emoticon reaction to a PR comment").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).requiredOption("--comment-id <n>", "Comment ID", positiveInt).addOption(
|
|
736
|
-
new
|
|
813
|
+
new Option7("--emoticon <name>", "Emoticon to react with").choices(["thumbsup", "thumbsdown", "heart", "thinking_face", "laughing"]).makeOptionMandatory()
|
|
737
814
|
).addHelpText(
|
|
738
815
|
"after",
|
|
739
816
|
`
|
|
@@ -756,10 +833,10 @@ Examples:
|
|
|
756
833
|
}
|
|
757
834
|
|
|
758
835
|
// src/commands/pr/reaction-remove.ts
|
|
759
|
-
import { Option as
|
|
836
|
+
import { Option as Option8 } from "commander";
|
|
760
837
|
function reactionRemove(parent) {
|
|
761
838
|
parent.command("reaction-remove").description("Remove an emoticon reaction from a PR comment").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).requiredOption("--comment-id <n>", "Comment ID", positiveInt).addOption(
|
|
762
|
-
new
|
|
839
|
+
new Option8("--emoticon <name>", "Emoticon to remove").choices(["thumbsup", "thumbsdown", "heart", "thinking_face", "laughing"]).makeOptionMandatory()
|
|
763
840
|
).addHelpText(
|
|
764
841
|
"after",
|
|
765
842
|
`
|
|
@@ -781,10 +858,10 @@ Examples:
|
|
|
781
858
|
}
|
|
782
859
|
|
|
783
860
|
// src/commands/pr/review.ts
|
|
784
|
-
import { Option as
|
|
861
|
+
import { Option as Option9 } from "commander";
|
|
785
862
|
var REVIEW_STATUSES = ["APPROVED", "NEEDS_WORK", "UNAPPROVED"];
|
|
786
863
|
function review(parent) {
|
|
787
|
-
parent.command("review").description("Update review status for a pull request").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).addOption(new
|
|
864
|
+
parent.command("review").description("Update review status for a pull request").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").requiredOption("--id <n>", "Pull request ID", positiveInt).addOption(new Option9("--status <status>", "Review status").choices(REVIEW_STATUSES).makeOptionMandatory()).addHelpText(
|
|
788
865
|
"after",
|
|
789
866
|
`
|
|
790
867
|
Examples:
|
|
@@ -814,9 +891,7 @@ Examples:
|
|
|
814
891
|
bitbucketdc pr update --project PROJ --repo my-repo --id 42 --title "New" --description "Both"`
|
|
815
892
|
).action(async (opts) => {
|
|
816
893
|
if (!opts.title && !opts.description) {
|
|
817
|
-
|
|
818
|
-
`);
|
|
819
|
-
process.exit(1);
|
|
894
|
+
throw new Error("At least one of --title or --description is required");
|
|
820
895
|
}
|
|
821
896
|
const client = getClient();
|
|
822
897
|
const result = await client.pullRequests.update({
|
|
@@ -851,10 +926,9 @@ Examples:
|
|
|
851
926
|
`
|
|
852
927
|
);
|
|
853
928
|
inbox(pr);
|
|
854
|
-
|
|
929
|
+
get2(pr);
|
|
855
930
|
changes3(pr);
|
|
856
931
|
diff3(pr);
|
|
857
|
-
fileDiff(pr);
|
|
858
932
|
activities(pr);
|
|
859
933
|
create(pr);
|
|
860
934
|
comment(pr);
|
|
@@ -873,7 +947,7 @@ Examples:
|
|
|
873
947
|
}
|
|
874
948
|
|
|
875
949
|
// src/commands/project/list.ts
|
|
876
|
-
function
|
|
950
|
+
function list4(parent) {
|
|
877
951
|
parent.command("list").description("List projects").option("--name <name>", "Filter projects by name (partial match)").option("--permission <permission>", "Filter by permission (e.g., PROJECT_READ, PROJECT_WRITE, PROJECT_ADMIN)").option("--start <start>", "Starting index for pagination", nonNegativeInt).option("--limit <limit>", "Maximum number of projects to return (1-1000)", intInRange(1, 1e3), 25).addHelpText(
|
|
878
952
|
"after",
|
|
879
953
|
'\nExamples:\n bitbucketdc project list\n bitbucketdc project list --name "My Project"\n bitbucketdc project list --permission PROJECT_READ --limit 10'
|
|
@@ -899,7 +973,7 @@ Examples:
|
|
|
899
973
|
$ bitbucketdc project list --name "My Project" --limit 10
|
|
900
974
|
`
|
|
901
975
|
);
|
|
902
|
-
|
|
976
|
+
list4(project);
|
|
903
977
|
}
|
|
904
978
|
|
|
905
979
|
// src/commands/repo/attachment/download.ts
|
|
@@ -981,11 +1055,7 @@ Examples:
|
|
|
981
1055
|
const token = process.env.BITBUCKET_TOKEN;
|
|
982
1056
|
if (!baseUrl || !token) {
|
|
983
1057
|
const missing = [...!baseUrl ? ["BITBUCKET_URL"] : [], ...!token ? ["BITBUCKET_TOKEN"] : []];
|
|
984
|
-
|
|
985
|
-
`${JSON.stringify({ error: `Missing required environment variables: ${missing.join(", ")}` })}
|
|
986
|
-
`
|
|
987
|
-
);
|
|
988
|
-
process.exit(1);
|
|
1058
|
+
throw new Error(`Missing required environment variables: ${missing.join(", ")}`);
|
|
989
1059
|
}
|
|
990
1060
|
const cloneUrl = `${baseUrl}/scm/${opts.project}/${opts.repo}.git`;
|
|
991
1061
|
const args = ["-c", `http.extraHeader=Authorization: Bearer ${token}`, "clone", cloneUrl];
|
|
@@ -994,25 +1064,62 @@ Examples:
|
|
|
994
1064
|
});
|
|
995
1065
|
}
|
|
996
1066
|
|
|
1067
|
+
// src/commands/repo/default-branch.ts
|
|
1068
|
+
function defaultBranch(parent) {
|
|
1069
|
+
parent.command("default-branch").description("Read the default branch configured for a repository (read-only)").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").addHelpText(
|
|
1070
|
+
"after",
|
|
1071
|
+
`
|
|
1072
|
+
Examples:
|
|
1073
|
+
bitbucketdc repo default-branch --project AI --repo delivery
|
|
1074
|
+
|
|
1075
|
+
Note: this command is read-only. Setting a default branch is not exposed by this CLI.`
|
|
1076
|
+
).action(async (opts) => {
|
|
1077
|
+
const client = getClient();
|
|
1078
|
+
const result = await client.repositories.getDefaultBranch({
|
|
1079
|
+
projectKey: opts.project,
|
|
1080
|
+
repositorySlug: opts.repo
|
|
1081
|
+
});
|
|
1082
|
+
output(result);
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// src/commands/repo/get.ts
|
|
1087
|
+
function get3(parent) {
|
|
1088
|
+
parent.command("get").description("Get full metadata for a repository (includes defaultBranch, project, links)").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").addHelpText(
|
|
1089
|
+
"after",
|
|
1090
|
+
`
|
|
1091
|
+
Examples:
|
|
1092
|
+
bitbucketdc repo get --project AI --repo delivery
|
|
1093
|
+
bitbucketdc repo get --project AI --repo gregosystem-v2`
|
|
1094
|
+
).action(async (opts) => {
|
|
1095
|
+
const client = getClient();
|
|
1096
|
+
const result = await client.repositories.get({
|
|
1097
|
+
projectKey: opts.project,
|
|
1098
|
+
repositorySlug: opts.repo
|
|
1099
|
+
});
|
|
1100
|
+
output(result);
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
|
|
997
1104
|
// src/commands/repo/list.ts
|
|
998
|
-
import { Option as
|
|
1105
|
+
import { Option as Option10 } from "commander";
|
|
999
1106
|
var VISIBILITIES = ["public", "private"];
|
|
1000
1107
|
var ARCHIVE_STATES = ["ACTIVE", "ARCHIVED", "ALL"];
|
|
1001
|
-
function
|
|
1002
|
-
parent.command("list").description("List repositories with optional filters").option("--name <name>", "Filter by repository name (case-insensitive)").option("--project
|
|
1108
|
+
function list5(parent) {
|
|
1109
|
+
parent.command("list").description("List repositories with optional filters").option("--name <name>", "Filter by repository name (case-insensitive)").option("--project <key>", "Filter by project key").option("--project-name <name>", "Filter by project name (case-insensitive)").addOption(new Option10("--visibility <type>", "Filter by visibility").choices(VISIBILITIES)).addOption(new Option10("--archived <status>", "Filter by archived status").choices(ARCHIVE_STATES)).option("--start <n>", "Starting index for pagination", nonNegativeInt).option("--limit <n>", "Maximum results to return (1-1000)", intInRange(1, 1e3), 25).addHelpText(
|
|
1003
1110
|
"after",
|
|
1004
1111
|
`
|
|
1005
1112
|
Examples:
|
|
1006
1113
|
bitbucketdc repo list
|
|
1007
1114
|
bitbucketdc repo list --name my-repo
|
|
1008
|
-
bitbucketdc repo list --project
|
|
1009
|
-
bitbucketdc repo list --project
|
|
1115
|
+
bitbucketdc repo list --project AI
|
|
1116
|
+
bitbucketdc repo list --project AI --name svc --limit 50`
|
|
1010
1117
|
).action(
|
|
1011
1118
|
async (opts) => {
|
|
1012
1119
|
const client = getClient();
|
|
1013
1120
|
const result = await client.repositories.list({
|
|
1014
1121
|
name: opts.name,
|
|
1015
|
-
projectkey: opts.
|
|
1122
|
+
projectkey: opts.project,
|
|
1016
1123
|
projectname: opts.projectName,
|
|
1017
1124
|
visibility: opts.visibility,
|
|
1018
1125
|
archived: opts.archived,
|
|
@@ -1031,18 +1138,53 @@ function registerRepoCommands(program2) {
|
|
|
1031
1138
|
`
|
|
1032
1139
|
Examples:
|
|
1033
1140
|
$ bitbucketdc repo list
|
|
1034
|
-
$ bitbucketdc repo list --name my-repo --project
|
|
1141
|
+
$ bitbucketdc repo list --name my-repo --project AI
|
|
1035
1142
|
$ bitbucketdc repo clone --project AI --repo my-repo
|
|
1036
1143
|
$ bitbucketdc repo attachment download --project PROJ --repo my-repo --id abc123 --output ./file.png
|
|
1037
1144
|
`
|
|
1038
1145
|
);
|
|
1039
|
-
|
|
1146
|
+
list5(repo);
|
|
1147
|
+
get3(repo);
|
|
1148
|
+
defaultBranch(repo);
|
|
1040
1149
|
clone(repo);
|
|
1041
1150
|
registerAttachmentCommands(repo);
|
|
1042
1151
|
}
|
|
1043
1152
|
|
|
1153
|
+
// src/commands/tag/list.ts
|
|
1154
|
+
import { Option as Option11 } from "commander";
|
|
1155
|
+
var ORDER_BY_MODES2 = ["ALPHABETICAL", "MODIFICATION"];
|
|
1156
|
+
function list6(parent) {
|
|
1157
|
+
parent.command("list").description("List tags in a repository with optional filters").requiredOption("--project <key>", "Bitbucket project key").requiredOption("--repo <slug>", "Repository slug").option("--filter <text>", "Prefix-match on tag name").addOption(new Option11("--order-by <mode>", "Sort order").choices(ORDER_BY_MODES2)).option("--start <n>", "Starting index for pagination", nonNegativeInt).option("--limit <n>", "Maximum results to return (1-1000)", intInRange(1, 1e3), 25).addHelpText(
|
|
1158
|
+
"after",
|
|
1159
|
+
`
|
|
1160
|
+
Examples:
|
|
1161
|
+
bitbucketdc tag list --project AI --repo delivery
|
|
1162
|
+
bitbucketdc tag list --project AI --repo delivery --filter v --limit 10
|
|
1163
|
+
bitbucketdc tag list --project AI --repo delivery --order-by MODIFICATION`
|
|
1164
|
+
).action(
|
|
1165
|
+
async (opts) => {
|
|
1166
|
+
const client = getClient();
|
|
1167
|
+
const result = await client.tags.list({
|
|
1168
|
+
projectKey: opts.project,
|
|
1169
|
+
repositorySlug: opts.repo,
|
|
1170
|
+
filterText: opts.filter,
|
|
1171
|
+
orderBy: opts.orderBy,
|
|
1172
|
+
start: opts.start,
|
|
1173
|
+
limit: opts.limit
|
|
1174
|
+
});
|
|
1175
|
+
output(result);
|
|
1176
|
+
}
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/commands/tag/index.ts
|
|
1181
|
+
function registerTagCommands(program2) {
|
|
1182
|
+
const tag = program2.command("tag").description("Tag operations");
|
|
1183
|
+
list6(tag);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1044
1186
|
// src/commands/user/list.ts
|
|
1045
|
-
function
|
|
1187
|
+
function list7(parent) {
|
|
1046
1188
|
parent.command("list").description("List all users").option("--filter <filter>", "Filter users by username, name or email (partial match)").addHelpText("after", "\nExamples:\n bitbucketdc user list\n bitbucketdc user list --filter john").action(async (opts) => {
|
|
1047
1189
|
const client = getClient();
|
|
1048
1190
|
const result = await client.users.getAll(opts.filter ? { filter: opts.filter } : void 0);
|
|
@@ -1070,7 +1212,7 @@ Examples:
|
|
|
1070
1212
|
`
|
|
1071
1213
|
);
|
|
1072
1214
|
profile(user);
|
|
1073
|
-
|
|
1215
|
+
list7(user);
|
|
1074
1216
|
}
|
|
1075
1217
|
|
|
1076
1218
|
// src/index.ts
|
|
@@ -1086,7 +1228,7 @@ function readPackageVersion() {
|
|
|
1086
1228
|
}
|
|
1087
1229
|
var DIM = "\x1B[2m";
|
|
1088
1230
|
var RESET = "\x1B[0m";
|
|
1089
|
-
var program = new
|
|
1231
|
+
var program = new Command12();
|
|
1090
1232
|
program.name("bitbucketdc").description("Bitbucket Data Center CLI").version(readPackageVersion()).configureHelp({
|
|
1091
1233
|
styleTitle: (str) => styleText("bold", str),
|
|
1092
1234
|
styleUsage: (str) => styleText("dim", str),
|
|
@@ -1118,6 +1260,8 @@ program.hook("preAction", (thisCommand) => {
|
|
|
1118
1260
|
registerUserCommands(program);
|
|
1119
1261
|
registerProjectCommands(program);
|
|
1120
1262
|
registerRepoCommands(program);
|
|
1263
|
+
registerBranchCommands(program);
|
|
1264
|
+
registerTagCommands(program);
|
|
1121
1265
|
registerFileCommands(program);
|
|
1122
1266
|
registerCommitCommands(program);
|
|
1123
1267
|
registerCompareCommands(program);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bitbucketdc-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"publish": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"commander": "^13.1.0",
|
|
15
|
-
"bitbucket-data-center-client": "1.4.
|
|
15
|
+
"bitbucket-data-center-client": "1.4.18"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "24.10.4",
|