confluence-cli 1.11.1 → 1.12.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 +13 -0
- package/bin/confluence.js +44 -0
- package/lib/confluence-client.js +10 -0
- package/package.json +1 -1
- package/tests/confluence-client.test.js +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/pchuri/confluence-cli/compare/v1.11.1...v1.12.0) (2025-12-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add page delete command ([#25](https://github.com/pchuri/confluence-cli/issues/25)) ([bc3e412](https://github.com/pchuri/confluence-cli/commit/bc3e412a6ccd0774d62ab0816a6c2735cbd470a4))
|
|
7
|
+
|
|
1
8
|
## [1.11.1](https://github.com/pchuri/confluence-cli/compare/v1.11.0...v1.11.1) (2025-12-17)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ A powerful command-line interface for Atlassian Confluence that allows you to re
|
|
|
10
10
|
- 🏠 **List spaces** - View all available Confluence spaces
|
|
11
11
|
- ✏️ **Create pages** - Create new pages with support for Markdown, HTML, or Storage format
|
|
12
12
|
- 📝 **Update pages** - Update existing page content and titles
|
|
13
|
+
- 🗑️ **Delete pages** - Delete (or move to trash) pages by ID or URL
|
|
13
14
|
- 📎 **Attachments** - List or download page attachments
|
|
14
15
|
- 📦 **Export** - Save a page and its attachments to a local folder
|
|
15
16
|
- 🛠️ **Edit workflow** - Export page content for editing and re-import
|
|
@@ -209,6 +210,18 @@ confluence update 123456789 --file ./updated-content.md --format markdown
|
|
|
209
210
|
confluence update 123456789 --title "New Title" --content "And new content"
|
|
210
211
|
```
|
|
211
212
|
|
|
213
|
+
### Delete a Page
|
|
214
|
+
```bash
|
|
215
|
+
# Delete by page ID (prompts for confirmation)
|
|
216
|
+
confluence delete 123456789
|
|
217
|
+
|
|
218
|
+
# Delete by URL
|
|
219
|
+
confluence delete "https://your-domain.atlassian.net/wiki/viewpage.action?pageId=123456789"
|
|
220
|
+
|
|
221
|
+
# Skip confirmation (useful for scripts)
|
|
222
|
+
confluence delete 123456789 --yes
|
|
223
|
+
```
|
|
224
|
+
|
|
212
225
|
### Edit Workflow
|
|
213
226
|
The `edit` and `update` commands work together to create a seamless editing workflow.
|
|
214
227
|
```bash
|
package/bin/confluence.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { program } = require('commander');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
+
const inquirer = require('inquirer');
|
|
5
6
|
const ConfluenceClient = require('../lib/confluence-client');
|
|
6
7
|
const { getConfig, initConfig } = require('../lib/config');
|
|
7
8
|
const Analytics = require('../lib/analytics');
|
|
@@ -274,6 +275,49 @@ program
|
|
|
274
275
|
}
|
|
275
276
|
});
|
|
276
277
|
|
|
278
|
+
// Delete command
|
|
279
|
+
program
|
|
280
|
+
.command('delete <pageIdOrUrl>')
|
|
281
|
+
.description('Delete a Confluence page by ID or URL')
|
|
282
|
+
.option('-y, --yes', 'Skip confirmation prompt')
|
|
283
|
+
.action(async (pageIdOrUrl, options) => {
|
|
284
|
+
const analytics = new Analytics();
|
|
285
|
+
try {
|
|
286
|
+
const config = getConfig();
|
|
287
|
+
const client = new ConfluenceClient(config);
|
|
288
|
+
const pageInfo = await client.getPageInfo(pageIdOrUrl);
|
|
289
|
+
|
|
290
|
+
if (!options.yes) {
|
|
291
|
+
const spaceLabel = pageInfo.space?.key ? ` (${pageInfo.space.key})` : '';
|
|
292
|
+
const { confirmed } = await inquirer.prompt([
|
|
293
|
+
{
|
|
294
|
+
type: 'confirm',
|
|
295
|
+
name: 'confirmed',
|
|
296
|
+
default: false,
|
|
297
|
+
message: `Delete "${pageInfo.title}" (ID: ${pageInfo.id})${spaceLabel}?`
|
|
298
|
+
}
|
|
299
|
+
]);
|
|
300
|
+
|
|
301
|
+
if (!confirmed) {
|
|
302
|
+
console.log(chalk.yellow('Cancelled.'));
|
|
303
|
+
analytics.track('delete_cancel', true);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const result = await client.deletePage(pageInfo.id);
|
|
309
|
+
|
|
310
|
+
console.log(chalk.green('✅ Page deleted successfully!'));
|
|
311
|
+
console.log(`Title: ${chalk.blue(pageInfo.title)}`);
|
|
312
|
+
console.log(`ID: ${chalk.blue(result.id)}`);
|
|
313
|
+
analytics.track('delete', true);
|
|
314
|
+
} catch (error) {
|
|
315
|
+
analytics.track('delete', false);
|
|
316
|
+
console.error(chalk.red('Error:'), error.message);
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
277
321
|
// Edit command - opens page content for editing
|
|
278
322
|
program
|
|
279
323
|
.command('edit <pageId>')
|
package/lib/confluence-client.js
CHANGED
|
@@ -1208,6 +1208,16 @@ class ConfluenceClient {
|
|
|
1208
1208
|
};
|
|
1209
1209
|
}
|
|
1210
1210
|
|
|
1211
|
+
/**
|
|
1212
|
+
* Delete a Confluence page
|
|
1213
|
+
* Note: Confluence may move the page to trash depending on instance settings.
|
|
1214
|
+
*/
|
|
1215
|
+
async deletePage(pageIdOrUrl) {
|
|
1216
|
+
const pageId = await this.extractPageId(pageIdOrUrl);
|
|
1217
|
+
await this.client.delete(`/content/${pageId}`);
|
|
1218
|
+
return { id: String(pageId) };
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1211
1221
|
/**
|
|
1212
1222
|
* Search for a page by title and space
|
|
1213
1223
|
*/
|
package/package.json
CHANGED
|
@@ -267,6 +267,29 @@ describe('ConfluenceClient', () => {
|
|
|
267
267
|
expect(typeof client.getPageForEdit).toBe('function');
|
|
268
268
|
expect(typeof client.createChildPage).toBe('function');
|
|
269
269
|
expect(typeof client.findPageByTitle).toBe('function');
|
|
270
|
+
expect(typeof client.deletePage).toBe('function');
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('deletePage', () => {
|
|
275
|
+
test('should delete a page by ID', async () => {
|
|
276
|
+
const mock = new MockAdapter(client.client);
|
|
277
|
+
mock.onDelete('/content/123456789').reply(204);
|
|
278
|
+
|
|
279
|
+
await expect(client.deletePage('123456789')).resolves.toEqual({ id: '123456789' });
|
|
280
|
+
|
|
281
|
+
mock.restore();
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test('should delete a page by URL', async () => {
|
|
285
|
+
const mock = new MockAdapter(client.client);
|
|
286
|
+
mock.onDelete('/content/987654321').reply(204);
|
|
287
|
+
|
|
288
|
+
await expect(
|
|
289
|
+
client.deletePage('https://test.atlassian.net/wiki/viewpage.action?pageId=987654321')
|
|
290
|
+
).resolves.toEqual({ id: '987654321' });
|
|
291
|
+
|
|
292
|
+
mock.restore();
|
|
270
293
|
});
|
|
271
294
|
});
|
|
272
295
|
|