0.0.1 • Published 9 months ago

@jfconley/confluence-downloader v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Confluence Downloader

A powerful CLI tool to download and sync Confluence spaces to local markdown files, maintaining the original page hierarchy and metadata.

Features

  • šŸš€ Interactive CLI for easy space management
  • šŸ“ Maintains Confluence page hierarchy in local directory structure
  • šŸ”„ Incremental sync with last update tracking
  • šŸ·ļø Preserves page metadata, labels, and comments
  • šŸ“ Converts Confluence content to clean markdown
  • 🌳 Directory-based structure for pages with children
  • ⚔ Concurrent processing for faster downloads
  • šŸ” Fuzzy search for space selection
  • šŸŽØ Beautiful progress bars and status updates

Installation

# Using npm
npm install -g @jfconley/confluence-downloader

# Using pnpm
pnpm add -g @jfconley/confluence-downloader

# Using yarn
yarn global add @jfconley/confluence-downloader

Quick Start

  1. Create a .env file with your Confluence credentials:
CONFLUENCE_BASE=https://your-domain.atlassian.net
CONFLUENCE_TOKEN=your-api-token
CONFLUENCE_EMAIL=your-email@domain.com
CONFLUENCE_CONFIG=./confluence.json
  1. Initialize the library:
confluence-downloader init
  1. Start the interactive mode:
confluence-downloader interactive

Usage

Interactive Mode

The easiest way to use the tool is through interactive mode:

confluence-downloader interactive -t <token> -b <base-url> -c <config-path>

This provides a menu-driven interface with the following options:

  • List spaces
  • Add space
  • Remove space
  • Sync space
  • Sync all spaces
  • Show configuration
  • Exit

Command Line Interface

# Initialize a new library
confluence-downloader init --baseUrl <url> --apiToken <token>

# Add a space
confluence-downloader add-space --spaceKey <key> [--localPath <path>]

# Remove a space
confluence-downloader remove-space --spaceKey <key>

# List configured spaces
confluence-downloader list-spaces

# Sync a specific space
confluence-downloader sync --spaceKey <key>

# Sync all configured spaces
confluence-downloader sync

# Show configuration
confluence-downloader show

Legacy Single Space Sync

For one-off space downloads without library management:

confluence-downloader sync-space \
  --baseUrl <url> \
  --apiToken <token> \
  --spaceKey <key> \
  --outputDir <dir> \
  --email <email>

Configuration

Environment Variables

VariableDescription
CONFLUENCE_BASEBase URL of your Confluence instance
CONFLUENCE_TOKENConfluence API token
CONFLUENCE_EMAILYour Confluence account email
CONFLUENCE_CONFIGPath to configuration file
CONFLUENCE_OUTPUT_DIRDefault output directory for spaces

Configuration Files

The tool maintains two types of configuration files:

  1. confluence.json (Library configuration):
{
  "baseUrl": "https://your-domain.atlassian.net",
  "spaces": [
    {
      "spaceKey": "SPACE",
      "localPath": "space-docs",
      "lastSync": "2024-01-22T12:00:00.000Z"
    }
  ]
}
  1. space.json (Space metadata, one per space):
{
  "key": "SPACE",
  "name": "Space Name",
  "description": "Space description",
  "lastSynced": "2024-01-22T12:00:00.000Z"
}

Output Structure

The tool creates a clean, hierarchical directory structure:

output-dir/
ā”œā”€ā”€ space-1/
│   ā”œā”€ā”€ space.json
│   ā”œā”€ā”€ Page 1.md
│   └── Directory Page/
│       ā”œā”€ā”€ description.md
│       ā”œā”€ā”€ Child Page 1.md
│       └── Child Page 2.md
└── space-2/
    ā”œā”€ā”€ space.json
    └── ...

Pages with children are saved as description.md inside their respective directories.

Markdown Format

Each markdown file includes:

  • YAML frontmatter with metadata
  • Original Confluence content
  • Comments section (if any)

Example:

---
title: Page Title
labels:
  - label1
  - label2
author: John Doe
lastUpdated: 2024-01-22T12:00:00.000Z
confluence:
  id: 123456
  version: 5
  space: SPACE
---

# Page Title

Page content in markdown format...

---

## Comments

### Jane Smith (Jan 20, 2024)
Comment content in markdown format...

Requirements

  • Node.js >= 18.0.0
  • A valid Confluence API token
  • Confluence Cloud instance

License

MIT