@pilatos/bitbucket-cli 0.2.0

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +398 -0
  3. package/dist/index.js +35680 -0
  4. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,398 @@
1
+ <p align="center">
2
+ <img src="https://upload.wikimedia.org/wikipedia/commons/0/0e/Bitbucket-blue-logomark-only.svg" alt="Bitbucket Logo" width="80" height="80">
3
+ </p>
4
+
5
+ <h1 align="center">Bitbucket CLI</h1>
6
+
7
+ <p align="center">
8
+ <strong>A powerful command-line interface for Bitbucket Cloud</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <em>Inspired by GitHub's <code>gh</code> CLI — bringing the same great experience to Bitbucket</em>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/bitbucket-cli"><img src="https://img.shields.io/npm/v/bitbucket-cli.svg?style=flat-square&color=blue" alt="npm version"></a>
17
+ <a href="https://www.npmjs.com/package/bitbucket-cli"><img src="https://img.shields.io/npm/dm/bitbucket-cli.svg?style=flat-square&color=blue" alt="npm downloads"></a>
18
+ <a href="https://github.com/0pilatos0/bitbucket-cli/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="License"></a>
19
+ <a href="https://github.com/0pilatos0/bitbucket-cli/issues"><img src="https://img.shields.io/github/issues/0pilatos0/bitbucket-cli.svg?style=flat-square" alt="GitHub issues"></a>
20
+ </p>
21
+
22
+ <p align="center">
23
+ <sub>
24
+ <strong>Note:</strong> This is an <strong>unofficial</strong>, community-maintained CLI tool.<br>
25
+ It is not affiliated with or endorsed by Atlassian or Bitbucket.
26
+ </sub>
27
+ </p>
28
+
29
+ ---
30
+
31
+ ## Why Bitbucket CLI?
32
+
33
+ If you've used GitHub's `gh` CLI and loved it, you've probably wished for something similar for Bitbucket. **Now you have it.**
34
+
35
+ `bb` brings the power of command-line workflows to Bitbucket Cloud, letting you:
36
+
37
+ - **Stay in your terminal** — No more context-switching to the browser
38
+ - **Automate your workflow** — Script common operations with ease
39
+ - **Work faster** — Clone repos, create PRs, and manage code reviews in seconds
40
+ - **Maintain consistency** — Use familiar patterns if you work across GitHub and Bitbucket
41
+
42
+ ---
43
+
44
+ ## Table of Contents
45
+
46
+ - [Installation](#installation)
47
+ - [Quick Start](#quick-start)
48
+ - [Commands](#commands)
49
+ - [Authentication](#authentication)
50
+ - [Repositories](#repositories)
51
+ - [Pull Requests](#pull-requests)
52
+ - [Configuration](#configuration)
53
+ - [Shell Completion](#shell-completion)
54
+ - [Global Options](#global-options)
55
+ - [Authentication Setup](#authentication-setup)
56
+ - [Configuration](#configuration-1)
57
+ - [Examples](#examples)
58
+ - [Development](#development)
59
+ - [Contributing](#contributing)
60
+ - [License](#license)
61
+
62
+ ---
63
+
64
+ ## Installation
65
+
66
+ ### Using npm (Recommended)
67
+
68
+ ```bash
69
+ npm install -g bitbucket-cli
70
+ ```
71
+
72
+ ### Using Bun
73
+
74
+ ```bash
75
+ bun install -g bitbucket-cli
76
+ ```
77
+
78
+ ### Using Yarn
79
+
80
+ ```bash
81
+ yarn global add bitbucket-cli
82
+ ```
83
+
84
+ ### Verify Installation
85
+
86
+ ```bash
87
+ bb --version
88
+ ```
89
+
90
+ > **Requirements:** Node.js 20 or higher
91
+
92
+ ---
93
+
94
+ ## Quick Start
95
+
96
+ Get up and running in under a minute:
97
+
98
+ ```bash
99
+ # 1. Authenticate with Bitbucket
100
+ bb auth login
101
+
102
+ # 2. Clone a repository
103
+ bb repo clone myworkspace/myrepo
104
+
105
+ # 3. Create a feature branch and make changes
106
+ cd myrepo
107
+ git checkout -b feature/awesome-feature
108
+
109
+ # 4. Create a pull request
110
+ bb pr create --title "Add awesome feature" --source feature/awesome-feature --destination main
111
+
112
+ # 5. List open pull requests
113
+ bb pr list
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Commands
119
+
120
+ ### Authentication
121
+
122
+ Manage your Bitbucket authentication securely.
123
+
124
+ | Command | Description |
125
+ |---------|-------------|
126
+ | `bb auth login` | Authenticate with Bitbucket using an App Password |
127
+ | `bb auth logout` | Log out and remove stored credentials |
128
+ | `bb auth status` | Check your current authentication status |
129
+ | `bb auth token` | Print your current access token |
130
+
131
+ ### Repositories
132
+
133
+ Clone, create, and manage your Bitbucket repositories.
134
+
135
+ | Command | Description |
136
+ |---------|-------------|
137
+ | `bb repo clone <repo>` | Clone a repository to your local machine |
138
+ | `bb repo create <name>` | Create a new repository |
139
+ | `bb repo list` | List repositories in a workspace |
140
+ | `bb repo view [repo]` | View repository details and metadata |
141
+ | `bb repo delete <repo>` | Delete a repository (use with caution!) |
142
+
143
+ ### Pull Requests
144
+
145
+ Full pull request workflow management from your terminal.
146
+
147
+ | Command | Description |
148
+ |---------|-------------|
149
+ | `bb pr create` | Create a new pull request |
150
+ | `bb pr list` | List pull requests with filtering options |
151
+ | `bb pr view <id>` | View pull request details, diff, and comments |
152
+ | `bb pr merge <id>` | Merge a pull request |
153
+ | `bb pr approve <id>` | Approve a pull request |
154
+ | `bb pr decline <id>` | Decline a pull request |
155
+ | `bb pr checkout <id>` | Checkout a pull request branch locally |
156
+
157
+ ### Configuration
158
+
159
+ Customize your CLI experience.
160
+
161
+ | Command | Description |
162
+ |---------|-------------|
163
+ | `bb config get <key>` | Get a configuration value |
164
+ | `bb config set <key> <value>` | Set a configuration value |
165
+ | `bb config list` | List all configuration values |
166
+
167
+ ### Shell Completion
168
+
169
+ Enable intelligent tab completion for faster command entry.
170
+
171
+ | Command | Description |
172
+ |---------|-------------|
173
+ | `bb completion install` | Install shell completions (auto-detects shell) |
174
+ | `bb completion uninstall` | Remove shell completions |
175
+
176
+ **Setup:**
177
+
178
+ ```bash
179
+ # Install completions
180
+ bb completion install
181
+
182
+ # Restart your shell or source your profile
183
+ source ~/.bashrc # Bash
184
+ source ~/.zshrc # Zsh
185
+ source ~/.config/fish/config.fish # Fish
186
+ ```
187
+
188
+ **Usage:**
189
+
190
+ ```bash
191
+ bb re<Tab> # → bb repo
192
+ bb repo cl<Tab> # → bb repo clone
193
+ bb pr l<Tab> # → bb pr list
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Global Options
199
+
200
+ These options work with any command:
201
+
202
+ | Option | Description |
203
+ |--------|-------------|
204
+ | `--json` | Output results as JSON for scripting |
205
+ | `-w, --workspace <workspace>` | Specify the workspace (overrides default) |
206
+ | `-r, --repo <repo>` | Specify the repository (overrides default) |
207
+ | `-h, --help` | Show help information |
208
+ | `-v, --version` | Show version number |
209
+
210
+ ---
211
+
212
+ ## Authentication Setup
213
+
214
+ The CLI uses **Bitbucket App Passwords** for secure authentication. Here's how to set it up:
215
+
216
+ ### Step 1: Create an App Password
217
+
218
+ 1. Go to [Bitbucket App Passwords](https://bitbucket.org/account/settings/app-passwords/)
219
+ 2. Click **"Create app password"**
220
+ 3. Enter a descriptive label (e.g., "bb CLI")
221
+ 4. Select the required permissions:
222
+ - **Account:** Read
223
+ - **Repositories:** Read, Write, Admin (as needed)
224
+ - **Pull requests:** Read, Write
225
+ 5. Click **"Create"**
226
+ 6. **Copy the generated password** (you won't see it again!)
227
+
228
+ ### Step 2: Authenticate
229
+
230
+ ```bash
231
+ bb auth login
232
+ ```
233
+
234
+ Enter your Bitbucket username and the App Password when prompted.
235
+
236
+ ### Step 3: Verify
237
+
238
+ ```bash
239
+ bb auth status
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Configuration
245
+
246
+ Configuration files are stored in platform-specific locations:
247
+
248
+ | Platform | Location |
249
+ |----------|----------|
250
+ | **macOS / Linux** | `~/.config/bb/config.json` |
251
+ | **Windows** | `%APPDATA%\bb\config.json` |
252
+
253
+ ### Available Settings
254
+
255
+ ```bash
256
+ # Set your default workspace
257
+ bb config set workspace myworkspace
258
+
259
+ # Set your default repository
260
+ bb config set repo myrepo
261
+
262
+ # View all settings
263
+ bb config list
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Examples
269
+
270
+ ### Daily Workflow
271
+
272
+ ```bash
273
+ # Start your day: check open PRs assigned to you
274
+ bb pr list --state OPEN
275
+
276
+ # Review a specific PR
277
+ bb pr view 42
278
+
279
+ # Approve and merge
280
+ bb pr approve 42
281
+ bb pr merge 42
282
+ ```
283
+
284
+ ### Creating a Pull Request
285
+
286
+ ```bash
287
+ # From your feature branch
288
+ bb pr create \
289
+ --title "feat: Add user notifications" \
290
+ --description "Implements real-time notifications using WebSockets" \
291
+ --source feature/notifications \
292
+ --destination main
293
+ ```
294
+
295
+ ### Scripting with JSON Output
296
+
297
+ ```bash
298
+ # Get all open PRs as JSON for processing
299
+ bb pr list --state OPEN --json | jq '.[] | .title'
300
+
301
+ # List repos and filter by name
302
+ bb repo list --json | jq '.[] | select(.name | contains("api"))'
303
+ ```
304
+
305
+ ### Quick Repository Setup
306
+
307
+ ```bash
308
+ # Create and clone a new repo in one flow
309
+ bb repo create my-new-project
310
+ bb repo clone myworkspace/my-new-project
311
+ cd my-new-project
312
+ ```
313
+
314
+ ---
315
+
316
+ ## Development
317
+
318
+ Want to contribute or run locally? Here's how:
319
+
320
+ ```bash
321
+ # Clone the repository
322
+ git clone https://github.com/0pilatos0/bitbucket-cli.git
323
+ cd bitbucket-cli
324
+
325
+ # Install dependencies
326
+ bun install
327
+
328
+ # Run in development mode
329
+ bun run dev
330
+
331
+ # Run tests
332
+ bun test
333
+
334
+ # Build for production
335
+ bun run build
336
+
337
+ # Generate API client from OpenAPI spec
338
+ bun run generate:api
339
+ ```
340
+
341
+ ### Project Structure
342
+
343
+ ```
344
+ bitbucket-cli/
345
+ ├── src/
346
+ │ ├── commands/ # Command implementations
347
+ │ ├── core/ # Core utilities and base classes
348
+ │ └── index.ts # Entry point
349
+ ├── tests/ # Test files
350
+ ├── docs/ # Documentation site (Astro)
351
+ └── specs/ # OpenAPI specifications
352
+ ```
353
+
354
+ ---
355
+
356
+ ## Contributing
357
+
358
+ We welcome contributions from the community! Whether it's:
359
+
360
+ - Reporting bugs
361
+ - Suggesting new features
362
+ - Improving documentation
363
+ - Submitting pull requests
364
+
365
+ Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
366
+
367
+ ### Quick Contribution Steps
368
+
369
+ 1. Fork the repository
370
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
371
+ 3. Make your changes
372
+ 4. Run tests (`bun test`)
373
+ 5. Commit with a descriptive message
374
+ 6. Push and open a Pull Request
375
+
376
+ ---
377
+
378
+ ## Acknowledgments
379
+
380
+ - Inspired by [GitHub CLI (`gh`)](https://cli.github.com/) — the gold standard for repository CLIs
381
+ - Built with [Commander.js](https://github.com/tj/commander.js) for robust command parsing
382
+ - Uses the [Bitbucket Cloud REST API](https://developer.atlassian.com/cloud/bitbucket/rest/)
383
+
384
+ ---
385
+
386
+ ## License
387
+
388
+ This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
389
+
390
+ ---
391
+
392
+ <p align="center">
393
+ <sub>
394
+ Made with care by the community<br>
395
+ <a href="https://github.com/0pilatos0/bitbucket-cli/issues">Report a Bug</a> ·
396
+ <a href="https://github.com/0pilatos0/bitbucket-cli/issues">Request a Feature</a>
397
+ </sub>
398
+ </p>