@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/.eslintrc.js +23 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +26 -0
- package/.github/ISSUE_TEMPLATE/feedback.md +37 -0
- package/.github/pull_request_template.md +31 -0
- package/.github/workflows/ci.yml +67 -0
- package/.github/workflows/publish.yml +26 -0
- package/.releaserc +17 -0
- package/CHANGELOG.md +232 -0
- package/CONTRIBUTING.md +246 -0
- package/LICENSE +21 -0
- package/README.md +454 -0
- package/bin/confluence.js +1225 -0
- package/bin/index.js +24 -0
- package/docs/PROMOTION.md +63 -0
- package/eslint.config.js +33 -0
- package/examples/copy-tree-example.sh +117 -0
- package/examples/create-child-page-example.sh +67 -0
- package/examples/demo-page-management.sh +68 -0
- package/examples/demo.sh +43 -0
- package/examples/sample-page.md +30 -0
- package/jest.config.js +13 -0
- package/lib/analytics.js +87 -0
- package/lib/config.js +437 -0
- package/lib/confluence-client.js +1810 -0
- package/llms.txt +46 -0
- package/package.json +57 -0
- package/tests/confluence-client.test.js +459 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* confluence-cli
|
|
5
|
+
* A powerful command-line interface for Atlassian Confluence
|
|
6
|
+
*
|
|
7
|
+
* @author Your Name
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
// Make sure we're using a supported Node.js version
|
|
14
|
+
const nodeVersion = process.version;
|
|
15
|
+
const requiredVersion = '14.0.0';
|
|
16
|
+
|
|
17
|
+
if (!nodeVersion.startsWith('v') ||
|
|
18
|
+
parseInt(nodeVersion.slice(1).split('.')[0]) < parseInt(requiredVersion.split('.')[0])) {
|
|
19
|
+
console.error(`Error: Node.js ${requiredVersion} or higher is required. You are using ${nodeVersion}.`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Load the main CLI application
|
|
24
|
+
require('./confluence.js');
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# GitHub Repository Topics
|
|
2
|
+
|
|
3
|
+
When setting up your GitHub repository, add these topics for better discoverability:
|
|
4
|
+
|
|
5
|
+
## Suggested Topics:
|
|
6
|
+
- `confluence`
|
|
7
|
+
- `atlassian`
|
|
8
|
+
- `cli`
|
|
9
|
+
- `command-line`
|
|
10
|
+
- `wiki`
|
|
11
|
+
- `documentation`
|
|
12
|
+
- `nodejs`
|
|
13
|
+
- `javascript`
|
|
14
|
+
- `api-client`
|
|
15
|
+
- `automation`
|
|
16
|
+
- `developer-tools`
|
|
17
|
+
- `productivity`
|
|
18
|
+
|
|
19
|
+
## How to add topics:
|
|
20
|
+
1. Go to https://github.com/pchuri/confluence-cli
|
|
21
|
+
2. Click the ⚙️ gear icon next to "About"
|
|
22
|
+
3. Add the topics above in the "Topics" field
|
|
23
|
+
4. Add a description: "A powerful command-line interface for Atlassian Confluence"
|
|
24
|
+
5. Add website: https://www.npmjs.com/package/confluence-cli
|
|
25
|
+
|
|
26
|
+
## Social Media Promotion Ideas:
|
|
27
|
+
|
|
28
|
+
### Twitter/X Posts:
|
|
29
|
+
```
|
|
30
|
+
🚀 Just released confluence-cli v1.0!
|
|
31
|
+
|
|
32
|
+
A powerful CLI tool for @Atlassian Confluence:
|
|
33
|
+
✅ Read pages from terminal
|
|
34
|
+
✅ Search documentation
|
|
35
|
+
✅ List spaces
|
|
36
|
+
✅ Works with environment variables
|
|
37
|
+
|
|
38
|
+
Perfect for automation & DevOps workflows!
|
|
39
|
+
|
|
40
|
+
#CLI #Confluence #DevTools #OpenSource
|
|
41
|
+
https://github.com/pchuri/confluence-cli
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### LinkedIn Post:
|
|
45
|
+
```
|
|
46
|
+
Excited to share my latest open-source project: confluence-cli! 🎉
|
|
47
|
+
|
|
48
|
+
As someone who works with Confluence daily, I built this CLI tool to streamline documentation workflows. Now you can:
|
|
49
|
+
|
|
50
|
+
• Read Confluence pages from your terminal
|
|
51
|
+
• Search across your wiki content
|
|
52
|
+
• Integrate with CI/CD pipelines
|
|
53
|
+
• Automate documentation tasks
|
|
54
|
+
|
|
55
|
+
Available on NPM and fully open-source. Would love your feedback!
|
|
56
|
+
|
|
57
|
+
#OpenSource #CLI #Confluence #DevTools #Automation
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Dev.to Article Ideas:
|
|
61
|
+
1. "Building a CLI Tool for Confluence: From Bash Functions to NPM Package"
|
|
62
|
+
2. "How to Automate Your Documentation Workflow with Confluence CLI"
|
|
63
|
+
3. "Open Source Journey: Lessons Learned Building confluence-cli"
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const util = require('util');
|
|
2
|
+
const js = require('@eslint/js');
|
|
3
|
+
const globals = require('globals');
|
|
4
|
+
|
|
5
|
+
if (typeof global.structuredClone !== 'function') {
|
|
6
|
+
global.structuredClone = typeof util.structuredClone === 'function'
|
|
7
|
+
? util.structuredClone
|
|
8
|
+
: (value) => JSON.parse(JSON.stringify(value));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = [
|
|
12
|
+
js.configs.recommended,
|
|
13
|
+
{
|
|
14
|
+
files: ['**/*.js'],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
ecmaVersion: 2021,
|
|
17
|
+
sourceType: 'module',
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.node,
|
|
20
|
+
...globals.jest
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
indent: ['error', 2],
|
|
25
|
+
'linebreak-style': ['error', 'unix'],
|
|
26
|
+
quotes: ['error', 'single'],
|
|
27
|
+
semi: ['error', 'always'],
|
|
28
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }],
|
|
29
|
+
'no-console': 'off',
|
|
30
|
+
'no-process-exit': 'off'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Confluence CLI - Copy Page Tree Example
|
|
4
|
+
# This script shows how to copy a page and all its descendants to a new location.
|
|
5
|
+
|
|
6
|
+
echo "📋 Confluence CLI - Copy Page Tree Example"
|
|
7
|
+
echo "=================================================="
|
|
8
|
+
|
|
9
|
+
# Prerequisites
|
|
10
|
+
echo ""
|
|
11
|
+
echo "📝 Prerequisites:"
|
|
12
|
+
echo "- confluence CLI is set up (confluence init)"
|
|
13
|
+
echo "- You have access to source and target locations"
|
|
14
|
+
echo "- You have permissions to create pages"
|
|
15
|
+
echo ""
|
|
16
|
+
|
|
17
|
+
# Step 1: Find the source page
|
|
18
|
+
echo "1️⃣ Find the source page"
|
|
19
|
+
echo "=============================="
|
|
20
|
+
echo ""
|
|
21
|
+
echo "Method 1: Find by title"
|
|
22
|
+
echo "confluence find \"Project Docs\" --space MYTEAM"
|
|
23
|
+
echo ""
|
|
24
|
+
echo "Method 2: Search"
|
|
25
|
+
echo "confluence search \"Project\""
|
|
26
|
+
echo ""
|
|
27
|
+
echo "📝 Note the source page ID from the output (e.g., 123456789)"
|
|
28
|
+
echo ""
|
|
29
|
+
|
|
30
|
+
# Step 2: Find the target parent page
|
|
31
|
+
echo "2️⃣ Find the target parent page"
|
|
32
|
+
echo "========================="
|
|
33
|
+
echo ""
|
|
34
|
+
echo "confluence find \"Backup\" --space BACKUP"
|
|
35
|
+
echo "or"
|
|
36
|
+
echo "confluence find \"Archive\" --space ARCHIVE"
|
|
37
|
+
echo ""
|
|
38
|
+
echo "📝 Note the target parent page ID (e.g., 987654321)"
|
|
39
|
+
echo ""
|
|
40
|
+
|
|
41
|
+
# Step 3: Run the copy
|
|
42
|
+
echo "3️⃣ Run copy"
|
|
43
|
+
echo "========================"
|
|
44
|
+
echo ""
|
|
45
|
+
|
|
46
|
+
echo "📄 Basic: copy with all children"
|
|
47
|
+
echo 'confluence copy-tree 123456789 987654321 "Project Docs (Backup)"'
|
|
48
|
+
echo ""
|
|
49
|
+
|
|
50
|
+
echo "📄 Depth-limited (3 levels)"
|
|
51
|
+
echo 'confluence copy-tree 123456789 987654321 "Project Docs (Summary)" --max-depth 3'
|
|
52
|
+
echo ""
|
|
53
|
+
|
|
54
|
+
echo "📄 Exclude patterns"
|
|
55
|
+
echo 'confluence copy-tree 123456789 987654321 "Project Docs (Clean)" --exclude "temp*,test*,*draft*"'
|
|
56
|
+
echo ""
|
|
57
|
+
|
|
58
|
+
echo "📄 Quiet mode"
|
|
59
|
+
echo 'confluence copy-tree 123456789 987654321 --quiet'
|
|
60
|
+
echo ""
|
|
61
|
+
|
|
62
|
+
echo "📄 Control pacing and naming"
|
|
63
|
+
echo 'confluence copy-tree 123456789 987654321 --delay-ms 150 --copy-suffix " (Backup)"'
|
|
64
|
+
echo ""
|
|
65
|
+
|
|
66
|
+
# Practical example
|
|
67
|
+
echo "💡 Practical example"
|
|
68
|
+
echo "================="
|
|
69
|
+
echo ""
|
|
70
|
+
echo "# 1. Capture source page ID"
|
|
71
|
+
echo 'SOURCE_ID=$(confluence find "Project Docs" --space MYTEAM | grep "ID:" | awk "{print \$2}")'
|
|
72
|
+
echo ""
|
|
73
|
+
echo "# 2. Capture target parent ID"
|
|
74
|
+
echo 'TARGET_ID=$(confluence find "Backup Folder" --space BACKUP | grep "ID:" | awk "{print \$2}")'
|
|
75
|
+
echo ""
|
|
76
|
+
echo "# 3. Run backup with date suffix"
|
|
77
|
+
echo 'confluence copy-tree $SOURCE_ID $TARGET_ID "Project Docs Backup - $(date +%Y%m%d)"'
|
|
78
|
+
echo ""
|
|
79
|
+
|
|
80
|
+
# Advanced usage
|
|
81
|
+
echo "🚀 Advanced"
|
|
82
|
+
echo "============="
|
|
83
|
+
echo ""
|
|
84
|
+
echo "1. Large trees with progress"
|
|
85
|
+
echo " confluence copy-tree 123456789 987654321 | tee copy-log.txt"
|
|
86
|
+
echo ""
|
|
87
|
+
echo "2. Multiple exclude patterns"
|
|
88
|
+
echo " confluence copy-tree 123456789 987654321 --exclude \"temp*,test*,*draft*,*temp*\""
|
|
89
|
+
echo ""
|
|
90
|
+
echo "3. Shallow copy (only direct children)"
|
|
91
|
+
echo " confluence copy-tree 123456789 987654321 --max-depth 1"
|
|
92
|
+
echo ""
|
|
93
|
+
|
|
94
|
+
# Notes and tips
|
|
95
|
+
echo "⚠️ Notes and tips"
|
|
96
|
+
echo "=================="
|
|
97
|
+
echo "- Large trees may take time to copy"
|
|
98
|
+
echo "- A short delay between siblings helps avoid rate limits (tune with --delay-ms)"
|
|
99
|
+
echo "- Partial copies can remain if errors occur"
|
|
100
|
+
echo "- Pages without permission are skipped; run with --fail-on-error to fail the run"
|
|
101
|
+
echo "- Validate links and references after copying"
|
|
102
|
+
echo "- Try with a small tree first"
|
|
103
|
+
echo ""
|
|
104
|
+
|
|
105
|
+
echo "📊 Verify results"
|
|
106
|
+
echo "================"
|
|
107
|
+
echo "After completion, you can check the results:"
|
|
108
|
+
echo ""
|
|
109
|
+
echo "# Root page info"
|
|
110
|
+
echo "confluence info [NEW_PAGE_ID]"
|
|
111
|
+
echo ""
|
|
112
|
+
echo "# Find copied pages"
|
|
113
|
+
echo "confluence search \"Copy\" --limit 20"
|
|
114
|
+
echo ""
|
|
115
|
+
|
|
116
|
+
echo "✅ Example complete!"
|
|
117
|
+
echo "Replace example IDs with real ones when running."
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
#!/bin/bash
|
|
4
|
+
|
|
5
|
+
# Create a test page under the Project Documentation page
|
|
6
|
+
# This script demonstrates typical Confluence CLI usage.
|
|
7
|
+
|
|
8
|
+
echo "🔍 Create a test page under Project Documentation"
|
|
9
|
+
echo "================================================"
|
|
10
|
+
|
|
11
|
+
# Step 1: Find the parent page
|
|
12
|
+
echo ""
|
|
13
|
+
echo "1️⃣ Find the parent page..."
|
|
14
|
+
echo "Run: confluence find \"Project Documentation\" --space MYTEAM"
|
|
15
|
+
echo ""
|
|
16
|
+
|
|
17
|
+
# For real execution, uncomment below
|
|
18
|
+
# confluence find "Project Documentation" --space MYTEAM
|
|
19
|
+
|
|
20
|
+
echo "📝 Note the page ID from the output (e.g., 123456789)"
|
|
21
|
+
echo ""
|
|
22
|
+
|
|
23
|
+
# Step 2: Inspect page info
|
|
24
|
+
echo "2️⃣ Inspect page info..."
|
|
25
|
+
echo "Run: confluence info [PAGE_ID]"
|
|
26
|
+
echo "Example: confluence info 123456789"
|
|
27
|
+
echo ""
|
|
28
|
+
|
|
29
|
+
# Step 3: Read page content (optional)
|
|
30
|
+
echo "3️⃣ Read content (optional)..."
|
|
31
|
+
echo "Run: confluence read [PAGE_ID] | head -20"
|
|
32
|
+
echo "Example: confluence read 123456789 | head -20"
|
|
33
|
+
echo ""
|
|
34
|
+
|
|
35
|
+
# Step 4: Create a child test page
|
|
36
|
+
echo "4️⃣ Create child test page..."
|
|
37
|
+
echo ""
|
|
38
|
+
|
|
39
|
+
# Simple text content
|
|
40
|
+
echo "📄 Option 1: Simple text content"
|
|
41
|
+
echo 'confluence create-child "Test Page - $(date +%Y%m%d)" [PARENT_PAGE_ID] --content "This is a test page created via CLI. Created at: $(date)"'
|
|
42
|
+
echo ""
|
|
43
|
+
|
|
44
|
+
# From Markdown file
|
|
45
|
+
echo "📄 Option 2: From Markdown file"
|
|
46
|
+
echo "confluence create-child \"Test Documentation - $(date +%Y%m%d)\" [PARENT_PAGE_ID] --file ./sample-page.md --format markdown"
|
|
47
|
+
echo ""
|
|
48
|
+
|
|
49
|
+
# From HTML content
|
|
50
|
+
echo "📄 Option 3: From HTML content"
|
|
51
|
+
echo 'confluence create-child "Test HTML Page" [PARENT_PAGE_ID] --content "<h1>Test Page</h1><p>This is a <strong>HTML</strong> example page.</p>" --format html'
|
|
52
|
+
echo ""
|
|
53
|
+
|
|
54
|
+
echo "💡 Practical example:"
|
|
55
|
+
echo "=============================="
|
|
56
|
+
echo "# 1. Get parent page ID"
|
|
57
|
+
echo 'PARENT_ID=$(confluence find "Project Documentation" --space MYTEAM | grep "ID:" | cut -d" " -f2)'
|
|
58
|
+
echo ""
|
|
59
|
+
echo "# 2. Create test page"
|
|
60
|
+
echo 'confluence create-child "Test Page - $(date +%Y%m%d_%H%M)" $PARENT_ID --content "Page for CLI testing."'
|
|
61
|
+
echo ""
|
|
62
|
+
|
|
63
|
+
echo "⚠️ Notes:"
|
|
64
|
+
echo "- confluence CLI must be set up (confluence init)"
|
|
65
|
+
echo "- You need appropriate permissions on the Confluence instance"
|
|
66
|
+
echo "- Ensure you have page creation permission"
|
|
67
|
+
echo "- Clean up test pages afterward"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Confluence CLI Demo Script
|
|
4
|
+
# This script demonstrates the new page creation and update features
|
|
5
|
+
|
|
6
|
+
echo "🚀 Confluence CLI - Page Creation Demo"
|
|
7
|
+
echo "======================================"
|
|
8
|
+
|
|
9
|
+
# Note: Replace with your actual space key and ensure you have confluence-cli configured
|
|
10
|
+
SPACE_KEY="MYTEAM" # Change this to your space key
|
|
11
|
+
|
|
12
|
+
echo ""
|
|
13
|
+
echo "1. Creating a page from Markdown file..."
|
|
14
|
+
echo "confluence create \"Sample Page from CLI\" $SPACE_KEY --file ./sample-page.md --format markdown"
|
|
15
|
+
|
|
16
|
+
echo ""
|
|
17
|
+
echo "2. Creating a page with inline content..."
|
|
18
|
+
echo "confluence create \"Quick Note\" $SPACE_KEY --content \"This is a quick note created from the CLI\" --format storage"
|
|
19
|
+
|
|
20
|
+
echo ""
|
|
21
|
+
echo "3. Updating a page (replace 123456789 with actual page ID)..."
|
|
22
|
+
echo "confluence update 123456789 --content \"This page has been updated via CLI\""
|
|
23
|
+
|
|
24
|
+
echo ""
|
|
25
|
+
echo "4. Getting page content for editing..."
|
|
26
|
+
echo "confluence edit 123456789 --output ./page-backup.xml"
|
|
27
|
+
|
|
28
|
+
echo ""
|
|
29
|
+
echo "5. Searching for pages..."
|
|
30
|
+
echo "confluence search \"CLI\""
|
|
31
|
+
|
|
32
|
+
echo ""
|
|
33
|
+
echo "6. Listing all spaces..."
|
|
34
|
+
echo "confluence spaces"
|
|
35
|
+
|
|
36
|
+
echo ""
|
|
37
|
+
echo "7. Finding a page by title..."
|
|
38
|
+
echo "confluence find \"Project Documentation\" --space MYTEAM"
|
|
39
|
+
|
|
40
|
+
echo ""
|
|
41
|
+
echo "8. Creating a child page under a parent page..."
|
|
42
|
+
echo "confluence create-child \"Test Page\" 123456789 --content \"This is a test page created as a child\""
|
|
43
|
+
|
|
44
|
+
echo ""
|
|
45
|
+
echo "9. Creating a child page from Markdown file..."
|
|
46
|
+
echo "confluence create-child \"Test Documentation\" 123456789 --file ./sample-page.md --format markdown"
|
|
47
|
+
|
|
48
|
+
echo ""
|
|
49
|
+
echo "💡 Tips:"
|
|
50
|
+
echo "- Use --format markdown to create pages from Markdown files"
|
|
51
|
+
echo "- Use --format html for HTML content"
|
|
52
|
+
echo "- Use --format storage for Confluence native format"
|
|
53
|
+
echo "- Always backup important pages before updating"
|
|
54
|
+
echo "- Use 'confluence find' to get page IDs by title"
|
|
55
|
+
echo "- Child pages inherit permissions from their parent"
|
|
56
|
+
|
|
57
|
+
echo ""
|
|
58
|
+
echo "📝 Edit workflow:"
|
|
59
|
+
echo "1. confluence edit [pageId] --output page.xml"
|
|
60
|
+
echo "2. Edit the file with your preferred editor"
|
|
61
|
+
echo "3. confluence update [pageId] --file page.xml --format storage"
|
|
62
|
+
|
|
63
|
+
echo ""
|
|
64
|
+
echo "🔍 Finding and creating child pages workflow:"
|
|
65
|
+
echo "1. confluence find \"Project Documentation\" --space MYTEAM"
|
|
66
|
+
echo "2. Note the page ID from the result"
|
|
67
|
+
echo "3. confluence create-child \"Meeting Notes\" [parentId] --content \"Child content\""
|
|
68
|
+
echo "4. Or use: confluence create-child \"Technical Docs\" [parentId] --file ./content.md --format markdown"
|
package/examples/demo.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Example script showing how to use confluence-cli
|
|
4
|
+
|
|
5
|
+
echo "🚀 Confluence CLI Examples"
|
|
6
|
+
echo "========================="
|
|
7
|
+
|
|
8
|
+
# Check if confluence command is available
|
|
9
|
+
if ! command -v confluence &> /dev/null; then
|
|
10
|
+
echo "❌ confluence command not found. Please install confluence-cli first:"
|
|
11
|
+
echo " npm install -g confluence-cli"
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
echo ""
|
|
16
|
+
echo "📋 Listing all spaces..."
|
|
17
|
+
confluence spaces
|
|
18
|
+
|
|
19
|
+
echo ""
|
|
20
|
+
echo "🔍 Searching for 'API' documentation..."
|
|
21
|
+
confluence search "API" --limit 5
|
|
22
|
+
|
|
23
|
+
echo ""
|
|
24
|
+
echo "ℹ️ Getting information about a specific page..."
|
|
25
|
+
# Replace this with an actual page ID from your Confluence
|
|
26
|
+
read -p "Enter a page ID to get info: " PAGE_ID
|
|
27
|
+
if [ ! -z "$PAGE_ID" ]; then
|
|
28
|
+
confluence info "$PAGE_ID"
|
|
29
|
+
|
|
30
|
+
echo ""
|
|
31
|
+
read -p "Do you want to read this page? (y/N): " READ_PAGE
|
|
32
|
+
if [ "$READ_PAGE" = "y" ] || [ "$READ_PAGE" = "Y" ]; then
|
|
33
|
+
echo ""
|
|
34
|
+
echo "📖 Reading page content..."
|
|
35
|
+
confluence read "$PAGE_ID" | head -20
|
|
36
|
+
echo ""
|
|
37
|
+
echo "(Showing first 20 lines only)"
|
|
38
|
+
fi
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
echo ""
|
|
42
|
+
echo "✅ Examples completed!"
|
|
43
|
+
echo "💡 Run 'confluence --help' for more commands"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Welcome to Confluence CLI
|
|
2
|
+
|
|
3
|
+
This is a sample page created using the **Confluence CLI** tool.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Easy page creation from Markdown files
|
|
8
|
+
- Support for multiple content formats
|
|
9
|
+
- Command-line interface for automation
|
|
10
|
+
|
|
11
|
+
## Code Example
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const client = new ConfluenceClient(config);
|
|
15
|
+
await client.createPage('My Page', 'SPACE', content, 'markdown');
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Lists
|
|
19
|
+
|
|
20
|
+
1. First item
|
|
21
|
+
2. Second item
|
|
22
|
+
3. Third item
|
|
23
|
+
|
|
24
|
+
- Bullet point one
|
|
25
|
+
- Bullet point two
|
|
26
|
+
- Bullet point three
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
*Created with ❤️ using confluence-cli*
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testEnvironment: 'node',
|
|
3
|
+
collectCoverageFrom: [
|
|
4
|
+
'lib/**/*.js',
|
|
5
|
+
'bin/**/*.js',
|
|
6
|
+
'!node_modules/**'
|
|
7
|
+
],
|
|
8
|
+
coverageDirectory: 'coverage',
|
|
9
|
+
coverageReporters: ['text', 'lcov', 'html'],
|
|
10
|
+
testMatch: [
|
|
11
|
+
'**/tests/**/*.test.js'
|
|
12
|
+
]
|
|
13
|
+
};
|
package/lib/analytics.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Simple anonymous usage analytics
|
|
7
|
+
* Helps understand which features are most used
|
|
8
|
+
*/
|
|
9
|
+
class Analytics {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.enabled = process.env.CONFLUENCE_CLI_ANALYTICS !== 'false';
|
|
12
|
+
this.configDir = path.join(os.homedir(), '.confluence-cli');
|
|
13
|
+
this.statsFile = path.join(this.configDir, 'stats.json');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Track command usage (anonymous)
|
|
18
|
+
*/
|
|
19
|
+
track(command, success = true) {
|
|
20
|
+
if (!this.enabled) return;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
let stats = {};
|
|
24
|
+
|
|
25
|
+
// Read existing stats
|
|
26
|
+
if (fs.existsSync(this.statsFile)) {
|
|
27
|
+
stats = JSON.parse(fs.readFileSync(this.statsFile, 'utf8'));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Initialize stats structure
|
|
31
|
+
if (!stats.commands) stats.commands = {};
|
|
32
|
+
if (!stats.firstUsed) stats.firstUsed = new Date().toISOString();
|
|
33
|
+
stats.lastUsed = new Date().toISOString();
|
|
34
|
+
|
|
35
|
+
// Track command usage
|
|
36
|
+
const commandKey = `${command}_${success ? 'success' : 'error'}`;
|
|
37
|
+
stats.commands[commandKey] = (stats.commands[commandKey] || 0) + 1;
|
|
38
|
+
|
|
39
|
+
// Create directory if it doesn't exist
|
|
40
|
+
if (!fs.existsSync(this.configDir)) {
|
|
41
|
+
fs.mkdirSync(this.configDir, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Save stats
|
|
45
|
+
fs.writeFileSync(this.statsFile, JSON.stringify(stats, null, 2));
|
|
46
|
+
} catch (error) {
|
|
47
|
+
// Silently fail - analytics should never break the main functionality
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get usage statistics
|
|
53
|
+
*/
|
|
54
|
+
getStats() {
|
|
55
|
+
if (!fs.existsSync(this.statsFile)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(fs.readFileSync(this.statsFile, 'utf8'));
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Show usage stats to user
|
|
68
|
+
*/
|
|
69
|
+
showStats() {
|
|
70
|
+
const stats = this.getStats();
|
|
71
|
+
if (!stats) {
|
|
72
|
+
console.log('No usage statistics available.');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
console.log('📊 Usage Statistics:');
|
|
77
|
+
console.log(`First used: ${new Date(stats.firstUsed).toLocaleDateString()}`);
|
|
78
|
+
console.log(`Last used: ${new Date(stats.lastUsed).toLocaleDateString()}`);
|
|
79
|
+
console.log('\nCommand usage:');
|
|
80
|
+
|
|
81
|
+
Object.entries(stats.commands).forEach(([command, count]) => {
|
|
82
|
+
console.log(` ${command}: ${count} times`);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = Analytics;
|