packages/common/scripts/README.md
Common Package Scripts
This directory contains build pipeline scripts for the common package.
Common Package Scripts
This directory contains build pipeline scripts for the common package.
Early Access Features Sync
The sync-early-access-features.ts script is a self-contained tool that synchronizes declared early access features with PostHog's API.
💡 Note: This script is primarily used by CI/CD pipelines. You typically don't need to run it manually!
📖 For comprehensive documentation, see docs/early-access-features.md
Usage
- Set the required environment variables:
export POSTHOG_PROJECT_ID="your-posthog-project-id"
export POSTHOG_API_KEY="your-posthog-api-key"
export POSTHOG_API_HOST="https://eu.posthog.com" # Optional, defaults to EU instance
- Run the sync script:
# Check if features are in sync
pnpm sync-early-access-features --check
# Dry run (show what would change)
pnpm sync-early-access-features --dry-run
# Sync features
pnpm sync-early-access-features
# Sync and delete untracked features
pnpm sync-early-access-features --delete-untracked
Options
--dry-run: Show what would be changed without making changes--delete-untracked: Delete features in PostHog that aren't declared--check: Only check if features are in sync (exit code 0 if in sync, 1 if not)--help: Show help message
How it works
- The script reads the declared features from
src/early_access_features.ts - Fetches current early access features from PostHog via API
- Compares and syncs differences:
- Creates new features declared but missing in PostHog
- Updates existing features with different metadata
- Optionally deletes features in PostHog not declared locally
CI/CD Integration (Primary Use Case)
This script is primarily designed for CI/CD automation. Environment variables should be configured in your CI system:
# CI/CD Environment Variables
POSTHOG_PROJECT_ID="your-project-id"
POSTHOG_API_KEY="your-api-key"
POSTHOG_API_HOST="https://eu.posthog.com" # Optional, defaults to EU instance
# Typical CI/CD pipeline usage:
pnpm sync-early-access-features --check # Validate in PRs
pnpm sync-early-access-features # Auto-sync on merge to main
Developers typically don't run these commands manually - CI handles everything automatically when you merge changes.