跳到主要内容

主题命令

本参考文档列出 Shoplazza CLI 的主题开发命令。完整命令参考见 CLI 命令参考。

命令总览​

命令说明
themes init基于 Nova 2023 创建新主题
themes serve实时预览主题
themes pull从店铺下载主题
themes push上传主题到店铺
themes share分享预览链接
themes package打包主题为 ZIP
themes env管理 shoplazza.theme.toml 中的主题环境
themes publish发布主题
themes list列出店铺主题
themes delete删除主题
auth login登录
auth logout注销
auth store use切换店铺
--version显示版本
--help显示帮助

主题开发命令​

以下是 shoplazza themes 下不带 + 前缀的子命令。pull、push、serve、share 还支持 -e, --environment <名称>,针对 shoplazza.theme.toml 中的环境执行,参见 env。

init​

基于 Nova 2023 创建新主题脚手架。无需登录,目标目录必须不存在或为空。

shell
shoplazza themes init --name <dir>

serve​

上传主题到店铺并实时预览。返回预览链接和主题编辑器链接。不传 --theme-id 时上传到当前目录的开发主题,首次运行时创建。每次文件变更都会同步到主题并刷新已连接的浏览器;同步是单向的,主题编辑器中的修改需用 themes pull 拉取。命令会一直运行,直到按 Ctrl-C。

启动时的上传会用本地文件替换服务器上的主题文件:只存在于服务器上的文件会被删除,主题编辑器中的修改会被覆盖。使用 --skip-push 可保留它们。

shell
shoplazza themes serve
参数说明
--theme-id, -t <THEME_ID>要预览并覆盖的主题 ID,省略则使用开发主题
--environment, -e <名称>shoplazza.theme.toml 中的环境(店铺、profile、主题)
--port <PORT>LiveReload 服务端口(默认:21647)
--skip-push跳过启动时的全量上传,直接开始监听;只同步运行期间变更的文件
--task-id <TASK_ID>继续等待之前的上传任务,不重新上传
--timeout <秒数>监听指定秒数后退出(默认:0,一直监听直到中断)

pull​

从 Shoplazza 下载主题文件,解压到当前目录,并把店铺和主题记录到 shoplazza.theme.toml。

shell
shoplazza themes pull --theme-id <THEME_ID>
参数说明
--theme-id, -t <THEME_ID>要下载的主题 ID。除非 -e 已提供,否则必填;在终端中也可以从列表中选择
--environment, -e <名称>shoplazza.theme.toml 中的环境(店铺、profile、主题)
--dry-run只打印将下载的内容和可能覆盖的本地文件,不发送请求

push​

上传本地主题文件到 Shoplazza,覆盖远端版本。在终端中,覆盖前会请你确认。最多等待 10 分钟让服务器处理上传,等待超时后可用 --task-id 重新运行继续等待。与 pull 一样,会把店铺和主题记录到 shoplazza.theme.toml。

shell
shoplazza themes push --theme-id <THEME_ID>
参数说明
--theme-id, -t <THEME_ID>要覆盖的主题 ID。除非 -e 已提供,否则必填;在终端中也可以从列表中选择
--environment, -e <名称>shoplazza.theme.toml 中的环境(店铺、profile、主题)
--task-id <TASK_ID>继续等待之前的上传任务,不重新上传(超时错误中返回的 task_id)
--dry-run只打印将上传的内容和目标,不打包也不发送请求

share​

上传主题为未发布主题,返回可分享的预览链接。不会覆盖已有主题。

shell
shoplazza themes share
参数说明
--environment, -e <名称>shoplazza.theme.toml 中的环境(店铺、profile)
--dry-run只打印将作为新预览上传的内容,不打包也不发送请求

package​

将主题文件打包为 theme_name-theme_version.zip。

shell
shoplazza themes package
参数说明
--no-ignore忽略 .themeignore 规则(默认:false)

env​

查看和编辑 shoplazza.theme.toml 中的环境。CLI 会从当前目录向上查找该文件。

shell
shoplazza themes env list
shoplazza themes env show [name]
shoplazza themes env check [name]
shoplazza themes env add [name] --store <domain> [--theme <id>]
shoplazza themes env set [name] [--store <domain>] [--theme <id>]
shoplazza themes env remove [name]
shoplazza.theme.toml
[environments.default]
store = "my-store.myshoplaza.com"
theme = "123456"

[environments.staging]
store = "staging.myshoplaza.com"
theme = "654321"

用 -e <名称> 或环境变量 SHOPLAZZA_CLI_ENVIRONMENT 选择环境;两者都未设置时自动使用 default 环境。check 会离线校验每个环境都能对应到已登录的 profile。该文件不保存凭证。

主题 API 命令​

主题 API 命令的路径参数放在 --params 中。全部主题 API 命令见 themes (API)。

list​

列出店铺主题及其 ID 和状态。默认每页返回 10 个,传 --params '{"page_size":250}' 最多返回 250 个。

shell
shoplazza themes list --format table

publish​

发布主题到线上店铺。

shell
shoplazza themes publish --params '{"theme_id":"<THEME_ID>"}'

delete​

删除主题。店铺的默认主题不能删除。

shell
shoplazza themes delete --params '{"theme_id":"<THEME_ID>"}'

认证命令​

login​

通过 OAuth 2.0 登录:

shell
shoplazza auth login --store-domain my-store.myshoplaza.com --domain themes

选择店铺时还需传 --domain 或 --scope;在终端中两者都省略时会提示你选择。

logout​

注销并移除本机所有 profile 和凭证:

shell
shoplazza auth logout

store use​

切换到其他店铺:

shell
shoplazza auth store use --store-domain another-store.myshoplaza.com

工具命令​

version​

shell
shoplazza --version

help​

shell
shoplazza --help
shoplazza [命令] --help