td-web-cli 0.1.27 → 0.1.28

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.
@@ -1,6 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  /**
3
- * 提取前端项目词条主函数
3
+ * 提取前端项目词条主函数(固定简体中文)
4
4
  */
5
5
  export declare function extractEntry(program: Command): Promise<void>;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/i18n/extractEntry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsWpC;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,iBAkNlD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/i18n/extractEntry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2UpC;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,iBAuLlD"}
@@ -1,4 +1,4 @@
1
- import { input, select, confirm, Separator } from '@inquirer/prompts';
1
+ import { input, confirm } from '@inquirer/prompts';
2
2
  import XLSX from 'xlsx';
3
3
  import fs from 'fs';
4
4
  import { fileURLToPath } from 'url';
@@ -29,26 +29,6 @@ function containsChinese(text) {
29
29
  const hanRegex = /\p{Script=Han}/u;
30
30
  return hanRegex.test(text);
31
31
  }
32
- /**
33
- * 读取并解析配置文件
34
- */
35
- function loadConfig(configPath) {
36
- if (!fs.existsSync(configPath)) {
37
- throw new Error(`配置文件不存在:${configPath}`);
38
- }
39
- const content = fs.readFileSync(configPath, { encoding: 'utf-8' });
40
- const json = JSON.parse(content);
41
- if (!json.i18n) {
42
- throw new Error('配置文件格式错误,缺少i18n');
43
- }
44
- if (!json.i18n.defaultKey) {
45
- throw new Error('配置文件格式错误,缺少i18n.defaultKey');
46
- }
47
- if (!json.i18n.langs) {
48
- throw new Error('配置文件格式错误,缺少i18n.langs');
49
- }
50
- return json.i18n;
51
- }
52
32
  /**
53
33
  * 从表达式中提取字符串字面量(支持单引号、双引号、模板字符串)
54
34
  */
@@ -309,23 +289,10 @@ function isValidGlobPattern(pattern) {
309
289
  }
310
290
  }
311
291
  /**
312
- * 提取前端项目词条主函数
292
+ * 提取前端项目词条主函数(固定简体中文)
313
293
  */
314
294
  export async function extractEntry(program) {
315
- var _a;
316
295
  const configPath = path.join(__dirname, '../../../../setting.json');
317
- let i18nConfig;
318
- try {
319
- logger.info(`开始加载配置文件:${configPath}`, true);
320
- i18nConfig = loadConfig(configPath);
321
- logger.info('配置文件加载成功', true);
322
- }
323
- catch (error) {
324
- const msg = `读取配置文件失败:${normalizeError(error).stack},程序已退出`;
325
- logger.error(msg);
326
- console.error('程序执行时发生异常,已记录日志,程序已退出');
327
- process.exit(1);
328
- }
329
296
  // 1. 输入项目根目录
330
297
  const answer = await input({
331
298
  message: '请输入项目根目录:',
@@ -409,21 +376,8 @@ export async function extractEntry(program) {
409
376
  else {
410
377
  logger.info(`使用默认忽略模式:${defaultPatterns.join(', ')}`, true);
411
378
  }
412
- // 3. 选择目标语言
413
- const langChoices = Object.entries(i18nConfig.langs).map(([key, names]) => ({
414
- name: names[0],
415
- value: key,
416
- }));
417
- const selectedLangKey = await select({
418
- message: '请选择需要提取的目标语言(将生成该语言对应的翻译列)',
419
- choices: [
420
- ...langChoices,
421
- new Separator(), // 分割线,方便未来扩展更多功能
422
- ],
423
- default: i18nConfig.defaultKey,
424
- loop: true, // 是否循环滚动选项
425
- });
426
- const targetLangName = ((_a = i18nConfig.langs[selectedLangKey]) === null || _a === void 0 ? void 0 : _a[0]) || selectedLangKey;
379
+ // 固定目标语言为简体中文
380
+ const targetLangName = '简体中文';
427
381
  try {
428
382
  logger.info(`开始扫描目录:${rootDir}`, true);
429
383
  const files = getFiles(rootDir, SUPPORTED_EXTENSIONS, ignorePatterns, rootDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "td-web-cli",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "A CLI tool for efficiency",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",