ai-yuca 1.1.3 → 1.1.4

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,58 @@ 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
- "uploadPath": "out",
286
- "s3Static": "static/aiAgent"
287
- },
288
- "deploy": {
289
- "baseUrlExample": "baseUrl: ['/', 'en-us/', 'zh-hk/', 'test/']",
290
- "baseUrl": [
291
- "/",
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
- ],
303
- "host": "https://www.china2u.xyz",
304
- "testHost": "https://ai.decom.valleysound.xyz"
285
+ "uploadPath": "./dist",
286
+ "bucketName": "your-bucket-name",
287
+ "destination": "uploads/",
288
+ "enableCompression": true,
289
+ "enableCache": true
305
290
  },
306
291
  "aws": {
307
- "Bucket": "decom-cdn",
308
- "prefix": "fed",
309
- "Region": "us-east-1",
310
- "HostName": "https://cdn.cn2u.xyz"
292
+ "region": "ap-southeast-1",
293
+ "fromIni": false,
294
+ "accessKeyId": "your-access-key-id",
295
+ "secretAccessKey": "your-secret-access-key"
296
+ },
297
+ "deploy": {
298
+ "environments": {
299
+ "dev": {
300
+ "bucketName": "your-dev-bucket",
301
+ "destination": "dev/"
302
+ },
303
+ "production": {
304
+ "bucketName": "your-prod-bucket",
305
+ "destination": "prod/"
306
+ }
307
+ }
311
308
  },
312
309
  "crowdin": {
313
- "project": "fed-buy-buy-buy-home",
314
- "langMap": ["zh-cn","en-us", "de-de", "pt-pt", "fr-fr", "es-es", "it-it", "ru-ru"],
315
- "workDir": "src",
316
- "reg": "{#(.+?)#}",
317
- "keysDir": "src/_i18n",
318
- "Bucket": "mall-rocket-cdn",
319
- "prefix": "fed",
320
- "Region": "us-east-1",
321
- "FromIni": "mall",
322
- "HostName": "https://cdn.alvinclub.ca"
310
+ "project": "your-project-name",
311
+ "keysDir": "./locales",
312
+ "prefix": "crowdin/",
313
+ "hostName": "https://your-host.com",
314
+ "langMap": {
315
+ "en-US": "en",
316
+ "zh-CN": "zh"
317
+ }
323
318
  }
324
319
  };
325
320
 
326
321
  // 写入配置文件
327
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf-8');
322
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8');
328
323
 
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您可以根据需要修改配置文件中的值。');
324
+ console.log('✓ vs.config.json 配置文件已生成');
325
+ console.log('请根据您的项目需求修改配置文件中的相关参数。');
335
326
 
336
327
  } catch (err) {
337
328
  console.error(`生成配置文件失败: ${err instanceof Error ? err.message : String(err)}`);
@@ -339,10 +330,42 @@ program
339
330
  }
340
331
  });
341
332
 
342
- // 解析命令行参数
333
+ // 添加pull-crowdin命令
334
+ program
335
+ .command('pull-crowdin')
336
+ .description('从GCP下载Crowdin相关的JSON资源文件')
337
+ .option('-c, --config <path>', '指定配置文件路径(默认为项目根目录下的vs.config.json)')
338
+ .option('-k, --key-file <path>', 'GCP服务账号密钥文件路径(可选,不提供则使用应用默认凭证)')
339
+ .option('-r, --region <region>', 'GCP区域(默认为ap-southeast-1)')
340
+ .option('--exclude <pattern>', '排除包含指定模式的文件')
341
+ .option('--aws', '使用AWS凭证而非GCP凭证')
342
+ .action(async (options: PullCrowdinCommandOptions) => {
343
+ try {
344
+ const {
345
+ config: configPath,
346
+ keyFile,
347
+ region,
348
+ exclude,
349
+ aws = false
350
+ } = options;
351
+
352
+ // 执行pull-crowdin操作
353
+ await pullCrowdin({
354
+ config: configPath,
355
+ keyFile,
356
+ region,
357
+ exclude,
358
+ aws
359
+ });
360
+
361
+ } catch (err) {
362
+ console.error(`Pull Crowdin 操作失败: ${err instanceof Error ? err.message : String(err)}`);
363
+ process.exit(1);
364
+ }
365
+ });
366
+
343
367
  program.parse(process.argv);
344
368
 
