lingo.dev 0.92.7 → 0.92.9

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
@@ -26,9 +26,9 @@ function getSettings(explicitApiKey) {
26
26
  _envVarsInfo();
27
27
  return {
28
28
  auth: {
29
- apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _28 => _28.auth, 'optionalAccess', _29 => _29.apiKey]) || defaults.auth.apiKey,
30
- apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _30 => _30.auth, 'optionalAccess', _31 => _31.apiUrl]) || defaults.auth.apiUrl,
31
- webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _32 => _32.auth, 'optionalAccess', _33 => _33.webUrl]) || defaults.auth.webUrl
29
+ apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _30 => _30.auth, 'optionalAccess', _31 => _31.apiKey]) || defaults.auth.apiKey,
30
+ apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _32 => _32.auth, 'optionalAccess', _33 => _33.apiUrl]) || defaults.auth.apiUrl,
31
+ webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _34 => _34.auth, 'optionalAccess', _35 => _35.webUrl]) || defaults.auth.webUrl
32
32
  }
33
33
  };
34
34
  }
@@ -99,7 +99,7 @@ Please use LINGODOTDEV_API_KEY instead.
99
99
  function _envVarsInfo() {
100
100
  const env = _loadEnv();
101
101
  const systemFile = _loadSystemFile();
102
- if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _34 => _34.auth, 'optionalAccess', _35 => _35.apiKey])) {
102
+ if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _36 => _36.auth, 'optionalAccess', _37 => _37.apiKey])) {
103
103
  console.info(
104
104
  "\x1B[36m%s\x1B[0m",
105
105
  `\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
@@ -154,7 +154,7 @@ function createAuthenticator(params) {
154
154
  });
155
155
  if (res.ok) {
156
156
  const payload = await res.json();
157
- if (!_optionalChain([payload, 'optionalAccess', _36 => _36.email])) {
157
+ if (!_optionalChain([payload, 'optionalAccess', _38 => _38.email])) {
158
158
  return null;
159
159
  }
160
160
  return {
@@ -774,7 +774,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
774
774
  });
775
775
  const auth2 = await newAuthenticator.whoami();
776
776
  if (auth2) {
777
- _ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _37 => _37.email])}`);
777
+ _ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _39 => _39.email])}`);
778
778
  } else {
779
779
  _ora2.default.call(void 0, ).fail("Authentication failed.");
780
780
  }
@@ -851,45 +851,66 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
851
851
 
852
852
 
853
853
 
854
+
855
+
854
856
  function getBuckets(i18nConfig) {
855
- const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
856
- const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
857
- const excludeItems = _optionalChain([bucketEntry, 'access', _38 => _38.exclude, 'optionalAccess', _39 => _39.map, 'call', _40 => _40((item) => resolveBucketItem(item))]);
858
- const config = {
859
- type: bucketType,
860
- paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
861
- };
862
- if (bucketEntry.injectLocale) {
863
- config.injectLocale = bucketEntry.injectLocale;
864
- }
865
- if (bucketEntry.lockedKeys) {
866
- config.lockedKeys = bucketEntry.lockedKeys;
867
- }
868
- if (bucketEntry.lockedPatterns) {
869
- config.lockedPatterns = bucketEntry.lockedPatterns;
857
+ const result = Object.entries(i18nConfig.buckets).map(
858
+ ([bucketType, bucketEntry]) => {
859
+ const includeItems = bucketEntry.include.map(
860
+ (item) => resolveBucketItem(item)
861
+ );
862
+ const excludeItems = _optionalChain([bucketEntry, 'access', _40 => _40.exclude, 'optionalAccess', _41 => _41.map, 'call', _42 => _42(
863
+ (item) => resolveBucketItem(item)
864
+ )]);
865
+ const config = {
866
+ type: bucketType,
867
+ paths: extractPathPatterns(
868
+ i18nConfig.locale.source,
869
+ includeItems,
870
+ excludeItems
871
+ )
872
+ };
873
+ if (bucketEntry.injectLocale) {
874
+ config.injectLocale = bucketEntry.injectLocale;
875
+ }
876
+ if (bucketEntry.lockedKeys) {
877
+ config.lockedKeys = bucketEntry.lockedKeys;
878
+ }
879
+ if (bucketEntry.lockedPatterns) {
880
+ config.lockedPatterns = bucketEntry.lockedPatterns;
881
+ }
882
+ if (bucketEntry.ignoredKeys) {
883
+ config.ignoredKeys = bucketEntry.ignoredKeys;
884
+ }
885
+ return config;
870
886
  }
871
- return config;
872
- });
887
+ );
873
888
  return result;
874
889
  }
875
890
  function extractPathPatterns(sourceLocale, include, exclude) {
876
891
  const includedPatterns = include.flatMap(
877
- (pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
878
- (pathPattern) => ({
879
- pathPattern,
880
- delimiter: pattern.delimiter
881
- })
882
- )
892
+ (pattern) => expandPlaceholderedGlob(
893
+ pattern.path,
894
+ __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
895
+ ).map((pathPattern) => ({
896
+ pathPattern,
897
+ delimiter: pattern.delimiter
898
+ }))
883
899
  );
884
- const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _41 => _41.flatMap, 'call', _42 => _42(
885
- (pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
886
- (pathPattern) => ({
887
- pathPattern,
888
- delimiter: pattern.delimiter
889
- })
890
- )
900
+ const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _43 => _43.flatMap, 'call', _44 => _44(
901
+ (pattern) => expandPlaceholderedGlob(
902
+ pattern.path,
903
+ __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
904
+ ).map((pathPattern) => ({
905
+ pathPattern,
906
+ delimiter: pattern.delimiter
907
+ }))
891
908
  )]);
892
- const result = _lodash2.default.differenceBy(includedPatterns, _nullishCoalesce(excludedPatterns, () => ( [])), (item) => item.pathPattern);
909
+ const result = _lodash2.default.differenceBy(
910
+ includedPatterns,
911
+ _nullishCoalesce(excludedPatterns, () => ( [])),
912
+ (item) => item.pathPattern
913
+ );
893
914
  return result;
894
915
  }
895
916
  function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
@@ -908,12 +929,15 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
908
929
  });
909
930
  }
910
931
  const pathPatternChunks = pathPattern.split(path14.default.sep);
911
- const localeSegmentIndexes = pathPatternChunks.reduce((indexes, segment, index) => {
912
- if (segment.includes("[locale]")) {
913
- indexes.push(index);
914
- }
915
- return indexes;
916
- }, []);
932
+ const localeSegmentIndexes = pathPatternChunks.reduce(
933
+ (indexes, segment, index) => {
934
+ if (segment.includes("[locale]")) {
935
+ indexes.push(index);
936
+ }
937
+ return indexes;
938
+ },
939
+ []
940
+ );
917
941
  const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
918
942
  const sourcePaths = _glob.glob.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => path14.default.relative(process.cwd(), fullpath));
919
943
  const placeholderedPaths = sourcePaths.map((sourcePath) => {
@@ -1010,12 +1034,12 @@ function composeLoaders(...loaders) {
1010
1034
  return {
1011
1035
  init: async () => {
1012
1036
  for (const loader of loaders) {
1013
- await _optionalChain([loader, 'access', _43 => _43.init, 'optionalCall', _44 => _44()]);
1037
+ await _optionalChain([loader, 'access', _45 => _45.init, 'optionalCall', _46 => _46()]);
1014
1038
  }
1015
1039
  },
1016
1040
  setDefaultLocale(locale) {
1017
1041
  for (const loader of loaders) {
1018
- _optionalChain([loader, 'access', _45 => _45.setDefaultLocale, 'optionalCall', _46 => _46(locale)]);
1042
+ _optionalChain([loader, 'access', _47 => _47.setDefaultLocale, 'optionalCall', _48 => _48(locale)]);
1019
1043
  }
1020
1044
  return this;
1021
1045
  },
@@ -1048,7 +1072,7 @@ function createLoader(lDefinition) {
1048
1072
  if (state.initCtx) {
1049
1073
  return state.initCtx;
1050
1074
  }
1051
- state.initCtx = await _optionalChain([lDefinition, 'access', _47 => _47.init, 'optionalCall', _48 => _48()]);
1075
+ state.initCtx = await _optionalChain([lDefinition, 'access', _49 => _49.init, 'optionalCall', _50 => _50()]);
1052
1076
  return state.initCtx;
1053
1077
  },
1054
1078
  setDefaultLocale(locale) {
@@ -1152,7 +1176,7 @@ function createNormalizeLoader() {
1152
1176
  return normalized;
1153
1177
  },
1154
1178
  push: async (locale, data, originalInput) => {
1155
- const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _49 => _49.keysMap]), () => ( {}));
1179
+ const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _51 => _51.keysMap]), () => ( {}));
1156
1180
  const input2 = mapDenormalizedKeys(data, keysMap);
1157
1181
  const denormalized = _flat.unflatten.call(void 0, input2, {
1158
1182
  delimiter: "/",
@@ -1226,7 +1250,7 @@ function createTextFileLoader(pathPattern) {
1226
1250
  const trimmedResult = result.trim();
1227
1251
  return trimmedResult;
1228
1252
  },
1229
- async push(locale, data, _27, originalLocale) {
1253
+ async push(locale, data, _29, originalLocale) {
1230
1254
  const draftPath = pathPattern.replaceAll("[locale]", locale);
1231
1255
  const finalPath = path14.default.resolve(draftPath);
1232
1256
  const dirPath = path14.default.dirname(finalPath);
@@ -1255,8 +1279,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
1255
1279
  if (!templateData) {
1256
1280
  templateData = await readFileForLocale(pathPattern, originalLocale);
1257
1281
  }
1258
- if (_optionalChain([templateData, 'optionalAccess', _50 => _50.match, 'call', _51 => _51(/[\r\n]$/)])) {
1259
- const ending = _optionalChain([templateData, 'optionalAccess', _52 => _52.includes, 'call', _53 => _53("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _54 => _54.includes, 'call', _55 => _55("\r")]) ? "\r" : "\n";
1282
+ if (_optionalChain([templateData, 'optionalAccess', _52 => _52.match, 'call', _53 => _53(/[\r\n]$/)])) {
1283
+ const ending = _optionalChain([templateData, 'optionalAccess', _54 => _54.includes, 'call', _55 => _55("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _56 => _56.includes, 'call', _57 => _57("\r")]) ? "\r" : "\n";
1260
1284
  return ending;
1261
1285
  }
1262
1286
  return "";
@@ -1540,6 +1564,9 @@ function createCsvLoader() {
1540
1564
  skip_empty_lines: true
1541
1565
  });
1542
1566
  const columns = input2.length > 0 ? Object.keys(input2[0]) : ["id", locale];
1567
+ if (!columns.includes(locale)) {
1568
+ columns.push(locale);
1569
+ }
1543
1570
  const updatedRows = input2.map((row) => ({
1544
1571
  ...row,
1545
1572
  [locale]: data[row.id] || row[locale] || ""
@@ -1595,7 +1622,7 @@ function createHtmlLoader() {
1595
1622
  break;
1596
1623
  }
1597
1624
  const siblings = Array.from(parent.childNodes).filter(
1598
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _56 => _56.textContent, 'optionalAccess', _57 => _57.trim, 'call', _58 => _58()])
1625
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _58 => _58.textContent, 'optionalAccess', _59 => _59.trim, 'call', _60 => _60()])
1599
1626
  );
1600
1627
  const index = siblings.indexOf(current);
1601
1628
  if (index !== -1) {
@@ -1630,11 +1657,11 @@ function createHtmlLoader() {
1630
1657
  result[getPath(element, attr)] = value;
1631
1658
  }
1632
1659
  });
1633
- Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _59 => _59.textContent, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()])).forEach(processNode);
1660
+ Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _61 => _61.textContent, 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()])).forEach(processNode);
1634
1661
  }
1635
1662
  };
1636
- Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _62 => _62.textContent, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()])).forEach(processNode);
1637
- Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()])).forEach(processNode);
1663
+ Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _64 => _64.textContent, 'optionalAccess', _65 => _65.trim, 'call', _66 => _66()])).forEach(processNode);
1664
+ Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _67 => _67.textContent, 'optionalAccess', _68 => _68.trim, 'call', _69 => _69()])).forEach(processNode);
1638
1665
  return result;
1639
1666
  },
1640
1667
  async push(locale, data, originalInput) {
@@ -1656,7 +1683,7 @@ function createHtmlLoader() {
1656
1683
  for (let i = 0; i < indices.length; i++) {
1657
1684
  const index = parseInt(indices[i]);
1658
1685
  const siblings = Array.from(parent.childNodes).filter(
1659
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _68 => _68.textContent, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()])
1686
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _70 => _70.textContent, 'optionalAccess', _71 => _71.trim, 'call', _72 => _72()])
1660
1687
  );
1661
1688
  if (index >= siblings.length) {
1662
1689
  if (i === indices.length - 1) {
@@ -1707,7 +1734,7 @@ function createMarkdownLoader() {
1707
1734
  yaml: yamlEngine
1708
1735
  }
1709
1736
  });
1710
- const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _71 => _71.trim, 'call', _72 => _72()]), () => ( ""))).filter(Boolean);
1737
+ const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]), () => ( ""))).filter(Boolean);
1711
1738
  return {
1712
1739
  ...Object.fromEntries(
1713
1740
  sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
@@ -1719,7 +1746,7 @@ function createMarkdownLoader() {
1719
1746
  const frontmatter = Object.fromEntries(
1720
1747
  Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
1721
1748
  );
1722
- let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]), () => ( ""))).filter(Boolean).join("\n\n");
1749
+ let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _75 => _75.trim, 'call', _76 => _76()]), () => ( ""))).filter(Boolean).join("\n\n");
1723
1750
  if (Object.keys(frontmatter).length > 0) {
1724
1751
  content = `
