ai-yuca 1.1.3 → 1.1.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/bin/cli.ts CHANGED
@@ -9,7 +9,8 @@ import { createStorageClient, uploadFiles } from '../src/upload';
9
9
  import { downloadFiles } from '../src/download';
10
10
  import { uploadFilesWithConfig, getConfigSummary } from '../src/uploadWithConfig';
11
11
  import { deployFiles } from '../src/deploy';
12
- import { AnalyzeOptions, UploadFilesResult, UploadCommandOptions, DownloadCommandOptions, UploadWithConfigOptions, DeployCommandOptions } from '../src/types';
12
+ import { pullCrowdin } from '../src/pullCrowdin';
13
+ import { AnalyzeOptions, UploadFilesResult, UploadCommandOptions, DownloadCommandOptions, UploadWithConfigOptions, DeployCommandOptions, PullCrowdinCommandOptions } from '../src/types';
13
14
 
14
15
  const program = new Command();
15
16
 
@@ -270,68 +271,53 @@ program
270
271
  .option('-f, --force', '强制覆盖已存在的配置文件')
271
272
  .action(async (options: any) => {
272
273
  try {
273
- const { force = false } = options;
274
274
  const configPath = path.join(process.cwd(), 'vs.config.json');
275
275
 
276
276
  // 检查文件是否已存在
277
- if (fs.existsSync(configPath) && !force) {
278
- console.error('错误: vs.config.json 文件已存在。使用 --force 选项强制覆盖。');
279
- process.exit(1);
277
+ if (fs.existsSync(configPath) && !options.force) {
278
+ console.log('vs.config.json 文件已存在。使用 --force 选项强制覆盖。');
279
+ return;
280
280
  }
281
281
 
282
- // 默认配置数据
282
+ // 默认配置内容
283
283
  const defaultConfig = {
284
284
  "upload": {
285
285
  "uploadPath": "out",
286
- "s3Static": "static/aiAgent"
286
+ "s3Static": "static/projectName"
287
287
  },
288
288
  "deploy": {
289
289
  "baseUrlExample": "baseUrl: ['/', 'en-us/', 'zh-hk/', 'test/']",
290
290
  "baseUrl": [
291
291
  "/",
292
292
  "en-us/",
293
- "zh-cn/",
294
- "de-de/",
295
- "it-it/",
296
- "pt-pt/",
297
- "es-es/",
298
- "fr-fr/",
299
- "ru-ru/",
300
- "error/",
301
- "download-v2/"
302
293
  ],
303
- "host": "https://www.china2u.xyz",
304
- "testHost": "https://ai.decom.valleysound.xyz"
294
+ "host": "",
295
+ "testHost": ""
305
296
  },
306
297
  "aws": {
307
- "Bucket": "decom-cdn",
298
+ "Bucket": "cdn",
308
299
  "prefix": "fed",
309
300
  "Region": "us-east-1",
310
- "HostName": "https://cdn.cn2u.xyz"
301
+ "HostName": ""
311
302
  },
312
303
  "crowdin": {
313
- "project": "fed-buy-buy-buy-home",
304
+ "project": "fed-project-name",
314
305
  "langMap": ["zh-cn","en-us", "de-de", "pt-pt", "fr-fr", "es-es", "it-it", "ru-ru"],
315
306
  "workDir": "src",
316
307
  "reg": "{#(.+?)#}",
317
308
  "keysDir": "src/_i18n",
318
- "Bucket": "mall-rocket-cdn",
319
309
  "prefix": "fed",
320
310
  "Region": "us-east-1",
321
311
  "FromIni": "mall",
322
- "HostName": "https://cdn.alvinclub.ca"
312
+ "HostName": ""
323
313
  }
324
314
  };
325
315
 
326
316
  // 写入配置文件
327
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf-8');
317
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8');
328
318
 
329
- console.log(`✓ 成功生成配置文件: ${configPath}`);
330
- console.log('\n配置文件内容:');
331
- console.log(` 桶名称: ${defaultConfig.aws.Bucket}`);
332
- console.log(` 源路径: ${defaultConfig.upload.uploadPath}`);
333
- console.log(` 目标路径: ${defaultConfig.aws.prefix}/${defaultConfig.upload.s3Static}`);
334
- console.log('\n您可以根据需要修改配置文件中的值。');
319
+ console.log('✓ vs.config.json 配置文件已生成');
320
+ console.log('请根据您的项目需求修改配置文件中的相关参数。');
335
321
 
336
322
  } catch (err) {
337
323
  console.error(`生成配置文件失败: ${err instanceof Error ? err.message : String(err)}`);
@@ -339,10 +325,42 @@ program
339
325
  }
340
326
  });
341
327
 
342
- // 解析命令行参数
328
+ // 添加pull-crowdin命令
329
+ program
330
+ .command('pull-crowdin')
331
+ .description('从GCP下载Crowdin相关的JSON资源文件')
332
+ .option('-c, --config <path>', '指定配置文件路径(默认为项目根目录下的vs.config.json)')
333
+ .option('-k, --key-file <path>', 'GCP服务账号密钥文件路径(可选,不提供则使用应用默认凭证)')
334
+ .option('-r, --region <region>', 'GCP区域(默认为ap-southeast-1)')
335
+ .option('--exclude <pattern>', '排除包含指定模式的文件')
336
+ .option('--aws', '使用AWS凭证而非GCP凭证')
337
+ .action(async (options: PullCrowdinCommandOptions) => {
338
+ try {
339
+ const {
340
+ config: configPath,
341
+ keyFile,
342
+ region,
343
+ exclude,
344
+ aws = false
345
+ } = options;
346
+
347
+ // 执行pull-crowdin操作
348
+ await pullCrowdin({
349
+ config: configPath,
350
+ keyFile,
351
+ region,
352
+ exclude,
353
+ aws
354
+ });
355
+
356
+ } catch (err) {
357
+ console.error(`Pull Crowdin 操作失败: ${err instanceof Error ? err.message : String(err)}`);
358
+ process.exit(1);
359
+ }
360
+ });
361
+
343
362
  program.parse(process.argv);
344
363
 
345
- // 如果没有提供任何命令,显示帮助信息
346
364
  if (!process.argv.slice(2).length) {
347
365
  program.outputHelp();
348
366
  }
package/dist/bin/cli.js CHANGED
@@ -43,6 +43,7 @@ const upload_1 = require("../src/upload");
43
43
  const download_1 = require("../src/download");
44
44
  const uploadWithConfig_1 = require("../src/uploadWithConfig");
45
45
  const deploy_1 = require("../src/deploy");
46
+ const pullCrowdin_1 = require("../src/pullCrowdin");
46
47
  const program = new commander_1.Command();
47
48
  // 设置版本和描述
48
49
  program
@@ -268,73 +269,82 @@ program
268
269
  .option('-f, --force', '强制覆盖已存在的配置文件')
269
270
  .action(async (options) => {
270
271
  try {
271
- const { force = false } = options;
272
272
  const configPath = path.join(process.cwd(), 'vs.config.json');
273
273
  // 检查文件是否已存在
274
- if (fs.existsSync(configPath) && !force) {
275
- console.error('错误: vs.config.json 文件已存在。使用 --force 选项强制覆盖。');
276
- process.exit(1);
274
+ if (fs.existsSync(configPath) && !options.force) {
275
+ console.log('vs.config.json 文件已存在。使用 --force 选项强制覆盖。');
276
+ return;
277
277
  }
278
- // 默认配置数据
278
+ // 默认配置内容
279
279
  const defaultConfig = {
280
280
  "upload": {
281
281
  "uploadPath": "out",
282
- "s3Static": "static/aiAgent"
282
+ "s3Static": "static/projectName"
283
283
  },
284
284
  "deploy": {
285
285
  "baseUrlExample": "baseUrl: ['/', 'en-us/', 'zh-hk/', 'test/']",
286
286
  "baseUrl": [
287
287
  "/",
288
288
  "en-us/",
289
- "zh-cn/",
290
- "de-de/",
291
- "it-it/",
292
- "pt-pt/",
293
- "es-es/",
294
- "fr-fr/",
295
- "ru-ru/",
296
- "error/",
297
- "download-v2/"
298
289
  ],
299
- "host": "https://www.china2u.xyz",
300
- "testHost": "https://ai.decom.valleysound.xyz"
290
+ "host": "",
291
+ "testHost": ""
301
292
  },
302
293
  "aws": {
303
- "Bucket": "decom-cdn",
294
+ "Bucket": "cdn",
304
295
  "prefix": "fed",
305
296
  "Region": "us-east-1",
306
- "HostName": "https://cdn.cn2u.xyz"
297
+ "HostName": ""
307
298
  },
308
299
  "crowdin": {
309
- "project": "fed-buy-buy-buy-home",
300
+ "project": "fed-project-name",
310
301
  "langMap": ["zh-cn", "en-us", "de-de", "pt-pt", "fr-fr", "es-es", "it-it", "ru-ru"],
311
302
  "workDir": "src",
312
303
  "reg": "{#(.+?)#}",
313
304
  "keysDir": "src/_i18n",
314
- "Bucket": "mall-rocket-cdn",
315
305
  "prefix": "fed",
316
306
  "Region": "us-east-1",
317
307
  "FromIni": "mall",
318
- "HostName": "https://cdn.alvinclub.ca"
308
+ "HostName": ""
319
309
  }
320
310
  };
321
311
  // 写入配置文件
322
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf-8');
323
- console.log(`✓ 成功生成配置文件: ${configPath}`);
324
- console.log('\n配置文件内容:');
325
- console.log(` 桶名称: ${defaultConfig.aws.Bucket}`);
326
- console.log(` 源路径: ${defaultConfig.upload.uploadPath}`);
327
- console.log(` 目标路径: ${defaultConfig.aws.prefix}/${defaultConfig.upload.s3Static}`);
328
- console.log('\n您可以根据需要修改配置文件中的值。');
312
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8');
313
+ console.log('✓ vs.config.json 配置文件已生成');
314
+ console.log('请根据您的项目需求修改配置文件中的相关参数。');
329
315
  }
330
316
  catch (err) {
331
317
  console.error(`生成配置文件失败: ${err instanceof Error ? err.message : String(err)}`);
332
318
  process.exit(1);
333
319
  }
334
320
  });
335
- // 解析命令行参数
321
+ // 添加pull-crowdin命令
322
+ program
323
+ .command('pull-crowdin')
324
+ .description('从GCP下载Crowdin相关的JSON资源文件')
325
+ .option('-c, --config <path>', '指定配置文件路径(默认为项目根目录下的vs.config.json)')
326
+ .option('-k, --key-file <path>', 'GCP服务账号密钥文件路径(可选,不提供则使用应用默认凭证)')
327
+ .option('-r, --region <region>', 'GCP区域(默认为ap-southeast-1)')
328
+ .option('--exclude <pattern>', '排除包含指定模式的文件')
329
+ .option('--aws', '使用AWS凭证而非GCP凭证')
330
+ .action(async (options) => {
331
+ try {
332
+ const { config: configPath, keyFile, region, exclude, aws = false } = options;
333
+ // 执行pull-crowdin操作
334
+ await (0, pullCrowdin_1.pullCrowdin)({
335
+ config: configPath,
336
+ keyFile,
337
+ region,
338
+ exclude,
339
+ aws
340
+ });
341
+ }
342
+ catch (err) {
343
+ console.error(`Pull Crowdin 操作失败: ${err instanceof Error ? err.message : String(err)}`);
344
+ process.exit(1);
345
+ }
346
+ });
336
347
  program.parse(process.argv);
337
- // 如果没有提供任何命令,显示帮助信息
338
348
  if (!process.argv.slice(2).length) {
339
349
  program.outputHelp();
340
350
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.1.3",
3
+ "version": "1.1.6",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -34,6 +34,7 @@
34
34
  "axios": "^1.12.1",
35
35
  "chalk": "^4.1.2",
36
36
  "commander": "^10.0.0",
37
+ "fast-glob": "^3.3.3",
37
38
  "inquirer": "^12.9.4",
38
39
  "md5-file": "^5.0.0"
39
40
  },
@@ -0,0 +1,22 @@
1
+ import { Storage } from '@google-cloud/storage';
2
+ import { PullCrowdinCommandOptions, CreateGCPClientResult, MergedConfig, OnlineKeysResult, FileDownloadResult, TranslateFilesResult } from './types/pullCrowdin';
3
+ /**
4
+ * 创建GCP客户端实例
5
+ */
6
+ export declare function createGCPClient(argv: PullCrowdinCommandOptions): Promise<CreateGCPClientResult>;
7
+ /**
8
+ * 下载远端keys文件
9
+ */
10
+ export declare function getFilesOnline(gcpClient: Storage, config: MergedConfig): Promise<FileDownloadResult>;
11
+ /**
12
+ * 获取在线密钥列表
13
+ */
14
+ export declare function getOnlineKeys(exclude?: string): Promise<OnlineKeysResult>;
15
+ /**
16
+ * 下载翻译文件
17
+ */
18
+ export declare function getTransLateFiles(gcpClient: Storage, config: MergedConfig): Promise<TranslateFilesResult>;
19
+ /**
20
+ * pull-crowdin主函数
21
+ */
22
+ export declare function pullCrowdin(options: PullCrowdinCommandOptions): Promise<void>;