cocos-obfuscator 1.0.0
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/GITEE.md +331 -0
- package/README/INSTALL.md +261 -0
- package/README/QUICKSTART.md +160 -0
- package/README/README.md +130 -0
- package/README/USAGE.md +100 -0
- package/README//345/234/250/345/205/266/344/273/226/351/241/271/347/233/256/344/270/255/344/275/277/347/224/250.md +252 -0
- package/README//345/256/211/350/243/205/346/226/271/346/263/225/346/200/273/347/273/223.md +267 -0
- package/index.js +361 -0
- package/package.json +34 -0
package/README/GITEE.md
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
# 使用 Gitee 托管和安装
|
|
2
|
+
|
|
3
|
+
## ⚠️ 重要说明
|
|
4
|
+
|
|
5
|
+
**Gitee 目前不支持 npm 包托管功能**,但可以通过以下方式使用:
|
|
6
|
+
|
|
7
|
+
1. ✅ **从 Gitee Git 仓库直接安装**(推荐)
|
|
8
|
+
2. ✅ **使用其他私有 npm 仓库**(如 Verdaccio、GitLab 等)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 方法一:从 Gitee Git 仓库安装(推荐)
|
|
13
|
+
|
|
14
|
+
这是最简单的方法,直接将代码推送到 Gitee,然后从 Git 仓库安装。
|
|
15
|
+
|
|
16
|
+
### 步骤 1:推送到 Gitee
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 在 cocos-obfuscator 目录初始化 Git(如果还没有)
|
|
20
|
+
cd cocos-obfuscator
|
|
21
|
+
git init
|
|
22
|
+
|
|
23
|
+
# 添加文件
|
|
24
|
+
git add .
|
|
25
|
+
|
|
26
|
+
# 提交
|
|
27
|
+
git commit -m "Initial commit: Cocos Obfuscator"
|
|
28
|
+
|
|
29
|
+
# 在 Gitee 上创建仓库,然后添加远程仓库
|
|
30
|
+
git remote add origin https://gitee.com/your-username/cocos-obfuscator.git
|
|
31
|
+
|
|
32
|
+
# 推送代码
|
|
33
|
+
git push -u origin master
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 步骤 2:在其他项目中安装
|
|
37
|
+
|
|
38
|
+
#### 公开仓库
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install git+https://gitee.com/your-username/cocos-obfuscator.git
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
或在 `package.json` 中:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"cocos-obfuscator": "git+https://gitee.com/your-username/cocos-obfuscator.git"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### 私有仓库(需要认证)
|
|
55
|
+
|
|
56
|
+
**方式 A:使用 HTTPS + 用户名密码**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install git+https://username:password@gitee.com/your-username/cocos-obfuscator.git
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**方式 B:使用 SSH(推荐)**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install git+ssh://git@gitee.com/your-username/cocos-obfuscator.git
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
或在 `package.json` 中:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"cocos-obfuscator": "git+ssh://git@gitee.com/your-username/cocos-obfuscator.git"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**方式 C:使用 Gitee Token**
|
|
79
|
+
|
|
80
|
+
1. 在 Gitee 生成访问令牌:设置 → 安全设置 → 私人令牌
|
|
81
|
+
2. 使用令牌安装:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install git+https://your-token@gitee.com/your-username/cocos-obfuscator.git
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 步骤 3:指定版本或分支
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"cocos-obfuscator": "git+https://gitee.com/your-username/cocos-obfuscator.git#v1.0.0",
|
|
93
|
+
"cocos-obfuscator": "git+https://gitee.com/your-username/cocos-obfuscator.git#develop"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 步骤 4:使用
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# 安装后使用
|
|
102
|
+
npx cocos-obfuscate
|
|
103
|
+
|
|
104
|
+
# 或在 package.json 中添加脚本
|
|
105
|
+
npm run obfuscate
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 方法二:使用私有 npm 仓库
|
|
111
|
+
|
|
112
|
+
如果 Gitee 不支持,可以使用其他私有 npm 仓库方案:
|
|
113
|
+
|
|
114
|
+
### 方案 A:Verdaccio(自建私有 npm 仓库)
|
|
115
|
+
|
|
116
|
+
#### 1. 安装 Verdaccio
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install -g verdaccio
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### 2. 启动 Verdaccio
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
verdaccio
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
默认运行在 `http://localhost:4873`
|
|
129
|
+
|
|
130
|
+
#### 3. 配置 npm 使用 Verdaccio
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm config set registry http://localhost:4873
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### 4. 发布包
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cd cocos-obfuscator
|
|
140
|
+
npm publish
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### 5. 在其他项目中安装
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm install cocos-obfuscator
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 方案 B:GitLab Package Registry
|
|
150
|
+
|
|
151
|
+
如果团队使用 GitLab:
|
|
152
|
+
|
|
153
|
+
#### 1. 配置 .npmrc
|
|
154
|
+
|
|
155
|
+
在 `cocos-obfuscator` 目录创建 `.npmrc`:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
@your-scope:registry=https://gitlab.com/api/v4/packages/npm/
|
|
159
|
+
//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### 2. 更新 package.json
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"name": "@your-scope/cocos-obfuscator",
|
|
167
|
+
"publishConfig": {
|
|
168
|
+
"@your-scope:registry": "https://gitlab.com/api/v4/projects/YOUR_PROJECT_ID/packages/npm/"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### 3. 发布
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npm publish
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 方案 C:华为云 CodeArts Artifact
|
|
180
|
+
|
|
181
|
+
#### 1. 创建 npm 私有仓库
|
|
182
|
+
|
|
183
|
+
在华为云 CodeArts 中创建 npm 私有仓库
|
|
184
|
+
|
|
185
|
+
#### 2. 配置认证
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npm config set registry https://your-registry-url
|
|
189
|
+
npm login --registry=https://your-registry-url
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### 3. 发布
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
cd cocos-obfuscator
|
|
196
|
+
npm publish
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 方法三:使用 Gitee + npm link(本地开发)
|
|
202
|
+
|
|
203
|
+
适合本地开发,结合 Gitee 做版本控制:
|
|
204
|
+
|
|
205
|
+
### 步骤 1:克隆到本地
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
git clone https://gitee.com/your-username/cocos-obfuscator.git
|
|
209
|
+
cd cocos-obfuscator
|
|
210
|
+
npm install
|
|
211
|
+
npm link
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 步骤 2:在其他项目中使用
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
cd /path/to/your/project
|
|
218
|
+
npm link cocos-obfuscator
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 推荐方案对比
|
|
224
|
+
|
|
225
|
+
| 方案 | 优点 | 缺点 | 适用场景 |
|
|
226
|
+
|------|------|------|----------|
|
|
227
|
+
| **Gitee Git 安装** | 简单,无需额外服务 | 安装较慢,无版本管理 | 小团队,私有项目 |
|
|
228
|
+
| **Verdaccio** | 完全控制,快速 | 需要服务器,需维护 | 大团队,企业内网 |
|
|
229
|
+
| **GitLab Package** | 集成 GitLab,功能完善 | 需要 GitLab 服务 | 使用 GitLab 的团队 |
|
|
230
|
+
| **华为云 CodeArts** | 国内访问快,企业级 | 需要付费(部分功能) | 企业用户 |
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 完整示例:从 Gitee 安装
|
|
235
|
+
|
|
236
|
+
### 1. 在 Gitee 创建仓库
|
|
237
|
+
|
|
238
|
+
- 仓库名:`cocos-obfuscator`
|
|
239
|
+
- 设置为私有(如果需要)
|
|
240
|
+
|
|
241
|
+
### 2. 推送代码
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
cd cocos-obfuscator
|
|
245
|
+
git init
|
|
246
|
+
git add .
|
|
247
|
+
git commit -m "Initial commit"
|
|
248
|
+
git remote add origin https://gitee.com/your-username/cocos-obfuscator.git
|
|
249
|
+
git push -u origin master
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 3. 在其他项目中安装
|
|
253
|
+
|
|
254
|
+
创建或编辑 `package.json`:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"name": "my-game",
|
|
259
|
+
"version": "1.0.0",
|
|
260
|
+
"devDependencies": {
|
|
261
|
+
"cocos-obfuscator": "git+https://gitee.com/your-username/cocos-obfuscator.git"
|
|
262
|
+
},
|
|
263
|
+
"scripts": {
|
|
264
|
+
"obfuscate": "cocos-obfuscate"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 4. 安装和使用
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
npm install
|
|
273
|
+
npm run obfuscate
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## 私有仓库认证配置
|
|
279
|
+
|
|
280
|
+
### 使用 .npmrc 文件(推荐)
|
|
281
|
+
|
|
282
|
+
在项目根目录创建 `.npmrc`:
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
@gitee:registry=https://gitee.com/api/v4/packages/npm/
|
|
286
|
+
//gitee.com/api/v4/packages/npm/:_authToken=YOUR_TOKEN
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**注意**:Gitee 目前不支持 npm registry,此方法仅适用于其他支持 npm 的 Git 服务(如 GitLab)。
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## 常见问题
|
|
294
|
+
|
|
295
|
+
### Q: Gitee 支持 npm 包托管吗?
|
|
296
|
+
|
|
297
|
+
A: 目前不支持。但可以从 Git 仓库直接安装。
|
|
298
|
+
|
|
299
|
+
### Q: 如何更新从 Git 安装的包?
|
|
300
|
+
|
|
301
|
+
A:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
npm update cocos-obfuscator
|
|
305
|
+
# 或
|
|
306
|
+
npm install git+https://gitee.com/your-username/cocos-obfuscator.git
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Q: 可以指定版本吗?
|
|
310
|
+
|
|
311
|
+
A: 可以,使用 Git 标签:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# 在 cocos-obfuscator 仓库中打标签
|
|
315
|
+
git tag v1.0.0
|
|
316
|
+
git push origin v1.0.0
|
|
317
|
+
|
|
318
|
+
# 在其他项目中安装指定版本
|
|
319
|
+
npm install git+https://gitee.com/your-username/cocos-obfuscator.git#v1.0.0
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Q: 私有仓库如何认证?
|
|
323
|
+
|
|
324
|
+
A: 使用 SSH 密钥或访问令牌(Token)。
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 总结
|
|
329
|
+
|
|
330
|
+
虽然 Gitee 不支持 npm 包托管,但**从 Git 仓库安装是最简单可行的方案**。对于需要完整 npm 仓库功能的团队,建议使用 Verdaccio 或其他支持 npm 的 Git 服务。
|
|
331
|
+
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# 在其他项目中使用 Cocos Obfuscator
|
|
2
|
+
|
|
3
|
+
## 方法一:使用 npm link(推荐 - 适合本地开发)
|
|
4
|
+
|
|
5
|
+
这是最简单的方法,适合在本地开发时使用。
|
|
6
|
+
|
|
7
|
+
### 步骤 1:在当前项目中链接包
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 进入 cocos-obfuscator 目录
|
|
11
|
+
cd cocos-obfuscator
|
|
12
|
+
|
|
13
|
+
# 创建全局链接
|
|
14
|
+
npm link
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 步骤 2:在其他项目中使用
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 进入你的其他 Cocos Creator 项目
|
|
21
|
+
cd /path/to/your/other/project
|
|
22
|
+
|
|
23
|
+
# 链接到全局包
|
|
24
|
+
npm link cocos-obfuscator
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 步骤 3:使用命令
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 交互式选择模式
|
|
31
|
+
cocos-obfuscate
|
|
32
|
+
|
|
33
|
+
# 或使用命令行参数
|
|
34
|
+
cocos-obfuscate --platform bytedance
|
|
35
|
+
cocos-obfuscate --platform wechatgame --include-subpackages
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 方法二:从本地路径安装(推荐 - 适合团队使用)
|
|
41
|
+
|
|
42
|
+
如果你的项目在同一个机器或共享目录中,可以直接从路径安装。
|
|
43
|
+
|
|
44
|
+
### 步骤 1:在其他项目的 package.json 中添加依赖
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"cocos-obfuscator": "file:../cocos-obfuscator"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**注意**:`../cocos-obfuscator` 是相对于其他项目的路径,请根据实际情况调整。
|
|
55
|
+
|
|
56
|
+
### 步骤 2:安装依赖
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cd /path/to/your/other/project
|
|
60
|
+
npm install
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 步骤 3:使用命令
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 使用 npx 运行
|
|
67
|
+
npx cocos-obfuscate
|
|
68
|
+
|
|
69
|
+
# 或在 package.json 中添加脚本
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
在 `package.json` 中添加:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"scripts": {
|
|
77
|
+
"obfuscate": "cocos-obfuscate",
|
|
78
|
+
"obfuscate:bytedance": "cocos-obfuscate --platform bytedance",
|
|
79
|
+
"obfuscate:wechat": "cocos-obfuscate --platform wechatgame --include-subpackages"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
然后运行:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm run obfuscate
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 方法三:发布到私有 npm 仓库(适合团队协作)
|
|
93
|
+
|
|
94
|
+
如果你的团队有私有 npm 仓库(如 npmjs.com、GitLab Package Registry、GitHub Packages 等)。
|
|
95
|
+
|
|
96
|
+
### 步骤 1:发布包
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
cd cocos-obfuscator
|
|
100
|
+
|
|
101
|
+
# 登录 npm(如果是私有仓库,需要配置 registry)
|
|
102
|
+
npm login
|
|
103
|
+
|
|
104
|
+
# 发布包
|
|
105
|
+
npm publish
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 步骤 2:在其他项目中安装
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
cd /path/to/your/other/project
|
|
112
|
+
npm install cocos-obfuscator --save-dev
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 步骤 3:使用
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx cocos-obfuscate
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 方法四:从 Git 仓库安装(适合版本控制,支持 Gitee)
|
|
124
|
+
|
|
125
|
+
如果包在 Git 仓库中(包括 Gitee、GitHub、GitLab 等),可以直接从 Git 安装。
|
|
126
|
+
|
|
127
|
+
### 步骤 1:推送到 Git 仓库(如 Gitee)
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
cd cocos-obfuscator
|
|
131
|
+
git init
|
|
132
|
+
git add .
|
|
133
|
+
git commit -m "Initial commit"
|
|
134
|
+
git remote add origin https://gitee.com/your-username/cocos-obfuscator.git
|
|
135
|
+
git push -u origin master
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 步骤 2:在其他项目的 package.json 中添加
|
|
139
|
+
|
|
140
|
+
**Gitee 公开仓库:**
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"devDependencies": {
|
|
145
|
+
"cocos-obfuscator": "git+https://gitee.com/your-username/cocos-obfuscator.git"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Gitee 私有仓库(使用 SSH):**
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"devDependencies": {
|
|
155
|
+
"cocos-obfuscator": "git+ssh://git@gitee.com/your-username/cocos-obfuscator.git"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**GitHub/GitLab:**
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"devDependencies": {
|
|
165
|
+
"cocos-obfuscator": "git+https://github.com/your-username/cocos-obfuscator.git"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 步骤 3:安装
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npm install
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 步骤 4:使用
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npx cocos-obfuscate
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**注意**:Gitee 目前不支持 npm 包托管,但可以从 Git 仓库直接安装。详细说明请查看 [GITEE.md](./GITEE.md)。
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 完整使用示例
|
|
187
|
+
|
|
188
|
+
假设你有一个新的 Cocos Creator 项目,想要使用混淆工具:
|
|
189
|
+
|
|
190
|
+
### 1. 安装包(选择一种方法)
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# 方法一:npm link
|
|
194
|
+
npm link cocos-obfuscator
|
|
195
|
+
|
|
196
|
+
# 方法二:从路径安装(在 package.json 中配置后)
|
|
197
|
+
npm install
|
|
198
|
+
|
|
199
|
+
# 方法三:从 npm 安装(如果已发布)
|
|
200
|
+
npm install cocos-obfuscator --save-dev
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 2. 在 package.json 中添加脚本(可选但推荐)
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"scripts": {
|
|
208
|
+
"build": "你的构建命令",
|
|
209
|
+
"obfuscate": "cocos-obfuscate",
|
|
210
|
+
"build:obfuscate": "npm run build && npm run obfuscate"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 3. 使用
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# 交互式选择
|
|
219
|
+
npm run obfuscate
|
|
220
|
+
|
|
221
|
+
# 或直接使用命令
|
|
222
|
+
cocos-obfuscate --platform bytedance
|
|
223
|
+
|
|
224
|
+
# 构建后自动混淆
|
|
225
|
+
npm run build:obfuscate
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 常见问题
|
|
231
|
+
|
|
232
|
+
### Q: 找不到命令?
|
|
233
|
+
|
|
234
|
+
A: 确保已经正确安装,使用 `npx cocos-obfuscate` 或 `npm run obfuscate`。
|
|
235
|
+
|
|
236
|
+
### Q: 如何更新包?
|
|
237
|
+
|
|
238
|
+
A:
|
|
239
|
+
- 如果使用 npm link:在 `cocos-obfuscator` 目录修改后,重新运行 `npm link`
|
|
240
|
+
- 如果使用 file: 路径:运行 `npm install` 重新安装
|
|
241
|
+
- 如果从 npm 安装:运行 `npm update cocos-obfuscator`
|
|
242
|
+
|
|
243
|
+
### Q: 可以全局安装吗?
|
|
244
|
+
|
|
245
|
+
A: 可以,但不推荐。如果确实需要:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
cd cocos-obfuscator
|
|
249
|
+
npm install -g .
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
然后可以在任何地方使用 `cocos-obfuscate` 命令。
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 推荐工作流程
|
|
257
|
+
|
|
258
|
+
1. **开发阶段**:使用 `npm link` 方法,方便调试和更新
|
|
259
|
+
2. **生产环境**:使用 `file:` 路径或发布到私有 npm 仓库
|
|
260
|
+
3. **团队协作**:发布到私有 npm 仓库或使用 Git 仓库安装
|
|
261
|
+
|