# Overview

> How to use the legacy Shoplazza CLI app command group: prerequisites, every command from init to versions list, and the two TOML configuration files.

The **shoplazza app command** is the core command group within the Shoplazza CLI, designed for developing and managing Shoplazza applications. It provides comprehensive support for the entire application development lifecycle, from project **initialization** to **deployment** and **publishing**.

## Prerequisites

Before using the **shoplazza app commands**, ensure that you have:

1.  Installed Node.js (supported version: v20.9.0/v20.18.0)
2.  Installed Git
3.  Installed the newest version Shoplazza CLI

```shell
npm i -g shoplazza-cli
```

## App Command Overview

| Command | Function Description | Usage Scenario |
| --- | --- | --- |
| [shoplazza app init](#shoplazza-app-init----initialize-application-project) | Initialize a new application project | Create a new application project,<br>or connect an existing application project. |
| [shoplazza app generate extension](#shoplazza-app-generate-extension---generate-extension-template) | Generate an extension template | Add new extensions to an existing application |
| [shoplazza app dev](#shoplazza-app-dev---local-development) | Start a local development server | Local development and debugging |
| [shoplazza app deploy](#shoplazza-app-deploy---deploy-application) | Deploy the application to the<br>production environment | Publish the application to production. |
| [shoplazza app config link](#shoplazza-app-config-link---link-application-configuration) | Link an application configuration file | Connect an existing application to a local project |
| [shoplazza app config use](#shoplazza-app-config-use---switch-application-configuration) | Switch between application configuration files | Switch between multiple application configurations |
| [shoplazza app versions list](#shoplazza-app-versions-list---view-application-versions) | View the list of application versions | Manage application version history |

## App Command Descriptions

### `shoplazza app init` - Initialize Application Project

**Function:**

*   Create a new Shoplazza application project, including project templates and configuration files. Or connect an existing application project.

**Usage Scenarios:**

*   Starting development of a new Shoplazza application, andcreate an application project from scratch
*   Connect to an existing application project

**Command Format:**

```shell
shoplazza app init [options]
```

**Flags:**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project creation path (Default: Current directory) |
| `--client-id <client-id>` | Specify the client ID of the existing application to connect to |
| `--name <name>` | Specify the application name |

**Usage Examples:**

```shell
# Create a new application in the current directory:
shoplazza app init

# Create a new application in a specified directory:
shoplazza app init --path ./my-new-app

# Create a new application with a specified name:
shoplazza app init --name "your_app_name"

# Connect to an existing application:
shoplazza app init --client-id your-client-id
```

### `shoplazza app generate extension` - Generate Extension Template

**Function:**

*   Generate a new extension template for an existing application, supporting various types of extensions.
    **Usage Scenarios:**
*   Adding new features to an existing application
*   Creating theme extensions, checkout extensions, or function extensions

**Command Format:**

```shell
shoplazza app generate extension [options]
```

**Flags:**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project path (Default: Current directory) |

**Supported Extension Types**:

*   _**[Theme Extension](/docs/app/extensions/online-store/)**_:
    Provide a way to extend and customize theme pages, integrating with Online Store themes. Theme App Extensions act as a replacement for using Script to integrate apps with online stores.
*   _**[Checkout Extension](/docs/app/extensions/checkout/)**_:
    Allow developers to customize the checkout page, including hiding certain modules, modifying product information, address details, shipping information, payment details, and order result information. You can also insert custom content.
*   _**Function Extension**_:
    Allow developers to define custom logic for calculating shopping cart prices. When a cart-transformfunction is bound to a cart price modification point, Shoplazza automatically executes the bound function code during the cart or checkout phase, dynamically adjusting pricing strategies through update operations.

**Usage Examples:**

```shell
# Generate a new extension in the current project:
shoplazza app generate extension

# Generate a new extension in a specified project:
shoplazza app generate extension --path ./my-app
```

### `shoplazza app dev` - Local Development

**Function:**

*   Start a local development server

**Usage Scenarios:**

*   Local development and debugging of applications
*   Testing extension functionalities

**Command Format:**

```shell
shoplazza app dev
```

**Flag**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project path (Default: Current directory) |

### `shoplazza app deploy` - Deploy Application

**Function:**

*   Deploy the application to the production environment, making it live in the Shoplazza Store.

**Usage Scenarios:**

*   Publishing a completed application to the production environment
*   Updating existing application versions

**Command Format:**

```text
shoplazza app deploy [options]
```

**Flag**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project path (Default: Current directory) |

**Usage Examples:**

```shell
# Deploy the application:
shoplazza app deploy

# Deploy a specified project:
shoplazza app deploy --path ./my-app
```

### `shoplazza app config link` - Link Application Configuration

**Function:**

*   Link an existing Shoplazza application to a local project, creating a configuration file.

**Usage Scenarios:**

*   Connecting an existing application to the local development environment
*   Creating a local configuration file for an existing application
*   Managing multiple application configurations within a local project

**Command Format:**

```shell
shoplazza app config link [options]
```

**Flag**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project path (Default: Current directory) |
| `--client-id <client-id>` | Specify the client ID of the application to link |

**Usage Examples:**

```shell
# Link an application configuration:
shoplazza app config link

# Link a specified application:
shoplazza app config link --client-id your-client-id

#Link in a specified directory:
shoplazza app config link --path ./my-project
```

### shoplazza app config use - Switch Application Configuration

**Function:**

*   Switch between multiple application configuration files within a project, activating the specified configuration.

**Usage Scenarios:**

*   Managing multiple application configurations within a project
*   Switching between different applications for development

**Command Format:**

```shell
shoplazza app config use [options]
```

**Flag**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project path (Default: Current directory) |

**Usage Examples:**

```shell
# Switch application configuration:
shoplazza app config use

# Switch configuration in a specified project:
shoplazza app config use --path ./my-project
```

### `shoplazza app versions list` - View Application Versions

**Function:**

*   View all deployed versions of the application, supporting pagination and detailed information display.

**Usage Scenarios:**

*   Viewing application version history
*   Understanding version deployment status

**Command Format:**

```shell
shoplazza app versions list [options]
```

**Flag**

| Flag | Description |
| --- | --- |
| `--path <path>` | Specify the project path (Default: Current directory) |
| `--page-size <number>` | Number of versions to display per page (Default: 10) |

**Usage Examples:**

```shell
# View the version list:
shoplazza app versions list

# Specify the number of versions displayed per page:
shoplazza app versions list --page-size 50

# View versions of a specified project:
shoplazza app versions list --path ./my-app
```

## Configuration Files Explanation

### `shoplazza.app.toml` Application Configuration File

This is the core configuration file for the application, containing essential application information:

```shell

# Application Client ID (Required)

client_id = "your-client-id"

# Application Permission Scopes

scopes = "read_customer write_cart_transform"
```

### `shoplazza.extension.toml` Extension Configuration File

Each extension has its own configuration file:

```shell
# Extension ID (Generated by the system)

id = "extension-id"

# Extension Name

name = "My Extension"

# Extension Type (theme/checkout/function)

type = "theme"
```
