用途
Tapcart Blocks 技能用于管理 Tapcart 的区块(blocks)与全局组件(components)。区块和组件的操作完全相同,本技能同时覆盖两者。所有命令都需要在 Tapcart 项目目录的根目录下运行。除特别说明外,所有命令由代理直接执行。
主要能力
创建
创建区块或组件:
# 区块
tapcart block create <BlockFolderName>
# 组件
tapcart component create <ComponentFolderName>
创建完成后,需要告知用户如何启动开发服务器(见下文“开发服务器”)。
拉取
从 Tapcart 仪表盘同步到本地的 ./blocks 或 ./components 文件夹:
# 拉取全部区块
tapcart block pull -a
# 拉取指定区块
tapcart block pull -b MyBlock
tapcart block pull -b BlockOne -b BlockTwo
# 拉取区块的指定版本
tapcart block pull -b MyBlock -v 2
# 拉取全部组件
tapcart component pull -a
# 拉取指定组件
tapcart component pull -c ProductCard
tapcart component pull -c ProductCard -c Button
# 拉取组件的指定版本
tapcart component pull -c ProductCard -v 3
约束条件:
-a不能与-b/-c同时使用。-v只能与单个区块/组件名称一起使用。
推送
推送前,先阅读本地的 code.jsx 和 config.json,确认改动无误,并在运行前与用户确认。
# 推送指定区块(创建新版本,不会立即上线)
tapcart block push -b MyBlock
# 推送并立即将新版本设为线上版本
tapcart block push -b MyBlock --live
# 推送多个区块
tapcart block push -b BlockOne -b BlockTwo
# 推送全部区块
tapcart block push -a
# 推送指定组件
tapcart component push -c ProductCard
# 推送并设为线上
tapcart component push -c ProductCard --live
# 推送全部组件
tapcart component push -a
警告:--live 会使新版本立即对所有 App 用户可见。默认应不带 --live 推送,待用户验证结果后再使用 versions set 上线。
开发服务器
在后台运行开发服务器,并告知用户它正在运行。保持运行,直到用户要求停止。
# 区块开发服务器
tapcart block dev -b MyBlock
tapcart block dev -b MyBlock -p 4995 # 自定义端口,默认 4995
# 组件开发服务器
tapcart component dev -c ProductCard
tapcart component dev -c ProductCard -p 4996 # 默认 4996
开发服务器地址为 http://localhost:<port>(区块默认 4995,组件默认 4996)。当用户要求停止开发服务器时,终止该进程。
版本管理
列出所有版本:
tapcart block versions list -b MyBlock
tapcart component versions list -c ProductCard
输出会显示每个版本号、哪个是本地版本、哪个是仪表盘上的线上版本。
将某个版本设为线上版本:
tapcart block versions set -b MyBlock -v 2
tapcart component versions set -c ProductCard -v 3
版本号从 1 开始(版本 1 是第一次推送)。
使用方式
所有命令均在 Tapcart 项目根目录下执行。代理直接运行命令,并在创建、推送、上线等关键操作前与用户确认。推送前应检查本地 code.jsx 与 config.json。开发服务器在后台运行,直到用户要求停止。
适用场景
适用于需要创建、同步、推送或管理 Tapcart 区块与全局组件的开发工作流,包括本地开发调试、版本回滚与上线发布。
限制
-a与-b/-c不能组合使用。-v只能用于单个区块/组件名称。--live会立即对所有 App 用户生效,需谨慎使用。- 版本号从 1 开始计数。
- 其他未在资料中说明的功能、收费、价格、平台或效果暂未提供。