{"_id":"@dave_robinson/mailchimp-config-sync","name":"@dave_robinson/mailchimp-config-sync","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dave_robinson/mailchimp-config-sync","version":"1.0.0","description":"Utility to copy config ( merge fields) between mailchimp audiences","license":"MIT","author":{"name":"Dave Robinson"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/DaveRobinson/mailchimp-config-sync.git"},"bugs":{"url":"https://github.com/DaveRobinson/mailchimp-config-sync/issues"},"homepage":"https://github.com/DaveRobinson/mailchimp-config-sync#readme","keywords":["mailchimp","audience","merge-fields","cli","sync","marketing","automation","config"],"engines":{"node":">=20.0.0"},"type":"module","main":"dist/index.js","bin":{"mailchimp-config-sync":"dist/index.js"},"scripts":{"build":"tsc","dev":"tsc --watch","prepare":"npm run build","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage"},"devDependencies":{"@types/mailchimp__mailchimp_marketing":"^3.0.22","@types/node":"^25.0.3","@types/prompts":"^2.4.9","@vitest/coverage-v8":"^4.0.16","typescript":"^5.9.3","vitest":"^4.0.16"},"dependencies":{"@mailchimp/mailchimp_marketing":"^3.0.80","commander":"^14.0.2","prompts":"^2.4.2"},"gitHead":"44efa0dadf4e261901a39aa0df8a5eb37e54ac3c","types":"./dist/index.d.ts","_id":"@dave_robinson/mailchimp-config-sync@1.0.0","_nodeVersion":"25.2.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-9NELlNfIraKti6z64knckDd3G1oa7Wbv2P+OF7RZ6y1itgZ5jSkWVRNL/uNIzlgWZJhawG/SqmOFH7WE6udsaw==","shasum":"1ab39a5624d71b964e26135ce874a06da35bdcd8","tarball":"https://registry.npmjs.org/@dave_robinson/mailchimp-config-sync/-/mailchimp-config-sync-1.0.0.tgz","fileCount":27,"unpackedSize":43111,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCRPj7NLGPnAEkBBWtbtkIIt7dO+O5uoXmkzvwsAQkZNwIgBlk1+OS3xnJZvtTJun+zDRJIrXazIsLjy8UgP/dH7Co="}]},"_npmUser":{"name":"dave_robinson","email":"dave.robinson.personal@googlemail.com"},"directories":{},"maintainers":[{"name":"dave_robinson","email":"dave.robinson.personal@googlemail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mailchimp-config-sync_1.0.0_1768318558318_0.9383306304987913"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-13T15:35:58.200Z","1.0.0":"2026-01-13T15:35:58.488Z","modified":"2026-01-13T15:35:58.786Z"},"maintainers":[{"name":"dave_robinson","email":"dave.robinson.personal@googlemail.com"}],"description":"Utility to copy config ( merge fields) between mailchimp audiences","homepage":"https://github.com/DaveRobinson/mailchimp-config-sync#readme","keywords":["mailchimp","audience","merge-fields","cli","sync","marketing","automation","config"],"repository":{"type":"git","url":"git+https://github.com/DaveRobinson/mailchimp-config-sync.git"},"author":{"name":"Dave Robinson"},"bugs":{"url":"https://github.com/DaveRobinson/mailchimp-config-sync/issues"},"license":"MIT","readme":"# Mailchimp Config Sync\n\nA zero-config CLI tool for syncing configuration between Mailchimp audiences. Currently supports copying merge fields with an interactive selection interface.\n\n## Features\n\n- **Zero Configuration**: No config files needed - just your API key\n- **Interactive Audience Selection**: Browse and select audiences from a visual menu with member counts\n- **Interactive Field Selection**: Choose which merge fields to copy with multi-select\n- **Smart Comparison**: Automatically identifies which fields already exist in the target\n- **Pagination Support**: Handles audiences with large numbers of merge fields\n- **Type Safe**: Built with TypeScript for reliability\n- **No Live API Required for Tests**: Comprehensive test suite with mocked API calls\n\n## Quick Start\n\n### Run with npx (Recommended)\n\nNo installation needed! Run directly from GitHub:\n\n```bash\nnpx github:DaveRobinson/mailchimp-config-sync merge-fields\n```\n\n### Local Development\n\nClone and build from source:\n\n```bash\ngit clone https://github.com/DaveRobinson/mailchimp-config-sync\ncd mailchimp-config-sync\nnpm install\nnpm run build\n\n# Run locally\nnode dist/index.js merge-fields\n```\n\n## Usage\n\n### Basic Usage\n\nRun the CLI and follow the interactive prompts:\n\n```bash\nnpx github:DaveRobinson/mailchimp-config-sync merge-fields\n```\n\nYou'll be prompted for:\n1. Your Mailchimp API key (hidden input)\n2. Source audience (select from list)\n3. Target audience (select from list)\n4. Which merge fields to copy (multi-select)\n\n### With API Key Parameter\n\nPass your API key directly to skip the prompt:\n\n```bash\nnpx github:DaveRobinson/mailchimp-config-sync merge-fields --api-key YOUR_API_KEY-us10\n```\n\nOr using the short form:\n\n```bash\nnpx github:DaveRobinson/mailchimp-config-sync merge-fields -k YOUR_API_KEY-us10\n```\n\n### Example Session\n\n```bash\n$ npx github:DaveRobinson/mailchimp-config-sync merge-fields\n\n? Enter your Mailchimp API key: ••••••••••••••••••••••••••\n\nFetching audiences...\nFound 3 audiences\n\n? Select source audience:\n  ❯ My Newsletter (1,234 members) - abc123\n    Product Updates (567 members) - def456\n    Beta Testers (89 members) - ghi789\n\n? Select target audience:\n  ❯ Product Updates (567 members) - def456\n    Beta Testers (89 members) - ghi789\n\nSource: My Newsletter (abc123def)\nTarget: Product Updates (def456ghi)\n\nFetching merge fields...\n\nMerge fields status:\n  ✓ Already exists: FNAME (First Name) - text\n  ✓ Already exists: LNAME (Last Name) - text\n  ○ Available to copy: PHONE (Phone Number) - phone\n  ○ Available to copy: BIRTHDAY (Birthday) - birthday\n  ○ Available to copy: COMPANY (Company) - text\n\n? Select merge fields to copy: (Space to select, Enter to confirm)\n  ◉ PHONE - Phone Number (phone)\n  ◯ BIRTHDAY - Birthday (birthday)\n  ◉ COMPANY - Company (text)\n\nCopying 2 merge field(s)...\n✓ Created merge field: PHONE (Phone Number)\n✓ Created merge field: COMPANY (Company)\n\n✓ Successfully copied 2 merge field(s)\n```\n\n## Getting Your Mailchimp API Key\n\n1. Log in to your Mailchimp account\n2. Go to **Account > Extras > API Keys**\n3. Create a new API key or use an existing one\n4. Your API key format will be: `key-datacenter` (e.g., `abc123xyz-us10`)\n\nThe datacenter (the part after the dash) is automatically extracted from your API key.\n\n**Note**: This tool works with multiple audiences within the same Mailchimp account. Audiences are automatically fetched and displayed for selection - no need to manually look up IDs!\n\n## Development\n\n### Setup\n\n```bash\nnpm install\n```\n\n### Build\n\n```bash\nnpm run build\n```\n\n### Watch Mode\n\nAuto-rebuild on changes:\n\n```bash\nnpm run dev\n```\n\n### Project Structure\n\n```\nsrc/\n├── index.ts              # CLI entry point with Commander\n├── lists.ts              # Audience/list fetching and selection\n├── mailchimp-client.ts   # Mailchimp API client wrapper\n├── merge-fields.ts       # Merge field operations\n└── types.ts              # TypeScript type extensions\n\ntest/\n├── mocks/\n│   └── mailchimp.ts      # Mock factories for testing\n├── lists.test.ts\n├── mailchimp-client.test.ts\n└── merge-fields.test.ts\n```\n\n## Testing\n\nTests use **vitest** with comprehensive mocking - no live API key required.\n\n### Run Tests\n\n```bash\n# Run tests once\nnpm test\n\n# Watch mode\nnpm run test:watch\n\n# With coverage report\nnpm run test:coverage\n```\n\n### Test Coverage\n\nCurrent coverage: **97.56%**\n\n- 28 tests across 3 test suites\n- All merge field and list operations tested\n- Pagination, error handling, and edge cases covered\n- Interactive selection flow fully tested\n\n## API\n\n### Merge Fields Operations\n\nThe tool automatically handles:\n\n- **Pagination**: Fetches all merge fields regardless of count\n- **Filtering**: Excludes the default EMAIL field from copy operations\n- **Error Handling**: Continues copying even if some fields fail\n- **Validation**: Prevents duplicate fields in the target audience\n\n### Supported Merge Field Types\n\nAll Mailchimp merge field types are supported:\n- text\n- number\n- address\n- phone\n- date\n- url\n- imageurl\n- radio\n- dropdown\n- birthday\n- zip\n\n## Limitations\n\n- Currently only supports merge fields (not other audience settings)\n- Does not copy field values, only field definitions\n- Designed for copying between audiences in the same Mailchimp account\n- Field comparison is based on tag names - use custom tag names for all merge fields\n\n## Troubleshooting\n\n### Invalid API Key Format\n\n```\nError: Invalid API key format. Expected format: key-server\n```\n\nMake sure your API key includes the datacenter suffix (e.g., `-us10`).\n\n### Field Already Exists\n\nIf a field with the same tag already exists in the target audience, it will be marked as \"Already exists\" and skipped from the selection list.\n\n## License\n\nMIT\n\n## Contributing\n\nContributions welcome! Please ensure tests pass before submitting PRs:\n\n```bash\nnpm test\nnpm run build\n```\n","readmeFilename":"README.md","_rev":"1-9edf501c2053b28c28b312c6a828d8ca"}