@playcraft/cli 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +204 -5
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,12 +1,211 @@
1
1
  # @playcraft/cli
2
2
 
3
- CLI 文档已收拢到 `docs/cli/` 目录:
4
- - `docs/cli/README.md`
5
- - `docs/cli/build.md`
6
- - `docs/cli/config.md`
3
+ > PlayCraft 命令行工具 - 本地开发助手与 Playable Ads 打包工具
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@playcraft/cli.svg)](https://www.npmjs.com/package/@playcraft/cli)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@playcraft/cli.svg)](https://www.npmjs.com/package/@playcraft/cli)
7
+
8
+ PlayCraft CLI 是一个功能强大的命令行工具,支持本地代码与云端编辑器实时同步,以及将 PlayCanvas/PlayCraft 项目打包为多平台 Playable Ads。
9
+
10
+ ## ✨ 特性
11
+
12
+ - 🚀 **本地开发隧道** - 在本地 IDE 编写代码,云端编辑器实时预览与热更新
13
+ - 📦 **Playable Ads 打包** - 支持 10 个主流广告平台的一键打包
14
+ - 🎯 **两阶段构建** - Base Build + Channel Build,灵活可控
15
+ - ⚡ **Vite 构建** - 使用 Vite 进行资源内联与压缩,性能优异
16
+ - 🔧 **交互式配置** - 友好的命令行交互,快速上手
17
+ - 📊 **构建分析** - 生成详细的打包分析报告
18
+
19
+ ## 📦 安装
20
+
21
+ ### 使用 npx(推荐,无需安装)
7
22
 
8
- 快速使用:
9
23
  ```bash
10
24
  npx @playcraft/cli <command>
25
+ ```
26
+
27
+ ### 全局安装
28
+
29
+ ```bash
30
+ npm install -g @playcraft/cli
31
+ ```
32
+
33
+ 安装后可直接使用 `playcraft` 命令:
34
+
35
+ ```bash
11
36
  playcraft <command>
12
37
  ```
38
+
39
+ ## 🚀 快速开始
40
+
41
+ ### 1. 初始化配置
42
+
43
+ ```bash
44
+ npx @playcraft/cli init
45
+ ```
46
+
47
+ 交互式创建 `playcraft.config.json` 配置文件。
48
+
49
+ ### 2. 启动本地开发服务
50
+
51
+ ```bash
52
+ # 前台运行
53
+ npx @playcraft/cli start --project <project-id>
54
+
55
+ # 后台运行(守护进程)
56
+ npx @playcraft/cli start --project <project-id> --daemon
57
+ ```
58
+
59
+ 启动后,云端编辑器会自动检测本地服务,直接读取本地文件进行运行与调试。
60
+
61
+ ### 3. 打包 Playable Ads
62
+
63
+ ```bash
64
+ # 交互式打包(推荐)
65
+ npx @playcraft/cli build
66
+
67
+ # 命令行打包
68
+ npx @playcraft/cli build --platform facebook --format html --output ./dist
69
+ ```
70
+
71
+ ## 📖 命令说明
72
+
73
+ ### 开发相关
74
+
75
+ | 命令 | 说明 | 示例 |
76
+ |------|------|------|
77
+ | `init` | 交互式创建配置文件 | `playcraft init` |
78
+ | `start` | 启动本地开发服务 | `playcraft start --project <id>` |
79
+ | `stop` | 停止运行中的服务 | `playcraft stop --project <id>` |
80
+ | `status` | 查看服务运行状态 | `playcraft status` |
81
+ | `logs` | 查看服务日志 | `playcraft logs --follow` |
82
+ | `config` | 读取/修改配置项 | `playcraft config get --key projectId` |
83
+ | `inspect` | 检测项目类型与结构 | `playcraft inspect .` |
84
+
85
+ ### 构建相关
86
+
87
+ | 命令 | 说明 | 示例 |
88
+ |------|------|------|
89
+ | `build` | 完整打包(阶段1 + 阶段2) | `playcraft build --platform facebook` |
90
+ | `build-base` | 仅执行阶段1(生成多文件产物) | `playcraft build-base ./src --output ./build` |
91
+ | `build-playable` | 仅执行阶段2(从多文件产物生成 Playable) | `playcraft build-playable ./build --platform facebook` |
92
+ | `analyze` | 生成打包分析报告 | `playcraft analyze --platform facebook` |
93
+
94
+ ## 🎯 支持的平台
95
+
96
+ 现已支持 **10 个主流广告平台**:
97
+
98
+ | 平台 | 格式 | 大小限制 | SDK/API |
99
+ |------|------|----------|---------|
100
+ | **Facebook** | HTML | 2MB | FbPlayableAd |
101
+ | **Snapchat** | ZIP | 5MB | MRAID 2.0 |
102
+ | **ironSource** | HTML | 5MB | MRAID + dapi |
103
+ | **AppLovin** | HTML | 5MB | MRAID 2.0 |
104
+ | **Google Ads** | ZIP | 5MB | ExitApi |
105
+ | **TikTok/Pangle** | ZIP | 5MB | Pangle SDK |
106
+ | **Unity Ads** | HTML | 5MB | MRAID 3.0 |
107
+ | **Liftoff** | ZIP | 5MB | MRAID |
108
+ | **Moloco** | HTML | 5MB | FbPlayableAd |
109
+ | **BIGO Ads** | ZIP | 5MB | BIGO SDK |
110
+
111
+ ## 💡 使用示例
112
+
113
+ ### 本地开发模式
114
+
115
+ ```bash
116
+ # 1. 初始化配置
117
+ playcraft init
118
+
119
+ # 2. 启动本地服务
120
+ playcraft start --project your-project-id
121
+
122
+ # 3. 在本地 IDE 编辑代码,云端编辑器自动同步
123
+ ```
124
+
125
+ ### 打包 Playable Ads
126
+
127
+ ```bash
128
+ # Facebook 平台(单 HTML)
129
+ playcraft build --platform facebook --format html --output ./dist/facebook
130
+
131
+ # Snapchat 平台(ZIP)
132
+ playcraft build --platform snapchat --format zip --output ./dist/snapchat
133
+
134
+ # 批量打包所有平台
135
+ for platform in facebook snapchat ironsource applovin google tiktok unity liftoff moloco bigo; do
136
+ playcraft build --platform $platform --output ./dist/$platform
137
+ done
138
+ ```
139
+
140
+ ### 构建优化
141
+
142
+ ```bash
143
+ # 启用图片压缩
144
+ playcraft build --platform facebook --compress-images --image-quality 75
145
+
146
+ # 启用模型压缩
147
+ playcraft build --platform facebook --compress-models --model-compression draco
148
+
149
+ # 生成分析报告
150
+ playcraft build --platform facebook --analyze
151
+ ```
152
+
153
+ ## ⚙️ 配置
154
+
155
+ 配置文件 `playcraft.config.json`:
156
+
157
+ ```json
158
+ {
159
+ "agent": {
160
+ "projectId": "your-project-id",
161
+ "token": "your-token",
162
+ "port": 2468,
163
+ "dir": "./"
164
+ },
165
+ "build": {
166
+ "platform": "facebook",
167
+ "format": "html",
168
+ "outputDir": "./dist",
169
+ "useVite": true,
170
+ "compressImages": true,
171
+ "imageQuality": 75,
172
+ "convertToWebP": true,
173
+ "compressModels": true,
174
+ "modelCompression": "draco"
175
+ }
176
+ }
177
+ ```
178
+
179
+ ### 配置优先级
180
+
181
+ 1. CLI 参数(最高优先级)
182
+ 2. 环境变量(`PLAYCRAFT_PROJECT_ID`/`PLAYCRAFT_TOKEN`/`PLAYCRAFT_PORT`)
183
+ 3. 配置文件(`playcraft.config.json`)
184
+ 4. 默认值
185
+
186
+ ## 📁 数据目录
187
+
188
+ CLI 会在 `~/.playcraft/` 目录下存储:
189
+
190
+ - `pids/` - 进程文件
191
+ - `logs/` - 日志文件
192
+
193
+ ## 🔗 相关链接
194
+
195
+ - [PlayCraft 项目](https://github.com/your-org/playcraft)
196
+ - [完整文档](./docs/cli/README.md)
197
+ - [快速开始指南](./docs/cli/quick-start.md)
198
+ - [构建命令详解](./docs/cli/build.md)
199
+ - [配置文件说明](./docs/cli/config.md)
200
+
201
+ ## 📝 许可证
202
+
203
+ MIT
204
+
205
+ ## 🤝 贡献
206
+
207
+ 欢迎提交 Issue 和 Pull Request!
208
+
209
+ ---
210
+
211
+ **Made with ❤️ by PlayCraft Team**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcraft/cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,7 +14,8 @@
14
14
  "scripts": {
15
15
  "dev": "tsc -w",
16
16
  "build": "tsc",
17
- "start": "node dist/index.js"
17
+ "start": "node dist/index.js",
18
+ "publish": "npm version patch --no-git-tag && pnpm build && npm publish --access public"
18
19
  },
19
20
  "dependencies": {
20
21
  "@playcraft/build": "workspace:*",