xw-devtool-cli 1.0.5 → 1.0.6

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  一个基于 Node.js 的开发者命令行工具箱,旨在提供开箱即用的常用开发工具,帮助开发者快速处理日常任务。
4
4
 
5
- 主要功能包括:Base64 编解码、图片格式转换、图片与 Base64 互转、Mock 数据生成、时间戳/日期格式化、URL 编解码、UUID 生成、汉字转拼音等。所有结果均自动复制到剪贴板,极大提升开发效率。
5
+ 主要功能包括:Base64 编解码、图片格式转换、图片与 Base64 互转、Mock 数据生成、时间戳/日期格式化、URL 编解码、UUID 生成、汉字转拼音、颜色转换、变量格式转换、哈希计算、二维码生成、特殊符号大全等。所有结果均自动复制到剪贴板,极大提升开发效率。
6
6
 
7
7
  ## ✨ 功能特性
8
8
 
@@ -16,13 +16,19 @@
16
16
  - **时间工具**:
17
17
  - **时间格式化**:时间戳/日期字符串 -> `YYYY-MM-DD HH:mm:ss`。
18
18
  - **获取时间戳**:快速获取当前毫秒级时间戳。
19
- - **其他工具**:
19
+ - **开发辅助工具**:
20
20
  - **URL 编解码**:Encode/Decode URL。
21
21
  - **UUID**:生成 UUID v4。
22
22
  - **中文转拼音**:将汉字转换为不带声调的拼音。
23
+ - **颜色转换**:Hex <-> RGB 互转。
24
+ - **变量格式转换**:支持 CamelCase, PascalCase, SnakeCase, KebabCase, ConstantCase 互转。
25
+ - **哈希计算**:支持 MD5, SHA1, SHA256, SHA512, SM3 算法。
26
+ - **二维码生成**:终端直接显示二维码,支持保存为 PNG 图片(带时间戳文件名)。
27
+ - **特殊符号大全**:包含常用符号、箭头、数学符号、货币、希腊字母等 170+ 个符号,支持一键复制。
23
28
  - **便捷操作**:
24
29
  - 支持文件选择对话框 (Windows)。
25
30
  - 结果自动复制到剪贴板。
31
+ - 支持从剪贴板自动读取输入(部分工具支持直接回车读取)。
26
32
  - 支持将大文本结果保存为文件。
27
33
 
28
34
  ## 📦 安装
@@ -31,7 +37,7 @@
31
37
  ```bash
32
38
  npm install -g xw-devtool-cli
33
39
  ```
34
- 安装后即可在终端直接使用 `xw-devtool` 命令。
40
+ 安装后即可在终端直接使用 `xw-devtool` 或 `xw-dev` 命令。
35
41
 
36
42
  ### 免安装运行 (npx)
37
43
  ```bash
@@ -45,20 +51,27 @@ npx xw-devtool-cli@latest
45
51
  xw-devtool
46
52
  ```
47
53
 
48
- 启动后将显示交互式菜单,通过键盘方向键或输入数字选择功能:
54
+ 启动后将显示交互式菜单,通过键盘输入对应的数字或字母选择功能:
49
55
 
50
56
  ```text
51
- ? Select a tool: (Use arrow keys)
52
- > 1. URL Encode/Decode
53
- 2. String Encode/Decode (Base64)
54
- 3. Image <-> Base64
55
- 4. Image Format Convert
56
- 5. Time Format
57
- 6. Get Current Timestamp
58
- 7. Mock Text
59
- 8. Get UUID
60
- 9. Chinese to Pinyin
61
- 0. Exit
57
+ =================================
58
+ xw-devtool-cli Menu
59
+ =================================
60
+ 1. URL Encode/Decode
61
+ 2. String Encode/Decode (Base64)
62
+ 3. Image <-> Base64
63
+ 4. Image Format Convert
64
+ 5. Time Format / Timestamp
65
+ 6. Mock Text
66
+ 7. Get UUID
67
+ 8. Chinese to Pinyin
68
+ 9. Color Converter (Hex <-> RGB)
69
+ a. Variable Format Converter
70
+ b. Hash Calculator (MD5/SHA/SM3)
71
+ c. QR Code Generator
72
+ d. Special Characters (Symbols)
73
+ 0. Exit
74
+ =================================
62
75
  ```
63
76
 
64
77
  ## 📖 详细使用指南
@@ -93,30 +106,32 @@ xw-devtool
93
106
  - 生成的新图片将保存在源文件同级目录。
