ReAPI CLI Sync

Deploy directly to ReAPI’s CDN without publishing to npm.

Benefits

  • Private: No public npm package required
  • Simple: One command to deploy
  • Automatic: URL generated automatically
  • Fast: Skip npm publish process

Installation

npm install -g @reapi/cli
 
# Or use npx
npx @reapi/cli

Authentication

# Login to ReAPI
reapi login
 
# Or use API key
export REAPI_API_KEY=your-api-key

Deploy

# Build first
npm run build
 
# Sync to ReAPI
reapi lib sync --project <project-id>

Options

reapi lib sync \
  --project <project-id> \      # Required: Target project
  --name "My Test Library" \    # Library display name
  --lib-name MyTestLib \        # Global variable name
  --file dist/build.umd.js \    # Bundle file (default: dist/build.umd.js)
  --types dist/build.d.ts       # Types file (default: dist/build.d.ts)

Output

$ reapi lib sync --project proj_123
 
 Building library...
 Uploading bundle (125 KB)
 Uploading types (4 KB)
 Syncing components...
 
Library deployed successfully!
 
URL: https://libs.reapi.com/proj_123/my-test-lib@1.0.0/bundle.js
Types: https://libs.reapi.com/proj_123/my-test-lib@1.0.0/types.d.ts
 
Components synced:
  - 5 assertions
  - 3 value generators
  - 2 API hooks
  - 8 test cases

package.json Script

Add to your package.json:

{
  "scripts": {
    "deploy": "npm run build && reapi lib sync --project $REAPI_PROJECT_ID",
    "deploy:staging": "npm run build && reapi lib sync --project proj_staging",
    "deploy:prod": "npm run build && reapi lib sync --project proj_prod"
  }
}

Then:

npm run deploy

CI/CD Integration

GitHub Actions

name: Deploy to ReAPI
 
on:
  push:
    branches: [main]
 
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "20"
      
      - run: npm ci
      - run: npm test
      - run: npm run build
      
      - name: Deploy to ReAPI
        env:
          REAPI_API_KEY: ${{ secrets.REAPI_API_KEY }}
        run: npx @reapi/cli lib sync --project ${{ vars.REAPI_PROJECT_ID }}

GitLab CI

deploy:
  stage: deploy
  script:
    - npm ci
    - npm run build
    - npx @reapi/cli lib sync --project $REAPI_PROJECT_ID
  variables:
    REAPI_API_KEY: $REAPI_API_KEY
  only:
    - main

Versioning

The CLI auto-increments versions:

# First deploy
reapi lib sync  # -> 1.0.0
 
# Next deploy
reapi lib sync  # -> 1.0.1
 
# Force specific version
reapi lib sync --version 2.0.0

Multiple Projects

Deploy to different projects:

# Staging
reapi lib sync --project proj_staging
 
# Production
reapi lib sync --project proj_production

Comparing to npm

Aspectnpm + CDNReAPI CLI
Public visibilityYesNo
npm account neededYesNo
Version managementManualAutomatic
Deploy commandnpm publishreapi lib sync
URL formatunpkg.com/…libs.reapi.com/…
Cache controlCDN managesReAPI manages