345
- // 如果没有提供任何命令,显示帮助信息
346
369
  if (!process.argv.slice(2).length) {
347
370
  program.outputHelp();
348
371
  }
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,87 @@ 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
- "uploadPath": "out",
282
- "s3Static": "static/aiAgent"
283
- },
284
- "deploy": {
285
- "baseUrlExample": "baseUrl: ['/', 'en-us/', 'zh-hk/', 'test/']",
286
- "baseUrl": [
287
- "/",
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
- ],
299
- "host": "https://www.china2u.xyz",
300
- "testHost": "https://ai.decom.valleysound.xyz"
281
+ "uploadPath": "./dist",
282
+ "bucketName": "your-bucket-name",
283
+ "destination": "uploads/",
284
+ "enableCompression": true,
285
+ "enableCache": true
301
286
  },
302
287
  "aws": {
303
- "Bucket": "decom-cdn",
304
- "prefix": "fed",
305
- "Region": "us-east-1",
306
- "HostName": "https://cdn.cn2u.xyz"
288
+ "region": "ap-southeast-1",
289
+ "fromIni": false,
290
+ "accessKeyId": "your-access-key-id",
291
+ "secretAccessKey": "your-secret-access-key"
292
+ },
293
+ "deploy": {
294
+ "environments": {
295
+ "dev": {
296
+ "bucketName": "your-dev-bucket",
297
+ "destination": "dev/"
298
+ },
299
+ "production": {
300
+ "bucketName": "your-prod-bucket",
301
+ "destination": "prod/"
302
+ }
303
+ }
307
304
  },
308
305
  "crowdin": {
309
- "project": "fed-buy-buy-buy-home",
310
- "langMap": ["zh-cn", "en-us", "de-de", "pt-pt", "fr-fr", "es-es", "it-it", "ru-ru"],
311
- "workDir": "src",
312
- "reg": "{#(.+?)#}",
313
- "keysDir": "src/_i18n",
314
- "Bucket": "mall-rocket-cdn",
315
- "prefix": "fed",
316
- "Region": "us-east-1",
317
- "FromIni": "mall",
318
- "HostName": "https://cdn.alvinclub.ca"
306
+ "project": "your-project-name",
307
+ "keysDir": "./locales",
308
+ "prefix": "crowdin/",
309
+ "hostName": "https://your-host.com",
310
+ "langMap": {
311
+ "en-US": "en",
312
+ "zh-CN": "zh"
313
+ }
319
314
  }
320
315
  };
321
316
  // 写入配置文件
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您可以根据需要修改配置文件中的值。');
317
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8');
318
+ console.log('✓ vs.config.json 配置文件已生成');
319
+ console.log('请根据您的项目需求修改配置文件中的相关参数。');
329
320
  }
330
321
  catch (err) {
331
322
  console.error(`生成配置文件失败: ${err instanceof Error ? err.message : String(err)}`);
332
323
  process.exit(1);
333
324
  }
334
325
  });
335
- // 解析命令行参数
326
+ // 添加pull-crowdin命令
327
+ program
328
+ .command('pull-crowdin')
329
+ .description('从GCP下载Crowdin相关的JSON资源文件')
330
+ .option('-c, --config <path>', '指定配置文件路径(默认为项目根目录下的vs.config.json)')
331
+ .option('-k, --key-file <path>', 'GCP服务账号密钥文件路径(可选,不提供则使用应用默认凭证)')
332
+ .option('-r, --region <region>', 'GCP区域(默认为ap-southeast-1)')
333
+ .option('--exclude <pattern>', '排除包含指定模式的文件')
334
+ .option('--aws', '使用AWS凭证而非GCP凭证')
335
+ .action(async (options) => {
336
+ try {
337
+ const { config: configPath, keyFile, region, exclude, aws = false } = options;
338
+ // 执行pull-crowdin操作
339
+ await (0, pullCrowdin_1.pullCrowdin)({
340
+ config: configPath,
341
+ keyFile,
342
+ region,
343
+ exclude,
344
+ aws
345
+ });
346
+ }
347
+ catch (err) {
348
+ console.error(`Pull Crowdin 操作失败: ${err instanceof Error ? err.message : String(err)}`);
349
+ process.exit(1);
350
+ }
351
+ });
336
352
  program.parse(process.argv);
337
- // 如果没有提供任何命令,显示帮助信息
338
353
  if (!process.argv.slice(2).length) {
339
354
  program.outputHelp();
340
355
  }
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.4",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -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>;