ai-yuca 1.1.4 → 1.1.7

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.
Files changed (76) hide show
  1. package/.cdn.cache.json +5 -1
  2. package/bin/cli.ts +65 -38
  3. package/dist/bin/cli.js +60 -38
  4. package/dist/package.json +2 -1
  5. package/dist/src/config.d.ts +1 -0
  6. package/dist/src/download.js +17 -0
  7. package/dist/src/pullCrowdin.js +13 -5
  8. package/dist/src/types/pullCrowdin.d.ts +1 -0
  9. package/dist/src/upload.js +17 -0
  10. package/dist/src/uploadWithConfig.js +17 -0
  11. package/i18n/de-de.json +1211 -0
  12. package/i18n/en-us.json +1211 -0
  13. package/i18n/es-es.json +1211 -0
  14. package/i18n/fr-fr.json +1211 -0
  15. package/i18n/it-it.json +1211 -0
  16. package/i18n/keys/aiAgent.json +259 -0
  17. package/i18n/keys/dev_20250102.json +14 -0
  18. package/i18n/keys/h5.json +37 -0
  19. package/i18n/keys/main.json +436 -0
  20. package/i18n/keys/newsite.json +473 -0
  21. package/i18n/lang/de-de/aiAgent.json +259 -0
  22. package/i18n/lang/de-de/dev_20250102.json +14 -0
  23. package/i18n/lang/de-de/h5.json +37 -0
  24. package/i18n/lang/de-de/main.json +436 -0
  25. package/i18n/lang/de-de/newsite.json +473 -0
  26. package/i18n/lang/en-us/aiAgent.json +259 -0
  27. package/i18n/lang/en-us/dev_20250102.json +14 -0
  28. package/i18n/lang/en-us/dev_241116.json +49 -0
  29. package/i18n/lang/en-us/h5.json +37 -0
  30. package/i18n/lang/en-us/main.json +436 -0
  31. package/i18n/lang/en-us/newsite.json +473 -0
  32. package/i18n/lang/es-es/aiAgent.json +259 -0
  33. package/i18n/lang/es-es/dev_20250102.json +14 -0
  34. package/i18n/lang/es-es/h5.json +37 -0
  35. package/i18n/lang/es-es/main.json +436 -0
  36. package/i18n/lang/es-es/newsite.json +473 -0
  37. package/i18n/lang/fr-fr/aiAgent.json +259 -0
  38. package/i18n/lang/fr-fr/dev_20250102.json +14 -0
  39. package/i18n/lang/fr-fr/h5.json +37 -0
  40. package/i18n/lang/fr-fr/main.json +436 -0
  41. package/i18n/lang/fr-fr/newsite.json +473 -0
  42. package/i18n/lang/it-it/aiAgent.json +259 -0
  43. package/i18n/lang/it-it/dev_20250102.json +14 -0
  44. package/i18n/lang/it-it/h5.json +37 -0
  45. package/i18n/lang/it-it/main.json +436 -0
  46. package/i18n/lang/it-it/newsite.json +473 -0
  47. package/i18n/lang/pt-pt/aiAgent.json +259 -0
  48. package/i18n/lang/pt-pt/dev_20250102.json +14 -0
  49. package/i18n/lang/pt-pt/h5.json +37 -0
  50. package/i18n/lang/pt-pt/main.json +436 -0
  51. package/i18n/lang/pt-pt/newsite.json +473 -0
  52. package/i18n/lang/ru-ru/aiAgent.json +259 -0
  53. package/i18n/lang/ru-ru/dev_20250102.json +14 -0
  54. package/i18n/lang/ru-ru/h5.json +37 -0
  55. package/i18n/lang/ru-ru/main.json +436 -0
  56. package/i18n/lang/ru-ru/newsite.json +473 -0
  57. package/i18n/lang/zh-cn/aiAgent.json +259 -0
  58. package/i18n/lang/zh-cn/dev_20250102.json +14 -0
  59. package/i18n/lang/zh-cn/dev_241116.json +49 -0
  60. package/i18n/lang/zh-cn/h5.json +37 -0
  61. package/i18n/lang/zh-cn/main.json +436 -0
  62. package/i18n/lang/zh-cn/newsite.json +473 -0
  63. package/i18n/lang/zh-hk/dev_241116.json +49 -0
  64. package/i18n/lang/zh-hk/main.json +128 -0
  65. package/i18n/pt-pt.json +1211 -0
  66. package/i18n/ru-ru.json +1211 -0
  67. package/i18n/zh-cn.json +1211 -0
  68. package/i18n/zh-hk.json +128 -0
  69. package/package.json +2 -1
  70. package/src/config.ts +1 -0
  71. package/src/download.ts +16 -0
  72. package/src/pullCrowdin.ts +10 -4
  73. package/src/types/pullCrowdin.ts +1 -0
  74. package/src/upload.ts +16 -0
  75. package/src/uploadWithConfig.ts +15 -0
  76. package/vs.config.json +35 -29
