@zzclub/z-cli 0.7.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v0.8.0
5
+
6
+ [compare changes](https://github.com/aatrooox/z-cli/compare/v0.7.1...v0.8.0)
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - 翻译目标文件类型校验 ([cc87490](https://github.com/aatrooox/z-cli/commit/cc87490))
11
+
12
+ ### ❤️ Contributors
13
+
14
+ - Aatrox <gnakzz@qq.com>
15
+
16
+ ## v0.7.1
17
+
18
+ [compare changes](https://github.com/aatrooox/z-cli/compare/v0.7.0...v0.7.1)
19
+
20
+ ### 📖 Documentation
21
+
22
+ - 更新说明 ([459c72f](https://github.com/aatrooox/z-cli/commit/459c72f))
23
+
24
+ ### ❤️ Contributors
25
+
26
+ - Aatrox <gnakzz@qq.com>
27
+
4
28
  ## v0.7.0
5
29
 
6
30
  [compare changes](https://github.com/aatrooox/z-cli/compare/v0.6.2...v0.7.0)
package/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  **这是一个效率类命令行工具, 为了解决工作中或个人开发过程中的重复或繁琐问题**
4
4
 
5
- node >= 18.18.0
6
-
7
- 推荐版本(我的):`20.18.1`
8
-
9
5
  ## 功能一览
10
6
 
11
7
  - `i18n`: 提取 `.vue` 文件中的 `i18n` 语法
@@ -20,15 +16,58 @@
20
16
  **特别注意:**
21
17
  **tiny命令不再支持和picgo联动, 仅支持压缩后,自动替换一下md文件里的图片链接, 之后的操作可以用obsidian里的插件[image auto upload Plugin]完成~~**
22
18
 
23
-
24
19
  ## 安装
25
20
 
26
- `1.0.0` 之前的版本都为不稳定版本
21
+ > 对于不擅长nodejs的使用者更推荐使用 `bun`
22
+
23
+ ### Node
24
+
25
+ 使用 `nvm` 管理多个 `node` 版本
26
+
27
+ `node >= 18.18.0`
28
+
29
+ 推荐版本(我的):`20.18.1`
30
+
31
+ 查看 `registry` (非必要步骤)
32
+
33
+ ```bash
34
+ npm config get registry
35
+ # https://registry.npmjs.org
36
+ # 如果不是,则需要先设置
37
+ npm config set registry=https://registry.npmjs.org
38
+ ```
39
+
40
+ 安装最新版
27
41
 
28
42
  ```shell
29
43
  npm i -g @zzclub/z-cli
30
44
  ```
31
45
 
46
+ 安装后只能在当前 `node` 版本下使用,切换到其他低版本 `node` 则无效
47
+
48
+ 全局命令为:`zz` 或 `z`
49
+
50
+ ### Bun
51
+
52
+ macos
53
+ ```bash
54
+ curl -fsSL https://bun.sh/install | bash
55
+ ```
56
+
57
+ wind
58
+ ```bash
59
+ powershell -c "irm bun.sh/install.ps1 | iex"
60
+ ```
61
+
62
+ 安装最新版
63
+
64
+ ```shell
65
+ bun i -g @zzclub/z-cli
66
+ ```
67
+
68
+ **如果提示缺少某个包**,可以按提示再次运行相关命令
69
+
70
+
32
71
  ## i18n 规则说明
33
72
 
34
73
  ### 文件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzclub/z-cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "all-in-one 工具箱,专为提升日常及工作效率而生",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -81,23 +81,27 @@ const translateCmd = {
81
81
  } else {
82
82
  file_spinner.succeed(`正在翻译${chalk.yellowBright(filePath)}`);
83
83
  file_spinner.start();
84
- let file_content = await readAndTranslateFileContent(filePath);
85
- let fileName = path.basename(filePath);
86
- let dirPath = path.dirname(filePath);
87
- let newFileName =
88
- fileName.split(".")[0] +
89
- `-${option.language}.` +
90
- fileName.split(".")[1];
91
- let newFilePath = dirPath + "/" + newFileName;
92
- writeFileContent(newFilePath, file_content, (spinner, isOk) => {
93
- if (isOk) {
94
- spinner.succeed("翻译结束");
95
- } else {
96
- spinner.fail("翻译失败!");
97
- }
84
+ if (filePath.endsWith(".js") || filePath.endsWith(".ts")) {
85
+ let file_content = await readAndTranslateFileContent(filePath);
86
+ let fileName = path.basename(filePath);
87
+ let dirPath = path.dirname(filePath);
88
+ let newFileName =
89
+ fileName.split(".")[0] +
90
+ `-${option.language}.` +
91
+ fileName.split(".")[1];
92
+ let newFilePath = dirPath + "/" + newFileName;
93
+ writeFileContent(newFilePath, file_content, (spinner, isOk) => {
94
+ if (isOk) {
95
+ spinner.succeed("翻译结束");
96
+ } else {
97
+ spinner.fail("翻译失败!");
98
+ }
98
99
 
99
- file_spinner.stop();
100
- });
100
+ file_spinner.stop();
101
+ });
102
+ } else {
103
+ file_spinner.fail("无效的文件");
104
+ }
101
105
  }
102
106
  },
103
107
  };
@@ -280,12 +284,15 @@ function getAllFilePaths(translateConfig, dirPath, filePaths) {
280
284
  // 找到目标文件夹, 获取所有文件
281
285
  let files = fs.readdirSync(filePath);
282
286
  files.forEach((file) => {
283
- let jsPath = path.join(filePath, file);
284
- let targetPath = path.join(dirPath, translateConfig.targetDirName);
285
- filePaths.push({
286
- sourcePath: jsPath,
287
- targetPath,
288
- });
287
+ // 判断文件是否是以.js或.ts结尾
288
+ if (file.endsWith(".js") || file.endsWith(".ts")) {
289
+ let jsPath = path.join(filePath, file);
290
+ let targetPath = path.join(dirPath, translateConfig.targetDirName);
291
+ filePaths.push({
292
+ sourcePath: jsPath,
293
+ targetPath,
294
+ });
295
+ }
289
296
  });
290
297
  } else if (!translateConfig.ignoreFiles.includes(file)) {
291
298
  getAllFilePaths(translateConfig, filePath, filePaths);