ai-yuca 1.4.4 → 1.4.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+ # JumpServer 登录脚本
3
+ # 用法: ./脚本名.sh -s 目标IP [-u 用户名]
4
+
5
+ # 定义默认配置
6
+ DEFAULT_JUMP_USER="zhengjingpei"
7
+ JUMP_HOST="jump.valleysound.xyz"
8
+ JUMP_PORT=2222
9
+
10
+ JUMP_USER="${DEFAULT_JUMP_USER}"
11
+ TARGET=""
12
+
13
+ # 处理参数逻辑
14
+ while getopts "s:u:" opt; do
15
+ case $opt in
16
+ s)
17
+ TARGET="$OPTARG"
18
+ ;;
19
+ u)
20
+ JUMP_USER="$OPTARG"
21
+ ;;
22
+ \?)
23
+ echo "无效选项: -$OPTARG" >&2
24
+ exit 1
25
+ ;;
26
+ esac
27
+ done
28
+
29
+ if [ -z "$TARGET" ]; then
30
+ echo "错误: 必须指定目标IP (-s)"
31
+ echo "用法: $0 -s <目标IP/关键字> [-u <JumpServer用户名>]"
32
+ echo " 示例: $0 -s 10.10.0.3"
33
+ echo " 示例: $0 -s 10.10.0.3 -u zhengjingpei"
34
+ exit 1
35
+ fi
36
+
37
+ # 核心登录逻辑
38
+ expect -c '
39
+ set timeout -1
40
+ # 拼接SSH命令(使用配置的用户名、端口、主机)
41
+ spawn ssh -tt -p '"${JUMP_PORT}"' '"${JUMP_USER}"'@'"${JUMP_HOST}"'
42
+ # 等待JumpServer主菜单提示符
43
+ expect "Opt>"
44
+ # 发送目标IP/关键字
45
+ send "'"${TARGET}"'\r"
46
+ # 处理后续交互场景
47
+ expect {
48
+ "复用SSH连接" { send "\r"; interact } # 复用连接时自动回车
49
+ "Last login:" { interact } # 直接登录成功
50
+ "Opt>" { interact } # 回到菜单(手动选择)
51
+ }
52
+ # 兜底保持交互
53
+ interact
54
+ '
@@ -115,24 +115,44 @@ async function transKey(options) {
115
115
  // 读取旧文件
116
116
  const oldFilePath = path.join(oldFilesDir, fileName);
117
117
  let oldData = {};
118
+ // 读取 keysDir 下的文件 (主翻译文件)
118
119
  if (fs.existsSync(oldFilePath)) {
119
120
  try {
120
121
  oldData = JSON.parse(fs.readFileSync(oldFilePath, 'utf8'));
121
- // console.log(`读取旧文件: ${oldFilePath}`);
122
122
  }
123
123
  catch (e) {
124
- console.warn(`无法解析旧文件: ${oldFilePath}`);
124
+ console.warn(`无法解析主翻译文件: ${oldFilePath}`);
125
125
  }
126
126
  }
127
- else {
128
- // console.log(`旧文件不存在: ${oldFilePath} (这是新语言?)`);
127
+ // 读取 source 下的旧文件 (如果存在)
128
+ const sourceFilePath = path.join(outputDir, fileName);
129
+ let sourceData = {};
130
+ if (fs.existsSync(sourceFilePath)) {
131
+ try {
132
+ sourceData = JSON.parse(fs.readFileSync(sourceFilePath, 'utf8'));
133
+ let hasChange = false;
134
+ // 将 source 中的翻译合并到 oldData (如果 oldData 中没有,或者 source 中有值而 oldData 为空)
135
+ for (const key in sourceData) {
136
+ if (sourceData[key] && !oldData[key]) {
137
+ oldData[key] = sourceData[key];
138
+ hasChange = true;
139
+ }
140
+ }
141
+ if (hasChange) {
142
+ fs.writeFileSync(oldFilePath, JSON.stringify(oldData, null, 2), 'utf8');
143
+ console.log(`♻️ 已将 source 中的翻译整合回: ${oldFilePath}`);
144
+ }
145
+ }
146
+ catch (e) {
147
+ console.warn(`无法解析 source 文件: ${sourceFilePath}`);
148
+ }
129
149
  }
130
- // 生成新数据
150
+ // 生成新数据 (输出到 source 目录)
131
151
  const newData = {};
132
152
  const sortedKeys = Array.from(keys).sort();
133
153
  let matchedCount = 0;
134
154
  for (const key of sortedKeys) {
135
- // 如果旧文件有值,就用旧文件的值,否则为空字符串
155
+ // 优先使用整合后的 oldData
136
156
  if (oldData[key]) {
137
157
  newData[key] = oldData[key];
138
158
  matchedCount++;
@@ -141,7 +161,7 @@ async function transKey(options) {
141
161
  newData[key] = '';
142
162
  }
143
163
  }
144
- // 写入文件
164
+ // 写入文件到 source 目录
145
165
  fs.writeFileSync(outputPath, JSON.stringify(newData, null, 2), 'utf8');
146
166
  console.log(`✅ 生成 ${fileName}: 总 Key 数 ${sortedKeys.length}, 已翻译 ${matchedCount}`);
147
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",