@bestend/confluence-cli 1.15.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/README.md ADDED
@@ -0,0 +1,454 @@
1
+ # Confluence CLI
2
+
3
+ A powerful command-line interface for Atlassian Confluence that allows you to read, search, and manage your Confluence content from the terminal.
4
+
5
+ ## Features
6
+
7
+ - 📖 **Read pages** - Get page content in text or HTML format
8
+ - 🔍 **Search** - Find pages using Confluence's powerful search
9
+ - â„šī¸ **Page info** - Get detailed information about pages
10
+ - 🏠 **List spaces** - View all available Confluence spaces
11
+ - âœī¸ **Create pages** - Create new pages with support for Markdown, HTML, or Storage format
12
+ - 📝 **Update pages** - Update existing page content and titles
13
+ - đŸ—‘ī¸ **Delete pages** - Delete (or move to trash) pages by ID or URL
14
+ - 📎 **Attachments** - List or download page attachments
15
+ - đŸ’Ŧ **Comments** - List, create, and delete page comments (footer or inline)
16
+ - đŸ“Ļ **Export** - Save a page and its attachments to a local folder
17
+ - đŸ› ī¸ **Edit workflow** - Export page content for editing and re-import
18
+ - 🔧 **Easy setup** - Simple configuration with environment variables or interactive setup
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install -g @bestend/confluence-cli
24
+ ```
25
+
26
+ Or run directly with npx:
27
+ ```bash
28
+ npx @bestend/confluence-cli
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ 1. **Initialize configuration:**
34
+ ```bash
35
+ confluence init
36
+ ```
37
+
38
+ 2. **Read a page:**
39
+ ```bash
40
+ confluence read 123456789
41
+ ```
42
+
43
+ 3. **Search for pages:**
44
+ ```bash
45
+ confluence search "my search term"
46
+ ```
47
+
48
+ 4. **List child pages:**
49
+ ```bash
50
+ confluence children 123456789
51
+ ```
52
+
53
+ 5. **Create a new page:**
54
+ ```bash
55
+ confluence create "My New Page" SPACEKEY --content "Hello World!"
56
+ ```
57
+
58
+ 6. **Update a page:**
59
+ ```bash
60
+ confluence update 123456789 --content "Updated content"
61
+ ```
62
+
63
+ ## Configuration
64
+
65
+ ### Option 1: Interactive Setup
66
+ ```bash
67
+ confluence init
68
+ ```
69
+
70
+ The wizard helps you choose the right API endpoint and authentication method. It recommends `/wiki/rest/api` for Atlassian Cloud domains (e.g., `*.atlassian.net`) and `/rest/api` for self-hosted/Data Center instances, then prompts for Basic (email + token) or Bearer authentication.
71
+
72
+ ### Option 2: Non-interactive Setup (CLI Flags)
73
+
74
+ Provide all required configuration via command-line flags. Perfect for CI/CD pipelines, Docker builds, and AI coding agents.
75
+
76
+ **Complete non-interactive mode** (all required fields provided):
77
+ ```bash
78
+ confluence init \
79
+ --domain "company.atlassian.net" \
80
+ --api-path "/wiki/rest/api" \
81
+ --auth-type "basic" \
82
+ --email "user@example.com" \
83
+ --token "your-api-token"
84
+ ```
85
+
86
+ **Hybrid mode** (some fields provided, rest via prompts):
87
+ ```bash
88
+ # Domain and token provided, will prompt for auth method and email
89
+ confluence init --domain "company.atlassian.net" --token "your-api-token"
90
+
91
+ # Email indicates basic auth, will prompt for domain and token
92
+ confluence init --email "user@example.com" --token "your-api-token"
93
+ ```
94
+
95
+ **Available flags:**
96
+ - `-d, --domain <domain>` - Confluence domain (e.g., `company.atlassian.net`)
97
+ - `-p, --api-path <path>` - REST API path (e.g., `/wiki/rest/api`)
98
+ - `-a, --auth-type <type>` - Authentication type: `basic` or `bearer`
99
+ - `-e, --email <email>` - Email for basic authentication
100
+ - `-t, --token <token>` - API token
101
+
102
+ âš ī¸ **Security note:** While flags work, storing tokens in shell history is risky. Prefer environment variables (Option 3) for production environments.
103
+
104
+ ### Option 3: Environment Variables
105
+ ```bash
106
+ export CONFLUENCE_DOMAIN="your-domain.atlassian.net"
107
+ export CONFLUENCE_API_TOKEN="your-api-token"
108
+ export CONFLUENCE_EMAIL="your.email@example.com" # required when using basic auth
109
+ export CONFLUENCE_API_PATH="/wiki/rest/api" # Cloud default; use /rest/api for Server/DC
110
+ # Optional: set to 'bearer' for self-hosted/Data Center instances
111
+ export CONFLUENCE_AUTH_TYPE="basic"
112
+ ```
113
+
114
+ `CONFLUENCE_API_PATH` defaults to `/wiki/rest/api` for Atlassian Cloud domains and `/rest/api` otherwise. Override it when your site lives under a custom reverse proxy or on-premises path. `CONFLUENCE_AUTH_TYPE` defaults to `basic` when an email is present and falls back to `bearer` otherwise.
115
+
116
+ ### Getting Your API Token
117
+
118
+ 1. Go to [Atlassian Account Settings](https://id.atlassian.com/manage-profile/security/api-tokens)
119
+ 2. Click "Create API token"
120
+ 3. Give it a label (e.g., "confluence-cli")
121
+ 4. Copy the generated token
122
+
123
+ ## Usage
124
+
125
+ ### Read a Page
126
+ ```bash
127
+ # Read by page ID
128
+ confluence read 123456789
129
+
130
+ # Read in markdown format
131
+ confluence read 123456789 --format markdown
132
+
133
+ # Read by URL (must contain pageId parameter)
134
+ confluence read "https://your-domain.atlassian.net/wiki/viewpage.action?pageId=123456789"
135
+ ```
136
+
137
+ ### Get Page Information
138
+ ```bash
139
+ confluence info 123456789
140
+ ```
141
+
142
+ ### Search Pages
143
+ ```bash
144
+ # Basic search
145
+ confluence search "search term"
146
+
147
+ # Limit results
148
+ confluence search "search term" --limit 5
149
+ ```
150
+
151
+ ### List or Download Attachments
152
+ ```bash
153
+ # List all attachments on a page
154
+ confluence attachments 123456789
155
+
156
+ # Filter by filename and limit the number returned
157
+ confluence attachments 123456789 --pattern "*.png" --limit 5
158
+
159
+ # Download matching attachments to a directory
160
+ confluence attachments 123456789 --pattern "*.png" --download --dest ./downloads
161
+ ```
162
+
163
+ ### Comments
164
+ ```bash
165
+ # List all comments (footer + inline)
166
+ confluence comments 123456789
167
+
168
+ # List inline comments as markdown
169
+ confluence comments 123456789 --location inline --format markdown
170
+
171
+ # Create a footer comment
172
+ confluence comment 123456789 --content "Looks good to me!"
173
+
174
+ # Create an inline comment
175
+ confluence comment 123456789 \
176
+ --location inline \
177
+ --content "Consider renaming this" \
178
+ --inline-selection "foo" \
179
+ --inline-original-selection "foo"
180
+
181
+ # Reply to a comment
182
+ confluence comment 123456789 --parent 998877 --content "Agree with this"
183
+
184
+ # Delete a comment
185
+ confluence comment-delete 998877
186
+ ```
187
+
188
+ Inline comment creation note (Confluence Cloud): Creating inline comments requires editor-generated highlight metadata (`matchIndex`, `lastFetchTime`, `serializedHighlights`, plus the selection text). The public REST API does not provide these fields, so inline creation and inline replies can fail with a 400 unless you supply the full `--inline-properties` payload captured from the editor. Footer comments and replies are fully supported.
189
+
190
+ ### Export a Page with Attachments
191
+ ```bash
192
+ # Export page content (markdown by default) and all attachments
193
+ confluence export 123456789 --dest ./exports
194
+
195
+ # Custom content format/filename and attachment filtering
196
+ confluence export 123456789 --format html --file content.html --pattern "*.png"
197
+
198
+ # Skip attachments if you only need the content file
199
+ confluence export 123456789 --skip-attachments
200
+ ```
201
+
202
+ ### List Spaces
203
+ ```bash
204
+ confluence spaces
205
+ ```
206
+
207
+ ### List Child Pages
208
+ ```bash
209
+ # List direct child pages
210
+ confluence children 123456789
211
+
212
+ # List all descendants recursively
213
+ confluence children 123456789 --recursive
214
+
215
+ # Display as tree structure
216
+ confluence children 123456789 --recursive --format tree
217
+
218
+ # Show page IDs and URLs
219
+ confluence children 123456789 --show-id --show-url
220
+
221
+ # Limit recursion depth
222
+ confluence children 123456789 --recursive --max-depth 3
223
+
224
+ # Output as JSON for scripting
225
+ confluence children 123456789 --recursive --format json > children.json
226
+ ```
227
+
228
+ ### Find a Page by Title
229
+ ```bash
230
+ # Find page by title
231
+ confluence find "Project Documentation"
232
+
233
+ # Find page by title in a specific space
234
+ confluence find "Project Documentation" --space MYTEAM
235
+ ```
236
+
237
+ ### Create a New Page
238
+ ```bash
239
+ # Create with inline content and markdown format
240
+ confluence create "My New Page" SPACEKEY --content "**Hello** World!" --format markdown
241
+
242
+ # Create from a file
243
+ confluence create "Documentation" SPACEKEY --file ./content.md --format markdown
244
+ ```
245
+
246
+ ### Create a Child Page
247
+ ```bash
248
+ # Create child page with inline content
249
+ confluence create-child "Meeting Notes" 123456789 --content "This is a child page"
250
+
251
+ # Create child page from a file
252
+ confluence create-child "Tech Specs" 123456789 --file ./specs.md --format markdown
253
+ ```
254
+
255
+ ### Copy Page Tree
256
+ ```bash
257
+ # Copy a page and all its children to a new location
258
+ confluence copy-tree 123456789 987654321 "Project Docs (Copy)"
259
+
260
+ # Copy with maximum depth limit (only 3 levels deep)
261
+ confluence copy-tree 123456789 987654321 --max-depth 3
262
+
263
+ # Exclude pages by title (supports wildcards * and ?; case-insensitive)
264
+ confluence copy-tree 123456789 987654321 --exclude "temp*,test*,*draft*"
265
+
266
+ # Control pacing and naming
267
+ confluence copy-tree 123456789 987654321 --delay-ms 150 --copy-suffix " (Backup)"
268
+
269
+ # Dry run (preview only)
270
+ confluence copy-tree 123456789 987654321 --dry-run
271
+
272
+ # Quiet mode (suppress progress output)
273
+ confluence copy-tree 123456789 987654321 --quiet
274
+ ```
275
+
276
+ Notes:
277
+ - Preserves the original parent-child hierarchy when copying.
278
+ - Continues on errors: failed pages are logged and the copy proceeds.
279
+ - Exclude patterns use simple globbing: `*` matches any sequence, `?` matches any single character, and special regex characters are treated literally.
280
+ - Large trees may take time; the CLI applies a small delay between sibling page creations to avoid rate limits (configurable via `--delay-ms`).
281
+ - Root title suffix defaults to ` (Copy)`; override with `--copy-suffix`. Child pages keep their original titles.
282
+ - Use `--fail-on-error` to exit non-zero if any page fails to copy.
283
+
284
+ ### Update an Existing Page
285
+ ```bash
286
+ # Update title only
287
+ confluence update 123456789 --title "A Newer Title for the Page"
288
+
289
+ # Update content only from a string
290
+ confluence update 123456789 --content "Updated page content."
291
+
292
+ # Update content from a file
293
+ confluence update 123456789 --file ./updated-content.md --format markdown
294
+
295
+ # Update both title and content
296
+ confluence update 123456789 --title "New Title" --content "And new content"
297
+ ```
298
+
299
+ ### Delete a Page
300
+ ```bash
301
+ # Delete by page ID (prompts for confirmation)
302
+ confluence delete 123456789
303
+
304
+ # Delete by URL
305
+ confluence delete "https://your-domain.atlassian.net/wiki/viewpage.action?pageId=123456789"
306
+
307
+ # Skip confirmation (useful for scripts)
308
+ confluence delete 123456789 --yes
309
+ ```
310
+
311
+ ### Edit Workflow
312
+ The `edit` and `update` commands work together to create a seamless editing workflow.
313
+ ```bash
314
+ # 1. Export page content to a file (in Confluence storage format)
315
+ confluence edit 123456789 --output ./page-to-edit.xml
316
+
317
+ # 2. Edit the file with your preferred editor
318
+ vim ./page-to-edit.xml
319
+
320
+ # 3. Update the page with your changes
321
+ confluence update 123456789 --file ./page-to-edit.xml --format storage
322
+ ```
323
+
324
+ ### View Usage Statistics
325
+ ```bash
326
+ confluence stats
327
+ ```
328
+
329
+ ## Commands
330
+
331
+ | Command | Description | Options |
332
+ |---|---|---|
333
+ | `init` | Initialize CLI configuration | |
334
+ | `read <pageId_or_url>` | Read page content | `--format <html\|text\|markdown>` |
335
+ | `info <pageId_or_url>` | Get page information | |
336
+ | `search <query>` | Search for pages | `--limit <number>` |
337
+ | `spaces` | List all available spaces | |
338
+ | `find <title>` | Find a page by its title | `--space <spaceKey>` |
339
+ | `children <pageId>` | List child pages of a page | `--recursive`, `--max-depth <number>`, `--format <list\|tree\|json>`, `--show-url`, `--show-id` |
340
+ | `create <title> <spaceKey>` | Create a new page | `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>`|
341
+ | `create-child <title> <parentId>` | Create a child page | `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>` |
342
+ | `copy-tree <sourcePageId> <targetParentId> [newTitle]` | Copy page tree with all children | `--max-depth <number>`, `--exclude <patterns>`, `--delay-ms <ms>`, `--copy-suffix <text>`, `--dry-run`, `--fail-on-error`, `--quiet` |
343
+ | `update <pageId>` | Update a page's title or content | `--title <string>`, `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>` |
344
+ | `delete <pageId_or_url>` | Delete a page by ID or URL | `--yes` |
345
+ | `edit <pageId>` | Export page content for editing | `--output <file>` |
346
+ | `attachments <pageId_or_url>` | List or download attachments for a page | `--limit <number>`, `--pattern <glob>`, `--download`, `--dest <directory>` |
347
+ | `comments <pageId_or_url>` | List comments for a page | `--format <text\|markdown\|json>`, `--limit <number>`, `--start <number>`, `--location <inline\|footer\|resolved>`, `--depth <root\|all>`, `--all` |
348
+ | `comment <pageId_or_url>` | Create a comment on a page | `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>`, `--parent <commentId>`, `--location <inline\|footer>`, `--inline-selection <text>`, `--inline-original-selection <text>`, `--inline-marker-ref <ref>`, `--inline-properties <json>` |
349
+ | `comment-delete <commentId>` | Delete a comment by ID | `--yes` |
350
+ | `export <pageId_or_url>` | Export a page to a directory with its attachments | `--format <html\|text\|markdown>`, `--dest <directory>`, `--file <filename>`, `--attachments-dir <name>`, `--pattern <glob>`, `--referenced-only`, `--skip-attachments` |
351
+ | `stats` | View your usage statistics | |
352
+
353
+ ## Examples
354
+
355
+ ```bash
356
+ # Setup
357
+ confluence init
358
+
359
+ # Read a page as text
360
+ confluence read 123456789
361
+
362
+ # Read a page as HTML
363
+ confluence read 123456789 --format html
364
+
365
+ # Get page details
366
+ confluence info 123456789
367
+
368
+ # Search with limit
369
+ confluence search "API documentation" --limit 3
370
+
371
+ # List all spaces
372
+ confluence spaces
373
+
374
+ # View usage statistics
375
+ confluence stats
376
+ ```
377
+
378
+ ## Development
379
+
380
+ ```bash
381
+ # Clone the repository
382
+ git clone https://github.com/pchuri/confluence-cli.git
383
+ cd confluence-cli
384
+
385
+ # Install dependencies
386
+ npm install
387
+
388
+ # Run locally
389
+ npm start -- --help
390
+
391
+ # Run tests
392
+ npm test
393
+
394
+ # Lint code
395
+ npm run lint
396
+ ```
397
+
398
+ ## Contributing
399
+
400
+ 1. Fork the repository
401
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
402
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
403
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
404
+ 5. Open a Pull Request
405
+
406
+ ## License
407
+
408
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
409
+
410
+ ## Roadmap
411
+
412
+ - [x] **Create and update pages** ✅
413
+ - [ ] Page templates
414
+ - [ ] Bulk operations
415
+ - [ ] Export pages to different formats
416
+ - [ ] Integration with other Atlassian tools (Jira)
417
+ - [ ] Page attachments management
418
+ - [x] Comments
419
+ - [ ] Reviews
420
+
421
+ ## Support & Feedback
422
+
423
+ ### đŸ’Ŧ We'd love to hear from you!
424
+
425
+ Your feedback helps make confluence-cli better for everyone. Here's how you can share your thoughts:
426
+
427
+ #### 🐛 Found a bug?
428
+ 1. Check the [Issues](https://github.com/pchuri/confluence-cli/issues) page
429
+ 2. Create a new [bug report](https://github.com/pchuri/confluence-cli/issues/new?template=bug_report.md)
430
+
431
+ #### 💡 Have a feature idea?
432
+ 1. Create a [feature request](https://github.com/pchuri/confluence-cli/issues/new?template=feature_request.md)
433
+ 2. Join our [Discussions](https://github.com/pchuri/confluence-cli/discussions) to chat with the community
434
+
435
+ #### 📝 General feedback?
436
+ - Share your experience with a [feedback issue](https://github.com/pchuri/confluence-cli/issues/new?template=feedback.md)
437
+ - Rate us on [NPM](https://www.npmjs.com/package/confluence-cli)
438
+ - Star the repo if you find it useful! ⭐
439
+
440
+ #### 🤝 Want to contribute?
441
+ Check out our [Contributing Guide](CONTRIBUTING.md) - all contributions are welcome!
442
+
443
+ ### 📈 Usage Analytics
444
+
445
+ To help us understand how confluence-cli is being used and improve it, we collect anonymous usage statistics. This includes:
446
+ - Command usage frequency (no personal data)
447
+ - Error patterns (to fix bugs faster)
448
+ - Feature adoption metrics
449
+
450
+ You can opt-out anytime by setting: `export CONFLUENCE_CLI_ANALYTICS=false`
451
+
452
+ ---
453
+
454
+ Made with â¤ī¸ for the Confluence community