ai-yuca 1.1.1 → 1.1.2
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 +333 -33
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,71 +10,371 @@ npm install -g ai-yuca
|
|
|
10
10
|
|
|
11
11
|
## 使用方法
|
|
12
12
|
|
|
13
|
+
### 分析文本
|
|
14
|
+
|
|
13
15
|
```bash
|
|
14
|
-
|
|
16
|
+
# 分析文件
|
|
17
|
+
ai-yuca analyze -f path/to/file.txt
|
|
18
|
+
|
|
19
|
+
# 分析文本
|
|
20
|
+
ai-yuca analyze -t "要分析的文本内容"
|
|
15
21
|
```
|
|
16
22
|
|
|
17
|
-
###
|
|
23
|
+
### 文件上传
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 上传文件到GCP存储桶
|
|
27
|
+
ai-yuca upload -s ./dist -b my-bucket -d static/app
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
- `upload`: 上传文件到GCP存储桶
|
|
29
|
+
# 基于配置文件上传
|
|
30
|
+
ai-yuca upload-config
|
|
31
|
+
```
|
|
23
32
|
|
|
24
|
-
###
|
|
33
|
+
### 文件下载
|
|
25
34
|
|
|
26
35
|
```bash
|
|
27
|
-
#
|
|
28
|
-
ai-yuca
|
|
36
|
+
# 从GCP存储桶下载文件
|
|
37
|
+
ai-yuca download -s static/app -b my-bucket -d ./downloads
|
|
38
|
+
```
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
ai-yuca upload --source path/to/file.txt --bucket your-bucket-name --key-file path/to/keyfile.json
|
|
40
|
+
### 部署
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
```bash
|
|
43
|
+
# 部署到指定环境
|
|
44
|
+
ai-yuca deploy -e test
|
|
45
|
+
|
|
46
|
+
# 部署到生产环境
|
|
47
|
+
ai-yuca deploy -e production
|
|
48
|
+
```
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
ai-yuca upload --source file1.txt file2.txt file3.txt --bucket your-bucket-name --key-file path/to/keyfile.json
|
|
50
|
+
### 初始化配置
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
```bash
|
|
53
|
+
# 生成配置文件
|
|
54
|
+
ai-yuca init
|
|
41
55
|
```
|
|
42
56
|
|
|
43
|
-
##
|
|
57
|
+
## 可用命令
|
|
44
58
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
- 支持多种GCP认证方式,包括密钥文件和应用默认凭证(免密上传)
|
|
49
|
-
- 完整的TypeScript类型支持
|
|
50
|
-
- 可扩展的插件系统
|
|
59
|
+
### `analyze` - 分析文本内容
|
|
60
|
+
- `-f, --file <path>` - 指定要分析的文件路径
|
|
61
|
+
- `-t, --text <text>` - 直接分析提供的文本
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
### `upload` - 上传文件到GCP存储桶
|
|
64
|
+
- `-s, --source <paths...>` - 指定要上传的文件或目录路径(支持多个)
|
|
65
|
+
- `-b, --bucket <name>` - GCP存储桶名称
|
|
66
|
+
- `-d, --destination <path>` - 目标路径(存储桶中的路径)
|
|
67
|
+
- `-k, --key-file <path>` - GCP服务账号密钥文件路径(可选)
|
|
68
|
+
- `-r, --recursive` - 递归上传目录中的文件
|
|
69
|
+
- `-c, --no-compression` - 禁用GZIP压缩
|
|
53
70
|
|
|
54
|
-
###
|
|
71
|
+
### `download` - 从GCP存储桶下载文件或文件夹
|
|
72
|
+
- `-s, --source <path>` - 指定要下载的GCP存储桶中的文件或目录路径
|
|
73
|
+
- `-b, --bucket <name>` - GCP存储桶名称
|
|
74
|
+
- `-d, --destination <path>` - 本地目标路径
|
|
75
|
+
- `-k, --key-file <path>` - GCP服务账号密钥文件路径(可选)
|
|
76
|
+
- `-r, --recursive` - 递归下载目录中的文件
|
|
55
77
|
|
|
78
|
+
### `upload-config` - 基于vs.config.json配置文件上传文件
|
|
79
|
+
- `-c, --config <path>` - 指定配置文件路径(默认为vs.config.json)
|
|
80
|
+
- `-k, --key-file <path>` - GCP服务账号密钥文件路径(可选)
|
|
81
|
+
- `-s, --source <path>` - 自定义源路径(覆盖配置文件中的uploadPath)
|
|
82
|
+
- `-d, --destination <path>` - 自定义目标路径
|
|
83
|
+
- `--no-recursive` - 禁用递归上传
|
|
84
|
+
- `--no-compression` - 禁用GZIP压缩
|
|
85
|
+
- `--no-cache` - 禁用文件缓存功能
|
|
86
|
+
- `--cache-file <path>` - 指定缓存文件路径
|
|
87
|
+
- `--show-config` - 仅显示配置信息,不执行上传
|
|
88
|
+
|
|
89
|
+
### `deploy` - 部署文件到指定环境
|
|
90
|
+
- `-e, --env <environment>` - 部署环境(如:dev、test、production)**(必需)**
|
|
91
|
+
- `-c, --config <path>` - 指定配置文件路径(默认为vs.config.json)
|
|
92
|
+
- `-k, --key-file <path>` - GCP服务账号密钥文件路径(可选)
|
|
93
|
+
- `-s, --source <path>` - 自定义源路径
|
|
94
|
+
- `-d, --destination <path>` - 自定义目标路径
|
|
95
|
+
- `--no-recursive` - 禁用递归上传
|
|
96
|
+
- `--no-compression` - 禁用GZIP压缩
|
|
97
|
+
- `--no-cache` - 禁用文件缓存功能
|
|
98
|
+
- `--cache-file <path>` - 指定缓存文件路径
|
|
99
|
+
- `--show-config` - 仅显示配置信息,不执行部署
|
|
100
|
+
- `-f, --force` - 强制执行,跳过交互式确认
|
|
101
|
+
|
|
102
|
+
### `init` - 在当前目录生成vs.config.json配置文件
|
|
103
|
+
- `-f, --force` - 强制覆盖已存在的配置文件
|
|
104
|
+
|
|
105
|
+
## 示例
|
|
106
|
+
|
|
107
|
+
### 文本分析
|
|
56
108
|
```bash
|
|
57
|
-
|
|
109
|
+
# 分析文件内容
|
|
110
|
+
ai-yuca analyze --file ./example.txt
|
|
111
|
+
|
|
112
|
+
# 分析指定文本
|
|
113
|
+
ai-yuca analyze --text "这是一段需要分析的文本"
|
|
58
114
|
```
|
|
59
115
|
|
|
60
|
-
###
|
|
116
|
+
### 文件上传
|
|
117
|
+
```bash
|
|
118
|
+
# 上传单个文件
|
|
119
|
+
ai-yuca upload -s ./dist/index.html -b my-bucket -d static/app/
|
|
120
|
+
|
|
121
|
+
# 上传整个目录(递归)
|
|
122
|
+
ai-yuca upload -s ./dist -b my-bucket -d static/app/ -r
|
|
123
|
+
|
|
124
|
+
# 上传多个文件/目录
|
|
125
|
+
ai-yuca upload -s ./dist ./assets -b my-bucket -d static/app/ -r
|
|
126
|
+
|
|
127
|
+
# 使用服务账号密钥文件
|
|
128
|
+
ai-yuca upload -s ./dist -b my-bucket -d static/app/ -k ./service-account.json
|
|
129
|
+
```
|
|
61
130
|
|
|
131
|
+
### 基于配置文件的上传
|
|
62
132
|
```bash
|
|
63
|
-
|
|
133
|
+
# 使用默认配置文件
|
|
134
|
+
ai-yuca upload-config
|
|
135
|
+
|
|
136
|
+
# 使用自定义配置文件
|
|
137
|
+
ai-yuca upload-config -c ./custom-config.json
|
|
138
|
+
|
|
139
|
+
# 覆盖配置文件中的源路径
|
|
140
|
+
ai-yuca upload-config -s ./build
|
|
141
|
+
|
|
142
|
+
# 仅显示配置信息
|
|
143
|
+
ai-yuca upload-config --show-config
|
|
64
144
|
```
|
|
65
145
|
|
|
66
|
-
###
|
|
146
|
+
### 文件下载
|
|
147
|
+
```bash
|
|
148
|
+
# 下载单个文件
|
|
149
|
+
ai-yuca download -s static/app/index.html -b my-bucket -d ./downloads/
|
|
67
150
|
|
|
151
|
+
# 递归下载整个目录
|
|
152
|
+
ai-yuca download -s static/app/ -b my-bucket -d ./downloads/ -r
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 部署
|
|
68
156
|
```bash
|
|
69
|
-
|
|
157
|
+
# 部署到测试环境
|
|
158
|
+
ai-yuca deploy -e test
|
|
159
|
+
|
|
160
|
+
# 部署到生产环境
|
|
161
|
+
ai-yuca deploy -e production
|
|
162
|
+
|
|
163
|
+
# 强制部署(跳过确认)
|
|
164
|
+
ai-yuca deploy -e test -f
|
|
165
|
+
|
|
166
|
+
# 仅显示部署配置
|
|
167
|
+
ai-yuca deploy -e test --show-config
|
|
70
168
|
```
|
|
71
169
|
|
|
72
|
-
###
|
|
170
|
+
### 初始化配置
|
|
171
|
+
```bash
|
|
172
|
+
# 生成默认配置文件
|
|
173
|
+
ai-yuca init
|
|
174
|
+
|
|
175
|
+
# 强制覆盖已存在的配置文件
|
|
176
|
+
ai-yuca init -f
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 配置文件
|
|
180
|
+
|
|
181
|
+
### vs.config.json 结构
|
|
182
|
+
|
|
183
|
+
使用 `ai-yuca init` 命令可以生成默认的配置文件,结构如下:
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"upload": {
|
|
188
|
+
"uploadPath": "out",
|
|
189
|
+
"s3Static": "static/aiAgent"
|
|
190
|
+
},
|
|
191
|
+
"deploy": {
|
|
192
|
+
"baseUrl": [
|
|
193
|
+
"/",
|
|
194
|
+
"en-us/",
|
|
195
|
+
"zh-cn/",
|
|
196
|
+
"de-de/",
|
|
197
|
+
"it-it/",
|
|
198
|
+
"pt-pt/",
|
|
199
|
+
"es-es/",
|
|
200
|
+
"fr-fr/",
|
|
201
|
+
"ru-ru/",
|
|
202
|
+
"error/",
|
|
203
|
+
"download-v2/"
|
|
204
|
+
],
|
|
205
|
+
"host": "",
|
|
206
|
+
"testHost": ""
|
|
207
|
+
},
|
|
208
|
+
"aws": {
|
|
209
|
+
"Bucket": "cdn",
|
|
210
|
+
"prefix": "fed",
|
|
211
|
+
"Region": "us-east-1",
|
|
212
|
+
"HostName": ""
|
|
213
|
+
},
|
|
214
|
+
"crowdin": {
|
|
215
|
+
"project": "project",
|
|
216
|
+
"langMap": ["zh-cn"],
|
|
217
|
+
"workDir": "src",
|
|
218
|
+
"reg": "{#(.+?)#}",
|
|
219
|
+
"keysDir": "src/_i18n",
|
|
220
|
+
"Bucket": "cdn",
|
|
221
|
+
"prefix": "fed",
|
|
222
|
+
"Region": "us-east-1",
|
|
223
|
+
"FromIni": "mall",
|
|
224
|
+
"HostName": ""
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 配置说明
|
|
230
|
+
|
|
231
|
+
- **upload.uploadPath**: 默认上传的本地源路径
|
|
232
|
+
- **upload.s3Static**: 存储桶中的目标路径
|
|
233
|
+
- **deploy.baseUrl**: 部署时支持的基础URL列表
|
|
234
|
+
- **deploy.host**: 生产环境主机地址
|
|
235
|
+
- **deploy.testHost**: 测试环境主机地址
|
|
236
|
+
- **aws.Bucket**: GCP存储桶名称
|
|
237
|
+
- **aws.prefix**: 存储桶中的前缀路径
|
|
238
|
+
- **aws.Region**: 存储桶区域
|
|
239
|
+
- **aws.HostName**: CDN主机名
|
|
240
|
+
|
|
241
|
+
## 特性
|
|
242
|
+
|
|
243
|
+
- 🔍 **文本分析**: 支持文件和直接文本分析
|
|
244
|
+
- ☁️ **云存储**: 支持上传/下载文件到Google Cloud Storage
|
|
245
|
+
- 🔐 **安全认证**: 支持服务账号密钥文件和应用默认凭证
|
|
246
|
+
- 📁 **批量操作**: 支持批量上传多个文件和递归上传目录
|
|
247
|
+
- 🚀 **高性能**: 使用Promise.all并行处理,提升上传/下载效率
|
|
248
|
+
- 🎨 **彩色输出**: 成功绿色、失败红色、跳过黄色的彩色终端输出
|
|
249
|
+
- ⚙️ **配置驱动**: 支持基于vs.config.json配置文件的操作
|
|
250
|
+
- 🗜️ **智能压缩**: 自动对js、css、json、html、woff文件启用GZIP压缩
|
|
251
|
+
- 📦 **部署功能**: 支持多环境部署(dev、test、production)
|
|
252
|
+
- 💾 **缓存机制**: 支持文件缓存,避免重复上传相同文件
|
|
253
|
+
- 🔧 **灵活配置**: 支持命令行参数覆盖配置文件设置
|
|
254
|
+
- 🛠️ **TypeScript**: 完整的TypeScript类型支持
|
|
255
|
+
- 🔌 **可扩展**: 可扩展的插件系统
|
|
256
|
+
|
|
257
|
+
## 开发
|
|
258
|
+
|
|
259
|
+
### 环境要求
|
|
260
|
+
|
|
261
|
+
- Node.js >= 14.0.0
|
|
262
|
+
- npm >= 6.0.0
|
|
263
|
+
- TypeScript >= 4.0.0
|
|
264
|
+
|
|
265
|
+
### 开发设置
|
|
73
266
|
|
|
74
267
|
```bash
|
|
268
|
+
# 克隆项目
|
|
269
|
+
git clone <repository-url>
|
|
270
|
+
cd ai-yuca
|
|
271
|
+
|
|
272
|
+
# 安装依赖
|
|
273
|
+
npm install
|
|
274
|
+
|
|
275
|
+
# 构建项目
|
|
276
|
+
npm run build
|
|
277
|
+
|
|
278
|
+
# 运行测试
|
|
75
279
|
npm test
|
|
280
|
+
|
|
281
|
+
# 开发模式(监听文件变化)
|
|
282
|
+
npm run dev
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 项目结构
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
ai-yuca/
|
|
289
|
+
├── bin/ # CLI入口文件
|
|
290
|
+
│ └── cli.ts # 命令行接口定义
|
|
291
|
+
├── src/ # 源代码
|
|
292
|
+
│ ├── index.ts # 主入口
|
|
293
|
+
│ ├── upload.ts # 上传功能
|
|
294
|
+
│ ├── download.ts # 下载功能
|
|
295
|
+
│ ├── deploy.ts # 部署功能
|
|
296
|
+
│ ├── uploadWithConfig.ts # 配置文件上传
|
|
297
|
+
│ └── types.ts # TypeScript类型定义
|
|
298
|
+
├── dist/ # 编译输出
|
|
299
|
+
├── package.json # 项目配置
|
|
300
|
+
└── README.md # 项目文档
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### 贡献指南
|
|
304
|
+
|
|
305
|
+
1. Fork 项目
|
|
306
|
+
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
|
307
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
308
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
309
|
+
5. 打开 Pull Request
|
|
310
|
+
|
|
311
|
+
### 发布流程
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# 更新版本号
|
|
315
|
+
npm version patch|minor|major
|
|
316
|
+
|
|
317
|
+
# 构建项目
|
|
318
|
+
npm run build
|
|
319
|
+
|
|
320
|
+
# 发布到npm
|
|
321
|
+
npm publish
|
|
76
322
|
```
|
|
77
323
|
|
|
324
|
+
## 常见问题
|
|
325
|
+
|
|
326
|
+
### Q: 如何设置GCP认证?
|
|
327
|
+
|
|
328
|
+
A: 有两种方式:
|
|
329
|
+
1. 使用服务账号密钥文件:`-k path/to/service-account.json`
|
|
330
|
+
2. 使用应用默认凭证:设置环境变量 `GOOGLE_APPLICATION_CREDENTIALS`
|
|
331
|
+
|
|
332
|
+
### Q: 上传失败怎么办?
|
|
333
|
+
|
|
334
|
+
A: 检查以下几点:
|
|
335
|
+
1. 确认GCP认证配置正确
|
|
336
|
+
2. 确认存储桶名称和权限
|
|
337
|
+
3. 检查网络连接
|
|
338
|
+
4. 查看详细错误信息
|
|
339
|
+
|
|
340
|
+
### Q: 如何自定义压缩设置?
|
|
341
|
+
|
|
342
|
+
A: 使用 `--no-compression` 参数禁用压缩,或在配置文件中设置相关选项。
|
|
343
|
+
|
|
344
|
+
### Q: 支持哪些文件类型的压缩?
|
|
345
|
+
|
|
346
|
+
A: 默认对以下文件类型启用GZIP压缩:
|
|
347
|
+
- JavaScript (.js)
|
|
348
|
+
- CSS (.css)
|
|
349
|
+
- JSON (.json)
|
|
350
|
+
- HTML (.html)
|
|
351
|
+
- Web字体 (.woff)
|
|
352
|
+
|
|
353
|
+
## 更新日志
|
|
354
|
+
|
|
355
|
+
### v1.0.0
|
|
356
|
+
- 🎉 初始版本发布
|
|
357
|
+
- ✨ 支持文本分析功能
|
|
358
|
+
- ✨ 支持GCP存储桶上传/下载
|
|
359
|
+
- ✨ 支持配置文件驱动的操作
|
|
360
|
+
- ✨ 支持多环境部署
|
|
361
|
+
- ✨ 支持并行处理和彩色输出
|
|
362
|
+
|
|
78
363
|
## 许可证
|
|
79
364
|
|
|
80
|
-
MIT
|
|
365
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
366
|
+
|
|
367
|
+
## 联系方式
|
|
368
|
+
|
|
369
|
+
- 作者:[Your Name]
|
|
370
|
+
- 邮箱:[your.email@example.com]
|
|
371
|
+
- 项目主页:[https://github.com/yourusername/ai-yuca]
|
|
372
|
+
- 问题反馈:[https://github.com/yourusername/ai-yuca/issues]
|
|
373
|
+
|
|
374
|
+
## 致谢
|
|
375
|
+
|
|
376
|
+
感谢所有贡献者和开源社区的支持!
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
**如果这个项目对您有帮助,请给我们一个 ⭐️!**
|
package/dist/package.json
CHANGED