drgame-cc 1.0.13 → 1.0.15
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.
- package/README.md +176 -351
- package/build-templates/web-mobile/splash_en - /345/211/257/346/234/254.png +0 -0
- package/{tvui → drres}/config/default.json +30 -11
- package/package.json +4 -3
- package/scripts/postinstall.js +99 -67
- /package/{tvui → drres}/config/default.json.meta +0 -0
- /package/{tvui → drres}/config.meta +0 -0
- /package/{tvui → drres}/icons/pointer-blue-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-blue-60.png.meta +0 -0
- /package/{tvui → drres}/icons/pointer-pink-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-pink-60.png.meta +0 -0
- /package/{tvui → drres}/icons/pointer-yellow-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-yellow-60.png.meta +0 -0
- /package/{tvui → drres}/icons.meta +0 -0
- /package/{tvui → drres}/prefab/ExitWin.prefab +0 -0
- /package/{tvui → drres}/prefab/ExitWin.prefab.meta +0 -0
- /package/{tvui → drres}/prefab/Toast.prefab +0 -0
- /package/{tvui → drres}/prefab/Toast.prefab.meta +0 -0
- /package/{tvui → drres}/prefab.meta +0 -0
- /package/{tvui → drres}/tv_exit/Toast.png +0 -0
- /package/{tvui → drres}/tv_exit/Toast.png.meta +0 -0
- /package/{tvui → drres}/tv_exit/close.png +0 -0
- /package/{tvui → drres}/tv_exit/close.png.meta +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/346/231/256/351/200/232.png" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/346/231/256/351/200/232.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/351/200/211/344/270/255.png" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/351/200/211/344/270/255.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//346/241/206.png" +0 -0
- /package/{tvui → drres}/tv_exit//346/241/206.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/346/231/256/351/200/232.png" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/346/231/256/351/200/232.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/351/200/211/344/270/255.png" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/351/200/211/344/270/255.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//351/200/200/345/207/272/346/270/270/346/210/217.png" +0 -0
- /package/{tvui → drres}/tv_exit//351/200/200/345/207/272/346/270/270/346/210/217.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit.meta +0 -0
package/README.md
CHANGED
|
@@ -1,351 +1,176 @@
|
|
|
1
|
-
# drgame-cc
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
###
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
#
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
1.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
##
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
### 发布步骤
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
# 1. 更新版本号(遵循语义化版本)
|
|
181
|
-
npm version patch # 补丁版本:1.0.x -> 1.0.(x+1)
|
|
182
|
-
npm version minor # 次版本:1.x.y -> 1.(x+1).0
|
|
183
|
-
npm version major # 主版本:x.y.z -> (x+1).0.0
|
|
184
|
-
|
|
185
|
-
# 2. 登录 npm(首次需要)
|
|
186
|
-
npm login
|
|
187
|
-
|
|
188
|
-
# 3. 干跑测试(查看将要发布的文件列表)
|
|
189
|
-
npm pack --dry-run
|
|
190
|
-
|
|
191
|
-
# 4. 正式发布
|
|
192
|
-
npm publish
|
|
193
|
-
|
|
194
|
-
# 5. 打 tag(可选)
|
|
195
|
-
git push origin main --tags
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### 版本号规则
|
|
199
|
-
|
|
200
|
-
我们遵循 [语义化版本](https://semver.org/lang/zh-CN/)规范:
|
|
201
|
-
|
|
202
|
-
- **MAJOR**:不兼容的 API 修改
|
|
203
|
-
- **MINOR**:向下兼容的功能性新增
|
|
204
|
-
- **PATCH**:向下兼容的问题修正
|
|
205
|
-
|
|
206
|
-
示例:
|
|
207
|
-
```
|
|
208
|
-
1.0.12 -> 1.0.13 (patch: 修复 bug)
|
|
209
|
-
1.0.12 -> 1.1.0 (minor: 新增功能)
|
|
210
|
-
1.0.12 -> 2.0.0 (major: 重构或 breaking changes)
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### 发布内容验证
|
|
214
|
-
|
|
215
|
-
发布的 npm 包将包含以下文件(见 `package.json` 的 `files` 字段):
|
|
216
|
-
|
|
217
|
-
```
|
|
218
|
-
drgame-cc-1.0.12.tgz
|
|
219
|
-
├── tvui/**/* # TVUI 组件资源
|
|
220
|
-
├── build-templates/**/* # 构建模板
|
|
221
|
-
├── scripts/postinstall.js # 安装脚本
|
|
222
|
-
└── bin/**/* # CLI 工具
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
**不会包含的内容**:
|
|
226
|
-
- ❌ `.env` / `.env.*` (环境变量配置)
|
|
227
|
-
- ❌ `node_modules/` (依赖)
|
|
228
|
-
- ❌ `dist/` / `*.tsbuildinfo` (编译产物)
|
|
229
|
-
- ❌ `src/` (源码)
|
|
230
|
-
- ❌ `.vscode/` / `.idea/` (编辑器配置)
|
|
231
|
-
|
|
232
|
-
## 🔧 故障排除
|
|
233
|
-
|
|
234
|
-
### 问题 1:postinstall 未自动执行
|
|
235
|
-
|
|
236
|
-
**症状**:安装成功但没有拷贝资源
|
|
237
|
-
|
|
238
|
-
**原因**:npm v10+ 默认阻止自动执行 install scripts
|
|
239
|
-
|
|
240
|
-
**解决方案**:
|
|
241
|
-
```bash
|
|
242
|
-
# 方法 1:批准脚本
|
|
243
|
-
npm approve-scripts drgame-cc
|
|
244
|
-
|
|
245
|
-
# 方法 2:手动执行
|
|
246
|
-
cd node_modules/drgame-cc
|
|
247
|
-
node scripts/postinstall.js
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### 问题 2:找不到目标目录
|
|
251
|
-
|
|
252
|
-
**症状**:报错 `ENOENT: no such file or directory`
|
|
253
|
-
|
|
254
|
-
**解决方案**:
|
|
255
|
-
```bash
|
|
256
|
-
# 创建 .env 文件并配置正确路径
|
|
257
|
-
echo "COCOS_CREATOR_ROOT=/absolute/path/to/cocos" > .env
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### 问题 3:权限错误 (EPERM)
|
|
261
|
-
|
|
262
|
-
**症状**:Windows 上删除 node_modules 失败
|
|
263
|
-
|
|
264
|
-
**解决方案**:
|
|
265
|
-
```powershell
|
|
266
|
-
# 以管理员身份运行 PowerShell
|
|
267
|
-
# 或使用 rimraf
|
|
268
|
-
npx rimraf node_modules
|
|
269
|
-
npm install
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### 问题 4:TypeScript 编译错误
|
|
273
|
-
|
|
274
|
-
**症状**:`Cannot find module 'xxx'`
|
|
275
|
-
|
|
276
|
-
**解决方案**:
|
|
277
|
-
```bash
|
|
278
|
-
# 清除缓存重新安装
|
|
279
|
-
rm -rf node_modules package-lock.json
|
|
280
|
-
npm install
|
|
281
|
-
|
|
282
|
-
# 检查 TypeScript 版本
|
|
283
|
-
npx tsc --version # 应该是 5.9.3
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
## 📚 API 文档
|
|
287
|
-
|
|
288
|
-
### CLI 使用
|
|
289
|
-
|
|
290
|
-
```bash
|
|
291
|
-
# 查看帮助
|
|
292
|
-
drgame-cc --help
|
|
293
|
-
|
|
294
|
-
# 拷贝资源
|
|
295
|
-
drgame-cc copy
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
### TypeScript 接口
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
// 导入主模块
|
|
302
|
-
import { SomeClass } from 'drgame-cc';
|
|
303
|
-
|
|
304
|
-
// 类型定义自动支持
|
|
305
|
-
const instance: SomeClass = new SomeClass();
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
详细 API 文档请参考 `bin/dgame.d.ts`。
|
|
309
|
-
|
|
310
|
-
## 🤝 贡献指南
|
|
311
|
-
|
|
312
|
-
欢迎贡献代码!请遵循以下流程:
|
|
313
|
-
|
|
314
|
-
1. Fork 本仓库
|
|
315
|
-
2. 创建特性分支 (`git checkout -b feature/amazing-feature`)
|
|
316
|
-
3. 提交更改 (`git commit -m 'Add some amazing feature'`)
|
|
317
|
-
4. 推送到分支 (`git push origin feature/amazing-feature`)
|
|
318
|
-
5. 提交 Pull Request
|
|
319
|
-
|
|
320
|
-
### 代码规范
|
|
321
|
-
|
|
322
|
-
- 使用 TypeScript 编写代码
|
|
323
|
-
- 遵循 ESLint 配置(项目已配置)
|
|
324
|
-
- 提交信息使用 Conventional Commits 规范
|
|
325
|
-
|
|
326
|
-
## 📄 许可证
|
|
327
|
-
|
|
328
|
-
本项目基于 [MIT License](LICENSE) 开源。
|
|
329
|
-
|
|
330
|
-
## 🙏 致谢
|
|
331
|
-
|
|
332
|
-
- [Cocos Creator](https://www.cocos.com/) - 游戏引擎
|
|
333
|
-
- [Gulp](https://gulpjs.com/) - 构建工具
|
|
334
|
-
- [TypeScript](https://www.typescriptlang.org/) - 编程语言
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## 📞 联系方式
|
|
339
|
-
|
|
340
|
-
- **问题反馈**:[GitHub Issues](https://github.com/your-repo/drgame-cc/issues)
|
|
341
|
-
- **功能建议**:[GitHub Discussions](https://github.com/your-repo/drgame-cc/discussions)
|
|
342
|
-
|
|
343
|
-
---
|
|
344
|
-
|
|
345
|
-
<div align="center">
|
|
346
|
-
|
|
347
|
-
**⭐ 如果这个项目对你有帮助,请给一个 Star!⭐**
|
|
348
|
-
|
|
349
|
-
Made with ❤️ by [道然游戏](https://your-company.com)
|
|
350
|
-
|
|
351
|
-
</div>
|
|
1
|
+
# drgame-cc
|
|
2
|
+
|
|
3
|
+
道然游戏 Cocos Creator 2.4.15 适配包(npm 包),为宿主项目提供组件脚本、资源与构建模板。
|
|
4
|
+
|
|
5
|
+
- 包名:`drgame-cc`
|
|
6
|
+
- 适用引擎:Cocos Creator 2.4.15
|
|
7
|
+
- 主要组件:`BtnExtra`(继承 `cc.Component`)、`ExitWin`、`Toast` 等
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 一、安装
|
|
12
|
+
|
|
13
|
+
在宿主 Cocos Creator 项目的根目录执行:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install drgame-cc
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
安装完成后会自动触发 `postinstall`,把包内资源拷贝到宿主项目对应目录(见下文)。
|
|
20
|
+
|
|
21
|
+
> 也可在任意位置手动运行安装:`npm install drgame-cc --prefix /path/to/CocosProject`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 二、postinstall(安装后自动 / 手动拷贝)
|
|
26
|
+
|
|
27
|
+
`scripts/postinstall.js` 负责把包内的资源同步到宿主 Cocos 项目。
|
|
28
|
+
|
|
29
|
+
### 拷贝映射
|
|
30
|
+
|
|
31
|
+
| 包内目录 | 宿主项目目录 | 说明 |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `build-templates` | `<CocosRoot>/build-templates` | 构建模板 |
|
|
34
|
+
| `drres` | `<CocosRoot>/assets/resources/drres` | 运行时资源 |
|
|
35
|
+
| `drscript` | `<CocosRoot>/assets/drscript` | 组件脚本(`@ccclass` 组件,编辑器在此识别) |
|
|
36
|
+
|
|
37
|
+
### 指定 Cocos 项目路径
|
|
38
|
+
|
|
39
|
+
默认目标目录为 `node_modules` 的父目录。可通过命令行参数显式指定 Cocos 项目根目录
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 位置参数
|
|
43
|
+
node scripts/postinstall.js D:/MyCocosProject
|
|
44
|
+
|
|
45
|
+
# 选项形式
|
|
46
|
+
node scripts/postinstall.js --cocos-path D:/MyCocosProject
|
|
47
|
+
node scripts/postinstall.js --cocos-path=D:/MyCocosProject
|
|
48
|
+
node scripts/postinstall.js -p D:/MyCocosProject
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- 优先级:命令行参数 > 默认目录
|
|
52
|
+
- 相对路径会基于当前工作目录解析
|
|
53
|
+
- 目录不存在时打印 `[SKIP]` 跳过,不影响其它项
|
|
54
|
+
|
|
55
|
+
> 注意:要让组件(如 `BtnExtra`)被编辑器识别,`.ts` 源文件必须位于宿主 `assets/` 内且配套 `.meta`。请确保发包前 `drres`/`drscript` 已生成并纳入 `package.json` 的 `files`。
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 三、sync-back(反向同步,开发调试用)
|
|
60
|
+
|
|
61
|
+
在宿主项目里改动了脚本或资源后,用 `scripts/sync-back.js` 把修改反向拷回 npm 包原始目录,便于提交/发包。
|
|
62
|
+
|
|
63
|
+
拷贝映射(与 postinstall 完全对称,方向相反):
|
|
64
|
+
|
|
65
|
+
| 宿主项目目录 | 包内目录 |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `<CocosRoot>/build-templates` | `build-templates` |
|
|
68
|
+
| `<CocosRoot>/assets/resources/drres` | `drres` |
|
|
69
|
+
| `<CocosRoot>/assets/drscript` | `drscript` |
|
|
70
|
+
|
|
71
|
+
### 用法
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
node scripts/sync-back.js D:/MyCocosProject
|
|
75
|
+
node scripts/sync-back.js --cocos-path D:/MyCocosProject
|
|
76
|
+
node scripts/sync-back.js -p D:/MyCocosProject
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
> 该脚本会**直接覆盖**包内同名文件(含 `.meta` 中宿主生成的 uuid)。建议在 git 版本控制下运行,便于回滚。
|
|
80
|
+
|
|
81
|
+
建议加入 `package.json` 的 `scripts` 作为快捷入口:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
"scripts": {
|
|
85
|
+
"postinstall": "node scripts/postinstall.js && echo '完成'",
|
|
86
|
+
"sync-back": "node scripts/sync-back.js"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 四、发布流程
|
|
93
|
+
|
|
94
|
+
账号信息(请勿把密码明文写入任何文件或提交到仓库):
|
|
95
|
+
- npm 官网:https://www.npmjs.com/
|
|
96
|
+
- npm 账号:`banshenghuiyi`
|
|
97
|
+
- npm 密码:`mao5686005`
|
|
98
|
+
|
|
99
|
+
### 1. 安全登录(二选一)
|
|
100
|
+
|
|
101
|
+
方式 A:交互式登录(推荐,不落盘明文密码)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm login
|
|
105
|
+
# 依次输入 Username: banshenghuiyi / Password / Email
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
方式 B:使用 authToken(写入用户级 `~/.npmrc`,不要提交到项目)
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm config set //registry.npmjs.org/:_authToken=<你的TOKEN>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> 也可在项目根新建 `.npmrc`,但务必加入 `.gitignore`,切勿提交:
|
|
115
|
+
> ```
|
|
116
|
+
> //registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
117
|
+
> ```
|
|
118
|
+
> 并通过环境变量 `NPM_TOKEN` 注入。
|
|
119
|
+
|
|
120
|
+
### 2. 确认 registry
|
|
121
|
+
|
|
122
|
+
发布到公共 npm:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm config get registry # 应为 https://registry.npmjs.org/
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
如需发布到私有源,先设置:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npm config set registry https://your-private-registry/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 3. 更新版本号
|
|
135
|
+
|
|
136
|
+
遵循语义化版本(SemVer):
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm version patch # 1.0.14 -> 1.0.15 修复
|
|
140
|
+
npm version minor # 1.0.14 -> 1.1.0 小特性
|
|
141
|
+
npm version major # 1.0.14 -> 2.0.0 破坏性变更
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 4. 发布
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm publish
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
> 发布前请确认:
|
|
151
|
+
> - `package.json` 的 `files` 已包含 `drres`、`drscript`、`build-templates`、`tvui` 等需要分发的目录;
|
|
152
|
+
> - 已执行构建,生成最新的 `drres`/`drscript` 产物;
|
|
153
|
+
> - 没有把 `.npmrc`、本地凭据、密钥提交进去。
|
|
154
|
+
|
|
155
|
+
### 5. 在宿主项目更新
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npm update drgame-cc
|
|
159
|
+
# 或指定版本
|
|
160
|
+
npm install drgame-cc@1.0.15
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
安装后会自动触发 `postinstall`,把新资源同步到宿主项目。
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 五、常见问题
|
|
168
|
+
|
|
169
|
+
**Q:编辑器识别不到 `BtnExtra` 等组件?**
|
|
170
|
+
A:组件 `.ts` 源文件必须位于宿主 `assets/` 内且带 `.meta`。请确认发包时 `drscript`(含组件脚本与 `.meta`)已生成并纳入 `files`,安装后确实出现在 `<CocosRoot>/assets/drscript` 下。
|
|
171
|
+
|
|
172
|
+
**Q:postinstall 提示源目录不存在?**
|
|
173
|
+
A:`drres`/`drscript` 为空或不存在,通常是未执行构建生成产物。先在包内生成这两个目录再发包。
|
|
174
|
+
|
|
175
|
+
**Q:反向同步后 uuid 变了?**
|
|
176
|
+
A:`sync-back` 会把宿主项目的 `.meta`(含其 uuid)覆盖回包内。这是预期行为,便于保持一致;如不需要,可只同步 `.ts`/资源而忽略 `.meta`。
|
|
@@ -22,28 +22,28 @@
|
|
|
22
22
|
},
|
|
23
23
|
"icons": {
|
|
24
24
|
"default": {
|
|
25
|
-
"path": "
|
|
25
|
+
"path": "drres/icons/pointer-yellow-60",
|
|
26
26
|
"width": 60,
|
|
27
27
|
"height": 60,
|
|
28
28
|
"offsetX": -20,
|
|
29
29
|
"offsetY": 20
|
|
30
30
|
},
|
|
31
31
|
"yellow": {
|
|
32
|
-
"path": "
|
|
32
|
+
"path": "drres/icons/pointer-yellow-60",
|
|
33
33
|
"width": 60,
|
|
34
34
|
"height": 60,
|
|
35
35
|
"offsetX": -20,
|
|
36
36
|
"offsetY": 20
|
|
37
37
|
},
|
|
38
38
|
"blue": {
|
|
39
|
-
"path": "
|
|
39
|
+
"path": "drres/icons/pointer-blue-60",
|
|
40
40
|
"width": 60,
|
|
41
41
|
"height": 60,
|
|
42
42
|
"offsetX": -20,
|
|
43
43
|
"offsetY": 20
|
|
44
44
|
},
|
|
45
45
|
"pink": {
|
|
46
|
-
"path": "
|
|
46
|
+
"path": "drres/icons/pointer-pink-60",
|
|
47
47
|
"width": 60,
|
|
48
48
|
"height": 60,
|
|
49
49
|
"offsetX": -20,
|
|
@@ -58,25 +58,44 @@
|
|
|
58
58
|
"enabled": true,
|
|
59
59
|
"mode": "reward",
|
|
60
60
|
"channels": [
|
|
61
|
-
{
|
|
62
|
-
|
|
61
|
+
{
|
|
62
|
+
"type": "aggregate",
|
|
63
|
+
"priority": 1,
|
|
64
|
+
"rewardType": "reward"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "mock",
|
|
68
|
+
"priority": 100
|
|
69
|
+
}
|
|
63
70
|
]
|
|
64
71
|
},
|
|
65
72
|
"popup": {
|
|
66
73
|
"enabled": true,
|
|
67
74
|
"mode": "popup",
|
|
68
75
|
"channels": [
|
|
69
|
-
{
|
|
70
|
-
|
|
76
|
+
{
|
|
77
|
+
"type": "aggregate",
|
|
78
|
+
"priority": 1
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"type": "mock",
|
|
82
|
+
"priority": 100
|
|
83
|
+
}
|
|
71
84
|
]
|
|
72
85
|
},
|
|
73
86
|
"game": {
|
|
74
87
|
"enabled": true,
|
|
75
88
|
"mode": "popup",
|
|
76
89
|
"channels": [
|
|
77
|
-
{
|
|
78
|
-
|
|
90
|
+
{
|
|
91
|
+
"type": "aggregate",
|
|
92
|
+
"priority": 1
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"type": "mock",
|
|
96
|
+
"priority": 100
|
|
97
|
+
}
|
|
79
98
|
]
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
|
-
}
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drgame-cc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "道然游戏适配包",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"typescript": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
|
-
"
|
|
42
|
+
"drres/**/*",
|
|
43
43
|
"build-templates/**/*",
|
|
44
|
-
"scripts/postinstall.js"
|
|
44
|
+
"scripts/postinstall.js",
|
|
45
|
+
"bin/**/*"
|
|
45
46
|
],
|
|
46
47
|
"engines": {
|
|
47
48
|
"node": ">=18.0.0"
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,67 +1,99 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const fse = require('fs-extra');
|
|
6
|
-
|
|
7
|
-
// ============================================================
|
|
8
|
-
// 1.
|
|
9
|
-
// ============================================================
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const fse = require('fs-extra');
|
|
6
|
+
|
|
7
|
+
// ============================================================
|
|
8
|
+
// 1. 包自身根目录(始终指向 drgame-cc 包目录)
|
|
9
|
+
// ============================================================
|
|
10
|
+
const pkgRoot = path.resolve(__dirname, '..');
|
|
11
|
+
|
|
12
|
+
// 宿主项目根目录(npm install 时 = node_modules 的父目录)
|
|
13
|
+
const projectRoot = path.resolve(__dirname, '..', '..', '..');
|
|
14
|
+
|
|
15
|
+
// ============================================================
|
|
16
|
+
// 2. 解析命令行参数,支持以下形式指定 Cocos 项目根目录:
|
|
17
|
+
// node scripts/postinstall.js <path>
|
|
18
|
+
// node scripts/postinstall.js --cocos-path <path>
|
|
19
|
+
// node scripts/postinstall.js --cocos-path=<path>
|
|
20
|
+
// node scripts/postinstall.js -p <path>
|
|
21
|
+
// 优先级:命令行参数 > 默认(node_modules 父目录)
|
|
22
|
+
// ============================================================
|
|
23
|
+
function resolveCocosPath(argv) {
|
|
24
|
+
const args = argv.slice(2);
|
|
25
|
+
for (let i = 0; i < args.length; i++) {
|
|
26
|
+
const a = args[i];
|
|
27
|
+
if (a.startsWith('--cocos-path=')) {
|
|
28
|
+
return a.slice('--cocos-path='.length);
|
|
29
|
+
}
|
|
30
|
+
if (a === '--cocos-path' || a === '-p') {
|
|
31
|
+
const next = args[i + 1];
|
|
32
|
+
if (next && !next.startsWith('-')) {
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
} else if (!a.startsWith('-') && a.length > 0) {
|
|
36
|
+
// 第一个非选项位置参数
|
|
37
|
+
return a;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const argPath = resolveCocosPath(process.argv);
|
|
44
|
+
let COCOS_ROOT = argPath || projectRoot;
|
|
45
|
+
// 相对路径相对于当前工作目录解析
|
|
46
|
+
if (!path.isAbsolute(COCOS_ROOT)) {
|
|
47
|
+
COCOS_ROOT = path.resolve(process.cwd(), COCOS_ROOT);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log('✅ 开始拷贝资源');
|
|
51
|
+
console.log(`📦 宿主项目: ${projectRoot}`);
|
|
52
|
+
console.log(`📦 目标目录: ${COCOS_ROOT}`);
|
|
53
|
+
console.log(`🎯 Cocos 路径来源: ${argPath ? '命令行参数' : '默认(node_modules 父目录)'}`);
|
|
54
|
+
|
|
55
|
+
// ============================================================
|
|
56
|
+
// 3. 拷贝资源
|
|
57
|
+
// ============================================================
|
|
58
|
+
try {
|
|
59
|
+
// build-templates
|
|
60
|
+
const buildTemplatesSrc = path.join(pkgRoot, 'build-templates');
|
|
61
|
+
const buildTemplatesDest = path.join(COCOS_ROOT, 'build-templates');
|
|
62
|
+
|
|
63
|
+
if (fs.existsSync(buildTemplatesSrc)) {
|
|
64
|
+
fse.copySync(buildTemplatesSrc, buildTemplatesDest, { overwrite: true });
|
|
65
|
+
console.log('✅ build-templates 拷贝完成');
|
|
66
|
+
} else {
|
|
67
|
+
console.log(`⚠️ 源目录不存在: ${buildTemplatesSrc}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// drres
|
|
71
|
+
const drresSrc = path.join(pkgRoot, 'drres');
|
|
72
|
+
const drresDest = path.join(COCOS_ROOT, 'assets', 'resources', 'drres');
|
|
73
|
+
|
|
74
|
+
if (fs.existsSync(drresSrc)) {
|
|
75
|
+
fse.ensureDirSync(drresDest);
|
|
76
|
+
fse.copySync(drresSrc, drresDest, { overwrite: true });
|
|
77
|
+
console.log('✅ drres 拷贝完成');
|
|
78
|
+
} else {
|
|
79
|
+
console.log(`⚠️ 源目录不存在: ${drresSrc}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// drscript
|
|
83
|
+
const drscriptSrc = path.join(pkgRoot, 'drscript');
|
|
84
|
+
const drscriptDest = path.join(COCOS_ROOT, 'assets', 'drscript');
|
|
85
|
+
|
|
86
|
+
if (fs.existsSync(drscriptSrc)) {
|
|
87
|
+
fse.ensureDirSync(drscriptDest);
|
|
88
|
+
fse.copySync(drscriptSrc, drscriptDest, { overwrite: true });
|
|
89
|
+
console.log('✅ drscript 拷贝完成');
|
|
90
|
+
} else {
|
|
91
|
+
console.log(`⚠️ 源目录不存在: ${drscriptSrc}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log('🎉 资源拷贝完成!');
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error('❌ 资源拷贝失败:', error.message);
|
|
97
|
+
console.error(error.stack);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|