@zzclub/z-cli 1.0.0 → 1.0.1
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/package.json +5 -5
- package/readme.md +47 -78
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zzclub/z-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "all-in-one 工具箱,专为提升日常及工作效率而生",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"type-check": "bun run tsc --noEmit",
|
|
40
40
|
"prepublishOnly": "bun run type-check && bun run build",
|
|
41
41
|
"release": "bun run release:patch",
|
|
42
|
-
"release:patch": "bunx changelogen@latest --patch --release --push
|
|
43
|
-
"release:minor": "bunx changelogen@latest --minor --release --push
|
|
44
|
-
"release:major": "bunx changelogen@latest --major --release --push
|
|
45
|
-
"release:main": "bunx changelogen@latest -r 1.0.0 --release --push
|
|
42
|
+
"release:patch": "bunx changelogen@latest --patch --release --push",
|
|
43
|
+
"release:minor": "bunx changelogen@latest --minor --release --push",
|
|
44
|
+
"release:major": "bunx changelogen@latest --major --release --push",
|
|
45
|
+
"release:main": "bunx changelogen@latest -r 1.0.0 --release --push"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=18.18.0",
|
package/readme.md
CHANGED
|
@@ -222,105 +222,74 @@ z config --reset
|
|
|
222
222
|
}
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
-
## 🔌 Skills
|
|
225
|
+
## 🔌 在 Skills 中使用
|
|
226
226
|
|
|
227
|
-
如果你想在 OpenCode Skills
|
|
227
|
+
如果你想在 OpenCode Skills 或其他自动化脚本中使用 z-cli,推荐使用 `bunx` 或 `npx` 调用。
|
|
228
228
|
|
|
229
|
-
###
|
|
229
|
+
### 前置要求
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
// 在 skill 中使用 bash 工具调用
|
|
233
|
-
import { bash } from './tools';
|
|
231
|
+
确保已安装 Bun 或 Node.js:
|
|
234
232
|
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
```bash
|
|
234
|
+
# 检查 Bun 是否安装
|
|
235
|
+
bun --version
|
|
237
236
|
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
# 如果未安装,安装 Bun(推荐)
|
|
238
|
+
curl -fsSL https://bun.sh/install | bash # macOS/Linux
|
|
239
|
+
# 或
|
|
240
|
+
powershell -c "irm bun.sh/install.ps1 | iex" # Windows
|
|
240
241
|
```
|
|
241
242
|
|
|
242
|
-
###
|
|
243
|
+
### 基础用法
|
|
243
244
|
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
```bash
|
|
246
|
+
# 使用 bunx(推荐)
|
|
247
|
+
bunx @zzclub/z-cli tiny -f ./images -r -q 85
|
|
248
|
+
|
|
249
|
+
# 或使用 npx(Node.js)
|
|
250
|
+
npx @zzclub/z-cli tiny -f ./images -r -q 85
|
|
251
|
+
```
|
|
248
252
|
|
|
249
|
-
|
|
250
|
-
const compressor = new ImageCompressor({ quality: 80 });
|
|
253
|
+
### 在 Skill 的 skill.md 中使用
|
|
251
254
|
|
|
252
|
-
|
|
253
|
-
const result = await compressor.compress('./image.jpg', './output.jpg');
|
|
254
|
-
console.log(`压缩率: ${result.compressionRatio}%`);
|
|
255
|
+
直接在你的 Skill 说明中添加压缩命令即可:
|
|
255
256
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
recursive: true,
|
|
259
|
-
overwrite: false,
|
|
260
|
-
outputDir: './compressed'
|
|
261
|
-
});
|
|
257
|
+
```markdown
|
|
258
|
+
## 图片处理流程
|
|
262
259
|
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
1. 下载图片到 `./downloads` 目录
|
|
261
|
+
2. 压缩图片:
|
|
262
|
+
```bash
|
|
263
|
+
bunx @zzclub/z-cli tiny -f ./downloads -r -q 85 --output ./compressed
|
|
264
|
+
```
|
|
265
|
+
3. 上传压缩后的图片
|
|
265
266
|
```
|
|
266
267
|
|
|
267
|
-
###
|
|
268
|
-
|
|
269
|
-
如果你要创建一个图片压缩 Skill,可以在 `skill.json` 中配置:
|
|
268
|
+
### 常用命令
|
|
270
269
|
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
"version": "1.0.0",
|
|
275
|
-
"description": "使用 z-cli 压缩图片",
|
|
276
|
-
"dependencies": {
|
|
277
|
-
"@zzclub/z-cli": "^1.0.0"
|
|
278
|
-
},
|
|
279
|
-
"commands": {
|
|
280
|
-
"compress": {
|
|
281
|
-
"command": "z tiny -f {{file}} -q {{quality}} {{flags}}",
|
|
282
|
-
"parameters": {
|
|
283
|
-
"file": {
|
|
284
|
-
"type": "string",
|
|
285
|
-
"required": true,
|
|
286
|
-
"description": "要压缩的文件或目录"
|
|
287
|
-
},
|
|
288
|
-
"quality": {
|
|
289
|
-
"type": "number",
|
|
290
|
-
"default": 80,
|
|
291
|
-
"description": "压缩质量 (1-100)"
|
|
292
|
-
},
|
|
293
|
-
"flags": {
|
|
294
|
-
"type": "string",
|
|
295
|
-
"default": "",
|
|
296
|
-
"description": "额外的标志,如 -r -o"
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
```
|
|
270
|
+
```bash
|
|
271
|
+
# 压缩单个文件
|
|
272
|
+
bunx @zzclub/z-cli tiny -f ./image.jpg -q 80
|
|
303
273
|
|
|
304
|
-
|
|
274
|
+
# 递归压缩目录
|
|
275
|
+
bunx @zzclub/z-cli tiny -f ./images -r -q 85
|
|
305
276
|
|
|
306
|
-
|
|
307
|
-
|
|
277
|
+
# 压缩并覆盖原文件
|
|
278
|
+
bunx @zzclub/z-cli tiny -f ./images -r -o
|
|
308
279
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
const process = spawn('z', ['tiny', '-f', file, '-q', quality.toString()]);
|
|
312
|
-
|
|
313
|
-
process.on('close', (code) => {
|
|
314
|
-
if (code === 0) resolve();
|
|
315
|
-
else reject(new Error(`压缩失败,退出码: ${code}`));
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
}
|
|
280
|
+
# 压缩到指定目录
|
|
281
|
+
bunx @zzclub/z-cli tiny -f ./images -r --output ./compressed
|
|
319
282
|
|
|
320
|
-
|
|
321
|
-
|
|
283
|
+
# 查看帮助
|
|
284
|
+
bunx @zzclub/z-cli --help
|
|
322
285
|
```
|
|
323
286
|
|
|
287
|
+
### 优势
|
|
288
|
+
|
|
289
|
+
- ✅ **自动安装依赖** - bunx/npx 会自动下载 z-cli 及其依赖(包括 Sharp)
|
|
290
|
+
- ✅ **无需全局安装** - 每次运行时自动使用最新版本
|
|
291
|
+
- ✅ **简单直接** - 一行命令完成压缩
|
|
292
|
+
|
|
324
293
|
## 🛠️ 开发
|
|
325
294
|
|
|
326
295
|
### 克隆仓库
|