# ShopDepot CLI

Install the shopdepot command, connect it to a store and build themes from your terminal with a live preview.

`shopdepot` is the command line tool for theme developers. It starts a theme from the reference theme, keeps a folder on your computer in sync with a theme in a store, shows you a live preview while you edit and checks the theme against the same rules the platform applies when it saves a file.

It is a single file with no dependencies. It talks to the [theme API](theme-api.md) with a developer token, so it never needs your admin password.

## Install

On macOS and Linux:

```bash
curl -fsSL https://shopdepot.dev/install.sh | sh
```

The script picks the build for your system, checks it against the published SHA-256 checksum and installs it to `~/.local/bin/shopdepot`. Set `SHOPDEPOT_INSTALL_DIR` to install somewhere else. If `~/.local/bin` is not on your `PATH`, the script prints the line to add to your shell profile.

On Windows, download [shopdepot-windows-amd64.exe](/cli/shopdepot-windows-amd64.exe), rename it to `shopdepot.exe` and put it in a folder on your `PATH`.

All builds and their checksums:

| System | File |
| --- | --- |
| macOS, Apple silicon | [shopdepot-darwin-arm64](/cli/shopdepot-darwin-arm64) |
| macOS, Intel | [shopdepot-darwin-amd64](/cli/shopdepot-darwin-amd64) |
| Linux, x86-64 | [shopdepot-linux-amd64](/cli/shopdepot-linux-amd64) |
| Linux, ARM64 | [shopdepot-linux-arm64](/cli/shopdepot-linux-arm64) |
| Windows, x86-64 | [shopdepot-windows-amd64.exe](/cli/shopdepot-windows-amd64.exe) |
| Checksums | [SHA256SUMS](/cli/SHA256SUMS) |

Check the installation:

```bash
shopdepot version
```

To update, run the install command again.

## Connect a store

Each store you work on needs a **developer token**. In the store admin open **Sales channels → Stores → your store → Appearance → Themes → Developer access**, give the token a name (your name, or the laptop it lives on) and create it. The token starts with `sdt_` and is shown **once** - copy it straight away.

```bash
shopdepot login
```

Paste the token when asked. The CLI checks it with the store, saves it under the store's handle and makes it the default store if it is your first one. You can pass everything at once:

```bash
shopdepot login --token sdt_... --store example
```

A token gives access to the themes of **one store** and nothing else: no orders, customers or settings. Revoke it on the same screen at any time - tools using it lose access at once. A store can have up to 20 tokens; create one per person and per machine, so that revoking one does not lock everybody out.

> [!TIP]
> Work in a **development store**. There, paid themes are editable and publishable, and nothing you push reaches real customers. In a live store, a paid theme on trial is read-only and `push` refuses it.

| Command | What it does |
| --- | --- |
| `shopdepot login [--store NAME] [--token sdt_...]` | Save a token. `NAME` defaults to the store handle. |
| `shopdepot stores` | List saved stores; the default is marked. |
| `shopdepot logout [--store NAME]` | Forget a saved token (revoke it in the admin too). |

Tokens are saved in your user configuration folder (`~/.config/shopdepot/config.json` on Linux, `~/Library/Application Support/shopdepot/config.json` on macOS, `%AppData%\shopdepot\config.json` on Windows), readable only by you. `SHOPDEPOT_CONFIG` points the CLI at another file.

## Start a theme

```bash
shopdepot theme init example
cd example
```

`init` downloads the current version of **base**, the free reference theme, into a new folder and renames it after the folder: `handle` becomes `example`, the version resets to `0.1.0` and the author is cleared. Fill in `name`, `author` and `description` in [theme.json](theme-json.md) - the `handle` identifies the theme in the registry and cannot change later.

`init` also writes:

- `.shopdepot.json` - which store and theme this folder belongs to (keep it out of git; `init` adds it to `.gitignore`),
- `.shopdepotignore` - patterns of files that never go to the store.

Upload the folder as a new theme:

```bash
shopdepot theme push --new
```

The theme is added to the store's library as a **draft** and the folder remembers it, so later commands need no `--theme`. The command prints a preview link.

## The development loop

```bash
shopdepot theme dev
```

`dev` first uploads anything that differs from the store, then watches the folder. Every file you save goes up within about a second, every file you delete is removed from the theme, and each change is printed with a mark:

```text
Watching /home/you/example → "Example"
Preview: https://example.myshopdepot.pl/?preview_theme=...
Press Ctrl+C to stop.
14:02:11  ✓ sections/content/hero.twig
14:02:19  ! sections/content/hero.twig: Unexpected "}" (line 12)
14:02:25  ✓ sections/content/hero.twig
14:03:40  ✗ snippets/old-card.twig
```

A file the platform refuses (a Twig syntax error, a filter the [sandbox](twig-sandbox.md) does not allow, a path outside the [file contract](file-structure.md)) is marked `!` with the reason and **not saved** - the theme keeps the previous version, so the preview never shows a broken page. Fix the file and save again.

Open the preview link and refresh after a change. The link shows your theme on the store's real data without publishing it, for you and anyone you send it to, and stays active in that browser for a day. Add `?preview_theme=off` to any store address to leave the preview.

`--interval 1s` changes how often the folder is checked (the default is 500 ms).

## Commands