package/.cdn.cache.json CHANGED
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "lastUploadVersion": "mfhlsh6u",
3
3
  "lastDeployTime": "2025-09-15T06:15:45.798Z",
4
- "lastDeployVersion": "mfkqd0es"
4
+ "lastDeployVersion": "mfkqd0es",
5
+ "66ed0b08d69ac10597199f757081f73f": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/package.json",
6
+ "8d687e843e19199df437e245ee166123": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/about.html",
7
+ "f7c4edbaf98ece51425d5a7bc7d92d8f": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/index.html",
8
+ "d41d8cd98f00b204e9800998ecf8427e": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/test.json"
5
9
  }
package/bin/cli.ts CHANGED
@@ -96,15 +96,47 @@ program
96
96
 
97
97
  console.log('开始上传文件...');
98
98
 
99
- // 执行上传
100
- const results = await uploadFiles({
101
- bucketName: bucket,
102
- sourcePath: source,
103
- destination,
104
- storageClient,
105
- recursive,
106
- enableCompression: compression
107
- });
99
+ // 处理多个源路径
100
+ let allResults: UploadFilesResult = { success: [], failed: [] };
101
+
102
+ for (const sourcePath of source) {
103
+ console.log(`\n处理路径: ${sourcePath}`);
104
+
105
+ // 检查路径是否存在
106
+ if (!fs.existsSync(sourcePath)) {
107
+ console.error(`错误: 路径不存在: ${sourcePath}`);
108
+ allResults.failed.push({
109
+ success: false,
110
+ file: sourcePath,
111
+ error: '路径不存在'
112
+ });
113
+ continue;
114
+ }
115
+
116
+ // 检查是文件还是文件夹
117
+ const stats = fs.statSync(sourcePath);
118
+ if (stats.isDirectory()) {
119
+ console.log(`检测到文件夹,将上传文件夹内的所有文件${recursive ? '(递归)' : '(仅当前层级)'}`);
120
+ } else {
121
+ console.log('检测到文件,将上传该文件');
122
+ }
123
+
124
+ // 执行上传
125
+ const results = await uploadFiles({
126
+ bucketName: bucket,
127
+ sourcePath: sourcePath,
128
+ destination,
129
+ storageClient,
130
+ recursive,
131
+ enableCompression: compression
132
+ });
133
+
134
+ // 合并结果
135
+ allResults.success = allResults.success.concat(results.success);
136
+ allResults.failed = allResults.failed.concat(results.failed);
137
+ }
138
+
139
+ const results = allResults;
108
140
 
109
141
  // 输出结果
110
142
  console.log('\n上传完成!');
@@ -282,39 +314,34 @@ program
282
314
  // 默认配置内容
283
315
  const defaultConfig = {
284
316
  "upload": {
285
- "uploadPath": "./dist",
286
- "bucketName": "your-bucket-name",
287
- "destination": "uploads/",
288
- "enableCompression": true,
289
- "enableCache": true
290
- },
291
- "aws": {
292
- "region": "ap-southeast-1",
293
- "fromIni": false,
294
- "accessKeyId": "your-access-key-id",
295
- "secretAccessKey": "your-secret-access-key"
317
+ "uploadPath": "out",
318
+ "s3Static": "static/projectName"
296
319
  },
297
320
  "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
- }
321
+ "baseUrlExample": "baseUrl: ['/', 'en-us/', 'zh-hk/', 'test/']",
322
+ "baseUrl": [
323
+ "/",
324
+ "en-us/",
325
+ ],
326
+ "host": "",
327
+ "testHost": ""
328
+ },
329
+ "aws": {
330
+ "Bucket": "cdn",
331
+ "prefix": "fed",
332
+ "Region": "us-east-1",
333
+ "HostName": ""
308
334
  },
