1.0.0 • Published 5 months ago
hubdb-copier v1.0.0
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
- Create a
.env
file in your working directory:
HUBSPOT_SOURCE_TOKEN=pat-na1-xxxx
HUBSPOT_TARGET_TOKEN=pat-na1-yyyy
- 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
- Validates both source and target API tokens
- Fetches all tables from the source portal
- Displays an interactive menu to select tables for copying
- 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
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env # Edit .env with your tokens
- Build the project:
npm run build
- Run in development mode:
npm run dev
License
MIT
1.0.0
5 months ago