1725
1752
  ${content}`;
@@ -1752,7 +1779,7 @@ function createPropertiesLoader() {
1752
1779
  return result;
1753
1780
  },
1754
1781
  async push(locale, payload) {
1755
- const result = Object.entries(payload).filter(([_27, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1782
+ const result = Object.entries(payload).filter(([_29, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1756
1783
  return result;
1757
1784
  }
1758
1785
  });
@@ -1763,7 +1790,7 @@ function isSkippableLine(line) {
1763
1790
  function parsePropertyLine(line) {
1764
1791
  const [key, ...valueParts] = line.split("=");
1765
1792
  return {
1766
- key: _optionalChain([key, 'optionalAccess', _75 => _75.trim, 'call', _76 => _76()]) || "",
1793
+ key: _optionalChain([key, 'optionalAccess', _77 => _77.trim, 'call', _78 => _78()]) || "",
1767
1794
  value: valueParts.join("=").trim()
1768
1795
  };
1769
1796
  }
@@ -1849,7 +1876,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1849
1876
  if (rootTranslationEntity.shouldTranslate === false) {
1850
1877
  continue;
1851
1878
  }
1852
- const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _77 => _77.localizations, 'optionalAccess', _78 => _78[locale]]);
1879
+ const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _79 => _79.localizations, 'optionalAccess', _80 => _80[locale]]);
1853
1880
  if (langTranslationEntity) {
1854
1881
  if ("stringUnit" in langTranslationEntity) {
1855
1882
  resultData[translationKey] = langTranslationEntity.stringUnit.value;
@@ -1858,7 +1885,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1858
1885
  resultData[translationKey] = {};
1859
1886
  const pluralForms = langTranslationEntity.variations.plural;
1860
1887
  for (const form in pluralForms) {
1861
- if (_optionalChain([pluralForms, 'access', _79 => _79[form], 'optionalAccess', _80 => _80.stringUnit, 'optionalAccess', _81 => _81.value])) {
1888
+ if (_optionalChain([pluralForms, 'access', _81 => _81[form], 'optionalAccess', _82 => _82.stringUnit, 'optionalAccess', _83 => _83.value])) {
1862
1889
  resultData[translationKey][form] = pluralForms[form].stringUnit.value;
1863
1890
  }
1864
1891
  }
@@ -1881,7 +1908,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1881
1908
  const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
1882
1909
  if (typeof value === "string") {
1883
1910
  langDataToMerge.strings[key] = {
1884
- extractionState: _optionalChain([originalInput, 'optionalAccess', _82 => _82.strings, 'optionalAccess', _83 => _83[key], 'optionalAccess', _84 => _84.extractionState]),
1911
+ extractionState: _optionalChain([originalInput, 'optionalAccess', _84 => _84.strings, 'optionalAccess', _85 => _85[key], 'optionalAccess', _86 => _86.extractionState]),
1885
1912
  localizations: {
1886
1913
  [locale]: {
1887
1914
  stringUnit: {
@@ -2019,10 +2046,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
2019
2046
  }
2020
2047
  }
2021
2048
  return false;
2022
- }).map(([key, _27]) => key);
2023
- const result = _lodash2.default.omitBy(input2, (_27, key) => passthroughKeys.includes(key));
2049
+ }).map(([key, _29]) => key);
2050
+ const result = _lodash2.default.omitBy(input2, (_29, key) => passthroughKeys.includes(key));
2024
2051
  if (returnUnlocalizedKeys) {
2025
- result.unlocalizable = _lodash2.default.omitBy(input2, (_27, key) => !passthroughKeys.includes(key));
2052
+ result.unlocalizable = _lodash2.default.omitBy(input2, (_29, key) => !passthroughKeys.includes(key));
2026
2053
  }
2027
2054
  return result;
2028
2055
  },
@@ -2061,7 +2088,7 @@ function createPoDataLoader(params) {
2061
2088
  Object.entries(entries).forEach(([msgid, entry]) => {
2062
2089
  if (msgid && entry.msgid) {
2063
2090
  const context = entry.msgctxt || "";
2064
- const fullEntry = _optionalChain([parsedPo, 'access', _85 => _85.translations, 'access', _86 => _86[context], 'optionalAccess', _87 => _87[msgid]]);
2091
+ const fullEntry = _optionalChain([parsedPo, 'access', _87 => _87.translations, 'access', _88 => _88[context], 'optionalAccess', _89 => _89[msgid]]);
2065
2092
  if (fullEntry) {
2066
2093
  result[msgid] = fullEntry;
2067
2094
  }
@@ -2071,8 +2098,8 @@ function createPoDataLoader(params) {
2071
2098
  return result;
2072
2099
  },
2073
2100
  async push(locale, data, originalInput, originalLocale, pullInput) {
2074
- const currentSections = _optionalChain([pullInput, 'optionalAccess', _88 => _88.split, 'call', _89 => _89("\n\n"), 'access', _90 => _90.filter, 'call', _91 => _91(Boolean)]) || [];
2075
- const originalSections = _optionalChain([originalInput, 'optionalAccess', _92 => _92.split, 'call', _93 => _93("\n\n"), 'access', _94 => _94.filter, 'call', _95 => _95(Boolean)]) || [];
2101
+ const currentSections = _optionalChain([pullInput, 'optionalAccess', _90 => _90.split, 'call', _91 => _91("\n\n"), 'access', _92 => _92.filter, 'call', _93 => _93(Boolean)]) || [];
2102
+ const originalSections = _optionalChain([originalInput, 'optionalAccess', _94 => _94.split, 'call', _95 => _95("\n\n"), 'access', _96 => _96.filter, 'call', _97 => _97(Boolean)]) || [];
2076
2103
  const result = originalSections.map((section) => {
2077
2104
  const sectionPo = _gettextparser2.default.po.parse(section);
2078
2105
  const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
@@ -2137,8 +2164,8 @@ function createPoContentLoader() {
2137
2164
  {
2138
2165
  ...entry,
2139
2166
  msgstr: [
2140
- _optionalChain([data, 'access', _96 => _96[entry.msgid], 'optionalAccess', _97 => _97.singular]),
2141
- _optionalChain([data, 'access', _98 => _98[entry.msgid], 'optionalAccess', _99 => _99.plural]) || null
2167
+ _optionalChain([data, 'access', _98 => _98[entry.msgid], 'optionalAccess', _99 => _99.singular]),
2168
+ _optionalChain([data, 'access', _100 => _100[entry.msgid], 'optionalAccess', _101 => _101.plural]) || null
2142
2169
  ].filter(Boolean)
2143
2170
  }
2144
2171
  ]).fromPairs().value();
@@ -2385,7 +2412,7 @@ function createDatoClient(params) {
2385
2412
  only_valid: "true",
2386
2413
  ids: !records.length ? void 0 : records.join(",")
2387
2414
  }
2388
- }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _100 => _100.response, 'optionalAccess', _101 => _101.body, 'optionalAccess', _102 => _102.data, 'optionalAccess', _103 => _103[0]]) || error));
2415
+ }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _102 => _102.response, 'optionalAccess', _103 => _103.body, 'optionalAccess', _104 => _104.data, 'optionalAccess', _105 => _105[0]]) || error));
2389
2416
  },
2390
2417
  findRecordsForModel: async (modelId, records) => {
2391
2418
  try {
@@ -2395,9 +2422,9 @@ function createDatoClient(params) {
2395
2422
  filter: {
2396
2423
  type: modelId,
2397
2424
  only_valid: "true",
2398
- ids: !_optionalChain([records, 'optionalAccess', _104 => _104.length]) ? void 0 : records.join(",")
2425
+ ids: !_optionalChain([records, 'optionalAccess', _106 => _106.length]) ? void 0 : records.join(",")
2399
2426
  }
2400
- }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _105 => _105.response, 'optionalAccess', _106 => _106.body, 'optionalAccess', _107 => _107.data, 'optionalAccess', _108 => _108[0]]) || error));
2427
+ }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _107 => _107.response, 'optionalAccess', _108 => _108.body, 'optionalAccess', _109 => _109.data, 'optionalAccess', _110 => _110[0]]) || error));
2401
2428
  return result;
2402
2429
  } catch (_error) {
2403
2430
  throw new Error(
@@ -2411,9 +2438,9 @@ function createDatoClient(params) {
2411
2438
  },
2412
2439
  updateRecord: async (id, payload) => {
2413
2440
  try {
2414
- await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _109 => _109.response, 'optionalAccess', _110 => _110.body, 'optionalAccess', _111 => _111.data, 'optionalAccess', _112 => _112[0]]) || error));
2441
+ await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _111 => _111.response, 'optionalAccess', _112 => _112.body, 'optionalAccess', _113 => _113.data, 'optionalAccess', _114 => _114[0]]) || error));
2415
2442
  } catch (_error) {
2416
- if (_optionalChain([_error, 'optionalAccess', _113 => _113.attributes, 'optionalAccess', _114 => _114.details, 'optionalAccess', _115 => _115.message])) {
2443
+ if (_optionalChain([_error, 'optionalAccess', _115 => _115.attributes, 'optionalAccess', _116 => _116.details, 'optionalAccess', _117 => _117.message])) {
2417
2444
  throw new Error(
2418
2445
  [
2419
2446
  `${_error.attributes.details.message}`,
@@ -2434,9 +2461,9 @@ function createDatoClient(params) {
2434
2461
  },
2435
2462
  enableFieldLocalization: async (args) => {
2436
2463
  try {
2437
- await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _116 => _116.response, 'optionalAccess', _117 => _117.body, 'optionalAccess', _118 => _118.data, 'optionalAccess', _119 => _119[0]]) || error));
2464
+ await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _118 => _118.response, 'optionalAccess', _119 => _119.body, 'optionalAccess', _120 => _120.data, 'optionalAccess', _121 => _121[0]]) || error));
2438
2465
  } catch (_error) {
2439
- if (_optionalChain([_error, 'optionalAccess', _120 => _120.attributes, 'optionalAccess', _121 => _121.code]) === "NOT_FOUND") {
2466
+ if (_optionalChain([_error, 'optionalAccess', _122 => _122.attributes, 'optionalAccess', _123 => _123.code]) === "NOT_FOUND") {
2440
2467
  throw new Error(
2441
2468
  [
2442
2469
  `Field "${args.fieldId}" not found in model "${args.modelId}".`,
@@ -2444,7 +2471,7 @@ function createDatoClient(params) {
2444
2471
  ].join("\n\n")
2445
2472
  );
2446
2473
  }
2447
- if (_optionalChain([_error, 'optionalAccess', _122 => _122.attributes, 'optionalAccess', _123 => _123.details, 'optionalAccess', _124 => _124.message])) {
2474
+ if (_optionalChain([_error, 'optionalAccess', _124 => _124.attributes, 'optionalAccess', _125 => _125.details, 'optionalAccess', _126 => _126.message])) {
2448
2475
  throw new Error(
2449
2476
  [`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
