confluence-cli 1.4.1 → 1.5.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.
- package/CHANGELOG.md +7 -0
- package/README.md +57 -70
- package/bin/confluence.js +6 -3
- package/lib/confluence-client.js +20 -9
- package/llm.txt +20 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/pchuri/confluence-cli/compare/v1.4.1...v1.5.0) (2025-08-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Align README with implementation and fix update command ([#7](https://github.com/pchuri/confluence-cli/issues/7)) ([87f48e0](https://github.com/pchuri/confluence-cli/commit/87f48e03c6310bb9bfc7fda2930247c0d61414ec))
|
|
7
|
+
|
|
1
8
|
## [1.4.1](https://github.com/pchuri/confluence-cli/compare/v1.4.0...v1.4.1) (2025-06-30)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -78,103 +78,85 @@ export CONFLUENCE_API_TOKEN="your-api-token"
|
|
|
78
78
|
# Read by page ID
|
|
79
79
|
confluence read 123456789
|
|
80
80
|
|
|
81
|
-
# Read in
|
|
82
|
-
confluence read 123456789 --format
|
|
81
|
+
# Read in markdown format
|
|
82
|
+
confluence read 123456789 --format markdown
|
|
83
83
|
|
|
84
|
-
# Read by URL
|
|
85
|
-
confluence read "https://your-domain.atlassian.net/wiki/
|
|
84
|
+
# Read by URL (must contain pageId parameter)
|
|
85
|
+
confluence read "https://your-domain.atlassian.net/wiki/viewpage.action?pageId=123456789"
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
###
|
|
88
|
+
### Get Page Information
|
|
89
89
|
```bash
|
|
90
|
-
|
|
91
|
-
confluence create "My New Page" SPACEKEY --content "This is my page content"
|
|
92
|
-
|
|
93
|
-
# Create from a file
|
|
94
|
-
confluence create "Documentation" SPACEKEY --file ./content.md --format markdown
|
|
95
|
-
|
|
96
|
-
# Create with HTML content
|
|
97
|
-
confluence create "Rich Content" SPACEKEY --file ./content.html --format html
|
|
98
|
-
|
|
99
|
-
# Create with Storage format (Confluence native)
|
|
100
|
-
confluence create "Advanced Page" SPACEKEY --file ./content.xml --format storage
|
|
90
|
+
confluence info 123456789
|
|
101
91
|
```
|
|
102
92
|
|
|
103
|
-
###
|
|
93
|
+
### Search Pages
|
|
104
94
|
```bash
|
|
105
|
-
#
|
|
106
|
-
confluence
|
|
107
|
-
|
|
108
|
-
# Create child page with inline content
|
|
109
|
-
confluence create-child "Meeting Notes" 123456789 --content "This is a child page"
|
|
95
|
+
# Basic search
|
|
96
|
+
confluence search "search term"
|
|
110
97
|
|
|
111
|
-
#
|
|
112
|
-
confluence
|
|
98
|
+
# Limit results
|
|
99
|
+
confluence search "search term" --limit 5
|
|
100
|
+
```
|
|
113
101
|
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
### List Spaces
|
|
103
|
+
```bash
|
|
104
|
+
confluence spaces
|
|
116
105
|
```
|
|
117
106
|
|
|
118
|
-
### Find
|
|
107
|
+
### Find a Page by Title
|
|
119
108
|
```bash
|
|
120
109
|
# Find page by title
|
|
121
110
|
confluence find "Project Documentation"
|
|
122
111
|
|
|
123
|
-
# Find page by title in specific space
|
|
112
|
+
# Find page by title in a specific space
|
|
124
113
|
confluence find "Project Documentation" --space MYTEAM
|
|
125
114
|
```
|
|
126
115
|
|
|
127
|
-
###
|
|
116
|
+
### Create a New Page
|
|
128
117
|
```bash
|
|
129
|
-
#
|
|
130
|
-
confluence
|
|
131
|
-
|
|
132
|
-
# Update content from file
|
|
133
|
-
confluence update 123456789 --file ./updated-content.md --format markdown
|
|
134
|
-
|
|
135
|
-
# Update both title and content
|
|
136
|
-
confluence update 123456789 --title "New Title" --content "New content"
|
|
118
|
+
# Create with inline content and markdown format
|
|
119
|
+
confluence create "My New Page" SPACEKEY --content "**Hello** World!" --format markdown
|
|
137
120
|
|
|
138
|
-
#
|
|
139
|
-
confluence
|
|
121
|
+
# Create from a file
|
|
122
|
+
confluence create "Documentation" SPACEKEY --file ./content.md --format markdown
|
|
140
123
|
```
|
|
141
124
|
|
|
142
|
-
###
|
|
125
|
+
### Create a Child Page
|
|
143
126
|
```bash
|
|
144
|
-
#
|
|
145
|
-
confluence
|
|
146
|
-
|
|
147
|
-
# Edit the file with your preferred editor
|
|
148
|
-
vim ./page-content.xml
|
|
127
|
+
# Create child page with inline content
|
|
128
|
+
confluence create-child "Meeting Notes" 123456789 --content "This is a child page"
|
|
149
129
|
|
|
150
|
-
#
|
|
151
|
-
confluence
|
|
130
|
+
# Create child page from a file
|
|
131
|
+
confluence create-child "Tech Specs" 123456789 --file ./specs.md --format markdown
|
|
152
132
|
```
|
|
153
133
|
|
|
154
|
-
|
|
155
|
-
|
|
134
|
+
### Update an Existing Page
|
|
135
|
+
```bash
|
|
136
|
+
# Update title only
|
|
137
|
+
confluence update 123456789 --title "A Newer Title for the Page"
|
|
156
138
|
|
|
157
|
-
#
|
|
158
|
-
confluence
|
|
159
|
-
```
|
|
139
|
+
# Update content only from a string
|
|
140
|
+
confluence update 123456789 --content "Updated page content."
|
|
160
141
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
142
|
+
# Update content from a file
|
|
143
|
+
confluence update 123456789 --file ./updated-content.md --format markdown
|
|
144
|
+
|
|
145
|
+
# Update both title and content
|
|
146
|
+
confluence update 123456789 --title "New Title" --content "And new content"
|
|
164
147
|
```
|
|
165
148
|
|
|
166
|
-
###
|
|
149
|
+
### Edit Workflow
|
|
150
|
+
The `edit` and `update` commands work together to create a seamless editing workflow.
|
|
167
151
|
```bash
|
|
168
|
-
#
|
|
169
|
-
confluence
|
|
152
|
+
# 1. Export page content to a file (in Confluence storage format)
|
|
153
|
+
confluence edit 123456789 --output ./page-to-edit.xml
|
|
170
154
|
|
|
171
|
-
#
|
|
172
|
-
|
|
173
|
-
```
|
|
155
|
+
# 2. Edit the file with your preferred editor
|
|
156
|
+
vim ./page-to-edit.xml
|
|
174
157
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
confluence spaces
|
|
158
|
+
# 3. Update the page with your changes
|
|
159
|
+
confluence update 123456789 --file ./page-to-edit.xml --format storage
|
|
178
160
|
```
|
|
179
161
|
|
|
180
162
|
### View Usage Statistics
|
|
@@ -185,13 +167,18 @@ confluence stats
|
|
|
185
167
|
## Commands
|
|
186
168
|
|
|
187
169
|
| Command | Description | Options |
|
|
188
|
-
|
|
189
|
-
| `init` | Initialize CLI configuration |
|
|
190
|
-
| `read <
|
|
191
|
-
| `info <
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `init` | Initialize CLI configuration | |
|
|
172
|
+
| `read <pageId_or_url>` | Read page content | `--format <html\|text\|markdown>` |
|
|
173
|
+
| `info <pageId_or_url>` | Get page information | |
|
|
192
174
|
| `search <query>` | Search for pages | `--limit <number>` |
|
|
193
|
-
| `spaces` | List all spaces |
|
|
194
|
-
| `
|
|
175
|
+
| `spaces` | List all available spaces | |
|
|
176
|
+
| `find <title>` | Find a page by its title | `--space <spaceKey>` |
|
|
177
|
+
| `create <title> <spaceKey>` | Create a new page | `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>`|
|
|
178
|
+
| `create-child <title> <parentId>` | Create a child page | `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>` |
|
|
179
|
+
| `update <pageId>` | Update a page's title or content | `--title <string>`, `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>` |
|
|
180
|
+
| `edit <pageId>` | Export page content for editing | `--output <file>` |
|
|
181
|
+
| `stats` | View your usage statistics | |
|
|
195
182
|
|
|
196
183
|
## Examples
|
|
197
184
|
|
package/bin/confluence.js
CHANGED
|
@@ -238,10 +238,15 @@ program
|
|
|
238
238
|
.action(async (pageId, options) => {
|
|
239
239
|
const analytics = new Analytics();
|
|
240
240
|
try {
|
|
241
|
+
// Check if at least one option is provided
|
|
242
|
+
if (!options.title && !options.file && !options.content) {
|
|
243
|
+
throw new Error('At least one of --title, --file, or --content must be provided.');
|
|
244
|
+
}
|
|
245
|
+
|
|
241
246
|
const config = getConfig();
|
|
242
247
|
const client = new ConfluenceClient(config);
|
|
243
248
|
|
|
244
|
-
let content =
|
|
249
|
+
let content = null; // Use null to indicate no content change
|
|
245
250
|
|
|
246
251
|
if (options.file) {
|
|
247
252
|
const fs = require('fs');
|
|
@@ -251,8 +256,6 @@ program
|
|
|
251
256
|
content = fs.readFileSync(options.file, 'utf8');
|
|
252
257
|
} else if (options.content) {
|
|
253
258
|
content = options.content;
|
|
254
|
-
} else {
|
|
255
|
-
throw new Error('Either --file or --content option is required');
|
|
256
259
|
}
|
|
257
260
|
|
|
258
261
|
const result = await client.updatePage(pageId, options.title, content, options.format);
|
package/lib/confluence-client.js
CHANGED
|
@@ -552,17 +552,28 @@ class ConfluenceClient {
|
|
|
552
552
|
* Update an existing Confluence page
|
|
553
553
|
*/
|
|
554
554
|
async updatePage(pageId, title, content, format = 'storage') {
|
|
555
|
-
// First, get the current page to get the version number
|
|
556
|
-
const currentPage = await this.client.get(`/content/${pageId}
|
|
555
|
+
// First, get the current page to get the version number and existing content
|
|
556
|
+
const currentPage = await this.client.get(`/content/${pageId}`, {
|
|
557
|
+
params: {
|
|
558
|
+
expand: 'body.storage,version,space'
|
|
559
|
+
}
|
|
560
|
+
});
|
|
557
561
|
const currentVersion = currentPage.data.version.number;
|
|
558
562
|
|
|
559
|
-
let storageContent
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
563
|
+
let storageContent;
|
|
564
|
+
|
|
565
|
+
if (content !== undefined && content !== null) {
|
|
566
|
+
// If new content is provided, convert it to storage format
|
|
567
|
+
if (format === 'markdown') {
|
|
568
|
+
storageContent = this.markdownToStorage(content);
|
|
569
|
+
} else if (format === 'html') {
|
|
570
|
+
storageContent = this.htmlToConfluenceStorage(content); // Using the conversion function for robustness
|
|
571
|
+
} else { // 'storage' format
|
|
572
|
+
storageContent = content;
|
|
573
|
+
}
|
|
574
|
+
} else {
|
|
575
|
+
// If no new content, use the existing content
|
|
576
|
+
storageContent = currentPage.data.body.storage.value;
|
|
566
577
|
}
|
|
567
578
|
|
|
568
579
|
const pageData = {
|
package/llm.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
I have analyzed the codebase and identified several inconsistencies between the `README.md` documentation and the actual implementation of the CLI tool. I have addressed these issues by modifying the code to be more robust and by updating the documentation to be accurate and comprehensive.
|
|
2
|
+
|
|
3
|
+
Here is a summary of the changes:
|
|
4
|
+
|
|
5
|
+
1. **`update` Command Logic and Documentation:**
|
|
6
|
+
* **Inconsistency:** The `README.md` suggested that updating a page's title without changing its content was possible. However, the implementation in `bin/confluence.js` incorrectly threw an error if the `--content` or `--file` flags were not provided, making title-only updates impossible.
|
|
7
|
+
* **Fix:**
|
|
8
|
+
* I modified the `updatePage` function in `lib/confluence-client.js` to check if new content is provided. If not, it now fetches and re-uses the existing page content, preventing accidental data loss during title-only updates.
|
|
9
|
+
* I adjusted the validation logic in `bin/confluence.js` for the `update` command to only require that at least one of `--title`, `--content`, or `--file` is present.
|
|
10
|
+
* I updated the `README.md` to include an explicit example of a title-only update.
|
|
11
|
+
|
|
12
|
+
2. **Incomplete `README.md` Command Reference:**
|
|
13
|
+
* **Inconsistency:** The main command table in the `README.md` was missing several important commands that were fully implemented in the code, including `create`, `create-child`, `update`, `edit`, and `find`.
|
|
14
|
+
* **Fix:** I expanded the command table in `README.md` to include all available commands and their respective options, providing a complete and accurate reference for users.
|
|
15
|
+
|
|
16
|
+
3. **Misleading `read` Command URL Examples:**
|
|
17
|
+
* **Inconsistency:** The documentation for the `read` command provided examples using "display" or "pretty" URLs. The `extractPageId` function in the code, however, explicitly does not support this URL format and can only parse URLs that contain a `pageId` query parameter (e.g., `.../viewpage.action?pageId=12345`).
|
|
18
|
+
* **Fix:** I removed the incorrect URL examples from the `README.md` and replaced them with a valid example that uses the `pageId` parameter. I also added a note to clarify that this is the only supported URL format for the `read` command.
|
|
19
|
+
|
|
20
|
+
These changes have brought the code and documentation into alignment, fixed a bug in the update functionality, and improved the overall user experience by providing clearer and more accurate instructions.
|