lingo.dev 0.70.4 → 0.71.0

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/build/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkMNP3B6L4cjs = require('./chunk-MNP3B6L4.cjs');
3
+ var _chunkHODTYTE5cjs = require('./chunk-HODTYTE5.cjs');
4
4
 
5
5
 
6
6
 
@@ -10,11 +10,13 @@ var _chunkMNP3B6L4cjs = require('./chunk-MNP3B6L4.cjs');
10
10
 
11
11
 
12
12
 
13
- var _chunkDTGLPBE5cjs = require('./chunk-DTGLPBE5.cjs');
13
+ var _chunkBCCNAFJBcjs = require('./chunk-BCCNAFJB.cjs');
14
14
 
15
15
  // src/cli/index.ts
16
16
  var _dotenv = require('dotenv'); var _dotenv2 = _interopRequireDefault(_dotenv);
17
17
  var _interactivecommander = require('interactive-commander');
18
+ var _figlet = require('figlet'); var _figlet2 = _interopRequireDefault(_figlet);
19
+ var _gradientstring = require('gradient-string');
18
20
 
19
21
  // src/cli/cli/auth.ts
20
22
 
@@ -34,11 +36,12 @@ function getSettings(explicitApiKey) {
34
36
  const env = _loadEnv();
35
37
  const systemFile = _loadSystemFile();
36
38
  const defaults = _loadDefaults();
39
+ _legacyEnvVarWarning();
37
40
  return {
38
41
  auth: {
39
- apiKey: explicitApiKey || env.REPLEXICA_API_KEY || _optionalChain([systemFile, 'access', _20 => _20.auth, 'optionalAccess', _21 => _21.apiKey]) || defaults.auth.apiKey,
40
- apiUrl: env.REPLEXICA_API_URL || _optionalChain([systemFile, 'access', _22 => _22.auth, 'optionalAccess', _23 => _23.apiUrl]) || defaults.auth.apiUrl,
41
- webUrl: env.REPLEXICA_WEB_URL || _optionalChain([systemFile, 'access', _24 => _24.auth, 'optionalAccess', _25 => _25.webUrl]) || defaults.auth.webUrl
42
+ apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _20 => _20.auth, 'optionalAccess', _21 => _21.apiKey]) || defaults.auth.apiKey,
43
+ apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _22 => _22.auth, 'optionalAccess', _23 => _23.apiUrl]) || defaults.auth.apiUrl,
44
+ webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _24 => _24.auth, 'optionalAccess', _25 => _25.webUrl]) || defaults.auth.webUrl
42
45
  }
43
46
  };
44
47
  }
@@ -63,9 +66,9 @@ function _loadDefaults() {
63
66
  }
64
67
  function _loadEnv() {
65
68
  return _zod2.default.object({
66
- REPLEXICA_API_KEY: _zod2.default.string().optional(),
67
- REPLEXICA_API_URL: _zod2.default.string().optional(),
68
- REPLEXICA_WEB_URL: _zod2.default.string().optional()
69
+ LINGODOTDEV_API_KEY: _zod2.default.string().optional(),
70
+ LINGODOTDEV_API_URL: _zod2.default.string().optional(),
71
+ LINGODOTDEV_WEB_URL: _zod2.default.string().optional()
69
72
  }).passthrough().parse(process.env);
70
73
  }
