> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tagada.io/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Quick Start

> Get up and running with the TagadaPay CLI in minutes

# CLI Quick Start

Deploy your plugin to TagadaPay in 5 minutes.

## Prerequisites

* **Node.js 18+** ([Download](https://nodejs.org/))
* A TagadaPay account with access to a store
* Your plugin built (`dist/` directory with `index.html`)

## Install & Login

<Steps>
  <Step title="Install the CLI">
    ```bash theme={null}
    npm install -g @tagadapay/plugin-cli
    ```

    Verify:

    ```bash theme={null}
    tgd --version
    ```
  </Step>

  <Step title="Login">
    ```bash theme={null}
    tgd login
    ```

    This opens your browser for authentication. Once complete:

    ```
    ✅ Successfully logged in
    ```
  </Step>
</Steps>

## Deploy Your Plugin

### Option 1: Interactive (Recommended)

```bash theme={null}
tgd interactive
```

Select **"Deploy Plugin"**, then follow the wizard:

1. Pick a store from the list
2. Select a config variant (or skip)
3. Confirm and deploy
4. Get your deployment ID

### Option 2: Direct Command

```bash theme={null}
cd my-plugin
tgd deploy --store store_abc123
```

The CLI will:

1. Validate `plugin.manifest.json`
2. ZIP your `dist/` folder + manifest
3. Upload to blob storage
4. Deploy via API
5. Return the deployment ID

## Plugin Structure

Your plugin directory should look like this:

```
my-plugin/
├── plugin.manifest.json    # Required
├── dist/                   # Required (built files)
│   ├── index.html
│   └── assets/
│       ├── index.js
│       └── style.css
└── config/                 # Optional (presets, schema)
    ├── default.preset.json
    └── schema.json
```

### Create plugin.manifest.json

<Warning>
  All fields below are **required** by the CLI validator. Missing any will fail deployment.
</Warning>

```json theme={null}
{
  "pluginId": "my-first-plugin",
  "name": "My First Plugin",
  "version": "1.0.0",
  "description": "My first TagadaPay plugin",
  "author": "Your Name",
  "category": "checkout",
  "pages": [
    {
      "path": "/",
      "features": ["landing"],
      "remappable": false
    },
    {
      "path": "/checkout",
      "features": [
        {
          "type": "checkout",
          "requirements": ["payment"]
        }
      ],
      "remappable": true
    },
    {
      "path": "/thankyou/:orderId",
      "features": [{ "type": "thankyou" }],
      "remappable": true
    }
  ],
  "router": {
    "basePath": "/",
    "matcher": ".*",
    "excluder": null
  },
  "requirements": {
    "sdk": "@tagadapay/plugin-sdk",
    "sdkVersion": "v2"
  }
}
```

### Build

```bash theme={null}
npm run build
ls dist/   # Should contain index.html
```

## Step-by-Step Walkthrough

### 1. Verify Everything

```bash theme={null}
ls plugin.manifest.json   # Must exist
ls dist/index.html         # Must exist
cat plugin.manifest.json | python3 -m json.tool  # Must be valid JSON
```

### 2. Deploy

<Tabs>
  <Tab title="Interactive">
    ```bash theme={null}
    tgd interactive
    ```

    1. Select **Deploy Plugin**
    2. Choose your store
    3. Optionally pick a config from `config/` directory
    4. Confirm and deploy
  </Tab>

  <Tab title="Command Line">
    ```bash theme={null}
    tgd deploy --store store_abc123
    ```

    Output:

    ```
    📄 Reading plugin manifest from: plugin.manifest.json
    ✅ Manifest validation passed
    🚀 Deploying plugin: My First Plugin (my-first-plugin)
    📊 Version: 1.0.0
    📦 Creating deployment archive...
    ✓ Archive created: 0.45 MB
    ☁️  Uploading to blob storage...
    ✓ Uploaded
    🚀 Deploying via API...

    ✅ Deployment successful!
    ────────────────────────────────────────────────────────────
      Plugin ID:     my-first-plugin
      Version:       1.0.0
      Deployment ID: mlw1234abcdef
    ────────────────────────────────────────────────────────────
    ```
  </Tab>
</Tabs>

### 3. Install & Mount

After deploying, create an instance and mount it:

```bash theme={null}
tgd install --store store_abc123
# Select your deployment, configure if needed

tgd mount-alias --store store_abc123
# Select the instance, choose an alias path
```

Your plugin is now live.

### 4. Verify

```bash theme={null}
tgd list --store store_abc123
tgd list-instances --store store_abc123
tgd list-mounts --store store_abc123
```

## Common Workflows

### Update a Plugin

```bash theme={null}
# 1. Bump version in plugin.manifest.json
# 2. Rebuild
npm run build

# 3. Deploy new version
tgd deploy --store store_abc123

# Or overwrite same version
tgd deploy --store store_abc123 --overwrite
```

### Deploy to Multiple Environments

```bash theme={null}
tgd deploy --store store_dev --dev
tgd deploy --store store_staging --dev
tgd deploy --store store_prod --prod
```

### Add a Custom Domain

```bash theme={null}
tgd add-domain checkout.mystore.com
# Add the CNAME record shown in the output, then:
tgd verify-domain cdm_abc123
```

## Quick Reference

```bash theme={null}
# Auth
tgd login                          # Login (production)
tgd login --dev                    # Login (development)
tgd logout                         # Logout
tgd whoami                         # Check auth status

# Deploy
tgd deploy                         # Interactive store selection
tgd deploy -s store_123            # Direct deploy
tgd deploy -s store_123 --overwrite # Replace existing

# Manage
tgd list -s store_123              # List deployments
tgd install -s store_123           # Create instance
tgd mount-alias -s store_123       # Mount instance
tgd list-instances -s store_123    # List instances
tgd list-mounts -s store_123       # List mount points

# Domains
tgd list-domains                   # List all domains
tgd add-domain my.domain.com       # Add domain

# Interactive (all-in-one)
tgd interactive                    # Menu-driven interface
```

## What's Next?

<CardGroup cols={2}>
  <Card title="Full CLI Reference" icon="terminal" href="/developer-tools/cli/introduction">
    All commands and flags
  </Card>

  <Card title="CLI Configuration" icon="settings" href="/developer-tools/cli/configuration">
    Manifest, config variants, environments
  </Card>

  <Card title="Plugin SDK" icon="puzzle-piece" href="/developer-tools/sdk/introduction">
    Build interactive plugins with React
  </Card>

  <Card title="Hosting & A/B Testing" icon="flask-vial" href="/developer-tools/hosting/deploy-and-ab-test">
    Host pages and set up A/B tests
  </Card>
</CardGroup>