309
335
  "crowdin": {
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
- }
336
+ "project": "fed-project-name",
337
+ "langMap": ["zh-cn","en-us", "de-de", "pt-pt", "fr-fr", "es-es", "it-it", "ru-ru"],
338
+ "workDir": "src",
339
+ "reg": "{#(.+?)#}",
340
+ "keysDir": "src/_i18n",
341
+ "prefix": "fed",
342
+ "Region": "us-east-1",
343
+ "FromIni": "mall",
344
+ "HostName": ""
318
345
  }
319
346
  };
320
347
 
package/dist/bin/cli.js CHANGED
@@ -119,15 +119,42 @@ program
119
119
  ? (0, upload_1.createStorageClient)({ keyFilename: keyFile })
120
120
  : (0, upload_1.createStorageClient)(); // 使用应用默认凭证
121
121
  console.log('开始上传文件...');
122
- // 执行上传
123
- const results = await (0, upload_1.uploadFiles)({
124
- bucketName: bucket,
125
- sourcePath: source,
126
- destination,
127
- storageClient,
128
- recursive,
129
- enableCompression: compression
130
- });
122
+ // 处理多个源路径
123
+ let allResults = { success: [], failed: [] };
124
+ for (const sourcePath of source) {
125
+ console.log(`\n处理路径: ${sourcePath}`);
126
+ // 检查路径是否存在
127
+ if (!fs.existsSync(sourcePath)) {
128
+ console.error(`错误: 路径不存在: ${sourcePath}`);
129
+ allResults.failed.push({
130
+ success: false,
131
+ file: sourcePath,
132
+ error: '路径不存在'
133
+ });
134
+ continue;
135
+ }
136
+ // 检查是文件还是文件夹
137
+ const stats = fs.statSync(sourcePath);
138
+ if (stats.isDirectory()) {
139
+ console.log(`检测到文件夹,将上传文件夹内的所有文件${recursive ? '(递归)' : '(仅当前层级)'}`);
140
+ }
141
+ else {
142
+ console.log('检测到文件,将上传该文件');
143
+ }
144
+ // 执行上传
145
+ const results = await (0, upload_1.uploadFiles)({
146
+ bucketName: bucket,
147
+ sourcePath: sourcePath,
148
+ destination,
149
+ storageClient,
150
+ recursive,
151
+ enableCompression: compression
152
+ });
153
+ // 合并结果
154
+ allResults.success = allResults.success.concat(results.success);
155
+ allResults.failed = allResults.failed.concat(results.failed);
156
+ }
157
+ const results = allResults;
131
158
  // 输出结果
132
159
  console.log('\n上传完成!');
133
160
  console.log(`成功: ${results.success.length} 个文件`);
@@ -278,39 +305,34 @@ program
278
305
  // 默认配置内容
279
306
  const defaultConfig = {
280
307
  "upload": {
281
- "uploadPath": "./dist",
282
- "bucketName": "your-bucket-name",
283
- "destination": "uploads/",
284
- "enableCompression": true,
285
- "enableCache": true
286
- },
287
- "aws": {
288
- "region": "ap-southeast-1",
289
- "fromIni": false,
290
- "accessKeyId": "your-access-key-id",
291
- "secretAccessKey": "your-secret-access-key"
308
+ "uploadPath": "out",
309
+ "s3Static": "static/projectName"
292
310
  },
293
311
  "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
- }
312
+ "baseUrlExample": "baseUrl: ['/', 'en-us/', 'zh-hk/', 'test/']",
313
+ "baseUrl": [
314
+ "/",
315
+ "en-us/",
316
+ ],
317
+ "host": "",
318
+ "testHost": ""
319
+ },
320
+ "aws": {
321
+ "Bucket": "cdn",
322
+ "prefix": "fed",
323
+ "Region": "us-east-1",
324
+ "HostName": ""
304
325
  },
305
326
  "crowdin": {
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
- }
327
+ "project": "fed-project-name",
328
+ "langMap": ["zh-cn", "en-us", "de-de", "pt-pt", "fr-fr", "es-es", "it-it", "ru-ru"],
329
+ "workDir": "src",
330
+ "reg": "{#(.+?)#}",
331
+ "keysDir": "src/_i18n",
332
+ "prefix": "fed",
333
+ "Region": "us-east-1",
334
+ "FromIni": "mall",
335
+ "HostName": ""
314
336
  }
315
337
  };
316
338
  // 写入配置文件
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
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
  },
@@ -11,6 +11,7 @@ export interface VSConfig {
11
11
  prefix: string;
12
12
  Region: string;
13
13
  HostName: string;
14
+ FileKey?: string;
14
15
  };