71
74
  function _loadSystemFile() {
@@ -91,6 +94,21 @@ function _getSettingsFilePath() {
91
94
  const settingsFilePath = _path2.default.join(homedir, settingsFile);
92
95
  return settingsFilePath;
93
96
  }
97
+ function _legacyEnvVarWarning() {
98
+ const env = _loadEnv();
99
+ if (env.REPLEXICA_API_KEY && !env.LINGODOTDEV_API_KEY) {
100
+ console.warn(
101
+ "\x1B[33m%s\x1B[0m",
102
+ `
103
+ \u26A0\uFE0F WARNING: REPLEXICA_API_KEY env var is deprecated \u26A0\uFE0F
104
+ ===========================================================
105
+
106
+ Please use LINGODOTDEV_API_KEY instead.
107
+ ===========================================================
108
+ `
109
+ );
110
+ }
111
+ }
94
112
 
95
113
  // src/cli/utils/errors.ts
96
114
  var docLinks = {
@@ -195,7 +213,7 @@ Press Enter to open the browser for authentication.
195
213
 
196
214
  ---
197
215
 
198
- Having issues? Put REPLEXICA_API_KEY in your .env file instead.
216
+ Having issues? Put LINGODOTDEV_API_KEY in your .env file instead.
199
217
  `.trim() + "\n"
200
218
  );
201
219
  const spinner = _ora2.default.call(void 0, ).start("Waiting for the API key");
@@ -240,7 +258,7 @@ function getConfig(resave = true) {
240
258
  }
241
259
  const fileContents = _fs2.default.readFileSync(configFilePath, "utf8");
242
260
  const rawConfig = JSON.parse(fileContents);
243
- const result = _chunkDTGLPBE5cjs.parseI18nConfig.call(void 0, rawConfig);
261
+ const result = _chunkBCCNAFJBcjs.parseI18nConfig.call(void 0, rawConfig);
244
262
  const didConfigChange = !_lodash2.default.isEqual(rawConfig, result);
245
263
  if (resave && didConfigChange) {
246
264
  saveConfig(result);
@@ -262,9 +280,9 @@ function _getConfigFilePath() {
262
280
  var _child_process = require('child_process');
263
281
 
264
282
  var _prompts = require('@inquirer/prompts');
265
- var openUrl = (path7) => {
283
+ var openUrl = (path8) => {
266
284
  const settings = getSettings(void 0);
267
- _child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path7}`]);
285
+ _child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path8}`]);
268
286
  };
269
287
  var throwHelpError = (option, value) => {
270
288
  if (value === "help") {
@@ -279,7 +297,7 @@ Do you need support for ${value} ${option}? Type "help" and we will.`
279
297
  var init_default = new (0, _interactivecommander.InteractiveCommand)().command("init").description("Initialize Lingo.dev project").helpOption("-h, --help", "Show help").addOption(new (0, _interactivecommander.InteractiveOption)("-f --force", "Overwrite existing config").prompt(void 0).default(false)).addOption(
280
298
  new (0, _interactivecommander.InteractiveOption)("-s --source <locale>", "Source locale").argParser((value) => {
281
299
  try {
282
- _chunkDTGLPBE5cjs.resolveLocaleCode.call(void 0, value);
300
+ _chunkBCCNAFJBcjs.resolveLocaleCode.call(void 0, value);
283
301
  } catch (e) {
284
302
  throwHelpError("locale", value);
285
303
  }
@@ -290,7 +308,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
290
308
  const values = value.includes(",") ? value.split(",") : value.split(" ");
291
309
  values.forEach((value2) => {
292
310
  try {
293
- _chunkDTGLPBE5cjs.resolveLocaleCode.call(void 0, value2);
311
+ _chunkBCCNAFJBcjs.resolveLocaleCode.call(void 0, value2);
294
312
  } catch (e) {
295
313
  throwHelpError("locale", value2);
296
314
  }
@@ -299,7 +317,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
299
317
  }).default("es")
300
318
  ).addOption(
301
319
  new (0, _interactivecommander.InteractiveOption)("-b, --bucket <type>", "Type of bucket").argParser((value) => {
302
- if (!_chunkDTGLPBE5cjs.bucketTypes.includes(value)) {
320
+ if (!_chunkBCCNAFJBcjs.bucketTypes.includes(value)) {
303
321
  throwHelpError("bucket format", value);
304
322
  }
305
323
  return value;
@@ -307,14 +325,14 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
307
325
  ).addOption(
308
326
  new (0, _interactivecommander.InteractiveOption)("-p, --paths <path...>", "List of paths for the bucket").argParser((value) => {
309
327
  const values = value.includes(",") ? value.split(",") : value.split(" ");
310
- for (const path7 of values) {
328
+ for (const path8 of values) {
311
329
  try {
312
- const stats = _fs2.default.statSync(path7);
330
+ const stats = _fs2.default.statSync(path8);
313
331
  if (!stats.isDirectory()) {
314
- throw new Error(`${path7} is not a directory`);
332
+ throw new Error(`${path8} is not a directory`);
315
333
  }
316
334
  } catch (err) {
317
- throw new Error(`Invalid directory path: ${path7}`);
335
+ throw new Error(`Invalid directory path: ${path8}`);
318
336
  }
319
337
  }
320
338
  return values;
@@ -327,7 +345,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
327
345
  spinner.fail("Lingo.dev project already initialized");
328
346
  return process.exit(1);
329
347
  }
330
- const newConfig = _lodash2.default.cloneDeep(_chunkDTGLPBE5cjs.defaultConfig);
348
+ const newConfig = _lodash2.default.cloneDeep(_chunkBCCNAFJBcjs.defaultConfig);
331
349
  newConfig.locale.source = options.source;
332
350
  newConfig.locale.targets = options.targets;
333
351
  newConfig.buckets = {
@@ -388,7 +406,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
388
406
 
389
407
  var config_default = new (0, _interactivecommander.Command)().command("config").description("Print out the current configuration").helpOption("-h, --help", "Show help").action(async (options) => {
390
408
  const fileConfig = loadReplexicaFileConfig();
391
- const config = _lodash2.default.merge({}, _chunkDTGLPBE5cjs.defaultConfig, fileConfig);
409
+ const config = _lodash2.default.merge({}, _chunkBCCNAFJBcjs.defaultConfig, fileConfig);
392
410
  console.log(JSON.stringify(config, null, 2));
393
411
  });
394
412
  function loadReplexicaFileConfig() {
@@ -415,10 +433,10 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
415
433
  docUrl: "invalidType"
416
434
  });
417
435
  case "sources":
418
- _chunkDTGLPBE5cjs.localeCodes.forEach((locale) => console.log(locale));
436
+ _chunkBCCNAFJBcjs.localeCodes.forEach((locale) => console.log(locale));
419
437
  break;
420
438
  case "targets":
421
- _chunkDTGLPBE5cjs.localeCodes.forEach((locale) => console.log(locale));
439
+ _chunkBCCNAFJBcjs.localeCodes.forEach((locale) => console.log(locale));
422
440
  break;
423
441
  }
424
442
  } catch (error) {
@@ -448,7 +466,7 @@ function getBuckets(i18nConfig) {
448
466
  }
449
467
  function extractPathPatterns(sourceLocale, include, exclude) {
450
468
  const includedPatterns = include.flatMap(
451
- (pattern) => expandPlaceholderedGlob(pattern.path, _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
469
+ (pattern) => expandPlaceholderedGlob(pattern.path, _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
452
470
  (pathPattern) => ({
453
471
  pathPattern,
454
472
  delimiter: pattern.delimiter
@@ -456,7 +474,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
456
474
  )
457
475
  );
458
476
  const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _31 => _31.flatMap, 'call', _32 => _32(
459
- (pattern) => expandPlaceholderedGlob(pattern.path, _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
477
+ (pattern) => expandPlaceholderedGlob(pattern.path, _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
460
478
  (pathPattern) => ({
461
479
  pathPattern,
462
480
  delimiter: pattern.delimiter
@@ -526,10 +544,10 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
526
544
  const buckets = getBuckets(i18nConfig);
527
545
  for (const bucket of buckets) {
528
546
  for (const bucketConfig of bucket.config) {
529
- const sourceLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
547
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
530
548
  const sourcePath = bucketConfig.pathPattern.replace(/\[locale\]/g, sourceLocale);
531
549
  const targetPaths = i18nConfig.locale.targets.map((_targetLocale) => {
532
- const targetLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
550
+ const targetLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
533
551
  return bucketConfig.pathPattern.replace(/\[locale\]/g, targetLocale);
534
552
  });
535
553
  const result = [];
@@ -540,8 +558,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
540
558
  } else if (type.target) {
541
559
  result.push(...targetPaths);
542
560
  }
543
- result.forEach((path7) => {
544
- console.log(path7);
561
+ result.forEach((path8) => {
562
+ console.log(path8);
545
563
  });
546
564
  }
547
565
  }
@@ -979,9 +997,9 @@ function createHtmlLoader() {
979
997
  const bDepth = b.split("/").length;
980
998
  return aDepth - bDepth;
981
999
  });
982
- paths.forEach((path7) => {
983
- const value = data[path7];
984
- const [nodePath, attribute] = path7.split("#");
1000
+ paths.forEach((path8) => {
1001
+ const value = data[path8];
1002
+ const [nodePath, attribute] = path8.split("#");
985
1003
  const [rootTag, ...indices] = nodePath.split("/");
986
1004
  let parent = rootTag === "head" ? document.head : document.body;
987
1005
  let current = parent;
@@ -1979,18 +1997,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
1979
1997
  }
1980
1998
  function serializeStructuredText(rawStructuredText) {
1981
1999
  return serializeStructuredTextNode(rawStructuredText);
1982
- function serializeStructuredTextNode(node, path7 = [], acc = {}) {
2000
+ function serializeStructuredTextNode(node, path8 = [], acc = {}) {
1983
2001
  if ("document" in node) {
1984
- return serializeStructuredTextNode(node.document, [...path7, "document"], acc);
2002
+ return serializeStructuredTextNode(node.document, [...path8, "document"], acc);
1985
2003
  }
1986
2004
  if (!_lodash2.default.isNil(node.value)) {
1987
- acc[[...path7, "value"].join(".")] = node.value;
2005
+ acc[[...path8, "value"].join(".")] = node.value;
1988
2006
  } else if (_lodash2.default.get(node, "type") === "block") {
1989
- acc[[...path7, "item"].join(".")] = serializeBlock(node.item);
2007
+ acc[[...path8, "item"].join(".")] = serializeBlock(node.item);
1990
2008
  }
1991
2009
  if (node.children) {
1992
2010
  for (let i = 0; i < node.children.length; i++) {
1993
- serializeStructuredTextNode(node.children[i], [...path7, i.toString()], acc);
2011
+ serializeStructuredTextNode(node.children[i], [...path8, i.toString()], acc);
1994
2012
  }
1995
2013
  }
1996
2014
  return acc;
@@ -2049,8 +2067,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
2049
2067
  }
2050
2068
  function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
2051
2069
  const result = _lodash2.default.cloneDeep(originalRawStructuredText);
2052
- for (const [path7, value] of _lodash2.default.entries(parsedStructuredText)) {
2053
- const realPath = _lodash2.default.chain(path7.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
2070
+ for (const [path8, value] of _lodash2.default.entries(parsedStructuredText)) {
2071
+ const realPath = _lodash2.default.chain(path8.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
2054
2072
  const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
2055
2073
  _lodash2.default.set(result, realPath, deserializedValue);
2056
2074
  }
@@ -2395,6 +2413,13 @@ function createLockfileHelper() {
2395
2413
  lockfile.checksums[sectionKey] = sectionChecksums;
2396
2414
  _saveLockfile(lockfile);
2397
2415
  },
2416
+ registerPartialSourceData: (pathPattern, partialSourceData) => {
2417
+ const lockfile = _loadLockfile();
2418
+ const sectionKey = _objecthash.MD5.call(void 0, pathPattern);
2419
+ const sectionChecksums = _lodash2.default.mapValues(partialSourceData, (value) => _objecthash.MD5.call(void 0, value));
2420
+ lockfile.checksums[sectionKey] = _lodash2.default.merge({}, _nullishCoalesce(lockfile.checksums[sectionKey], () => ( {})), sectionChecksums);
2421
+ _saveLockfile(lockfile);
2422
+ },
2398
2423
  extractUpdatedData: (pathPattern, sourceData) => {
2399
2424
  const lockfile = _loadLockfile();
2400
2425
  const sectionKey = _objecthash.MD5.call(void 0, pathPattern);
@@ -2442,6 +2467,75 @@ var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
2442
2467
  var _diff = require('diff');
2443
2468
 
2444
2469
  var _externaleditor = require('external-editor'); var _externaleditor2 = _interopRequireDefault(_externaleditor);
2470
+
2471
+ // src/cli/utils/cache.ts
2472
+
2473
+
2474
+ var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
2475
+ const rows = Object.entries(sourceChunk).map(([key, source]) => ({
2476
+ targetLocale,
2477
+ key,
2478
+ source,
2479
+ processed: processedChunk[key]
2480
+ }));
2481
+ _appendToCache(rows);
2482
+ };
2483
+ function getNormalizedCache() {
2484
+ const rows = _loadCache();
2485
+ if (!rows.length) {
2486
+ return null;
2487
+ }
2488
+ const normalized = {};
2489
+ for (const row of rows) {
2490
+ if (!normalized[row.targetLocale]) {
2491
+ normalized[row.targetLocale] = {};
2492
+ }
2493
+ normalized[row.targetLocale][row.key] = {
2494
+ source: row.source,
2495
+ result: row.processed
2496
+ };
2497
+ }
2498
+ return normalized;
2499
+ }
2500
+ function deleteCache() {
2501
+ const cacheFilePath = _getCacheFilePath();
2502
+ try {
2503
+ _fs2.default.unlinkSync(cacheFilePath);
2504
+ } catch (e) {
2505
+ }
2506
+ }
2507
+ function _loadCache() {
2508
+ const cacheFilePath = _getCacheFilePath();
2509
+ if (!_fs2.default.existsSync(cacheFilePath)) {
2510
+ return [];
2511
+ }
2512
+ const content = _fs2.default.readFileSync(cacheFilePath, "utf-8");
2513
+ const result = _parseJSONLines(content);
2514
+ return result;
2515
+ }
2516
+ function _appendToCache(rows) {
2517
+ const cacheFilePath = _getCacheFilePath();
2518
+ const lines = _buildJSONLines(rows);
2519
+ _fs2.default.appendFileSync(cacheFilePath, lines);
2520
+ }
2521
+ function _getCacheFilePath() {
2522
+ return _path2.default.join(process.cwd(), "i18n.cache");
2523
+ }
2524
+ function _buildJSONLines(rows) {
2525
+ return rows.map((row) => JSON.stringify(row)).join("\n") + "\n";
2526
+ }
2527
+ function _parseJSONLines(lines) {
2528
+ return lines.split("\n").map(_tryParseJSON).filter((line) => line !== null);
2529
+ }
2530
+ function _tryParseJSON(line) {
2531
+ try {
2532
+ return JSON.parse(line);
2533
+ } catch (e) {
2534
+ return null;
2535
+ }
2536
+ }
2537
+
2538
+ // src/cli/cli/i18n.ts
2445
2539
  var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option("--key <key>", "Key to process").option("--frozen", `Don't update the translations and fail if an update is needed`).option("--force", "Ignore lockfile and process all keys").option("--verbose", "Show verbose output").option("--interactive", "Interactive mode").option("--api-key <api-key>", "Explicitly set the API key to use").option("--debug", "Debug mode").option("--strict", "Stop on first error").action(async function(options) {
2446
2540
  const ora = _ora2.default.call(void 0, );
2447
2541
  const flags = parseFlags(options);
@@ -2478,7 +2572,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
2478
2572
  ora.start("Creating i18n.lock...");
2479
2573
  for (const bucket of buckets) {
2480
2574
  for (const bucketConfig of bucket.config) {
2481
- const sourceLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2575
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2482
2576
  const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
2483
2577
  bucketLoader.setDefaultLocale(sourceLocale);
2484
2578
  await bucketLoader.init();
@@ -2490,12 +2584,51 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
2490
2584
  } else {
2491
2585
  ora.succeed("i18n.lock loaded");
2492
2586
  }
2587
+ const cache = getNormalizedCache();
2588
+ if (cache) {
2589
+ console.log();
2590
+ ora.succeed(`Cache loaded. Attempting recovery...`);
2591
+ const cacheOra = _ora2.default.call(void 0, { indent: 2 });
2592
+ for (const bucket of buckets) {
2593
+ cacheOra.info(`Processing bucket: ${bucket.type}`);
2594
+ for (const bucketConfig of bucket.config) {
2595
+ const bucketOra = ora.info(`Processing path: ${bucketConfig.pathPattern}`);
2596
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2597
+ const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
2598
+ bucketLoader.setDefaultLocale(sourceLocale);
2599
+ await bucketLoader.init();
2600
+ const sourceData = await bucketLoader.pull(sourceLocale);
2601
+ const cachedSourceData = {};
2602
+ for (const targetLocale in cache) {
2603
+ const targetData = await bucketLoader.pull(targetLocale);
2604
+ for (const key in cache[targetLocale]) {
2605
+ const { source, result } = cache[targetLocale][key];
2606
+ if (sourceData[key] === source && targetData[key] !== result) {
2607
+ targetData[key] = result;
2608
+ cachedSourceData[key] = source;
2609
+ }
2610
+ }
2611
+ await bucketLoader.push(targetLocale, targetData);
2612
+ lockfileHelper.registerPartialSourceData(bucketConfig.pathPattern, cachedSourceData);
2613
+ bucketOra.succeed(
2614
+ `[${sourceLocale} -> ${targetLocale}] Recovered ${Object.keys(cachedSourceData).length} entries from cache`
2615
+ );
2616
+ }
2617
+ }
2618
+ }
2619
+ deleteCache();
2620
+ if (flags.verbose) {
2621
+ cacheOra.info("Cache file deleted.");
2622
+ }
2623
+ } else if (flags.verbose) {
2624
+ ora.info("Cache file not found. Skipping recovery.");
2625
+ }
2493
2626
  if (flags.frozen) {
2494
2627
  ora.start("Checking for lockfile updates...");
2495
2628
  let requiresUpdate = false;
2496
2629
  for (const bucket of buckets) {
2497
2630
  for (const bucketConfig of bucket.config) {
2498
- const sourceLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2631
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2499
2632
  const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
2500
2633
  bucketLoader.setDefaultLocale(sourceLocale);
2501
2634
  await bucketLoader.init();
@@ -2521,13 +2654,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
2521
2654
  ora.info(`Processing bucket: ${bucket.type}`);
2522
2655
  for (const bucketConfig of bucket.config) {
2523
2656
  const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
2524
- const sourceLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2657
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2525
2658
  const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
2526
2659
  bucketLoader.setDefaultLocale(sourceLocale);
2527
2660
  await bucketLoader.init();
2528
2661
  let sourceData = await bucketLoader.pull(sourceLocale);
2529
2662
  for (const _targetLocale of targetLocales) {
2530
- const targetLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
2663
+ const targetLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
2531
2664
  try {
2532
2665
  bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
2533
2666
  sourceData = await bucketLoader.pull(sourceLocale);
@@ -2559,8 +2692,17 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
2559
2692
  targetLocale,
2560
2693
  targetData
2561
2694
  },
2562
- (progress) => {
2563
- bucketOra.text = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
2695
+ (progress, sourceChunk, processedChunk) => {
2696
+ cacheChunk(targetLocale, sourceChunk, processedChunk);
2697
+ const progressLog = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
2698
+ if (flags.verbose) {
2699
+ ora.info(progressLog);
2700
+ ora.info(
2701
+ `Caching chunk ${JSON.stringify(sourceChunk, null, 2)} -> ${JSON.stringify(processedChunk, null, 2)}`
2702
+ );
2703
+ } else {
2704
+ ora.text = progressLog;
2705
+ }
2564
2706
  }
2565
2707
  );
2566
2708
  if (flags.verbose) {
@@ -2612,6 +2754,10 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
2612
2754
  console.log();
2613
2755
  if (!hasErrors) {
2614
2756
  ora.succeed("Localization completed.");
2757
+ deleteCache();
2758
+ if (flags.verbose) {
2759
+ ora.info("Cache file deleted.");
2760
+ }
2615
2761
  } else {
2616
2762
  ora.warn("Localization completed with errors.");
2617
2763
  }
@@ -2639,7 +2785,7 @@ async function retryWithExponentialBackoff(operation, maxAttempts, baseDelay = 1
2639
2785
  throw new Error("Unreachable code");
2640
2786
  }
2641
2787
  function createLocalizationEngineConnection(params) {
2642
- const replexicaEngine = new (0, _chunkMNP3B6L4cjs.ReplexicaEngine)({
2788
+ const replexicaEngine = new (0, _chunkHODTYTE5cjs.ReplexicaEngine)({
2643
2789
  apiKey: params.apiKey,
2644
2790
  apiUrl: params.apiUrl
2645
2791
  });
@@ -2662,8 +2808,8 @@ function createLocalizationEngineConnection(params) {
2662
2808
  function parseFlags(options) {
2663
2809
  return _zod2.default.object({
2664
2810
  apiKey: _zod2.default.string().optional(),
2665
- locale: _zod2.default.array(_chunkDTGLPBE5cjs.localeCodeSchema).optional(),
2666
- bucket: _zod2.default.array(_chunkDTGLPBE5cjs.bucketTypeSchema).optional(),
2811
+ locale: _zod2.default.array(_chunkBCCNAFJBcjs.localeCodeSchema).optional(),
2812
+ bucket: _zod2.default.array(_chunkBCCNAFJBcjs.bucketTypeSchema).optional(),
2667
2813
  force: _zod2.default.boolean().optional(),
2668
2814
  frozen: _zod2.default.boolean().optional(),
2669
2815
  verbose: _zod2.default.boolean().optional(),
@@ -2827,7 +2973,7 @@ var lockfile_default = new (0, _interactivecommander.Command)().command("lockfil
2827
2973
  const buckets = getBuckets(i18nConfig);
2828
2974
  for (const bucket of buckets) {
2829
2975
  for (const bucketConfig of bucket.config) {
2830
- const sourceLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2976
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2831
2977
  const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
2832
2978
  bucketLoader.setDefaultLocale(sourceLocale);
2833
2979
  const sourceData = await bucketLoader.pull(sourceLocale);
@@ -2862,14 +3008,14 @@ var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup"
2862
3008
  console.log();
2863
3009
  ora.info(`Processing bucket: ${bucket.type}`);
2864
3010
  for (const bucketConfig of bucket.config) {
2865
- const sourceLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
3011
+ const sourceLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
2866
3012
  const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
2867
3013
  const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
2868
3014
  bucketLoader.setDefaultLocale(sourceLocale);
2869
3015
  const sourceData = await bucketLoader.pull(sourceLocale);
2870
3016
  const sourceKeys = Object.keys(sourceData);
2871
3017
  for (const _targetLocale of targetLocales) {
2872
- const targetLocale = _chunkDTGLPBE5cjs.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
3018
+ const targetLocale = _chunkBCCNAFJBcjs.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
2873
3019
  try {
2874
3020
  const targetData = await bucketLoader.pull(targetLocale);
2875
3021
  const targetKeys = Object.keys(targetData);
@@ -2934,7 +3080,7 @@ function displaySummary(results) {
2934
3080
  // package.json
2935
3081
  var package_default = {
2936
3082
  name: "lingo.dev",
2937
- version: "0.70.4",
3083
+ version: "0.71.0",
2938
3084
  description: "Lingo.dev CLI",
2939
3085
  private: false,
2940
3086
  type: "module",
@@ -2964,7 +3110,7 @@ var package_default = {
2964
3110
  "build"
2965
3111
  ],
2966
3112
  scripts: {
2967
- "lingo.dev": "node ./bin/cli.mjs",
3113
+ "lingo.dev": "node --inspect=9229 ./bin/cli.mjs",
2968
3114
  dev: "tsup --watch",
2969
3115
  build: "tsc --noEmit && tsup",
2970
3116
  test: "vitest run",
@@ -2986,9 +3132,12 @@ var package_default = {
2986
3132
  dotenv: "^16.4.7",
2987
3133
  express: "^4.21.2",
2988
3134
  "external-editor": "^3.1.0",
3135
+ figlet: "^1.8.0",
3136
+ "figlet-cli": "^0.2.0",
2989
3137
  flat: "^6.0.1",
2990
3138
  "gettext-parser": "^8.0.0",
2991
3139
  glob: "<11.0.0",
3140
+ "gradient-string": "^3.0.0",
2992
3141
  "gray-matter": "^4.0.3",
2993
3142
  ini: "^5.0.0",
2994
3143
  inquirer: "^12.3.0",
@@ -3026,6 +3175,7 @@ var package_default = {
3026
3175
  "@types/cors": "^2.8.17",
3027
3176
  "@types/diff": "^6.0.0",
3028
3177
  "@types/express": "^5.0.0",
3178
+ "@types/figlet": "^1.7.0",
3029
3179
  "@types/gettext-parser": "^4.0.4",
3030
3180
  "@types/glob": "^8.1.0",
3031
3181
  "@types/ini": "^4.1.1",
@@ -3052,12 +3202,25 @@ _dotenv2.default.config();
3052
3202
  var cli_default = new (0, _interactivecommander.InteractiveCommand)().name("lingo.dev").description("Lingo.dev CLI").helpOption("-h, --help", "Show help").addHelpText(
3053
3203
  "beforeAll",
3054
3204
  `
3055
- Lingo.dev CLI
3205
+ ${_gradientstring.vice.call(void 0,
3206
+ _figlet2.default.textSync("LINGO.DEV", {
3207
+ font: "ANSI Shadow",
3208
+ horizontalLayout: "default",
3209
+ verticalLayout: "default"
3210
+ })
3211
+ )}
3212
+
3056
3213
  Website: https://lingo.dev
3057
3214
  `
3058
- ).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(lockfile_default).addCommand(cleanup_default);
3215
+ ).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(lockfile_default).addCommand(cleanup_default).exitOverride((err) => {
3216
+ if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
3217
+ process.exit(0);
3218
+ }
3219
+ throw err;
3220
+ });
3059
3221
 
3060
3222
 
3061
3223
  exports.default = cli_default;
3062
3224
 
3063
3225
  module.exports = exports.default;
3226
+ //# sourceMappingURL=cli.cjs.map