xw-devtool-cli 1.0.37 → 1.0.39
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 +98 -55
- package/README_EN.md +3 -1
- package/package.json +7 -4
- package/src/commands/fileTree.js +90 -0
- package/src/index.js +30 -3
- package/src/locales/en.js +10 -0
- package/src/locales/zh.js +10 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
一个基于 Node.js 的开发者命令行工具箱,旨在提供开箱即用的常用开发工具,帮助开发者快速处理日常任务。
|
|
6
6
|
|
|
7
|
-
主要功能包括:Base64 编解码、图片格式转换、图片与 Base64 互转、Mock 数据生成、时间戳/日期格式化、时间计算、URL 编解码、UUID 生成、汉字转拼音、颜色转换、变量格式转换、哈希计算、二维码生成、特殊符号大全、Markdown 语法工具、VS Code
|
|
7
|
+
主要功能包括:Base64 编解码、图片格式转换、图片与 Base64 互转、Mock 数据生成、时间戳/日期格式化、时间计算、URL 编解码、UUID 生成、汉字转拼音、颜色转换、变量格式转换、哈希计算、二维码生成、特殊符号大全、Markdown 语法工具、VS Code 代码段生成、当前目录树生成等。所有结果均自动复制到剪贴板,极大提升开发效率。
|
|
8
8
|
|
|
9
9
|
## ✨ 功能特性
|
|
10
10
|
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
- **图片分割**:支持网格等分(自定义行/列数)或自定义分割线(像素/百分比),自动生成分割后的图片文件。
|
|
16
16
|
- **图片主色识别**:提取图片主色调(Hex/RGB/HSL/HSV),默认复制 Hex 到剪贴板,支持保存详细信息到文件。
|
|
17
17
|
- **颜色吸取**:从图片中吸取单像素颜色或区域平均颜色,支持 px/% 坐标输入,结果显示颜色条并自动复制 Hex/Hex8。
|
|
18
|
-
-
|
|
19
|
-
>
|
|
20
|
-
> 1.
|
|
21
|
-
> 2.
|
|
22
|
-
> 3.
|
|
18
|
+
- **屏幕取色**:实时显示鼠标所在位置的颜色值(Hex/RGB)。
|
|
19
|
+
> **操作说明**:
|
|
20
|
+
> 1. 进入模式后,屏幕右下角会实时显示当前颜色预览和数值。
|
|
21
|
+
> 2. 移动鼠标到目标位置,按 **Enter 键** 复制当前颜色 Hex 到剪贴板(会有成功提示)。
|
|
22
|
+
> 3. 按 **ESC 键** 退出取色模式。
|
|
23
|
+
> 4. 支持多显示器。
|
|
23
24
|
- **占位图生成**:快速生成指定尺寸、颜色、文字的占位图片 (Placeholder Image)。
|
|
24
|
-
-
|
|
25
|
+
- **全屏十字辅助线**:显示跟随鼠标的全屏红色十字线,用于屏幕对齐和定位。按 **ESC 键** 退出。
|
|
25
26
|
- **屏幕测距**:点击屏幕上任意两点,测量其像素距离。
|
|
26
27
|
- **屏幕文字标注**:在屏幕上点击并输入文字,进行临时标注。右键撤销,Delete 清空。
|
|
27
28
|
- **图片压缩**:支持文件或文件夹;文件夹可批量压缩其下所有图片(可选包含子文件夹)。支持 PNG/JPG/WebP,质量 1-100;输出文件名带时间戳并复制输出目录到剪贴板。
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
- **Markdown 语法工具**:提供常用 Markdown 语法模板 (Headers, Lists, Tables, Code 等),一键复制。
|
|
51
52
|
- **VS Code 代码段生成器**:将代码转换为 VS Code Snippet JSON,自动生成语法速查表注释。
|
|
52
53
|
- **Git 助手**: 标准化生成 Git 分支名 (feature/bugfix/custom) 和 Conventional Commits 提交日志。
|
|
54
|
+
- **当前目录树生成**:生成当前目录的文件树结构,支持指定层级,默认输出全部层级并自动复制到剪贴板。
|
|
53
55
|
- **占位图生成**:自定义尺寸、背景色、文字颜色和格式生成占位图。
|
|
54
56
|
- **便捷操作**:
|
|
55
57
|
- 支持文件选择对话框 (Windows)。
|
|
@@ -100,29 +102,39 @@ xw-devtool --en # 英文启动 (Start in English)
|
|
|
100
102
|
=================================
|
|
101
103
|
xw-devtool-cli 菜单
|
|
102
104
|
=================================
|
|
103
|
-
1. 图片
|
|
105
|
+
1. 图片 <-> Base64
|
|
104
106
|
2. 图片格式转换
|
|
105
|
-
3.
|
|
107
|
+
3. 图片分割工具
|
|
106
108
|
4. 图片主色识别
|
|
107
|
-
5.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
5. 颜色吸取
|
|
110
|
+
6. 全屏十字辅助线
|
|
111
|
+
7. 屏幕测距 (像素)
|
|
112
|
+
8. 屏幕文字标注
|
|
113
|
+
9. 图片压缩
|
|
114
|
+
a. 占位图生成器
|
|
115
|
+
b. 二维码生成器
|
|
116
|
+
c. URL 编码/解码
|
|
117
|
+
d. 进制转换工具
|
|
118
|
+
e. 字符串 编码/解码 (Base64)
|
|
119
|
+
f. Unicode 编码/解码
|
|
120
|
+
g. HTML 实体 编码/解码
|
|
121
|
+
h. 变量命名格式转换
|
|
122
|
+
i. JSON 格式化 (压缩/美化)
|
|
123
|
+
j. 汉字转拼音
|
|
124
|
+
k. 时间格式化 / 时间戳
|
|
125
|
+
l. 时间计算 (差值/偏移)
|
|
126
|
+
m. 颜色转换 (Hex <-> RGB)
|
|
127
|
+
n. 颜色预览
|
|
128
|
+
o. 生成 UUID
|
|
129
|
+
p. 哈希计算 (MD5/SHA/SM3)
|
|
130
|
+
q. Mock 文本生成
|
|
131
|
+
r. 特殊字符 (符号)
|
|
132
|
+
s. Emoji 选择器
|
|
133
|
+
t. Markdown 片段
|
|
134
|
+
u. VS Code 代码片段生成
|
|
135
|
+
v. Git 助手 (分支/提交模板)
|
|
136
|
+
w. 当前目录树生成
|
|
137
|
+
x. 设置 / 语言 (Settings)
|
|
126
138
|
0. 退出
|
|
127
139
|
=================================
|
|
128
140
|
```
|
|
@@ -146,6 +158,27 @@ s. 设置 (语言)
|
|
|
146
158
|
- 生成的新图片将保存在源文件同级目录。
|
|
147
159
|
- 生成 ICO 时可自定义尺寸,留空默认生成 `256` 尺寸;输出文件名包含时间戳。
|
|
148
160
|
|
|
161
|
+
### 图片压缩
|
|
162
|
+
- 选择 `imgCompress` (菜单对应数字/字母) 进入。
|
|
163
|
+
- **支持输入**:
|
|
164
|
+
- **文件**:单张图片压缩。
|
|
165
|
+
- **文件夹**:批量压缩文件夹内所有图片(可选是否递归子文件夹)。
|
|
166
|
+
- **参数设置**:
|
|
167
|
+
- **质量**:推荐 80,也可自定义 1-100。
|
|
168
|
+
- **文件夹结构**:批量处理时可选保留原目录结构。
|
|
169
|
+
- **文件名后缀**:可选是否添加 `_compressed_时间戳` 后缀。如果不添加,将保持原文件名(建议输出到不同目录以防覆盖)。
|
|
170
|
+
- **输出**:
|
|
171
|
+
- 默认输出到源目录下的 `compressed_YYYYMMDD_HHmmss` 文件夹。
|
|
172
|
+
- 自动复制输出目录路径。
|
|
173
|
+
- 完成后可选直接打开输出目录。
|
|
174
|
+
|
|
175
|
+
### 当前目录树生成
|
|
176
|
+
- 选择 `w` 进入。
|
|
177
|
+
- 先选择层级模式:
|
|
178
|
+
- **所有层级**:从当前目录递归到最深层。
|
|
179
|
+
- **指定层级**:输入层级数字(`0` 表示仅根目录,`1` 表示包含第一层子项)。
|
|
180
|
+
- 生成后的目录树会自动复制到剪贴板,便于粘贴到文档或 Issue 中。
|
|
181
|
+
|
|
149
182
|
### 3. 占位图生成 (Placeholder Image)
|
|
150
183
|
- 选择 `3` 进入。
|
|
151
184
|
- **模式 1:本地图片文件 (Local Image File)**
|
|
@@ -317,12 +350,15 @@ Key features include: Base64 encoding/decoding, image format conversion, image <
|
|
|
317
350
|
- **Image ↔ Base64**: Convert images to Base64 strings and vice versa.
|
|
318
351
|
- **Image Dominant Color**: Extract dominant color (Hex/RGB/HSL/HSV), copy Hex to clipboard by default, or save details to file.
|
|
319
352
|
- **Image Color Picker**: Pick color from image (single pixel or average), supports px/% coordinates, shows color bar and auto-copies Hex/Hex8.
|
|
320
|
-
- **Screen Color Picker**:
|
|
321
|
-
> **
|
|
322
|
-
> 1.
|
|
323
|
-
> 2.
|
|
324
|
-
> 3.
|
|
353
|
+
- **Screen Color Picker**: Real-time color picking from screen (Hex/RGB).
|
|
354
|
+
> **Usage**:
|
|
355
|
+
> 1. Real-time color preview and values are shown in the bottom-right corner.
|
|
356
|
+
> 2. Move mouse to target and press **Enter** to copy Hex color to clipboard.
|
|
357
|
+
> 3. Press **ESC** to exit.
|
|
358
|
+
> 4. Supports multiple monitors.
|
|
325
359
|
- **Placeholder Image**: Quickly generate placeholder images with custom size, color, and text.
|
|
360
|
+
- **Image Compression**: Support file or folder input; batch compress images in folder (recursive optional). Supports PNG/JPG/WebP, Quality 1-100. Output filename suffix optional.
|
|
361
|
+
- **Full Screen Crosshair**: Show red crosshair following mouse. Press **ESC** to exit.
|
|
326
362
|
- **Mock Data**:
|
|
327
363
|
- Generate: Lorem Ipsum, Chinese characters, ID cards, Emails, URLs, Order IDs, Phone numbers.
|
|
328
364
|
- Supports batch generation.
|
|
@@ -385,28 +421,22 @@ The interactive menu will appear:
|
|
|
385
421
|
=================================
|
|
386
422
|
xw-devtool-cli Menu
|
|
387
423
|
=================================
|
|
388
|
-
1. Image <-> Base64
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
h. Mock Text
|
|
405
|
-
i. Special Characters (Symbols)
|
|
406
|
-
j. Emoji Picker
|
|
407
|
-
k. Markdown Snippets
|
|
408
|
-
l. VS Code Snippet Generator
|
|
409
|
-
s. Settings (Language)
|
|
424
|
+
1. Image <-> Base64 2. Image Format Convert
|
|
425
|
+
3. Image Splitter 4. Image Dominant Color
|
|
426
|
+
5. Color Picker 6. Screen Crosshair
|
|
427
|
+
7. Pixel Distance Tool 8. Screen Mark Tool
|
|
428
|
+
9. Image Compression a. Placeholder Image Generator
|
|
429
|
+
b. QR Code Generator c. URL Encode/Decode
|
|
430
|
+
d. Number Base Converter e. String Encode/Decode (Base64)
|
|
431
|
+
f. Unicode Encode/Decode g. HTML Entity Encode/Decode
|
|
432
|
+
h. Variable Format Converter i. JSON Format (Minify/Prettify)
|
|
433
|
+
j. Chinese to Pinyin k. Time Format / Timestamp
|
|
434
|
+
l. Time Calculation (Diff/Offset) m. Color Converter (Hex <-> RGB)
|
|
435
|
+
n. Color Preview o. Get UUID
|
|
436
|
+
p. Hash Calculator (MD5/SHA/SM3) q. Mock Text
|
|
437
|
+
r. Special Characters (Symbols) s. Emoji Picker
|
|
438
|
+
t. Markdown Snippets u. VS Code Snippet Generator
|
|
439
|
+
v. Git Helper (Branch/Commit Template) w. Settings / Language
|
|
410
440
|
0. Exit
|
|
411
441
|
=================================
|
|
412
442
|
```
|
|
@@ -429,6 +459,19 @@ s. Settings (Language)
|
|
|
429
459
|
- Set quality/compression.
|
|
430
460
|
- Saved in the same directory.
|
|
431
461
|
|
|
462
|
+
#### Image Compression
|
|
463
|
+
- Select `imgCompress` (menu key).
|
|
464
|
+
- **Input**: File or Folder (batch processing).
|
|
465
|
+
- **Settings**:
|
|
466
|
+
- Quality (1-100).
|
|
467
|
+
- Recursive (for folders).
|
|
468
|
+
- Preserve directory structure.
|
|
469
|
+
- Suffix option: Add `_compressed_timestamp` or keep original filename.
|
|
470
|
+
- **Output**:
|
|
471
|
+
- Saved to `compressed_YYYYMMDD_HHmmss` folder.
|
|
472
|
+
- Auto-copy output path.
|
|
473
|
+
- Option to open output folder.
|
|
474
|
+
|
|
432
475
|
#### 3. Placeholder Image Generator
|
|
433
476
|
- Select `3`.
|
|
434
477
|
- **Mode 1: Local Image File**
|
package/README_EN.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A Node.js-based developer command-line toolbox designed to provide out-of-the-box common development tools to help developers handle daily tasks quickly.
|
|
6
6
|
|
|
7
|
-
Key features include: Base64 encoding/decoding, image format conversion, image <-> Base64, Mock data generation, timestamp/date formatting, time calculation, URL encoding/decoding, UUID generation, Chinese pinyin conversion, color conversion, variable format conversion, hash calculation, QR code generation, special symbols, Markdown snippets, VS Code snippet generation, etc. All results are automatically copied to the clipboard, greatly improving development efficiency.
|
|
7
|
+
Key features include: Base64 encoding/decoding, image format conversion, image <-> Base64, Mock data generation, timestamp/date formatting, time calculation, URL encoding/decoding, UUID generation, Chinese pinyin conversion, color conversion, variable format conversion, hash calculation, QR code generation, special symbols, Markdown snippets, VS Code snippet generation, current directory tree generation, etc. All results are automatically copied to the clipboard, greatly improving development efficiency.
|
|
8
8
|
|
|
9
9
|
## ✨ Features
|
|
10
10
|
|
|
@@ -45,6 +45,7 @@ Key features include: Base64 encoding/decoding, image format conversion, image <
|
|
|
45
45
|
- **Markdown Snippets**: Common Markdown templates.
|
|
46
46
|
- **VS Code Snippets**: Generate VS Code snippet JSON from code.
|
|
47
47
|
- **Git Helper**: Generate standardized Git branch names (feature/bugfix) and Conventional Commits messages.
|
|
48
|
+
- **Current Directory Tree**: Generate the file tree for the current directory, with optional depth limit (default: all levels), and copy result to clipboard.
|
|
48
49
|
- **Convenience**:
|
|
49
50
|
- File selection dialog (Windows).
|
|
50
51
|
- Auto-copy results to clipboard.
|
|
@@ -119,6 +120,7 @@ i. Special Characters (Symbols)
|
|
|
119
120
|
j. Emoji Picker
|
|
120
121
|
k. Markdown Snippets
|
|
121
122
|
l. VS Code Snippet Generator
|
|
123
|
+
m. Current Directory Tree
|
|
122
124
|
s. Settings (Language)
|
|
123
125
|
0. Exit
|
|
124
126
|
=================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xw-devtool-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "基于node的开发者助手cli",
|
|
6
6
|
"main": "index.js",
|
|
@@ -59,7 +59,9 @@
|
|
|
59
59
|
"git",
|
|
60
60
|
"git-branch",
|
|
61
61
|
"commit-message",
|
|
62
|
-
"conventional-commits"
|
|
62
|
+
"conventional-commits",
|
|
63
|
+
"directory-tree",
|
|
64
|
+
"file-tree"
|
|
63
65
|
],
|
|
64
66
|
"author": "npmxw",
|
|
65
67
|
"license": "ISC",
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
"url": "https://gitee.com/github-9819409/xw-devtool-cli/issues"
|
|
75
77
|
},
|
|
76
78
|
"dependencies": {
|
|
79
|
+
"cli-table3": "^0.6.5",
|
|
77
80
|
"clipboardy": "^5.0.2",
|
|
78
81
|
"commander": "^14.0.2",
|
|
79
82
|
"dayjs": "^1.11.19",
|
|
@@ -85,7 +88,7 @@
|
|
|
85
88
|
"qrcode": "^1.5.4",
|
|
86
89
|
"sharp": "^0.33.5",
|
|
87
90
|
"tinycolor2": "^1.6.0",
|
|
88
|
-
"
|
|
89
|
-
"
|
|
91
|
+
"to-ico": "^1.1.5",
|
|
92
|
+
"uuid": "^13.0.0"
|
|
90
93
|
}
|
|
91
94
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import i18next from '../i18n.js';
|
|
5
|
+
import { selectFromMenu } from '../utils/menu.js';
|
|
6
|
+
import { copy } from '../utils/clipboard.js';
|
|
7
|
+
|
|
8
|
+
export async function fileTreeHandler() {
|
|
9
|
+
const mode = await selectFromMenu(
|
|
10
|
+
i18next.t('fileTree.depthMode'),
|
|
11
|
+
[
|
|
12
|
+
{ name: i18next.t('fileTree.allDepth'), value: 'all' },
|
|
13
|
+
{ name: i18next.t('fileTree.customDepth'), value: 'custom' }
|
|
14
|
+
],
|
|
15
|
+
true,
|
|
16
|
+
i18next.t('common.back')
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (mode === '__BACK__') {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let maxDepth = Infinity;
|
|
24
|
+
if (mode === 'custom') {
|
|
25
|
+
const { depth } = await inquirer.prompt([
|
|
26
|
+
{
|
|
27
|
+
type: 'input',
|
|
28
|
+
name: 'depth',
|
|
29
|
+
message: i18next.t('fileTree.depthPrompt'),
|
|
30
|
+
validate: (input) => {
|
|
31
|
+
const value = Number.parseInt(input, 10);
|
|
32
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
33
|
+
return i18next.t('fileTree.depthInvalid');
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]);
|
|
39
|
+
maxDepth = Number.parseInt(depth, 10);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const cwd = process.cwd();
|
|
43
|
+
const tree = buildTree(cwd, maxDepth);
|
|
44
|
+
const depthText = Number.isFinite(maxDepth) ? String(maxDepth) : i18next.t('fileTree.allDepth');
|
|
45
|
+
|
|
46
|
+
console.log(i18next.t('fileTree.generated', { path: cwd, depth: depthText }));
|
|
47
|
+
const preview = tree.length > 2000 ? `${tree.slice(0, 1000)}\n...\n${tree.slice(-800)}` : tree;
|
|
48
|
+
console.log(`\n${preview}\n`);
|
|
49
|
+
await copy(tree);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function buildTree(rootPath, maxDepth) {
|
|
53
|
+
const rootName = path.basename(rootPath) || rootPath;
|
|
54
|
+
const lines = [rootName];
|
|
55
|
+
|
|
56
|
+
walkDir(rootPath, '', 0, maxDepth, lines);
|
|
57
|
+
|
|
58
|
+
return lines.join('\n');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function walkDir(currentPath, prefix, depth, maxDepth, lines) {
|
|
62
|
+
if (depth >= maxDepth) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let entries = [];
|
|
67
|
+
try {
|
|
68
|
+
entries = fs.readdirSync(currentPath, { withFileTypes: true });
|
|
69
|
+
} catch (error) {
|
|
70
|
+
lines.push(`${prefix}└── [${i18next.t('fileTree.readFailed')}: ${error.message}]`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
entries.sort((a, b) => {
|
|
75
|
+
if (a.isDirectory() && !b.isDirectory()) return -1;
|
|
76
|
+
if (!a.isDirectory() && b.isDirectory()) return 1;
|
|
77
|
+
return a.name.localeCompare(b.name, undefined, { sensitivity: 'base' });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
entries.forEach((entry, index) => {
|
|
81
|
+
const isLast = index === entries.length - 1;
|
|
82
|
+
const connector = isLast ? '└── ' : '├── ';
|
|
83
|
+
lines.push(`${prefix}${connector}${entry.name}`);
|
|
84
|
+
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
const nextPrefix = `${prefix}${isLast ? ' ' : '│ '}`;
|
|
87
|
+
walkDir(path.join(currentPath, entry.name), nextPrefix, depth + 1, maxDepth, lines);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
+
import Table from 'cli-table3';
|
|
3
4
|
import i18next from './i18n.js';
|
|
4
5
|
import { saveConfig } from './utils/config.js';
|
|
5
6
|
|
|
@@ -34,6 +35,7 @@ import { pixelDistanceHandler } from './commands/pixelDistance.js';
|
|
|
34
35
|
import { screenMarkHandler } from './commands/screenMark.js';
|
|
35
36
|
import { gitHelperHandler } from './commands/gitHelper.js';
|
|
36
37
|
import { imgCompressHandler } from './commands/imgCompress.js';
|
|
38
|
+
import { fileTreeHandler } from './commands/fileTree.js';
|
|
37
39
|
|
|
38
40
|
process.on('SIGINT', () => {
|
|
39
41
|
console.log(`\n${i18next.t('menu.bye')}`);
|
|
@@ -90,6 +92,7 @@ function getFeatures() {
|
|
|
90
92
|
{ name: i18next.t('menu.features.markdown'), value: 'markdown' },
|
|
91
93
|
{ name: i18next.t('menu.features.vscodeSnippet'), value: 'vscodeSnippet' },
|
|
92
94
|
{ name: i18next.t('menu.features.gitHelper'), value: 'gitHelper' },
|
|
95
|
+
{ name: i18next.t('menu.features.fileTree'), value: 'fileTree' },
|
|
93
96
|
|
|
94
97
|
// Settings
|
|
95
98
|
{ name: i18next.t('menu.features.settings'), value: 'settings' }
|
|
@@ -134,10 +137,31 @@ async function showMenu() {
|
|
|
134
137
|
console.log('\n=================================');
|
|
135
138
|
console.log(` ${i18next.t('menu.title')}`);
|
|
136
139
|
console.log('=================================');
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
|
|
141
|
+
// Prepare items for table
|
|
142
|
+
const items = features.map((feature, index) => `${getFeatureKey(index)}. ${feature.name}`);
|
|
143
|
+
items.push(`0. ${i18next.t('menu.exit')}`);
|
|
144
|
+
|
|
145
|
+
// Configure table
|
|
146
|
+
const table = new Table({
|
|
147
|
+
chars: {
|
|
148
|
+
'top': '', 'top-mid': '', 'top-left': '', 'top-right': '',
|
|
149
|
+
'bottom': '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '',
|
|
150
|
+
'left': '', 'left-mid': '', 'mid': '', 'mid-mid': '',
|
|
151
|
+
'right': '', 'right-mid': '', 'middle': ' '
|
|
152
|
+
},
|
|
153
|
+
style: { 'padding-left': 0, 'padding-right': 0 },
|
|
154
|
+
colWidths: [40, 40]
|
|
139
155
|
});
|
|
140
|
-
|
|
156
|
+
|
|
157
|
+
// Add items to table in pairs
|
|
158
|
+
const columns = 2;
|
|
159
|
+
for (let i = 0; i < items.length; i += columns) {
|
|
160
|
+
const row = items.slice(i, i + columns);
|
|
161
|
+
table.push(row);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
console.log(table.toString());
|
|
141
165
|
console.log('=================================\n');
|
|
142
166
|
|
|
143
167
|
const { choice } = await inquirer.prompt([
|
|
@@ -271,6 +295,9 @@ async function handleAction(action) {
|
|
|
271
295
|
case 'gitHelper':
|
|
272
296
|
await gitHelperHandler();
|
|
273
297
|
break;
|
|
298
|
+
case 'fileTree':
|
|
299
|
+
await fileTreeHandler();
|
|
300
|
+
break;
|
|
274
301
|
case 'settings':
|
|
275
302
|
await handleSettings();
|
|
276
303
|
break;
|
package/src/locales/en.js
CHANGED
|
@@ -64,6 +64,7 @@ export default {
|
|
|
64
64
|
markdown: 'Markdown Snippets',
|
|
65
65
|
vscodeSnippet: 'VS Code Snippet Generator',
|
|
66
66
|
gitHelper: 'Git Helper (Branch/Commit Template)',
|
|
67
|
+
fileTree: 'Current Directory Tree',
|
|
67
68
|
settings: 'Settings / Language'
|
|
68
69
|
}
|
|
69
70
|
},
|
|
@@ -157,5 +158,14 @@ export default {
|
|
|
157
158
|
scanResult: 'Images found',
|
|
158
159
|
preservePrompt: 'Preserve original directory structure in output?',
|
|
159
160
|
suffixPrompt: 'Append filename suffix (compressed + timestamp)?'
|
|
161
|
+
},
|
|
162
|
+
fileTree: {
|
|
163
|
+
depthMode: 'Select tree depth mode',
|
|
164
|
+
allDepth: 'All levels',
|
|
165
|
+
customDepth: 'Specify depth',
|
|
166
|
+
depthPrompt: 'Enter depth (0 means root only):',
|
|
167
|
+
depthInvalid: 'Please enter an integer greater than or equal to 0',
|
|
168
|
+
generated: 'Directory tree generated (path: {{path}}, depth: {{depth}}) and copied to clipboard',
|
|
169
|
+
readFailed: 'Failed to read directory'
|
|
160
170
|
}
|
|
161
171
|
};
|
package/src/locales/zh.js
CHANGED
|
@@ -64,6 +64,7 @@ export default {
|
|
|
64
64
|
markdown: 'Markdown 片段',
|
|
65
65
|
vscodeSnippet: 'VS Code 代码片段生成',
|
|
66
66
|
gitHelper: 'Git 助手 (分支/提交模板)',
|
|
67
|
+
fileTree: '当前目录树生成',
|
|
67
68
|
settings: '设置 / 语言 (Settings)'
|
|
68
69
|
}
|
|
69
70
|
},
|
|
@@ -158,5 +159,14 @@ export default {
|
|
|
158
159
|
preservePrompt: '递归时是否按原始目录结构输出'
|
|
159
160
|
,
|
|
160
161
|
suffixPrompt: '是否在文件名添加后缀(compressed+时间戳)'
|
|
162
|
+
},
|
|
163
|
+
fileTree: {
|
|
164
|
+
depthMode: '请选择目录树生成层级',
|
|
165
|
+
allDepth: '所有层级',
|
|
166
|
+
customDepth: '指定层级',
|
|
167
|
+
depthPrompt: '请输入层级(0 表示仅根目录):',
|
|
168
|
+
depthInvalid: '请输入大于等于 0 的整数',
|
|
169
|
+
generated: '目录树已生成(路径: {{path}},层级: {{depth}}),已复制到剪贴板',
|
|
170
|
+
readFailed: '读取目录失败'
|
|
161
171
|
}
|
|
162
172
|
};
|