1.0.0 • Published 5 months ago

hubdb-copier v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

HubDB Copier

A command-line tool to copy HubDB tables between HubSpot portals.

Features

  • Copy multiple HubDB tables between HubSpot portals
  • Interactive table selection interface
  • Preserves table schema and data
  • Progress indicators for long operations
  • Error handling and validation
  • Support for environment variables

Installation

npm install -g hubdb-copier

Usage

You can provide HubSpot API tokens either through command-line arguments or environment variables.

Using Command Line Arguments

hubdb-copier -s SOURCE_TOKEN -t TARGET_TOKEN

Using Environment Variables

  1. Create a .env file in your working directory:
HUBSPOT_SOURCE_TOKEN=pat-na1-xxxx
HUBSPOT_TARGET_TOKEN=pat-na1-yyyy
  1. Run the command without arguments:
hubdb-copier

Options

  • -s, --source-token <token>: Source HubSpot API token (optional if set in .env)
  • -t, --target-token <token>: Target HubSpot API token (optional if set in .env)
  • -V, --version: Output the version number
  • -h, --help: Display help information

Example

Using command line:

hubdb-copier -s pat-na1-xxxx -t pat-na1-yyyy

Using environment variables:

# Set up environment variables
cp .env.example .env
# Edit .env with your tokens
vim .env
# Run the tool
hubdb-copier

How it works

  1. Validates both source and target API tokens
  2. Fetches all tables from the source portal
  3. Displays an interactive menu to select tables for copying
  4. For each selected table:
    • Creates a new table with identical schema in the target portal
    • Exports data from the source table
    • Imports data into the target table
    • Publishes the table in the target portal

Requirements

  • Node.js 14 or higher
  • Valid HubSpot API tokens for both source and target portals

Development

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Set up environment variables:
    cp .env.example .env
    # Edit .env with your tokens
  4. Build the project:
    npm run build
  5. Run in development mode:
    npm run dev

License

MIT