15
16
  deploy?: {
16
17
  baseUrl: string[];
@@ -44,6 +44,7 @@ const storage_1 = require("@google-cloud/storage");
44
44
  const fs = __importStar(require("fs"));
45
45
  const path = __importStar(require("path"));
46
46
  const util = __importStar(require("util"));
47
+ const config_1 = require("./config");
47
48
  const mkdir = util.promisify(fs.mkdir);
48
49
  /**
49
50
  * 创建GCP存储客户端
@@ -51,6 +52,7 @@ const mkdir = util.promisify(fs.mkdir);
51
52
  * @returns GCP存储客户端实例
52
53
  */
53
54
  function createStorageClient(options = {}) {
55
+ var _a;
54
56
  const { keyFilename, projectId, credentials } = options;
55
57
  // 如果提供了keyFilename,使用密钥文件认证
56
58
  if (keyFilename) {
@@ -65,7 +67,22 @@ function createStorageClient(options = {}) {
65
67
  credentials
66
68
  });
67
69
  }
70
+ // 尝试从vs.config.json读取aws.FileKey
71
+ try {
72
+ const config = (0, config_1.loadConfig)();
73
+ if (((_a = config.aws) === null || _a === void 0 ? void 0 : _a.FileKey) && fs.existsSync(config.aws.FileKey)) {
74
+ console.log(`使用配置文件中的密钥文件: ${config.aws.FileKey}`);
75
+ return new storage_1.Storage({
76
+ keyFilename: config.aws.FileKey
77
+ });
78
+ }
79
+ }
80
+ catch (error) {
81
+ // 配置文件不存在或读取失败,继续使用免登方式
82
+ console.log('未找到配置文件或配置文件中无有效FileKey,使用免登方式');
83
+ }
68
84
  // 使用应用默认凭证(ADC)进行免密认证
85
+ console.log('使用应用默认凭证(免登方式)');
69
86
  return new storage_1.Storage();
70
87
  }
71
88
  /**
@@ -98,7 +98,7 @@ function getJsonArrayByPath(filePath) {
98
98
  * 创建GCP客户端实例
99
99
  */
