The CLI tool offers a command-line interface for managing various aspects of your Commerce instance.

Installation

You can install the CLI globally using npm, pnpm, or yarn:

# npm
npm install -g commerce-cli

# pnpm
pnpm add -g commerce-cli

# yarn
yarn global add commerce-cli

Usage

commerce-cli [command] [options]

For more information run:

commerce-cli -h

Our CLI will try to find required environment variables in [starter]/.env.local. Each variable will be prompted to you for confirmation when using commands.

To opt-in you have to follow the below naming convention:

Shopify admin access token: SHOPIFY_ADMIN_ACCESS_TOKEN
Shopify store URL: SHOPIFY_STORE_DOMAIN

And depending on the search platform:

Meilisearch admin key: MEILISEARCH_ADMIN_KEY
Meilisearch Host: MEILISEARCH_HOST
Categories index: MEILISEARCH_CATEGORIES_INDEX
Products index: MEILISEARCH_PRODUCTS_INDEX

or:

Algolia AppId: ALGOLIA_APP_ID
Algolia Write Api Key: ALGOLIA_WRITE_API_KEY
Categories index: ALGOLIA_CATEGORIES_INDEX
Products index: ALGOLIA_PRODUCTS_INDEX


Available Commands

sync

commerce-cli sync | s [opts]

This command allows you to pull all of your products and categories from your commerce platform, and synchronize it with your search & merch solution.

You will be asked whether to set up webhooks to keep your products and categories in sync continuously, eliminating the need for manual synchronization.

Importantly, this command does not modify your products in Shopify, eliminating the need for backups or concerns about data alteration. It solely fetches product data and uploads it to your search engine.

Options:
 -url, --storeUrl <url>: Platform store URL
 -token, --adminAccessToken <token>: Store admin access token
 -host, --searchHost <host>: Search host
 -adminKey, --searchAdminKey <key>: Search admin key
 -categoriesIndex, --categoriesIndex <index>: Search categories index
 -productsIndex, --productsIndex <index>: Search products index
 -env, --envFilePath <path>: Path to your .env file

webhook

commerce-cli webhook | w [opts]

This command helps you check and maintain webhooks set for your commerce platform with ease. You can delete and modify existing webhooks individually or in bulk, as well as create new ones.

This allows you to stay in control of background tasks set for your commerce.

Options:
  -c, --create                Create a webhook for your store
  -l, --list                  List and manage all webhooks for your store
  -u, --url <url>             Shopify store URL
  -t, --token <token>         Shopify admin access token
  -env, --envFilePath <path>  Path to your .env file

You can also simply run commerce-cli webhook and use the UI to get things done.


For more information on how to possess each of the keys please check our Setup Page