Every theme command accepts `--store NAME` (default: the store the folder belongs to, then the default store) and `--path DIR` (default: the current folder). `--theme ID` selects a theme by the id `theme list` prints; without it, the folder's theme is used.

| Command | What it does |
| --- | --- |
| `shopdepot theme init [DIR]` | Start a theme from `base` in a new folder (default `example-theme`). |
| `shopdepot theme list` | Themes installed in the store: id, name, role (live or draft), licence and whether you can edit them. |
| `shopdepot theme pull [--theme ID] [--only GLOB]` | Download a theme into the folder. Only changed files are written. |
| `shopdepot theme push [--theme ID] [--only GLOB] [--nodelete] [--dry-run] [--publish]` | Upload local changes. |
| `shopdepot theme push --new [--publish]` | Upload the folder as a new draft theme and link the folder to it. |
| `shopdepot theme dev [--theme ID] [--interval 500ms]` | Push every change as you save and print the preview link. |
| `shopdepot theme check [--strict]` | Check the theme against the platform rules without changing the store. |
| `shopdepot theme open [--theme ID] [--page /products/example/]` | Open the preview in your browser. |
| `shopdepot theme package [--out FILE]` | Build the ZIP you upload in the admin or submit to the theme store. |

### push

`push` compares checksums and uploads only what changed. Files that are in the theme but not in your folder are **deleted** from the theme, so the store ends up exactly like the folder; `--nodelete` keeps them. Use `--dry-run` to see the plan first:

```bash
shopdepot theme push --dry-run
```

`--only` limits a push or pull to matching paths and can be repeated:

```bash
shopdepot theme push --only 'sections/*' --only 'assets/css/base.css'
```

`--publish` makes the theme live after the push. In a store with customers, prefer publishing from the admin, where you see the theme next to the live one.

`push` never overwrites `config/settings_data.json` in the store, because it holds the values set in the theme editor. To replace them with your file on purpose, name it:

```bash
shopdepot theme push --only config/settings_data.json
```

(`dev` does upload it when you edit and save it, since that is a deliberate change.) Pull before you push when someone else, or the merchant in the theme editor, may have changed the theme: `templates/*.json` change too every time the theme is customized in the editor.

### check

```bash
shopdepot theme check
```

`check` sends the folder to the platform and runs every file through the same rules as a save: the [file contract](file-structure.md), JSON and `{% schema %}` syntax, Twig syntax and the [sandbox](twig-sandbox.md). It also reports problems that are allowed but usually a mistake:

- `layout/theme.twig` missing `{{ content_for_header }}` or `{{ content_for_layout }}`, or writing its own description, canonical or Open Graph tags,
- a missing `snippets/brand-tokens.twig` or a missing template for a page type,
- a section or block whose root element does not print `section.attributes` / `block.attributes`,
- files outside the contract, which would be skipped silently on upload.

Errors make the command exit with status 1; `--strict` does the same for warnings, which is what you want in continuous integration:

```yaml
# .gitlab-ci.yml or any CI
theme-check:
  script:
    - curl -fsSL https://shopdepot.dev/install.sh | sh
    - ~/.local/bin/shopdepot theme check --strict
  variables:
    SHOPDEPOT_TOKEN: $SHOPDEPOT_TOKEN
```

`check` reads the store only to run the rules - it never changes a theme.

### package

```bash
shopdepot theme package
```

Writes `<handle>-<version>.zip` with exactly the files the platform accepts, `theme.json` at the top of the archive. Bump `version` in `theme.json` before every package you hand over: versions in the registry are never overwritten. See [Publishing](publishing.md).

## Ignored files

These never go to the store and are never deleted from it by `push`: `.git`, `node_modules`, `.DS_Store`, `.shopdepot.json`, and the `demo/` folder (demo store data ships in the package, not in a store's theme). Add your own patterns to `.shopdepotignore`, one per line:

```text
# source files compiled into assets/
src/
*.map
assets/*.scss
```

A pattern without `/` matches a name at any depth; a pattern with `/` matches from the theme root; a trailing `/` matches a folder.

## Automation and CI

`SHOPDEPOT_TOKEN` (and optionally `SHOPDEPOT_API`) override the saved stores, so a pipeline needs no `login`:

```bash
SHOPDEPOT_TOKEN=sdt_... shopdepot theme push --theme 0193d7a2-... --nodelete
```

Keep the token in your CI's secret variables, never in the repository. Create a separate token for CI so you can revoke it without touching your own.

## Troubleshooting

| Message | What to do |
| --- | --- |
| `Missing or invalid token` | The token was revoked or mistyped. Create a new one and run `shopdepot login` again. |
| `"Example" is read-only in this store (licence: trial)` | A paid theme on trial cannot be changed. Buy it in the store, or work in a development store. |
| `outside the theme file contract` | Rename the file: lowercase letters, at most four folders deep, inside one of the theme folders. See [File structure](file-structure.md). |
| `Unexpected ... (line 12)` | A Twig syntax error. The file was not saved; the store still has the previous version. |
| `Filter "..." is not allowed` (or tag, function, method) | The template uses a tag, filter, function or method themes cannot call. See [The Twig sandbox](twig-sandbox.md). |
| `no theme.json in this folder` | Run the command inside the theme folder, or pass `--path`. |
