bitbucketdc-cli 1.0.16 → 1.0.17
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 +214 -64
- 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:
|
|
@@ -851,10 +928,9 @@ Examples:
|
|
|
851
928
|
`
|
|
852
929
|
);
|
|
853
930
|
inbox(pr);
|
|
854
|
-
|
|
931
|
+
get2(pr);
|
|
855
932
|
changes3(pr);
|
|
856
933
|
diff3(pr);
|
|
857
|
-
fileDiff(pr);
|
|
858
934
|
activities(pr);
|
|
859
935
|
create(pr);
|
|
860
936
|
comment(pr);
|
|
@@ -873,7 +949,7 @@ Examples:
|
|
|
873
949
|
}
|
|
874
950
|
|
|
875
951
|
// src/commands/project/list.ts
|
|
876
|
-
function
|
|
952
|
+
function list4(parent) {
|
|
877
953
|
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
954
|
"after",
|
|
879
955
|
'\nExamples:\n bitbucketdc project list\n bitbucketdc project list --name "My Project"\n bitbucketdc project list --permission PROJECT_READ --limit 10'
|
|
@@ -899,7 +975,7 @@ Examples:
|
|
|
899
975
|
$ bitbucketdc project list --name "My Project" --limit 10
|
|
900
976
|
`
|
|
901
977
|
);
|
|
902
|
-
|
|
978
|
+
list4(project);
|
|
903
979
|
}
|
|
904
980
|
|
|
905
981
|
// src/commands/repo/attachment/download.ts
|
|
@@ -994,25 +1070,62 @@ Examples:
|
|
|
994
1070
|
});
|
|
995
1071
|
}
|
|
996
1072
|
|
|
1073
|
+
// src/commands/repo/default-branch.ts
|
|
1074
|
+
function defaultBranch(parent) {
|
|
1075
|
+
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(
|
|
1076
|
+
"after",
|
|
1077
|
+
`
|
|
1078
|
+
Examples:
|
|
1079
|
+
bitbucketdc repo default-branch --project AI --repo delivery
|
|
1080
|
+
|
|
1081
|
+
Note: this command is read-only. Setting a default branch is not exposed by this CLI.`
|
|
1082
|
+
).action(async (opts) => {
|
|
1083
|
+
const client = getClient();
|
|
1084
|
+
const result = await client.repositories.getDefaultBranch({
|
|
1085
|
+
projectKey: opts.project,
|
|
1086
|
+
repositorySlug: opts.repo
|
|
1087
|
+
});
|
|
1088
|
+
output(result);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// src/commands/repo/get.ts
|
|
1093
|
+
function get3(parent) {
|
|
1094
|
+
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(
|
|
1095
|
+
"after",
|
|
1096
|
+
`
|
|
1097
|
+
Examples:
|
|
1098
|
+
bitbucketdc repo get --project AI --repo delivery
|
|
1099
|
+
bitbucketdc repo get --project AI --repo gregosystem-v2`
|
|
1100
|
+
).action(async (opts) => {
|
|
1101
|
+
const client = getClient();
|
|
1102
|
+
const result = await client.repositories.get({
|
|
1103
|
+
projectKey: opts.project,
|
|
1104
|
+
repositorySlug: opts.repo
|
|
1105
|
+
});
|
|
1106
|
+
output(result);
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
|
|
997
1110
|
// src/commands/repo/list.ts
|
|
998
|
-
import { Option as
|
|
1111
|
+
import { Option as Option10 } from "commander";
|
|
999
1112
|
var VISIBILITIES = ["public", "private"];
|
|
1000
1113
|
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
|
|
1114
|
+
function list5(parent) {
|
|
1115
|
+
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
1116
|
"after",
|
|
1004
1117
|
`
|
|
1005
1118
|
Examples:
|
|
1006
1119
|
bitbucketdc repo list
|
|
1007
1120
|
bitbucketdc repo list --name my-repo
|
|
1008
|
-
bitbucketdc repo list --project
|
|
1009
|
-
bitbucketdc repo list --project
|
|
1121
|
+
bitbucketdc repo list --project AI
|
|
1122
|
+
bitbucketdc repo list --project AI --name svc --limit 50`
|
|
1010
1123
|
).action(
|
|
1011
1124
|
async (opts) => {
|
|
1012
1125
|
const client = getClient();
|
|
1013
1126
|
const result = await client.repositories.list({
|
|
1014
1127
|
name: opts.name,
|
|
1015
|
-
projectkey: opts.
|
|
1128
|
+
projectkey: opts.project,
|
|
1016
1129
|
projectname: opts.projectName,
|
|
1017
1130
|
visibility: opts.visibility,
|
|
1018
1131
|
archived: opts.archived,
|
|
@@ -1031,18 +1144,53 @@ function registerRepoCommands(program2) {
|
|
|
1031
1144
|
`
|
|
1032
1145
|
Examples:
|
|
1033
1146
|
$ bitbucketdc repo list
|
|
1034
|
-
$ bitbucketdc repo list --name my-repo --project
|
|
1147
|
+
$ bitbucketdc repo list --name my-repo --project AI
|
|
1035
1148
|
$ bitbucketdc repo clone --project AI --repo my-repo
|
|
1036
1149
|
$ bitbucketdc repo attachment download --project PROJ --repo my-repo --id abc123 --output ./file.png
|
|
1037
1150
|
`
|
|
1038
1151
|
);
|
|
1039
|
-
|
|
1152
|
+
list5(repo);
|
|
1153
|
+
get3(repo);
|
|
1154
|
+
defaultBranch(repo);
|
|
1040
1155
|
clone(repo);
|
|
1041
1156
|
registerAttachmentCommands(repo);
|
|
1042
1157
|
}
|
|
1043
1158
|
|
|
1159
|
+
// src/commands/tag/list.ts
|
|
1160
|
+
import { Option as Option11 } from "commander";
|
|
1161
|
+
var ORDER_BY_MODES2 = ["ALPHABETICAL", "MODIFICATION"];
|
|
1162
|
+
function list6(parent) {
|
|
1163
|
+
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(
|
|
1164
|
+
"after",
|
|
1165
|
+
`
|
|
1166
|
+
Examples:
|
|
1167
|
+
bitbucketdc tag list --project AI --repo delivery
|
|
1168
|
+
bitbucketdc tag list --project AI --repo delivery --filter v --limit 10
|
|
1169
|
+
bitbucketdc tag list --project AI --repo delivery --order-by MODIFICATION`
|
|
1170
|
+
).action(
|
|
1171
|
+
async (opts) => {
|
|
1172
|
+
const client = getClient();
|
|
1173
|
+
const result = await client.tags.list({
|
|
1174
|
+
projectKey: opts.project,
|
|
1175
|
+
repositorySlug: opts.repo,
|
|
1176
|
+
filterText: opts.filter,
|
|
1177
|
+
orderBy: opts.orderBy,
|
|
1178
|
+
start: opts.start,
|
|
1179
|
+
limit: opts.limit
|
|
1180
|
+
});
|
|
1181
|
+
output(result);
|
|
1182
|
+
}
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// src/commands/tag/index.ts
|
|
1187
|
+
function registerTagCommands(program2) {
|
|
1188
|
+
const tag = program2.command("tag").description("Tag operations");
|
|
1189
|
+
list6(tag);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1044
1192
|
// src/commands/user/list.ts
|
|
1045
|
-
function
|
|
1193
|
+
function list7(parent) {
|
|
1046
1194
|
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
1195
|
const client = getClient();
|
|
1048
1196
|
const result = await client.users.getAll(opts.filter ? { filter: opts.filter } : void 0);
|
|
@@ -1070,7 +1218,7 @@ Examples:
|
|
|
1070
1218
|
`
|
|
1071
1219
|
);
|
|
1072
1220
|
profile(user);
|
|
1073
|
-
|
|
1221
|
+
list7(user);
|
|
1074
1222
|
}
|
|
1075
1223
|
|
|
1076
1224
|
// src/index.ts
|
|
@@ -1086,7 +1234,7 @@ function readPackageVersion() {
|
|
|
1086
1234
|
}
|
|
1087
1235
|
var DIM = "\x1B[2m";
|
|
1088
1236
|
var RESET = "\x1B[0m";
|
|
1089
|
-
var program = new
|
|
1237
|
+
var program = new Command12();
|
|
1090
1238
|
program.name("bitbucketdc").description("Bitbucket Data Center CLI").version(readPackageVersion()).configureHelp({
|
|
1091
1239
|
styleTitle: (str) => styleText("bold", str),
|
|
1092
1240
|
styleUsage: (str) => styleText("dim", str),
|
|
@@ -1118,6 +1266,8 @@ program.hook("preAction", (thisCommand) => {
|
|
|
1118
1266
|
registerUserCommands(program);
|
|
1119
1267
|
registerProjectCommands(program);
|
|
1120
1268
|
registerRepoCommands(program);
|
|
1269
|
+
registerBranchCommands(program);
|
|
1270
|
+
registerTagCommands(program);
|
|
1121
1271
|
registerFileCommands(program);
|
|
1122
1272
|
registerCommitCommands(program);
|
|
1123
1273
|
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.17",
|
|
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",
|