94
107
 
95
108
  ### 5. Mock 数据生成
96
- - 选择 `7` 进入。
97
- - 提供多种数据类型:
98
- - **英文段落**: 生成 Lorem Ipsum 文本。
99
- - **中文字符**: 生成随机常用汉字。
100
- - **身份证号**: 生成符合规则的虚拟身份证号 (包含校验位)。
101
- - **邮箱**: 生成随机电子邮箱地址。
102
- - **URL**: 生成随机网址。
103
- - **订单号**: 生成基于时间戳的模拟订单号。
104
- - **手机号**: 生成常见号段的手机号。
105
- - **座机号**: 生成带区号的座机号码。
106
- - 支持指定生成数量(批量生成)。
107
-
108
- ### 6. 时间工具
109
- - **时间格式化 (5)**: 输入时间戳(秒/毫秒)或日期字符串,输出标准化格式。留空直接回车则使用当前时间。
110
- - **当前时间戳 (6)**: 快速获取当前毫秒时间戳。
111
-
112
- ### 7. 其他
113
- - **UUID (8)**: 生成一个 UUID v4。
114
- - **中文转拼音 (9)**: 输入中文文本,输出拼音字符串(空格分隔)。
115
-
116
- ## 💻 系统要求
117
- - Node.js >= 18.0.0
118
- - Windows 用户可享受原生文件选择/保存对话框体验。
119
- - macOS/Linux 用户支持完整功能,但文件路径需手动输入。
109
+ - 选择 `6` 进入。
110
+ - 提供多种数据类型:英文段落、中文字符、身份证号、邮箱、手机号等。
111
+ - 支持指定生成数量。
112
+
113
+ ### 6. 变量格式转换
114
+ - 选择 `a` 进入。
115
+ - 输入变量名(支持直接回车读取剪贴板)。
116
+ - 自动展示 CamelCase, PascalCase, SnakeCase, KebabCase, ConstantCase 五种格式。
117
+ - 选择一种格式自动复制。
118
+
119
+ ### 7. 哈希计算 (Encryption)
120
+ - 选择 `b` 进入。
121
+ - 输入文本(支持直接回车读取剪贴板)。
122
+ - 同时计算并显示 MD5, SHA1, SHA256, SHA512, SM3 哈希值。
123
+
124
+ ### 8. 二维码生成
125
+ - 选择 `c` 进入。
126
+ - 输入文本或 URL(支持直接回车读取剪贴板)。
127
+ - 终端直接显示二维码预览。
128
+ - 可选保存为 PNG 图片,默认文件名包含时间戳。
129
+
130
+ ### 9. 特殊符号大全
131
+ - 选择 `d` 进入。
132
+ - 网格化展示常用特殊符号。
133
+ - 输入符号对应的编号即可一键复制。
120
134
 
121
135
  ## 📄 License
136
+
122
137
  ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xw-devtool-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "description": "基于node的开发者助手cli",
6
6
  "main": "index.js",