2450
2477
  );
@@ -2510,7 +2537,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
2510
2537
  }
2511
2538
  }
2512
2539
  const records = await dato.findRecordsForModel(modelId);
2513
- const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _125 => _125.models, 'access', _126 => _126[modelId], 'optionalAccess', _127 => _127.records]) || [], project);
2540
+ const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _127 => _127.models, 'access', _128 => _128[modelId], 'optionalAccess', _129 => _129.records]) || [], project);
2514
2541
  const selectedRecords = await promptRecordSelection(modelName, recordChoices);
2515
2542
  result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
2516
2543
  updatedConfig.models[modelId].records = selectedRecords;
@@ -2522,14 +2549,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
2522
2549
  },
2523
2550
  async pull(locale, input2, initCtx) {
2524
2551
  const result = {};
2525
- for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _128 => _128.models]) || {})) {
2526
- let records = _optionalChain([initCtx, 'optionalAccess', _129 => _129.models, 'access', _130 => _130[modelId], 'access', _131 => _131.records]) || [];
2552
+ for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _130 => _130.models]) || {})) {
2553
+ let records = _optionalChain([initCtx, 'optionalAccess', _131 => _131.models, 'access', _132 => _132[modelId], 'access', _133 => _133.records]) || [];
2527
2554
  const recordIds = records.map((record) => record.id);
2528
2555
  records = await dato.findRecords(recordIds);
2529
2556
  console.log(`Fetched ${records.length} records for model ${modelId}`);
2530
2557
  if (records.length > 0) {
2531
2558
  result[modelId] = {
2532
- fields: _optionalChain([initCtx, 'optionalAccess', _132 => _132.models, 'optionalAccess', _133 => _133[modelId], 'optionalAccess', _134 => _134.fields]) || [],
2559
+ fields: _optionalChain([initCtx, 'optionalAccess', _134 => _134.models, 'optionalAccess', _135 => _135[modelId], 'optionalAccess', _136 => _136.fields]) || [],
2533
2560
  records
2534
2561
  };
2535
2562
  }
@@ -2588,7 +2615,7 @@ function createRecordChoices(records, selectedIds = [], project) {
2588
2615
  return records.map((record) => ({
2589
2616
  name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
2590
2617
  value: record.id,
2591
- checked: _optionalChain([selectedIds, 'optionalAccess', _135 => _135.includes, 'call', _136 => _136(record.id)])
2618
+ checked: _optionalChain([selectedIds, 'optionalAccess', _137 => _137.includes, 'call', _138 => _138(record.id)])
2592
2619
  }));
2593
2620
  }
2594
2621
  async function promptRecordSelection(modelName, choices) {
@@ -2855,7 +2882,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
2855
2882
  function createVttLoader() {
2856
2883
  return createLoader({
2857
2884
  async pull(locale, input2) {
2858
- const vtt = _optionalChain([_nodewebvtt2.default, 'access', _137 => _137.parse, 'call', _138 => _138(input2), 'optionalAccess', _139 => _139.cues]);
2885
+ const vtt = _optionalChain([_nodewebvtt2.default, 'access', _139 => _139.parse, 'call', _140 => _140(input2), 'optionalAccess', _141 => _141.cues]);
2859
2886
  if (Object.keys(vtt).length === 0) {
2860
2887
  return {};
2861
2888
  } else {
@@ -2908,7 +2935,7 @@ function variableExtractLoader(params) {
2908
2935
  for (let i = 0; i < matches.length; i++) {
2909
2936
  const match = matches[i];
2910
2937
  const currentValue = result[key].value;
2911
- const newValue = _optionalChain([currentValue, 'optionalAccess', _140 => _140.replace, 'call', _141 => _141(match, `{variable:${i}}`)]);
2938
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _142 => _142.replace, 'call', _143 => _143(match, `{variable:${i}}`)]);
2912
2939
  result[key].value = newValue;
2913
2940
  result[key].variables[i] = match;
2914
2941
  }
@@ -2922,7 +2949,7 @@ function variableExtractLoader(params) {
2922
2949
  for (let i = 0; i < valueObj.variables.length; i++) {
2923
2950
  const variable = valueObj.variables[i];
2924
2951
  const currentValue = result[key];
2925
- const newValue = _optionalChain([currentValue, 'optionalAccess', _142 => _142.replace, 'call', _143 => _143(`{variable:${i}}`, variable)]);
2952
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _144 => _144.replace, 'call', _145 => _145(`{variable:${i}}`, variable)]);
2926
2953
  result[key] = newValue;
2927
2954
  }
2928
2955
  }
@@ -3103,7 +3130,7 @@ function createVueJsonLoader() {
3103
3130
  return createLoader({
3104
3131
  pull: async (locale, input2, ctx) => {
3105
3132
  const parsed = parseVueFile(input2);
3106
- return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _144 => _144.i18n, 'optionalAccess', _145 => _145[locale]]), () => ( {}));
3133
+ return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _146 => _146.i18n, 'optionalAccess', _147 => _147[locale]]), () => ( {}));
3107
3134
  },
3108
3135
  push: async (locale, data, originalInput) => {
3109
3136
  const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
@@ -3284,7 +3311,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
3284
3311
  objectExpression.properties.forEach((prop) => {
3285
3312
  if (!t.isObjectProperty(prop)) return;
3286
3313
  const key = getPropertyKey(prop);
3287
- const incomingVal = _optionalChain([data, 'optionalAccess', _146 => _146[key]]);
3314
+ const incomingVal = _optionalChain([data, 'optionalAccess', _148 => _148[key]]);
3288
3315
  if (incomingVal === void 0) {
3289
3316
  return;
3290
3317
  }
@@ -3320,7 +3347,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
3320
3347
  let modified = false;
3321
3348
  arrayExpression.elements.forEach((element, index) => {
3322
3349
  if (!element) return;
3323
- const incomingVal = _optionalChain([incoming, 'optionalAccess', _147 => _147[index]]);
3350
+ const incomingVal = _optionalChain([incoming, 'optionalAccess', _149 => _149[index]]);
3324
3351
  if (incomingVal === void 0) return;
3325
3352
  if (t.isStringLiteral(element) && typeof incomingVal === "string") {
3326
3353
  if (element.value !== incomingVal) {
@@ -3596,7 +3623,7 @@ function createMdxSectionsSplit2Loader() {
3596
3623
  const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
3597
3624
  const result = {
3598
3625
  frontmatter: data.frontmatter,
3599
- codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _148 => _148.codePlaceholders]) || {},
3626
+ codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _150 => _150.codePlaceholders]) || {},
3600
3627
  content
3601
3628
  };
3602
3629
  return result;
@@ -3653,8 +3680,23 @@ function createMdxLockedPatternsLoader(defaultPatterns) {
3653
3680
  });
3654
3681
  }
3655
3682
 
3683
+ // src/cli/loaders/ignored-keys.ts
3684
+
3685
+ function createIgnoredKeysLoader(ignoredKeys) {
3686
+ return createLoader({
3687
+ pull: async (locale, data) => {
3688
+ const result = _lodash2.default.chain(data).omit(ignoredKeys).value();
3689
+ return result;
3690
+ },
3691
+ push: async (locale, data, originalInput, originalLocale, pullInput) => {
3692
+ const result = _lodash2.default.merge({}, data, _lodash2.default.pick(pullInput, ignoredKeys));
3693
+ return result;
3694
+ }
3695
+ });
3696
+ }
3697
+
3656
3698
  // src/cli/loaders/index.ts
3657
- function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns) {
3699
+ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns, ignoredKeys) {
3658
3700
  switch (bucketType) {
3659
3701
  default:
3660
3702
  throw new Error(`Unsupported bucket type: ${bucketType}`);
@@ -3913,6 +3955,8 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
3913
3955
  createTypescriptLoader(),
3914
3956
  createFlatLoader(),
3915
3957
  createSyncLoader(),
3958
+ createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3959
+ createIgnoredKeysLoader(ignoredKeys || []),
3916
3960
  createUnlocalizableLoader(
3917
3961
  options.isCacheRestore,
3918
3962
  options.returnUnlocalizedKeys
@@ -3927,6 +3971,10 @@ var _diff = require('diff');
3927
3971
 
3928
3972
  var _externaleditor = require('external-editor'); var _externaleditor2 = _interopRequireDefault(_externaleditor);
3929
3973
 
3974
+ // src/cli/processor/index.ts
3975
+
3976
+ var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
3977
+
3930
3978
  // src/cli/processor/lingo.ts
3931
3979
  var __sdk = require('@lingo.dev/_sdk');
3932
3980
  function createLingoLocalizer(params) {
@@ -3961,9 +4009,6 @@ function createBasicTranslator(model, systemPrompt) {
3961
4009
  if (!Object.keys(input2.processableData).length) {
3962
4010
  return input2.processableData;
3963
4011
  }
3964
- if (!process.env.OPENAI_API_KEY) {
3965
- throw new Error("OPENAI_API_KEY is not set");
3966
- }
3967
4012
  const response = await _ai.generateText.call(void 0, {
3968
4013
  model,
3969
4014
  messages: [
@@ -4005,15 +4050,27 @@ function createBasicTranslator(model, systemPrompt) {
4005
4050
  ]
4006
4051
  });
4007
4052
  const result = JSON.parse(response.text);
4008
- return _optionalChain([result, 'optionalAccess', _149 => _149.data]) || {};
4053
+ return _optionalChain([result, 'optionalAccess', _151 => _151.data]) || {};
4009
4054
  };
4010
4055
  }
4011
4056
 
4012
4057
  // src/cli/processor/index.ts
4013
4058
  var _openai = require('@ai-sdk/openai');
4059
+
4060
+ // src/cli/constants.ts
4061
+ var colors = {
4062
+ orange: "#ff6600",
4063
+ green: "#6ae300",
4064
+ blue: "#0090ff",
4065
+ yellow: "#ffcc00",
4066
+ grey: "#808080",
4067
+ red: "#ff0000"
4068
+ };
4069
+
4070
+ // src/cli/processor/index.ts
4014
4071
  var _anthropic = require('@ai-sdk/anthropic');
4015
4072
  function createProcessor(provider, params) {
4016
- if (!provider || provider.id === "lingo") {
4073
+ if (!provider) {
4017
4074
  const result = createLingoLocalizer(params);
4018
4075
  return result;
4019
4076
  } else {
@@ -4023,10 +4080,30 @@ function createProcessor(provider, params) {
4023
4080
  }
4024
4081
  }
4025
4082
  function getPureModelProvider(provider) {
4026
- switch (_optionalChain([provider, 'optionalAccess', _150 => _150.id])) {
4083
+ const createMissingKeyErrorMessage = (providerId, envVar) => _dedent2.default`
4084
+ You're trying to use raw ${_chalk2.default.dim(providerId)} API for translation, however, ${_chalk2.default.dim(envVar)} environment variable is not set.
4085
+
4086
+ To fix this issue:
4087
+ 1. Set ${_chalk2.default.dim(envVar)} in your environment variables, or
4088
+ 2. Remove the ${_chalk2.default.italic("provider")} node from your i18n.json configuration to switch to ${_chalk2.default.hex(colors.green)("Lingo.dev")}
4089
+
4090
+ ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
4091
+ `;
4092
+ const createUnsupportedProviderErrorMessage = (providerId) => _dedent2.default`
4093
+ You're trying to use unsupported provider: ${_chalk2.default.dim(providerId)}.
4094
+
4095
+ To fix this issue:
4096
+ 1. Switch to one of the supported providers, or
4097
+ 2. Remove the ${_chalk2.default.italic("provider")} node from your i18n.json configuration to switch to ${_chalk2.default.hex(colors.green)("Lingo.dev")}
4098
+
4099
+ ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
4100
+ `;
4101
+ switch (_optionalChain([provider, 'optionalAccess', _152 => _152.id])) {
4027
4102
  case "openai":
4028
4103
  if (!process.env.OPENAI_API_KEY) {
4029
- throw new Error("OPENAI_API_KEY is not set.");
4104
+ throw new Error(
4105
+ createMissingKeyErrorMessage("OpenAI", "OPENAI_API_KEY")
4106
+ );
4030
4107
  }
4031
4108
  return _openai.createOpenAI.call(void 0, {
4032
4109
  apiKey: process.env.OPENAI_API_KEY,
@@ -4034,13 +4111,15 @@ function getPureModelProvider(provider) {
4034
4111
  })(provider.model);
4035
4112
  case "anthropic":
4036
4113
  if (!process.env.ANTHROPIC_API_KEY) {
4037
- throw new Error("ANTHROPIC_API_KEY is not set.");
4114
+ throw new Error(
4115
+ createMissingKeyErrorMessage("Anthropic", "ANTHROPIC_API_KEY")
4116
+ );
4038
4117
  }
4039
4118
  return _anthropic.createAnthropic.call(void 0, {
4040
4119
  apiKey: process.env.ANTHROPIC_API_KEY
4041
4120
  })(provider.model);
4042
4121
  default:
4043
- throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _151 => _151.id])}`);
4122
+ throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _153 => _153.id])));
4044
4123
  }
4045
4124
  }
4046
4125
 
@@ -4265,7 +4344,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4265
4344
  validateParams(i18nConfig, flags);
4266
4345
  ora.succeed("Localization configuration is valid");
4267
4346
  ora.start("Connecting to Lingo.dev Localization Engine...");
4268
- const isByokMode = _optionalChain([i18nConfig, 'optionalAccess', _152 => _152.provider]) && i18nConfig.provider.id !== "lingo";
4347
+ const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _154 => _154.provider]);
4269
4348
  if (isByokMode) {
4270
4349
  authId = null;
4271
4350
  ora.succeed("Using external provider (BYOK mode)");
@@ -4279,16 +4358,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4279
4358
  flags
4280
4359
  });
4281
4360
  let buckets = getBuckets(i18nConfig);
4282
- if (_optionalChain([flags, 'access', _153 => _153.bucket, 'optionalAccess', _154 => _154.length])) {
4361
+ if (_optionalChain([flags, 'access', _155 => _155.bucket, 'optionalAccess', _156 => _156.length])) {
4283
4362
  buckets = buckets.filter(
4284
4363
  (bucket) => flags.bucket.includes(bucket.type)
4285
4364
  );
4286
4365
  }
4287
4366
  ora.succeed("Buckets retrieved");
4288
- if (_optionalChain([flags, 'access', _155 => _155.file, 'optionalAccess', _156 => _156.length])) {
4367
+ if (_optionalChain([flags, 'access', _157 => _157.file, 'optionalAccess', _158 => _158.length])) {
4289
4368
  buckets = buckets.map((bucket) => {
4290
4369
  const paths = bucket.paths.filter(
4291
- (path17) => flags.file.find((file) => _optionalChain([path17, 'access', _157 => _157.pathPattern, 'optionalAccess', _158 => _158.includes, 'call', _159 => _159(file)]))
4370
+ (path17) => flags.file.find((file) => _optionalChain([path17, 'access', _159 => _159.pathPattern, 'optionalAccess', _160 => _160.includes, 'call', _161 => _161(file)]))
4292
4371
  );
4293
4372
  return { ...bucket, paths };
4294
4373
  }).filter((bucket) => bucket.paths.length > 0);
@@ -4307,7 +4386,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4307
4386
  });
4308
4387
  }
4309
4388
  }
4310
- const targetLocales = _optionalChain([flags, 'access', _160 => _160.locale, 'optionalAccess', _161 => _161.length]) ? flags.locale : i18nConfig.locale.targets;
4389
+ const targetLocales = _optionalChain([flags, 'access', _162 => _162.locale, 'optionalAccess', _163 => _163.length]) ? flags.locale : i18nConfig.locale.targets;
4311
4390
  ora.start("Setting up localization cache...");
4312
4391
  const checkLockfileProcessor = createDeltaProcessor("");
4313
4392
  const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
@@ -4328,7 +4407,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4328
4407
  injectLocale: bucket.injectLocale
4329
4408
  },
4330
4409
  bucket.lockedKeys,
4331
- bucket.lockedPatterns
4410
+ bucket.lockedPatterns,
4411
+ bucket.ignoredKeys
4332
4412
  );
4333
4413
  bucketLoader.setDefaultLocale(sourceLocale);
4334
4414
  await bucketLoader.init();
@@ -4515,7 +4595,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4515
4595
  injectLocale: bucket.injectLocale
4516
4596
  },
4517
4597
  bucket.lockedKeys,
4518
- bucket.lockedPatterns
4598
+ bucket.lockedPatterns,
4599
+ bucket.ignoredKeys
4519
4600
  );
4520
4601
  bucketLoader.setDefaultLocale(sourceLocale);
4521
4602
  await bucketLoader.init();
@@ -4546,7 +4627,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4546
4627
  if (flags.key) {
4547
4628
  processableData = _lodash2.default.pickBy(
4548
4629
  processableData,
4549
- (_27, key) => key === flags.key
4630
+ (_29, key) => key === flags.key
4550
4631
  );
4551
4632
  }
4552
4633
  if (flags.verbose) {
@@ -4573,15 +4654,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4573
4654
  targetData
4574
4655
  },
4575
4656
  (progress, sourceChunk, processedChunk) => {
4576
- const progressLog = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
4577
- if (flags.verbose) {
4578
- bucketOra.info(progressLog);
4579
- bucketOra.info(
4580
- `(${progress}%) Caching chunk ${JSON.stringify(sourceChunk, null, 2)} -> ${JSON.stringify(processedChunk, null, 2)}`
4581
- );
4582
- } else {
4583
- bucketOra.text = progressLog;
4584
- }
4657
+ bucketOra.text = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
4585
4658
  }
4586
4659
  );
4587
4660
  if (flags.verbose) {
@@ -4715,12 +4788,12 @@ function validateParams(i18nConfig, flags) {
4715
4788
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
4716
4789
  docUrl: "bucketNotFound"
4717
4790
  });
4718
- } else if (_optionalChain([flags, 'access', _162 => _162.locale, 'optionalAccess', _163 => _163.some, 'call', _164 => _164((locale) => !i18nConfig.locale.targets.includes(locale))])) {
4791
+ } else if (_optionalChain([flags, 'access', _164 => _164.locale, 'optionalAccess', _165 => _165.some, 'call', _166 => _166((locale) => !i18nConfig.locale.targets.includes(locale))])) {
4719
4792
  throw new CLIError({
4720
4793
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
4721
4794
  docUrl: "localeTargetNotFound"
4722
4795
  });
4723
- } else if (_optionalChain([flags, 'access', _165 => _165.bucket, 'optionalAccess', _166 => _166.some, 'call', _167 => _167(
4796
+ } else if (_optionalChain([flags, 'access', _167 => _167.bucket, 'optionalAccess', _168 => _168.some, 'call', _169 => _169(
4724
4797
  (bucket) => !i18nConfig.buckets[bucket]
4725
4798
  )])) {
4726
4799
  throw new CLIError({
@@ -5048,7 +5121,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
5048
5121
  var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
5049
5122
 
5050
5123
 
5051
- var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_27, program) => {
5124
+ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_29, program) => {
5052
5125
  const apiKey = program.args[0];
5053
5126
  const settings = getSettings(apiKey);
5054
5127
  if (!settings.auth.apiKey) {
@@ -5185,7 +5258,7 @@ var InBranchFlow = class extends IntegrationFlow {
5185
5258
  _child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
5186
5259
  _child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
5187
5260
  _child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
5188
- _optionalChain([this, 'access', _168 => _168.platformKit, 'optionalAccess', _169 => _169.gitConfig, 'call', _170 => _170()]);
5261
+ _optionalChain([this, 'access', _170 => _170.platformKit, 'optionalAccess', _171 => _171.gitConfig, 'call', _172 => _172()]);
5189
5262
  _child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
5190
5263
  _child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
5191
5264
  if (!processOwnCommits) {
@@ -5217,7 +5290,7 @@ var InBranchFlow = class extends IntegrationFlow {
5217
5290
  // src/cli/cmd/ci/flows/pull-request.ts
5218
5291
  var PullRequestFlow = class extends InBranchFlow {
5219
5292
  async preRun() {
5220
- const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _171 => _171()]);
5293
+ const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _173 => _173()]);
5221
5294
  if (!canContinue) {
5222
5295
  return false;
5223
5296
  }
@@ -5469,10 +5542,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
5469
5542
  repo_slug: this.platformConfig.repositoryName,
5470
5543
  state: "OPEN"
5471
5544
  }).then(({ data: { values } }) => {
5472
- return _optionalChain([values, 'optionalAccess', _172 => _172.find, 'call', _173 => _173(
5473
- ({ source, destination }) => _optionalChain([source, 'optionalAccess', _174 => _174.branch, 'optionalAccess', _175 => _175.name]) === branch && _optionalChain([destination, 'optionalAccess', _176 => _176.branch, 'optionalAccess', _177 => _177.name]) === this.platformConfig.baseBranchName
5545
+ return _optionalChain([values, 'optionalAccess', _174 => _174.find, 'call', _175 => _175(
5546
+ ({ source, destination }) => _optionalChain([source, 'optionalAccess', _176 => _176.branch, 'optionalAccess', _177 => _177.name]) === branch && _optionalChain([destination, 'optionalAccess', _178 => _178.branch, 'optionalAccess', _179 => _179.name]) === this.platformConfig.baseBranchName
5474
5547
  )]);
5475
- }).then((pr) => _optionalChain([pr, 'optionalAccess', _178 => _178.id]));
5548
+ }).then((pr) => _optionalChain([pr, 'optionalAccess', _180 => _180.id]));
5476
5549
  }
5477
5550
  async closePullRequest({ pullRequestNumber }) {
5478
5551
  await this.bb.repositories.declinePullRequest({
@@ -5568,7 +5641,7 @@ var GitHubPlatformKit = class extends PlatformKit {
5568
5641
  repo: this.platformConfig.repositoryName,
5569
5642
  base: this.platformConfig.baseBranchName,
5570
5643
  state: "open"
5571
- }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _179 => _179.number]));
5644
+ }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _181 => _181.number]));
5572
5645
  }
5573
5646
  async closePullRequest({ pullRequestNumber }) {
5574
5647
  await this.octokit.rest.pulls.update({
@@ -5695,7 +5768,7 @@ var GitlabPlatformKit = class extends PlatformKit {
5695
5768
  sourceBranch: branch,
5696
5769
  state: "opened"
5697
5770
  });
5698
- return _optionalChain([mergeRequests, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.iid]);
5771
+ return _optionalChain([mergeRequests, 'access', _182 => _182[0], 'optionalAccess', _183 => _183.iid]);
5699
5772
  }
5700
5773
  async closePullRequest({
5701
5774
  pullRequestNumber
@@ -5779,7 +5852,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5779
5852
  }
5780
5853
  const env = {
5781
5854
  LINGODOTDEV_API_KEY: settings.auth.apiKey,
5782
- LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _182 => _182.pullRequest, 'optionalAccess', _183 => _183.toString, 'call', _184 => _184()]) || "false",
5855
+ LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _184 => _184.pullRequest, 'optionalAccess', _185 => _185.toString, 'call', _186 => _186()]) || "false",
5783
5856
  ...options.commitMessage && {
5784
5857
  LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
5785
5858
  },
@@ -5799,7 +5872,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5799
5872
  const { isPullRequestMode } = platformKit.config;
5800
5873
  ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
5801
5874
  const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
5802
- const canRun = await _optionalChain([flow, 'access', _185 => _185.preRun, 'optionalCall', _186 => _186()]);
5875
+ const canRun = await _optionalChain([flow, 'access', _187 => _187.preRun, 'optionalCall', _188 => _188()]);
5803
5876
  if (canRun === false) {
5804
5877
  return;
5805
5878
  }
@@ -5807,7 +5880,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5807
5880
  if (!hasChanges) {
5808
5881
  return;
5809
5882
  }
5810
- await _optionalChain([flow, 'access', _187 => _187.postRun, 'optionalCall', _188 => _188()]);
5883
+ await _optionalChain([flow, 'access', _189 => _189.postRun, 'optionalCall', _190 => _190()]);
5811
5884
  });
5812
5885
 
5813
5886
  // src/cli/cmd/status.ts
@@ -5851,13 +5924,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5851
5924
  flags
5852
5925
  });
5853
5926
  let buckets = getBuckets(i18nConfig);
5854
- if (_optionalChain([flags, 'access', _189 => _189.bucket, 'optionalAccess', _190 => _190.length])) {
5927
+ if (_optionalChain([flags, 'access', _191 => _191.bucket, 'optionalAccess', _192 => _192.length])) {
5855
5928
  buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
5856
5929
  }
5857
5930
  ora.succeed("Buckets retrieved");
5858
- if (_optionalChain([flags, 'access', _191 => _191.file, 'optionalAccess', _192 => _192.length])) {
5931
+ if (_optionalChain([flags, 'access', _193 => _193.file, 'optionalAccess', _194 => _194.length])) {
5859
5932
  buckets = buckets.map((bucket) => {
5860
- const paths = bucket.paths.filter((path17) => flags.file.find((file) => _optionalChain([path17, 'access', _193 => _193.pathPattern, 'optionalAccess', _194 => _194.match, 'call', _195 => _195(file)])));
5933
+ const paths = bucket.paths.filter((path17) => flags.file.find((file) => _optionalChain([path17, 'access', _195 => _195.pathPattern, 'optionalAccess', _196 => _196.match, 'call', _197 => _197(file)])));
5861
5934
  return { ...bucket, paths };
5862
5935
  }).filter((bucket) => bucket.paths.length > 0);
5863
5936
  if (buckets.length === 0) {
@@ -5873,7 +5946,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5873
5946
  });
5874
5947
  }
5875
5948
  }
5876
- const targetLocales = _optionalChain([flags, 'access', _196 => _196.locale, 'optionalAccess', _197 => _197.length]) ? flags.locale : i18nConfig.locale.targets;
5949
+ const targetLocales = _optionalChain([flags, 'access', _198 => _198.locale, 'optionalAccess', _199 => _199.length]) ? flags.locale : i18nConfig.locale.targets;
5877
5950
  let totalSourceKeyCount = 0;
5878
5951
  let uniqueKeysToTranslate = 0;
5879
5952
  let totalExistingTranslations = 0;
@@ -6214,12 +6287,12 @@ function validateParams2(i18nConfig, flags) {
6214
6287
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
6215
6288
  docUrl: "bucketNotFound"
6216
6289
  });
6217
- } else if (_optionalChain([flags, 'access', _198 => _198.locale, 'optionalAccess', _199 => _199.some, 'call', _200 => _200((locale) => !i18nConfig.locale.targets.includes(locale))])) {
6290
+ } else if (_optionalChain([flags, 'access', _200 => _200.locale, 'optionalAccess', _201 => _201.some, 'call', _202 => _202((locale) => !i18nConfig.locale.targets.includes(locale))])) {
6218
6291
  throw new CLIError({
6219
6292
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
6220
6293
  docUrl: "localeTargetNotFound"
6221
6294
  });
6222
- } else if (_optionalChain([flags, 'access', _201 => _201.bucket, 'optionalAccess', _202 => _202.some, 'call', _203 => _203((bucket) => !i18nConfig.buckets[bucket])])) {
6295
+ } else if (_optionalChain([flags, 'access', _203 => _203.bucket, 'optionalAccess', _204 => _204.some, 'call', _205 => _205((bucket) => !i18nConfig.buckets[bucket])])) {
6223
6296
  throw new CLIError({
6224
6297
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
6225
6298
  docUrl: "bucketNotFound"
@@ -6233,7 +6306,7 @@ function validateParams2(i18nConfig, flags) {
6233
6306
 
6234
6307
 
6235
6308
 
6236
- var colors = {
6309
+ var colors2 = {
6237
6310
  orange: "#ff6600",
6238
6311
  green: "#6ae300",
6239
6312
  blue: "#0090ff",
@@ -6245,7 +6318,7 @@ var may_the_fourth_default = new (0, _interactivecommander.Command)().command("m
6245
6318
  await renderClear();
6246
6319
  await renderBanner();
6247
6320
  await renderSpacer();
6248
- console.log(_chalk2.default.hex(colors.yellow)("Loading the Star Wars movie..."));
6321
+ console.log(_chalk2.default.hex(colors2.yellow)("Loading the Star Wars movie..."));
6249
6322
  await renderSpacer();
6250
6323
  await new Promise((resolve, reject) => {
6251
6324
  const ssh = cp.spawn("ssh", ["starwarstel.net"], {
@@ -6264,7 +6337,7 @@ var may_the_fourth_default = new (0, _interactivecommander.Command)().command("m
6264
6337
  });
6265
6338
  await renderSpacer();
6266
6339
  console.log(
6267
- `${_chalk2.default.hex(colors.green)("We hope you enjoyed it! :)")} ${_chalk2.default.hex(colors.blue)("May the Fourth be with you! \u{1F680}")}`
6340
+ `${_chalk2.default.hex(colors2.green)("We hope you enjoyed it! :)")} ${_chalk2.default.hex(colors2.blue)("May the Fourth be with you! \u{1F680}")}`
6268
6341
  );
6269
6342
  await renderSpacer();
6270
6343
  console.log(_chalk2.default.dim(`---`));
@@ -6290,19 +6363,19 @@ async function renderBanner() {
6290
6363
  }
6291
6364
  async function renderHero() {
6292
6365
  console.log(
6293
- `\u26A1\uFE0F ${_chalk2.default.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
6366
+ `\u26A1\uFE0F ${_chalk2.default.hex(colors2.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
6294
6367
  );
6295
6368
  console.log(" ");
6296
6369
  console.log(
6297
- _chalk2.default.hex(colors.blue)("\u2B50 GitHub Repo: https://lingo.dev/go/gh")
6370
+ _chalk2.default.hex(colors2.blue)("\u2B50 GitHub Repo: https://lingo.dev/go/gh")
6298
6371
  );
6299
- console.log(_chalk2.default.hex(colors.blue)("\u{1F4AC} 24/7 Support: hi@lingo.dev"));
6372
+ console.log(_chalk2.default.hex(colors2.blue)("\u{1F4AC} 24/7 Support: hi@lingo.dev"));
6300
6373
  }
6301
6374
 
6302
6375
  // package.json
6303
6376
  var package_default = {
6304
6377
  name: "lingo.dev",
6305
- version: "0.92.7",
6378
+ version: "0.92.9",
6306
6379
  description: "Lingo.dev CLI",
6307
6380
  private: false,
6308
6381
  publishConfig: {
@@ -6359,22 +6432,24 @@ var package_default = {
6359
6432
  author: "",
6360
6433
  license: "Apache-2.0",
6361
6434
  dependencies: {
6362
- "@ai-sdk/anthropic": "^1.2.6",
6363
- "@ai-sdk/openai": "^1.3.7",
6435
+ "@ai-sdk/anthropic": "^1.2.11",
6436
+ "@ai-sdk/openai": "^1.3.22",
6364
6437
  "@babel/generator": "^7.27.1",
6365
6438
  "@babel/parser": "^7.27.1",
6366
6439
  "@babel/traverse": "^7.27.1",
6367
6440
  "@babel/types": "^7.27.1",
6368
6441
  "@datocms/cma-client-node": "^4.0.1",
6369
6442
  "@gitbeaker/rest": "^39.34.3",
6443
+ "@inkjs/ui": "^2.0.0",
6370
6444
  "@inquirer/prompts": "^7.4.1",
6371
6445
  "@lingo.dev/_sdk": "workspace:*",
6372
6446
  "@lingo.dev/_spec": "workspace:*",
6373
6447
  "@modelcontextprotocol/sdk": "^1.5.0",
6374
6448
  "@paralleldrive/cuid2": "^2.2.2",
6375
- ai: "^4.3.2",
6449
+ ai: "^4.3.15",
6376
6450
  bitbucket: "^2.12.0",
6377
6451
  chalk: "^5.4.1",
6452
+ "cli-progress": "^3.12.0",
6378
6453
  "cli-table3": "^0.6.5",
6379
6454
  cors: "^2.8.5",
6380
6455
  "csv-parse": "^5.6.0",
@@ -6392,12 +6467,16 @@ var package_default = {
6392
6467
  "gradient-string": "^3.0.0",
6393
6468
  "gray-matter": "^4.0.3",
6394
6469
  ini: "^5.0.0",
6470
+ ink: "^4.2.0",
6471
+ "ink-progress-bar": "^3.0.0",
6472
+ "ink-spinner": "^5.0.0",
6395
6473
  inquirer: "^12.6.0",
6396
6474
  "interactive-commander": "^0.5.194",
6397
6475
  "is-url": "^1.2.4",
6398
6476
  jsdom: "^25.0.1",
6399
6477
  json5: "^2.2.3",
6400
6478
  jsonrepair: "^3.11.2",
6479
+ listr2: "^8.3.2",
6401
6480
  lodash: "^4.17.21",
6402
6481
  marked: "^15.0.6",
6403
6482
  "mdast-util-from-markdown": "^2.0.2",
@@ -6414,6 +6493,7 @@ var package_default = {
6414
6493
  plist: "^3.1.0",
6415
6494
  "posthog-node": "^4.17.0",
6416
6495
  prettier: "^3.4.2",
6496
+ react: "^18.3.1",
6417
6497
  "rehype-stringify": "^10.0.1",
6418
6498
  "remark-disable-tokenizers": "^1.1.1",
6419
6499
  "remark-frontmatter": "^5.0.0",
@@ -6435,6 +6515,7 @@ var package_default = {
6435
6515
  },
6436
6516
  devDependencies: {
6437
6517
  "@types/babel__generator": "^7.27.0",
6518
+ "@types/cli-progress": "^3.11.6",
6438
6519
  "@types/cors": "^2.8.17",
6439
6520
  "@types/diff": "^7.0.0",
6440
6521
  "@types/express": "^5.0.1",
@@ -6450,6 +6531,7 @@ var package_default = {
6450
6531
  "@types/node-gettext": "^3.0.6",
6451
6532
  "@types/object-hash": "^3.0.6",
6452
6533
  "@types/plist": "^3.0.5",
6534
+ "@types/react": "^18.3.20",
6453
6535
  "@types/xml2js": "^0.4.14",
6454
6536
  tsup: "^8.3.5",
6455
6537
  typescript: "^5.8.3",
@@ -6460,6 +6542,739 @@ var package_default = {
6460
6542
  }
6461
6543
  };
6462
6544
 
6545
+ // src/cli/cmd/run/index.ts
6546
+
6547
+
6548
+ // src/cli/cmd/run/setup.ts
6549
+
6550
+ var _listr2 = require('listr2');
6551
+
6552
+ // src/cli/cmd/run/_const.ts
6553
+
6554
+
6555
+ var commonTaskRendererOptions = {
6556
+ color: {
6557
+ [_listr2.ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ? _chalk2.default.hex(colors.green)(msg) : _chalk2.default.hex(colors.green)("")
6558
+ },
6559
+ icon: {
6560
+ [_listr2.ListrDefaultRendererLogLevels.COMPLETED]: _chalk2.default.hex(colors.green)("\u2713")
6561
+ }
6562
+ };
6563
+
6564
+ // src/cli/localizer/lingodotdev.ts
6565
+
6566
+
6567
+
6568
+ function createLingoDotDevLocalizer(explicitApiKey) {
6569
+ const { auth } = getSettings(explicitApiKey);
6570
+ if (!auth) {
6571
+ throw new Error(
6572
+ _dedent2.default`
6573
+ You're trying to use ${_chalk2.default.hex(colors.green)("Lingo.dev")} provider, however, you are not authenticated.
6574
+
6575
+ To fix this issue:
6576
+ 1. Run ${_chalk2.default.dim("lingo.dev login")} to authenticate, or
6577
+ 2. Use the ${_chalk2.default.dim("--api-key")} flag to provide an API key.
6578
+ 3. Set ${_chalk2.default.dim("LINGODOTDEV_API_KEY")} environment variable.
6579
+ `
6580
+ );
6581
+ }
6582
+ const engine = new (0, __sdk.LingoDotDevEngine)({
6583
+ apiKey: auth.apiKey,
6584
+ apiUrl: auth.apiUrl
6585
+ });
6586
+ return {
6587
+ id: "Lingo.dev",
6588
+ checkAuth: async () => {
6589
+ try {
6590
+ const response = await engine.whoami();
6591
+ return {
6592
+ authenticated: !!response,
6593
+ username: _optionalChain([response, 'optionalAccess', _206 => _206.email])
6594
+ };
6595
+ } catch (e3) {
6596
+ return { authenticated: false };
6597
+ }
6598
+ },
6599
+ localize: async (input2, onProgress) => {
6600
+ if (!Object.keys(input2.processableData).length) {
6601
+ return input2;
6602
+ }
6603
+ const processedData = await engine.localizeObject(
6604
+ input2.processableData,
6605
+ {
6606
+ sourceLocale: input2.sourceLocale,
6607
+ targetLocale: input2.targetLocale,
6608
+ reference: {
6609
+ [input2.sourceLocale]: input2.sourceData,
6610
+ [input2.targetLocale]: input2.targetData
6611
+ }
6612
+ },
6613
+ onProgress
6614
+ );
6615
+ return processedData;
6616
+ }
6617
+ };
6618
+ }
6619
+
6620
+ // src/cli/localizer/explicit.ts
6621
+
6622
+
6623
+
6624
+
6625
+
6626
+ function createExplicitLocalizer(provider) {
6627
+ switch (provider.id) {
6628
+ default:
6629
+ throw new Error(
6630
+ _dedent2.default`
6631
+ You're trying to use unsupported provider: ${_chalk2.default.dim(provider.id)}.
6632
+
6633
+ To fix this issue:
6634
+ 1. Switch to one of the supported providers, or
6635
+ 2. Remove the ${_chalk2.default.italic("provider")} node from your i18n.json configuration to switch to ${_chalk2.default.hex(colors.green)("Lingo.dev")}
6636
+
6637
+ ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
6638
+ `
6639
+ );
6640
+ case "openai":
6641
+ return createAiSdkLocalizer({
6642
+ factory: (params) => _openai.createOpenAI.call(void 0, params).languageModel(provider.model),
6643
+ id: provider.id,
6644
+ prompt: provider.prompt,
6645
+ apiKeyName: "OPENAI_API_KEY",
6646
+ baseUrl: provider.baseUrl
6647
+ });
6648
+ case "anthropic":
6649
+ return createAiSdkLocalizer({
6650
+ factory: (params) => _anthropic.createAnthropic.call(void 0, params).languageModel(provider.model),
6651
+ id: provider.id,
6652
+ prompt: provider.prompt,
6653
+ apiKeyName: "ANTHROPIC_API_KEY",
6654
+ baseUrl: provider.baseUrl
6655
+ });
6656
+ }
6657
+ }
6658
+ function createAiSdkLocalizer(params) {
6659
+ const apiKey = process.env[params.apiKeyName];
6660
+ if (!apiKey) {
6661
+ throw new Error(
6662
+ _dedent2.default`
6663
+ You're trying to use raw ${_chalk2.default.dim(params.id)} API for translation, however, ${_chalk2.default.dim(params.apiKeyName)} environment variable is not set.
6664
+
6665
+ To fix this issue:
6666
+ 1. Set ${_chalk2.default.dim(params.apiKeyName)} in your environment variables, or
6667
+ 2. Remove the ${_chalk2.default.italic("provider")} node from your i18n.json configuration to switch to ${_chalk2.default.hex(colors.green)("Lingo.dev")}
6668
+
6669
+ ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
6670
+ `
6671
+ );
6672
+ }
6673
+ const model = params.factory({
6674
+ apiKey,
6675
+ baseUrl: params.baseUrl
6676
+ });
6677
+ return {
6678
+ id: params.id,
6679
+ checkAuth: async () => {
6680
+ try {
6681
+ await _ai.generateText.call(void 0, {
6682
+ model,
6683
+ messages: [
6684
+ { role: "system", content: "You are an echo server" },
6685
+ { role: "user", content: "OK" },
6686
+ { role: "assistant", content: "OK" },
6687
+ { role: "user", content: "OK" }
6688
+ ]
6689
+ });
6690
+ return { authenticated: true, username: "anonymous" };
6691
+ } catch (error) {
6692
+ return { authenticated: false };
6693
+ }
6694
+ },
6695
+ localize: async (input2) => {
6696
+ const systemPrompt = params.prompt.replaceAll("{source}", input2.sourceLocale).replaceAll("{target}", input2.targetLocale);
6697
+ const shots = [
6698
+ [
6699
+ {
6700
+ sourceLocale: "en",
6701
+ targetLocale: "es",
6702
+ data: {
6703
+ message: "Hello, world!"
6704
+ }
6705
+ },
6706
+ {
6707
+ sourceLocale: "en",
6708
+ targetLocale: "es",
6709
+ data: {
6710
+ message: "Hola, mundo!"
6711
+ }
6712
+ }
6713
+ ]
6714
+ ];
6715
+ const payload = {
6716
+ sourceLocale: input2.sourceLocale,
6717
+ targetLocale: input2.targetLocale,
6718
+ data: input2.processableData
6719
+ };
6720
+ const response = await _ai.generateText.call(void 0, {
6721
+ model,
6722
+ messages: [
6723
+ { role: "system", content: systemPrompt },
6724
+ { role: "user", content: "OK" },
6725
+ ...shots.flatMap(
6726
+ ([userShot, assistantShot]) => [
6727
+ { role: "user", content: JSON.stringify(userShot) },
6728
+ { role: "assistant", content: JSON.stringify(assistantShot) }
6729
+ ]
6730
+ ),
6731
+ { role: "user", content: JSON.stringify(payload) }
6732
+ ]
6733
+ });
6734
+ const result = JSON.parse(response.text);
6735
+ return result.data;
6736
+ }
6737
+ };
6738
+ }
6739
+
6740
+ // src/cli/localizer/index.ts
6741
+ function createLocalizer(provider) {
6742
+ if (!provider) {
6743
+ return createLingoDotDevLocalizer();
6744
+ } else {
6745
+ return createExplicitLocalizer(provider);
6746
+ }
6747
+ }
6748
+
6749
+ // src/cli/cmd/run/setup.ts
6750
+ async function setup(input2) {
6751
+ console.log(_chalk2.default.hex(colors.orange)("[Setup]"));
6752
+ return new (0, _listr2.Listr)(
6753
+ [
6754
+ {
6755
+ title: "Setting up the environment",
6756
+ task: async (ctx, task) => {
6757
+ task.title = `Environment setup completed`;
6758
+ }
6759
+ },
6760
+ {
6761
+ title: "Loading i18n configuration",
6762
+ task: async (ctx, task) => {
6763
+ ctx.config = getConfig(true);
6764
+ if (!ctx.config) {
6765
+ throw new Error(
6766
+ "i18n.json not found. Please run `lingo.dev init` to initialize the project."
6767
+ );
6768
+ } else if (!ctx.config.buckets || !Object.keys(ctx.config.buckets).length) {
6769
+ throw new Error(
6770
+ "No buckets found in i18n.json. Please add at least one bucket containing i18n content."
6771
+ );
6772
+ } else if (_optionalChain([ctx, 'access', _207 => _207.flags, 'access', _208 => _208.locale, 'optionalAccess', _209 => _209.some, 'call', _210 => _210(
6773
+ (locale) => !_optionalChain([ctx, 'access', _211 => _211.config, 'optionalAccess', _212 => _212.locale, 'access', _213 => _213.targets, 'access', _214 => _214.includes, 'call', _215 => _215(locale)])
6774
+ )])) {
6775
+ throw new Error(
6776
+ `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list first and try again.`
6777
+ );
6778
+ } else if (_optionalChain([ctx, 'access', _216 => _216.flags, 'access', _217 => _217.bucket, 'optionalAccess', _218 => _218.some, 'call', _219 => _219(
6779
+ (bucket) => !_optionalChain([ctx, 'access', _220 => _220.config, 'optionalAccess', _221 => _221.buckets, 'access', _222 => _222[bucket]])
6780
+ )])) {
6781
+ throw new Error(
6782
+ `One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
6783
+ );
6784
+ }
6785
+ task.title = `Loaded i18n configuration`;
6786
+ }
6787
+ },
6788
+ {
6789
+ title: "Selecting localization provider",
6790
+ task: async (ctx, task) => {
6791
+ ctx.localizer = createLocalizer(_optionalChain([ctx, 'access', _223 => _223.config, 'optionalAccess', _224 => _224.provider]));
6792
+ if (!ctx.localizer) {
6793
+ throw new Error(
6794
+ "Could not create localization provider. Please check your i18n.json configuration."
6795
+ );
6796
+ }
6797
+ task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${_chalk2.default.hex(colors.green)(ctx.localizer.id)} provider` : `Using raw ${_chalk2.default.hex(colors.yellow)(ctx.localizer.id)} API`;
6798
+ }
6799
+ },
6800
+ {
6801
+ title: "Checking authentication",
6802
+ task: async (ctx, task) => {
6803
+ const authStatus = await ctx.localizer.checkAuth();
6804
+ if (!authStatus.authenticated) {
6805
+ throw new Error(
6806
+ `Failed to authenticate with ${_chalk2.default.hex(colors.yellow)(ctx.localizer.id)} provider. Please check your API key and try again.`
6807
+ );
6808
+ }
6809
+ task.title = `Authenticated as ${_chalk2.default.hex(colors.yellow)(authStatus.username)}`;
6810
+ }
6811
+ },
6812
+ {
6813
+ title: "Initializing localization provider",
6814
+ async task(ctx, task) {
6815
+ const isLingoDotDev = ctx.localizer.id === "Lingo.dev";
6816
+ const subTasks = isLingoDotDev ? [
6817
+ "Brand voice enabled",
6818
+ "Translation memory connected",
6819
+ "Glossary enabled",
6820
+ "Quality assurance enabled"
6821
+ ].map((title) => ({ title, task: () => {
6822
+ } })) : [
6823
+ "Skipping brand voice",
6824
+ "Skipping glossary",
6825
+ "Skipping translation memory",
6826
+ "Skipping quality assurance"
6827
+ ].map((title) => ({ title, task: () => {
6828
+ }, skip: true }));
6829
+ return task.newListr(subTasks, {
6830
+ concurrent: true,
6831
+ rendererOptions: { collapseSubtasks: false }
6832
+ });
6833
+ }
6834
+ }
6835
+ ],
6836
+ {
6837
+ rendererOptions: commonTaskRendererOptions
6838
+ }
6839
+ ).run(input2);
6840
+ }
6841
+
6842
+ // src/cli/cmd/run/plan.ts
6843
+
6844
+
6845
+
6846
+ async function plan(input2) {
6847
+ console.log(_chalk2.default.hex(colors.orange)("[Planning]"));
6848
+ let buckets = getBuckets(input2.config);
6849
+ if (input2.flags.bucket) {
6850
+ buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
6851
+ }
6852
+ let locales = input2.config.locale.targets;
6853
+ if (input2.flags.locale) {
6854
+ locales = locales.filter((l) => input2.flags.locale.includes(l));
6855
+ }
6856
+ return new (0, _listr2.Listr)(
6857
+ [
6858
+ {
6859
+ title: "Locating content buckets",
6860
+ task: async (ctx, task) => {
6861
+ const bucketCount = buckets.length;
6862
+ const bucketFilter = input2.flags.bucket ? ` ${_chalk2.default.dim(`(filtered by: ${_chalk2.default.hex(colors.yellow)(input2.flags.bucket.join(", "))})`)}` : "";
6863
+ task.title = `Found ${_chalk2.default.hex(colors.yellow)(bucketCount.toString())} bucket(s)${bucketFilter}`;
6864
+ }
6865
+ },
6866
+ {
6867
+ title: "Detecting locales",
6868
+ task: async (ctx, task) => {
6869
+ if (!locales.length) {
6870
+ throw new Error(
6871
+ `No target locales found in config. Please add locales to your i18n.json config file.`
6872
+ );
6873
+ }
6874
+ const localeFilter = input2.flags.locale ? ` ${_chalk2.default.dim(`(filtered by: ${_chalk2.default.hex(colors.yellow)(input2.flags.locale.join(", "))})`)}` : "";
6875
+ task.title = `Found ${_chalk2.default.hex(colors.yellow)(locales.length.toString())} target locale(s)${localeFilter}`;
6876
+ }
6877
+ },
6878
+ {
6879
+ title: "Locating localizable files",
6880
+ task: async (ctx, task) => {
6881
+ const patterns = [];
6882
+ for (const bucket of buckets) {
6883
+ for (const bucketPath of bucket.paths) {
6884
+ if (input2.flags.file) {
6885
+ if (!input2.flags.file.some(
6886
+ (f) => bucketPath.pathPattern.includes(f)
6887
+ )) {
6888
+ continue;
6889
+ }
6890
+ }
6891
+ patterns.push(bucketPath.pathPattern);
6892
+ }
6893
+ }
6894
+ const fileFilter = input2.flags.file ? ` ${_chalk2.default.dim(`(filtered by: ${_chalk2.default.hex(colors.yellow)(input2.flags.file.join(", "))})`)}` : "";
6895
+ task.title = `Found ${_chalk2.default.hex(colors.yellow)(patterns.length.toString())} path pattern(s)${fileFilter}`;
6896
+ }
6897
+ },
6898
+ {
6899
+ title: "Computing translation tasks",
6900
+ task: async (ctx, task) => {
6901
+ for (const bucket of buckets) {
6902
+ for (const bucketPath of bucket.paths) {
6903
+ if (input2.flags.file) {
6904
+ if (!input2.flags.file.some(
6905
+ (f) => bucketPath.pathPattern.includes(f)
6906
+ )) {
6907
+ continue;
6908
+ }
6909
+ }
6910
+ const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
6911
+ ctx.config.locale.source,
6912
+ bucketPath.delimiter
6913
+ );
6914
+ for (const _targetLocale of locales) {
6915
+ const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
6916
+ _targetLocale,
6917
+ bucketPath.delimiter
6918
+ );
6919
+ if (sourceLocale === targetLocale) continue;
6920
+ ctx.tasks.push({
6921
+ sourceLocale,
6922
+ targetLocale,
6923
+ bucketType: bucket.type,
6924
+ bucketPathPattern: bucketPath.pathPattern,
6925
+ injectLocale: bucket.injectLocale || [],
6926
+ lockedKeys: bucket.lockedKeys || [],
6927
+ lockedPatterns: bucket.lockedPatterns || []
6928
+ });
6929
+ }
6930
+ }
6931
+ }
6932
+ task.title = `Prepared ${_chalk2.default.hex(colors.green)(ctx.tasks.length.toString())} translation task(s)`;
6933
+ }
6934
+ }
6935
+ ],
6936
+ {
6937
+ rendererOptions: commonTaskRendererOptions
6938
+ }
6939
+ ).run(input2);
6940
+ }
6941
+
6942
+ // src/cli/cmd/run/execute.ts
6943
+
6944
+
6945
+ var _plimit = require('p-limit'); var _plimit2 = _interopRequireDefault(_plimit);
6946
+
6947
+ var MAX_WORKER_COUNT = 10;
6948
+ async function execute(input2) {
6949
+ const effectiveConcurrency = Math.min(
6950
+ input2.flags.concurrency,
6951
+ input2.tasks.length,
6952
+ MAX_WORKER_COUNT
6953
+ );
6954
+ console.log(_chalk2.default.hex(colors.orange)(`[Localization]`));
6955
+ return new (0, _listr2.Listr)(
6956
+ [
6957
+ {
6958
+ title: "Initializing localization engine",
6959
+ task: async (ctx, task) => {
6960
+ task.title = `Localization engine ${_chalk2.default.hex(colors.green)("ready")} (${ctx.localizer.id})`;
6961
+ }
6962
+ },
6963
+ {
6964
+ title: `Processing localization tasks ${_chalk2.default.dim(`(tasks: ${input2.tasks.length}, concurrency: ${effectiveConcurrency})`)}`,
6965
+ task: (ctx, task) => {
6966
+ if (input2.tasks.length < 1) {
6967
+ task.title = `Skipping, nothing to localize.`;
6968
+ task.skip();
6969
+ return;
6970
+ }
6971
+ const i18nLimiter = _plimit2.default.call(void 0, effectiveConcurrency);
6972
+ const lockfileLimiter = _plimit2.default.call(void 0, 1);
6973
+ const workersCount = effectiveConcurrency;
6974
+ const workerTasks = [];
6975
+ for (let i = 0; i < workersCount; i++) {
6976
+ const assignedTasks = ctx.tasks.filter(
6977
+ (_29, idx) => idx % workersCount === i
6978
+ );
6979
+ workerTasks.push(
6980
+ createWorkerTask({
6981
+ ctx,
6982
+ assignedTasks,
6983
+ lockfileLimiter,
6984
+ i18nLimiter,
6985
+ onDone() {
6986
+ task.title = createExecutionProgressMessage(ctx);
6987
+ }
6988
+ })
6989
+ );
6990
+ }
6991
+ return task.newListr(workerTasks, {
6992
+ concurrent: true,
6993
+ exitOnError: false,
6994
+ rendererOptions: {
6995
+ ...commonTaskRendererOptions,
6996
+ collapseSubtasks: true
6997
+ }
6998
+ });
6999
+ }
7000
+ }
7001
+ ],
7002
+ {
7003
+ exitOnError: false,
7004
+ rendererOptions: commonTaskRendererOptions
7005
+ }
7006
+ ).run(input2);
7007
+ }
7008
+ function createWorkerStatusMessage(args) {
7009
+ const displayPath = args.assignedTask.bucketPathPattern.replace(
7010
+ "[locale]",
7011
+ args.assignedTask.targetLocale
7012
+ );
7013
+ return `[${_chalk2.default.hex(colors.yellow)(`${args.percentage}%`)}] Processing: ${_chalk2.default.dim(
7014
+ displayPath
7015
+ )} (${_chalk2.default.hex(colors.yellow)(args.assignedTask.sourceLocale)} -> ${_chalk2.default.hex(
7016
+ colors.yellow
7017
+ )(args.assignedTask.targetLocale)})`;
7018
+ }
7019
+ function createExecutionProgressMessage(ctx) {
7020
+ const succeededTasksCount = countTasks(
7021
+ ctx,
7022
+ (_t, result) => result.status === "success"
7023
+ );
7024
+ const failedTasksCount = countTasks(
7025
+ ctx,
7026
+ (_t, result) => result.status === "error"
7027
+ );
7028
+ const skippedTasksCount = countTasks(
7029
+ ctx,
7030
+ (_t, result) => result.status === "skipped"
7031
+ );
7032
+ return `Processed ${_chalk2.default.green(succeededTasksCount)}/${ctx.tasks.length}, Failed ${_chalk2.default.red(failedTasksCount)}, Skipped ${_chalk2.default.dim(skippedTasksCount)}`;
7033
+ }
7034
+ function createLoaderForTask(assignedTask) {
7035
+ const bucketLoader = createBucketLoader(
7036
+ assignedTask.bucketType,
7037
+ assignedTask.bucketPathPattern,
7038
+ {
7039
+ defaultLocale: assignedTask.sourceLocale,
7040
+ isCacheRestore: false,
7041
+ injectLocale: assignedTask.injectLocale
7042
+ },
7043
+ assignedTask.lockedKeys,
7044
+ assignedTask.lockedPatterns
7045
+ );
7046
+ bucketLoader.setDefaultLocale(assignedTask.sourceLocale);
7047
+ return bucketLoader;
7048
+ }
7049
+ function createWorkerTask(args) {
7050
+ return {
7051
+ title: "Initializing...",
7052
+ task: async (_subCtx, subTask) => {
7053
+ for (const assignedTask of args.assignedTasks) {
7054
+ subTask.title = createWorkerStatusMessage({
7055
+ assignedTask,
7056
+ percentage: 0
7057
+ });
7058
+ const bucketLoader = createLoaderForTask(assignedTask);
7059
+ const deltaProcessor = createDeltaProcessor(
7060
+ assignedTask.bucketPathPattern
7061
+ );
7062
+ const taskResult = await args.i18nLimiter(async () => {
7063
+ try {
7064
+ const sourceData = await bucketLoader.pull(
7065
+ assignedTask.sourceLocale
7066
+ );
7067
+ const targetData = await bucketLoader.pull(
7068
+ assignedTask.targetLocale
7069
+ );
7070
+ const checksums = await deltaProcessor.loadChecksums();
7071
+ const delta = await deltaProcessor.calculateDelta({
7072
+ sourceData,
7073
+ targetData,
7074
+ checksums
7075
+ });
7076
+ const processableData = _lodash2.default.chain(sourceData).entries().filter(
7077
+ ([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
7078
+ ).fromPairs().value();
7079
+ if (!Object.keys(processableData).length) {
7080
+ return { status: "skipped" };
7081
+ }
7082
+ const processedTargetData = await args.ctx.localizer.localize(
7083
+ {
7084
+ sourceLocale: assignedTask.sourceLocale,
7085
+ targetLocale: assignedTask.targetLocale,
7086
+ sourceData,
7087
+ targetData,
7088
+ processableData
7089
+ },
7090
+ (progress) => {
7091
+ subTask.title = createWorkerStatusMessage({
7092
+ assignedTask,
7093
+ percentage: progress
7094
+ });
7095
+ }
7096
+ );
7097
+ const finalTargetData = _lodash2.default.merge(
7098
+ {},
7099
+ sourceData,
7100
+ targetData,
7101
+ processedTargetData
7102
+ );
7103
+ await bucketLoader.push(assignedTask.targetLocale, finalTargetData);
7104
+ await args.lockfileLimiter(async () => {
7105
+ const checksums2 = await deltaProcessor.createChecksums(sourceData);
7106
+ await deltaProcessor.saveChecksums(checksums2);
7107
+ });
7108
+ return { status: "success" };
7109
+ } catch (error) {
7110
+ return {
7111
+ status: "error",
7112
+ error
7113
+ };
7114
+ }
7115
+ });
7116
+ args.ctx.results.set(assignedTask, taskResult);
7117
+ }
7118
+ subTask.title = "Done";
7119
+ }
7120
+ };
7121
+ }
7122
+ function countTasks(ctx, predicate) {
7123
+ return Array.from(ctx.results.entries()).filter(
7124
+ ([task, result]) => predicate(task, result)
7125
+ ).length;
7126
+ }
7127
+
7128
+ // src/cli/cmd/run/_types.ts
7129
+
7130
+
7131
+
7132
+
7133
+
7134
+ var flagsSchema2 = _zod.z.object({
7135
+ locale: _zod.z.array(__spec.localeCodeSchema).optional(),
7136
+ bucket: _zod.z.array(__spec.bucketTypeSchema).optional(),
7137
+ key: _zod.z.array(_zod.z.string()).optional(),
7138
+ file: _zod.z.array(_zod.z.string()).optional(),
7139
+ apiKey: _zod.z.string().optional(),
7140
+ force: _zod.z.boolean().optional(),
7141
+ frozen: _zod.z.boolean().optional(),
7142
+ verbose: _zod.z.boolean().optional(),
7143
+ strict: _zod.z.boolean().optional(),
7144
+ interactive: _zod.z.boolean().default(false),
7145
+ concurrency: _zod.z.number().positive().default(10),
7146
+ debug: _zod.z.boolean().default(false)
7147
+ });
7148
+
7149
+ // src/cli/cmd/run/_render.ts
7150
+
7151
+
7152
+
7153
+ var _readline = require('readline'); var _readline2 = _interopRequireDefault(_readline);
7154
+ async function renderClear2() {
7155
+ console.log("\x1Bc");
7156
+ }
7157
+ async function renderSpacer2() {
7158
+ console.log(" ");
7159
+ }
7160
+ async function renderBanner2() {
7161
+ console.log(
7162
+ _gradientstring.vice.call(void 0,
7163
+ _figlet2.default.textSync("LINGO.DEV", {
7164
+ font: "ANSI Shadow",
7165
+ horizontalLayout: "default",
7166
+ verticalLayout: "default"
7167
+ })
7168
+ )
7169
+ );
7170
+ }
7171
+ async function renderHero2() {
7172
+ console.log(
7173
+ `\u26A1\uFE0F ${_chalk2.default.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
7174
+ );
7175
+ console.log("");
7176
+ const label1 = "\u2B50 GitHub Repo:";
7177
+ const label2 = "\u{1F4DA} Docs:";
7178
+ const label3 = "\u{1F4AC} 24/7 Support:";
7179
+ const maxLabelWidth = 17;
7180
+ console.log(
7181
+ `${_chalk2.default.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${_chalk2.default.hex(colors.blue)("https://lingo.dev/go/gh")}`
7182
+ );
7183
+ console.log(
7184
+ `${_chalk2.default.hex(colors.blue)(label2.padEnd(maxLabelWidth + 1))} ${_chalk2.default.hex(colors.blue)("https://lingo.dev/go/docs")}`
7185
+ );
7186
+ console.log(
7187
+ `${_chalk2.default.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${_chalk2.default.hex(colors.blue)("hi@lingo.dev")}`
7188
+ );
7189
+ }
7190
+ async function pauseIfDebug(debug) {
7191
+ if (debug) {
7192
+ await waitForUserPrompt("Press Enter to continue...");
7193
+ }
7194
+ }
7195
+ async function waitForUserPrompt(message) {
7196
+ const rl = _readline2.default.createInterface({
7197
+ input: process.stdin,
7198
+ output: process.stdout
7199
+ });
7200
+ return new Promise((resolve) => {
7201
+ rl.question(_chalk2.default.dim(`[${message}]
7202
+ `), () => {
7203
+ rl.close();
7204
+ resolve();
7205
+ });
7206
+ });
7207
+ }
7208
+ async function renderSummary(ctx) {
7209
+ console.log(_chalk2.default.hex(colors.green)("[Done]"));
7210
+ const skippedTasksCount = ctx.results.values().filter((r) => r.status === "skipped").toArray().length;
7211
+ console.log(
7212
+ `\u2022 ${_chalk2.default.hex(colors.yellow)(skippedTasksCount)} restored from cache`
7213
+ );
7214
+ const succeededTasksCount = ctx.results.values().filter((r) => r.status === "success").toArray().length;
7215
+ console.log(`\u2022 ${_chalk2.default.hex(colors.yellow)(succeededTasksCount)} processed`);
7216
+ const failedTasksCount = ctx.results.values().filter((r) => r.status === "error").toArray().length;
7217
+ console.log(`\u2022 ${_chalk2.default.hex(colors.yellow)(failedTasksCount)} failed`);
7218
+ }
7219
+
7220
+ // src/cli/cmd/run/index.ts
7221
+ var run_default = new (0, _interactivecommander.Command)().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
7222
+ "--locale <locale>",
7223
+ "Locale to process",
7224
+ (val, prev) => prev ? [...prev, val] : [val]
7225
+ ).option(
7226
+ "--bucket <bucket>",
7227
+ "Bucket to process",
7228
+ (val, prev) => prev ? [...prev, val] : [val]
7229
+ ).option(
7230
+ "--file <file>",
7231
+ "File to process. Process only files that include this string in their path. Useful if you have a lot of files and want to focus on a specific one. Specify more files separated by commas or spaces.",
7232
+ (val, prev) => prev ? [...prev, val] : [val]
7233
+ ).option(
7234
+ "--key <key>",
7235
+ "Key to process. Process only a specific translation key, useful for updating a single entry",
7236
+ (val, prev) => prev ? [...prev, val] : [val]
7237
+ ).option(
7238
+ "--force",
7239
+ "Ignore lockfile and process all keys, useful for full re-translation"
7240
+ ).option(
7241
+ "--api-key <api-key>",
7242
+ "Explicitly set the API key to use, override the default API key from settings"
7243
+ ).option(
7244
+ "--debug",
7245
+ "Pause execution at start for debugging purposes, waits for user confirmation before proceeding"
7246
+ ).option(
7247
+ "--concurrency <concurrency>",
7248
+ "Number of concurrent tasks to run",
7249
+ (val) => parseInt(val)
7250
+ ).action(async (args) => {
7251
+ try {
7252
+ const ctx = {
7253
+ flags: flagsSchema2.parse(args),
7254
+ config: null,
7255
+ results: /* @__PURE__ */ new Map(),
7256
+ tasks: [],
7257
+ localizer: null
7258
+ };
7259
+ await pauseIfDebug(ctx.flags.debug);
7260
+ await renderClear2();
7261
+ await renderSpacer2();
7262
+ await renderBanner2();
7263
+ await renderHero2();
7264
+ await renderSpacer2();
7265
+ await setup(ctx);
7266
+ await renderSpacer2();
7267
+ await plan(ctx);
7268
+ await renderSpacer2();
7269
+ await execute(ctx);
7270
+ await renderSpacer2();
7271
+ await renderSummary(ctx);
7272
+ await renderSpacer2();
7273
+ } catch (error) {
7274
+ process.exit(1);
7275
+ }
7276
+ });
7277
+
6463
7278
  // src/cli/index.ts
6464
7279
  _dotenv2.default.config();
6465
7280
  var cli_default = new (0, _interactivecommander.InteractiveCommand)().name("lingo.dev").description("Lingo.dev CLI").helpOption("-h, --help", "Show help").addHelpText(
@@ -6477,11 +7292,11 @@ ${_gradientstring.vice.call(void 0,
6477
7292
 
6478
7293
  Star the the repo :) https://github.com/LingoDotDev/lingo.dev
6479
7294
  `
6480
- ).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).addCommand(mcp_default).addCommand(ci_default).addCommand(status_default).addCommand(may_the_fourth_default, { hidden: true }).exitOverride((err) => {
7295
+ ).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).addCommand(mcp_default).addCommand(ci_default).addCommand(status_default).addCommand(may_the_fourth_default, { hidden: true }).addCommand(run_default, { hidden: true }).exitOverride((err) => {
6481
7296
  if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
6482
7297
  process.exit(0);
6483
7298
  }
6484
- throw err;
7299
+ process.exit(1);
6485
7300
  });
6486
7301
 
6487
7302