# checkout-extension

> Shoplazza CLI checkout-extension commands to scaffold, develop, build, push, deploy, and preview a Shoplazza checkout extension from the terminal.

Build, develop and manage Shoplazza checkout extensions. Alias: `checkout`.

`build`, `dev` and `push` run the bundled Vite toolchain through Node.js, which must be version 14.18.0 or later and on your `PATH`. If the project has no `node_modules` yet, the first run installs its npm dependencies (`npm install`) for you.

In a terminal, commands ask for required flags you leave off instead of failing; `deploy`, `preview`, `undeploy` and `versions` let you pick the extension (and its version) from a list fetched from the store. With `--no-input`, in CI, or when stdin or stderr is not a terminal, nothing is asked and a missing flag fails fast.

## init

Scaffold a new checkout extension project (local, no network).

```shell
shoplazza checkout-extension init --name <project> --extension <first-extension>
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--name` | string | Project name (directory created in cwd) |
| `--extension` | string | First extension name |

### Examples

```shell
shoplazza checkout init --name my-project --extension my-ext
```

## create

Create a new extension in an existing project (local, no network). Must be run inside a project created by `init`.

```shell
shoplazza checkout-extension create --name <extension>
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--name` | string | Extension name |

### Examples

```shell
shoplazza checkout create --name another-ext
```

## dev

Run the checkout extension dev server (rebuild + HMR on :8888).

```shell
shoplazza checkout-extension dev [flags]
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--extension-name` | stringSlice | Extension name(s) to develop (repeatable, comma-separated) |
| `--all` | bool | Develop all extensions under ./extensions |

### Examples

```shell
# Develop a single extension
shoplazza checkout dev --extension-name my-ext

# Develop multiple extensions
shoplazza checkout dev --extension-name ext1,ext2

# Develop all extensions
shoplazza checkout dev --all
```

## build

Build a checkout extension with the bundled Vite toolchain.

```shell
shoplazza checkout-extension build [flags]
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--name` | string | Extension name (the directory under ./extensions); optional inside an extension dir |
| `--debug` | bool | Verbose build logs to stderr |

### Examples

```shell
# Build from the project root
shoplazza checkout build --name my-ext

# Build from inside the extension directory
cd extensions/my-ext && shoplazza checkout build
```

## push

Build and upload a new extension version (does NOT activate it). Use `deploy` to activate afterward.

```shell
shoplazza checkout-extension push --name <extension> [flags]
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--name` | string | Extension name (the directory under ./extensions) — **required** |
| `--version` | string | Optional. Write this version into extension.json before pushing (must be greater than the last pushed version) |
| `--debug` | bool | Verbose build logs to stderr |

### Examples

```shell
shoplazza checkout push --name my-ext
shoplazza checkout push --name my-ext --version 1.1
```

## deploy

Activate a previously pushed extension version on the current store. In a terminal, you are asked to confirm before the version replaces the live checkout extension; non-interactive runs and `--dry-run` skip the confirmation.

```shell
shoplazza checkout-extension deploy --extension-id <id> --version <version>
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--extension-id` | string | Server-side extension id |
| `--version` | string | Version to activate, e.g. 1.0 (resolved to its server id via `checkout versions`) |
| `--dry-run` | bool | Print the request that would be sent without executing it |

### Examples

```shell
shoplazza checkout deploy --extension-id abc123 --version 1.0
```

## undeploy

Undeploy an extension on the current store (extension-level; it stops serving immediately). In a terminal, you are asked to confirm first; non-interactive runs and `--dry-run` skip the confirmation.

```shell
shoplazza checkout-extension undeploy --extension-id <id>
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--extension-id` | string | Server-side extension id — **required** |
| `--dry-run` | bool | Print the request that would be sent without executing it |

### Examples

```shell
shoplazza checkout undeploy --extension-id abc123
```

## list

List the current store's checkout extensions. By default shows only published extensions.

```shell
shoplazza checkout-extension list [flags]
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--all`, `-a` | bool | List all extensions (not just published) |
| `--dry-run` | bool | Print the request that would be sent without executing it |

### Examples

```shell
shoplazza checkout list
shoplazza checkout list --all
```

## versions

List versions of a checkout extension.

```shell
shoplazza checkout-extension versions --extension-id <id>
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--extension-id` | string | Server-side extension id (from `checkout list`) — **required** |
| `--dry-run` | bool | Print the request that would be sent without executing it |

### Examples

```shell
shoplazza checkout versions --extension-id abc123
```

## preview

Generate a storefront preview URL for an extension version on the current store.

```shell
shoplazza checkout-extension preview --extension-id <id> --version <version>
```

### Flags

| Flag | Type | Description |
|------|------|-------------|
| `--extension-id` | string | Server-side extension id |
| `--version` | string | Version to preview, e.g. 1.0 (resolved to its server id via `checkout versions`) |
| `--dry-run` | bool | Print the request that would be sent without executing it |

### Examples

```shell
shoplazza checkout preview --extension-id abc123 --version 1.0
```
