ai-yuca 1.2.7 → 1.2.8

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/bin/cli.js CHANGED
@@ -38,6 +38,7 @@ const commander_1 = require("commander");
38
38
  const pkg = __importStar(require("../package.json"));
39
39
  const fs = __importStar(require("fs"));
40
40
  const path = __importStar(require("path"));
41
+ const child_process_1 = require("child_process");
41
42
  const index_1 = require("../src/index");
42
43
  const upload_1 = require("../src/upload");
43
44
  const download_1 = require("../src/download");
@@ -388,6 +389,72 @@ program
388
389
  process.exit(1);
389
390
  }
390
391
  });
392
+ // 添加crowdin-push命令
393
+ program
394
+ .command('crowdin-push')
395
+ .description('推送本地keys文件到Crowdin项目')
396
+ .option('-c, --config <path>', '指定配置文件路径(默认为项目根目录下的vs.config.json)')
397
+ .action(async (options) => {
398
+ try {
399
+ const { config: configPath } = options;
400
+ // 1. 读取vs.config.json文件
401
+ const configFile = configPath || path.join(process.cwd(), 'vs.config.json');
402
+ if (!fs.existsSync(configFile)) {
403
+ console.error(`❌ 配置文件不存在: ${configFile}`);
404
+ process.exit(1);
405
+ }
406
+ console.log(`📖 读取配置文件: ${configFile}`);
407
+ const configContent = fs.readFileSync(configFile, 'utf8');
408
+ const cg = JSON.parse(configContent);
409
+ // 检查crowdin配置是否存在
410
+ if (!cg.crowdin || !cg.crowdin.keysDir || !cg.crowdin.project) {
411
+ console.error('❌ 配置文件中缺少必要的crowdin配置项 (keysDir, project)');
412
+ process.exit(1);
413
+ }
414
+ // 检查必要的上传配置
415
+ if (!cg.crowdin.Bucket) {
416
+ console.error('❌ 配置文件中缺少必要的crowdin.Bucket配置项');
417
+ process.exit(1);
418
+ }
419
+ console.log(`📋 Crowdin项目: ${cg.crowdin.project}`);
420
+ console.log(`📁 Keys目录: ${cg.crowdin.keysDir}`);
421
+ console.log(`🪣 存储桶: ${cg.crowdin.Bucket}`);
422
+ // 2. 生成可执行命令
423
+ let command = `ai-yuca upload -s ${cg.crowdin.keysDir}/keys -d crowdin/keys/${cg.crowdin.project} -b ${cg.crowdin.Bucket} -r`;
424
+ // 如果有密钥文件配置,添加密钥文件参数
425
+ if (cg.aws && cg.aws.FileKey) {
426
+ command += ` -k ${cg.aws.FileKey}`;
427
+ console.log(`🔑 密钥文件: ${cg.aws.FileKey}`);
428
+ }
429
+ console.log(`🚀 执行命令: ${command}`);
430
+ // 3. 执行execSync并返回结果
431
+ try {
432
+ const result = (0, child_process_1.execSync)(command, {
433
+ encoding: 'utf8',
434
+ stdio: 'pipe',
435
+ cwd: process.cwd()
436
+ });
437
+ console.log('✅ 命令执行成功!');
438
+ console.log('📤 执行结果:');
439
+ console.log(result);
440
+ }
441
+ catch (execError) {
442
+ console.error('❌ 命令执行失败:');
443
+ console.error('错误信息:', execError.message);
444
+ if (execError.stdout) {
445
+ console.log('标准输出:', execError.stdout);
446
+ }
447
+ if (execError.stderr) {
448
+ console.error('错误输出:', execError.stderr);
449
+ }
450
+ process.exit(1);
451
+ }
452
+ }
453
+ catch (err) {
454
+ console.error(`❌ Crowdin Push 操作失败: ${err instanceof Error ? err.message : String(err)}`);
455
+ process.exit(1);
456
+ }
457
+ });
391
458
  program.parse(process.argv);
392
459
  if (!process.argv.slice(2).length) {
393
460
  program.outputHelp();
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -26,7 +26,7 @@ export declare class CacheManager {
26
26
  /**
27
27
  * 检查文件是否已经上传过
28
28
  */
29
- isFileUploaded(filePath: string): boolean;
29
+ isFileUploaded(filePath: string, replacePath?: string): boolean;
30
30
  /**
31
31
  * 获取已上传文件的URL
32
32
  */
package/dist/src/cache.js CHANGED
@@ -93,9 +93,12 @@ class CacheManager {
93
93
  /**
94
94
  * 检查文件是否已经上传过
95
95
  */
96
- isFileUploaded(filePath) {
96
+ isFileUploaded(filePath, replacePath) {
97
97
  const hash = this.getFileHash(filePath);
98
- return hash in this.cache;
98
+ const fileLink = filePath.replace(replacePath || '', '');
99
+ const newReg = new RegExp(`${fileLink}$`);
100
+ // console.log(hash in this.cache, !newReg.test(this.cache[hash]), filePath, this.cache[hash])
101
+ return hash in this.cache && newReg.test(this.cache[hash] || '');
99
102
  }
100
103
  /**
101
104
  * 获取已上传文件的URL
@@ -130,7 +130,7 @@ async function uploadFilesWithConfig(options = {}) {
130
130
  // 获取所有需要处理的文件
131
131
  const allFiles = await getFilesToProcess(sourcePath, recursive, exclude);
132
132
  for (const filePath of allFiles) {
133
- if (cacheManager.isFileUploaded(filePath)) {
133
+ if (cacheManager.isFileUploaded(filePath, path.join(process.cwd(), config.upload.uploadPath))) {
134
134
  skippedFiles.push(filePath);
135
135
  }
136
136
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",