100
100
  async function createGCPClient(argv) {
101
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
101
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
102
102
  // 读取当前工作目录下的vs.config.json文件
103
103
  const configPath = path.join(process.cwd(), 'vs.config.json');
104
104
  let vsConfig = {};
@@ -149,7 +149,17 @@ async function createGCPClient(argv) {
149
149
  if (argv.keyFile) {
150
150
  gcpOptions.keyFilename = argv.keyFile;
151
151
  }
152
- // 否则使用应用默认凭证(兼容GCP免登配置)
152
+ else {
153
+ // 尝试从vs.config.json读取aws.FileKey
154
+ if (((_0 = vsConfig.aws) === null || _0 === void 0 ? void 0 : _0.FileKey) && fs.existsSync(vsConfig.aws.FileKey)) {
155
+ console.log(`使用配置文件中的密钥文件: ${vsConfig.aws.FileKey}`);
156
+ gcpOptions.keyFilename = vsConfig.aws.FileKey;
157
+ }
158
+ else {
159
+ // 使用应用默认凭证(兼容GCP免登配置)
160
+ console.log('使用应用默认凭证(免登方式)');
161
+ }
162
+ }
153
163
  // 创建GCP Storage客户端
154
164
  const gcpClient = new storage_1.Storage(gcpOptions);
155
165
  return { gcpClient, config };
@@ -162,9 +172,7 @@ async function getFilesOnline(gcpClient, config) {
162
172
  try {
163
173
  const basePrefix = 'front-end'; // 默认前缀
164
174
  // 确定前缀
165
- const prefix = ((_a = config.crowdin) === null || _a === void 0 ? void 0 : _a.prefix) ||
166
- ((_b = config.aws) === null || _b === void 0 ? void 0 : _b.prefix) ||
167
- `${basePrefix}/crowdin/keys/${config.crowdin.project}`;
175
+ const prefix = `${((_a = config.crowdin) === null || _a === void 0 ? void 0 : _a.prefix) || ((_b = config.aws) === null || _b === void 0 ? void 0 : _b.prefix) || basePrefix}/crowdin/keys/${config.crowdin.project}`;
168
176
  console.log(`开始获取远端keys文件,前缀: ${prefix}`);
169
177
  // 获取存储桶
170
178
  const bucketName = ((_c = config.crowdin) === null || _c === void 0 ? void 0 : _c.Bucket) || ((_d = config.aws) === null || _d === void 0 ? void 0 : _d.Bucket) || '';
@@ -72,6 +72,7 @@ export interface PullCrowdinVSConfig {
72
72
  FromIni?: string;
73
73
  accessKeyId?: string;
74
74
  secretAccessKey?: string;
75
+ FileKey?: string;
75
76
  };
76
77
  crowdin?: {
77
78
  project?: string;
@@ -44,6 +44,7 @@ const fs = __importStar(require("fs"));
44
44
  const path = __importStar(require("path"));
45
45
  const util = __importStar(require("util"));
46
46
  const compression_1 = require("./utils/compression");
47
+ const config_1 = require("./config");
47
48
  const readdir = util.promisify(fs.readdir);
48
49
  const stat = util.promisify(fs.stat);
49
50
  /**
@@ -52,6 +53,7 @@ const stat = util.promisify(fs.stat);
52
53
  * @returns GCP存储客户端实例
53
54
  */
54
55
  function createStorageClient(options = {}) {
56
+ var _a;
55
57
  const { keyFilename, projectId, credentials } = options;
56
58
  // 如果提供了keyFilename,使用密钥文件认证
57
59
  if (keyFilename) {
@@ -66,8 +68,23 @@ function createStorageClient(options = {}) {
66
68
  credentials
67
69
  });
68
70
  }
71
+ // 尝试从vs.config.json读取aws.FileKey
72
+ try {
73
+ const config = (0, config_1.loadConfig)();
74
+ if (((_a = config.aws) === null || _a === void 0 ? void 0 : _a.FileKey) && fs.existsSync(config.aws.FileKey)) {
75
+ console.log(`使用配置文件中的密钥文件: ${config.aws.FileKey}`);
76
+ return new storage_1.Storage({
77
+ keyFilename: config.aws.FileKey
78
+ });
79
+ }
80
+ }
81
+ catch (error) {
82
+ // 配置文件不存在或读取失败,继续使用免登方式
83
+ console.log('未找到配置文件或配置文件中无有效FileKey,使用免登方式');
84
+ }
69
85
  // 使用应用默认凭证(ADC)进行免密认证
70
86
  // 这将使用环境变量 或默认服务账号
87
+ console.log('使用应用默认凭证(免登方式)');
71
88
  return new storage_1.Storage();
72
89
  }
73
90
  /**
@@ -43,6 +43,7 @@ exports.getConfigSummary = getConfigSummary;
43
43
  */
44
44
  const storage_1 = require("@google-cloud/storage");
45
45
  const path = __importStar(require("path"));
46
+ const fs = __importStar(require("fs"));
46
47
  const chalk_1 = __importDefault(require("chalk"));
47
48
  const upload_1 = require("./upload");
48
49
  const config_1 = require("./config");
@@ -80,6 +81,7 @@ async function getFilesToProcess(sourcePath, recursive) {
80
81
  * @returns GCP存储客户端实例
81
82
  */
82
83
  function createStorageClientFromConfig(options = {}) {
84
+ var _a;
83
85
  const { keyFilename, projectId, credentials } = options;
84
86
  // 如果提供了keyFilename,使用密钥文件认证
85
87
  if (keyFilename) {
@@ -94,7 +96,22 @@ function createStorageClientFromConfig(options = {}) {
94
96
  credentials
95
97
  });
96
98
  }
99
+ // 尝试从vs.config.json读取aws.FileKey
100
+ try {
101
+ const config = (0, config_1.loadConfig)();
102
+ if (((_a = config.aws) === null || _a === void 0 ? void 0 : _a.FileKey) && fs.existsSync(config.aws.FileKey)) {
103
+ console.log(`使用配置文件中的密钥文件: ${config.aws.FileKey}`);
104
+ return new storage_1.Storage({
105
+ keyFilename: config.aws.FileKey
106
+ });
107
+ }
108
+ }
109
+ catch (error) {
110
+ // 配置文件不存在或读取失败,继续使用免登方式
111
+ console.log('未找到配置文件或配置文件中无有效FileKey,使用免登方式');
112
+ }
97
113
  // 使用应用默认凭证(ADC)进行免密认证
114
+ console.log('使用应用默认凭证(免登方式)');
98
115
  return new storage_1.Storage();
99
116
  }
100
117
  /**