@@ -0,0 +1,94 @@
1
+ import inquirer from 'inquirer';
2
+ import { copy } from '../utils/clipboard.js';
3
+
4
+ const categories = {
5
+ 'Common Symbols': ['✓', '✗', '★', '☆', '♥', '☺', '☹', '☁', '☀', '☂', '☃', '✈', '♫', '♪'],
6
+ 'Arrows': ['←', '↑', '→', '↓', '↔', '↕', '↖', '↗', '↘', '↙', '⇐', '⇑', '⇒', '⇓', '⇔', '⇕'],
7
+ 'Math': ['+', '-', '×', '÷', '=', '≠', '≈', '±', '∞', '√', '∑', '∏', '∫', '∂', '∇', '∀', '∃', '∅', '∈', '∉', '⊂', '⊃', '∪', '∩', '⊥', '∠', '°', '%', '‰'],
8
+ 'Currency': ['$', '€', '£', '¥', '¢', '₹', '₽', '₩', '₪', '₫', '฿', '₺', '₴', '₦', '₲', '₵', '₡'],
9
+ 'Greek Letters': ['α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', 'Δ', 'Σ', 'Ω', 'Φ', 'Ψ', 'Γ', 'Λ', 'Π', 'Θ', 'Ξ'],
10
+ 'Punctuation & Typography': ['©', '®', '™', '§', '¶', '†', '‡', '•', '…', '–', '—', '“', '”', '‘', '’', '«', '»', '¿', '¡'],
11
+ 'Box Drawing': ['─', '│', '┌', '┐', '└', '┘', '├', '┤', '┬', '┴', '┼', '═', '║', '╔', '╗', '╚', '╝', '╠', '╣', '╦', '╩', '╬'],
12
+ 'Superscript & Subscript': ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹', '⁺', '⁻', '₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉', '₊', '₋']
13
+ };
14
+
15
+ export async function specialCharsHandler() {
16
+ const allSymbols = [];
17
+ let globalIndex = 1;
18
+ const colCount = 6; // Number of columns in the grid
19
+
20
+ // Prepare the list of symbols
21
+ Object.entries(categories).forEach(([category, symbols]) => {
22
+ symbols.forEach(char => {
23
+ allSymbols.push({
24
+ index: globalIndex++,
25
+ char: char,
26
+ category: category
27
+ });
28
+ });
29
+ });
30
+
31
+ while (true) {
32
+ console.log('\n=== Special Characters ===\n');
33
+
34
+ // Display symbols in a grid grouped by category
35
+ let currentCategory = '';
36
+ let rowBuffer = [];
37
+
38
+ allSymbols.forEach((item, i) => {
39
+ // Check if category changed
40
+ if (item.category !== currentCategory) {
41
+ // Print remaining buffer from previous category
42
+ if (rowBuffer.length > 0) {
43
+ console.log(rowBuffer.join(''));
44
+ rowBuffer = [];
45
+ }
46
+ currentCategory = item.category;
47
+ console.log(`\n--- ${currentCategory} ---`);
48
+ }
49
+
50
+ // Add item to buffer
51
+ // Format: "123. X " padded
52
+ const label = `${item.index}. ${item.char}`;
53
+ rowBuffer.push(label.padEnd(10)); // Adjust padding as needed
54
+
55
+ // If buffer full, print row
56
+ if (rowBuffer.length >= colCount) {
57
+ console.log(rowBuffer.join(''));
58
+ rowBuffer = [];
59
+ }
60
+ });
61
+
62
+ // Print remaining items
63
+ if (rowBuffer.length > 0) {
64
+ console.log(rowBuffer.join(''));
65
+ }
66
+
67
+ console.log('\n0. Back to Main Menu');
68
+ console.log('==========================\n');
69
+
70
+ const { input } = await inquirer.prompt([
71
+ {
72
+ type: 'input',
73
+ name: 'input',
74
+ message: 'Enter the number of the symbol to copy:',
75
+ validate: (val) => {
76
+ if (val === '0') return true;
77
+ const num = parseInt(val);
78
+ if (isNaN(num) || num < 1 || num > allSymbols.length) {
79
+ return 'Please enter a valid number.';
80
+ }
81
+ return true;
82
+ }
83
+ }
84
+ ]);
85
+
86
+ if (input === '0') {
87
+ break;
88
+ }
89
+
90
+ const selected = allSymbols[parseInt(input) - 1];
91
+ await copy(selected.char);
92
+ console.log(`\nCopied '${selected.char}' to clipboard!`);
93
+ }
94
+ }
package/src/index.js CHANGED
@@ -12,6 +12,7 @@ import { colorHandler } from './commands/color.js';
12
12
  import { variableFormatHandler } from './commands/variableFormat.js';
13
13
  import { hashingHandler } from './commands/hashing.js';
14
14
  import { qrcodeHandler } from './commands/qrcode.js';
15
+ import { specialCharsHandler } from './commands/specialChars.js';
15
16
 
16
17
  process.on('SIGINT', () => {
17
18
  console.log('\nBye!');
@@ -40,7 +41,8 @@ const features = [
40
41
  { name: 'Color Converter (Hex <-> RGB)', value: 'color' },
41
42
  { name: 'Variable Format Converter', value: 'variableFormat' },
42
43
  { name: 'Hash Calculator (MD5/SHA/SM3)', value: 'hashing' },
43
- { name: 'QR Code Generator', value: 'qrcode' }
44
+ { name: 'QR Code Generator', value: 'qrcode' },
45
+ { name: 'Special Characters (Symbols)', value: 'specialChars' }
44
46
  ];
45
47
 
46
48
  async function main() {
@@ -155,6 +157,9 @@ async function handleAction(action) {
155
157
  case 'qrcode':
156
158
  await qrcodeHandler();
157
159
  break;
160
+ case 'specialChars':
161
+ await specialCharsHandler();
162
+ break;
158
163
  default:
159
164
  console.log('Feature not implemented yet.');
160
165
  }