lingo.dev 0.92.8 → 0.92.10
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 +884 -110
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +867 -93
- package/build/cli.mjs.map +1 -1
- package/package.json +15 -6
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',
|
|
30
|
-
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access',
|
|
31
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access',
|
|
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',
|
|
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',
|
|
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',
|
|
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
|
}
|
|
@@ -859,7 +859,7 @@ function getBuckets(i18nConfig) {
|
|
|
859
859
|
const includeItems = bucketEntry.include.map(
|
|
860
860
|
(item) => resolveBucketItem(item)
|
|
861
861
|
);
|
|
862
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
862
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _40 => _40.exclude, 'optionalAccess', _41 => _41.map, 'call', _42 => _42(
|
|
863
863
|
(item) => resolveBucketItem(item)
|
|
864
864
|
)]);
|
|
865
865
|
const config = {
|
|
@@ -897,7 +897,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
897
897
|
delimiter: pattern.delimiter
|
|
898
898
|
}))
|
|
899
899
|
);
|
|
900
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
900
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _43 => _43.flatMap, 'call', _44 => _44(
|
|
901
901
|
(pattern) => expandPlaceholderedGlob(
|
|
902
902
|
pattern.path,
|
|
903
903
|
__spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
|
|
@@ -1034,12 +1034,12 @@ function composeLoaders(...loaders) {
|
|
|
1034
1034
|
return {
|
|
1035
1035
|
init: async () => {
|
|
1036
1036
|
for (const loader of loaders) {
|
|
1037
|
-
await _optionalChain([loader, 'access',
|
|
1037
|
+
await _optionalChain([loader, 'access', _45 => _45.init, 'optionalCall', _46 => _46()]);
|
|
1038
1038
|
}
|
|
1039
1039
|
},
|
|
1040
1040
|
setDefaultLocale(locale) {
|
|
1041
1041
|
for (const loader of loaders) {
|
|
1042
|
-
_optionalChain([loader, 'access',
|
|
1042
|
+
_optionalChain([loader, 'access', _47 => _47.setDefaultLocale, 'optionalCall', _48 => _48(locale)]);
|
|
1043
1043
|
}
|
|
1044
1044
|
return this;
|
|
1045
1045
|
},
|
|
@@ -1072,7 +1072,7 @@ function createLoader(lDefinition) {
|
|
|
1072
1072
|
if (state.initCtx) {
|
|
1073
1073
|
return state.initCtx;
|
|
1074
1074
|
}
|
|
1075
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1075
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _49 => _49.init, 'optionalCall', _50 => _50()]);
|
|
1076
1076
|
return state.initCtx;
|
|
1077
1077
|
},
|
|
1078
1078
|
setDefaultLocale(locale) {
|
|
@@ -1176,7 +1176,7 @@ function createNormalizeLoader() {
|
|
|
1176
1176
|
return normalized;
|
|
1177
1177
|
},
|
|
1178
1178
|
push: async (locale, data, originalInput) => {
|
|
1179
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1179
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _51 => _51.keysMap]), () => ( {}));
|
|
1180
1180
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1181
1181
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1182
1182
|
delimiter: "/",
|
|
@@ -1250,7 +1250,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1250
1250
|
const trimmedResult = result.trim();
|
|
1251
1251
|
return trimmedResult;
|
|
1252
1252
|
},
|
|
1253
|
-
async push(locale, data,
|
|
1253
|
+
async push(locale, data, _29, originalLocale) {
|
|
1254
1254
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1255
1255
|
const finalPath = path14.default.resolve(draftPath);
|
|
1256
1256
|
const dirPath = path14.default.dirname(finalPath);
|
|
@@ -1279,8 +1279,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1279
1279
|
if (!templateData) {
|
|
1280
1280
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1281
1281
|
}
|
|
1282
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1283
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
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";
|
|
1284
1284
|
return ending;
|
|
1285
1285
|
}
|
|
1286
1286
|
return "";
|
|
@@ -1564,6 +1564,9 @@ function createCsvLoader() {
|
|
|
1564
1564
|
skip_empty_lines: true
|
|
1565
1565
|
});
|
|
1566
1566
|
const columns = input2.length > 0 ? Object.keys(input2[0]) : ["id", locale];
|
|
1567
|
+
if (!columns.includes(locale)) {
|
|
1568
|
+
columns.push(locale);
|
|
1569
|
+
}
|
|
1567
1570
|
const updatedRows = input2.map((row) => ({
|
|
1568
1571
|
...row,
|
|
1569
1572
|
[locale]: data[row.id] || row[locale] || ""
|
|
@@ -1619,7 +1622,7 @@ function createHtmlLoader() {
|
|
|
1619
1622
|
break;
|
|
1620
1623
|
}
|
|
1621
1624
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1622
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1625
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _58 => _58.textContent, 'optionalAccess', _59 => _59.trim, 'call', _60 => _60()])
|
|
1623
1626
|
);
|
|
1624
1627
|
const index = siblings.indexOf(current);
|
|
1625
1628
|
if (index !== -1) {
|
|
@@ -1654,11 +1657,11 @@ function createHtmlLoader() {
|
|
|
1654
1657
|
result[getPath(element, attr)] = value;
|
|
1655
1658
|
}
|
|
1656
1659
|
});
|
|
1657
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
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);
|
|
1658
1661
|
}
|
|
1659
1662
|
};
|
|
1660
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1661
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
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);
|
|
1662
1665
|
return result;
|
|
1663
1666
|
},
|
|
1664
1667
|
async push(locale, data, originalInput) {
|
|
@@ -1680,7 +1683,7 @@ function createHtmlLoader() {
|
|
|
1680
1683
|
for (let i = 0; i < indices.length; i++) {
|
|
1681
1684
|
const index = parseInt(indices[i]);
|
|
1682
1685
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1683
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1686
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _70 => _70.textContent, 'optionalAccess', _71 => _71.trim, 'call', _72 => _72()])
|
|
1684
1687
|
);
|
|
1685
1688
|
if (index >= siblings.length) {
|
|
1686
1689
|
if (i === indices.length - 1) {
|
|
@@ -1731,7 +1734,7 @@ function createMarkdownLoader() {
|
|
|
1731
1734
|
yaml: yamlEngine
|
|
1732
1735
|
}
|
|
1733
1736
|
});
|
|
1734
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
1737
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]), () => ( ""))).filter(Boolean);
|
|
1735
1738
|
return {
|
|
1736
1739
|
...Object.fromEntries(
|
|
1737
1740
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -1743,7 +1746,7 @@ function createMarkdownLoader() {
|
|
|
1743
1746
|
const frontmatter = Object.fromEntries(
|
|
1744
1747
|
Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
|
|
1745
1748
|
);
|
|
1746
|
-
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',
|
|
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");
|
|
1747
1750
|
if (Object.keys(frontmatter).length > 0) {
|
|
1748
1751
|
content = `
|
|
1749
1752
|
${content}`;
|
|
@@ -1776,7 +1779,7 @@ function createPropertiesLoader() {
|
|
|
1776
1779
|
return result;
|
|
1777
1780
|
},
|
|
1778
1781
|
async push(locale, payload) {
|
|
1779
|
-
const result = Object.entries(payload).filter(([
|
|
1782
|
+
const result = Object.entries(payload).filter(([_29, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1780
1783
|
return result;
|
|
1781
1784
|
}
|
|
1782
1785
|
});
|
|
@@ -1787,7 +1790,7 @@ function isSkippableLine(line) {
|
|
|
1787
1790
|
function parsePropertyLine(line) {
|
|
1788
1791
|
const [key, ...valueParts] = line.split("=");
|
|
1789
1792
|
return {
|
|
1790
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1793
|
+
key: _optionalChain([key, 'optionalAccess', _77 => _77.trim, 'call', _78 => _78()]) || "",
|
|
1791
1794
|
value: valueParts.join("=").trim()
|
|
1792
1795
|
};
|
|
1793
1796
|
}
|
|
@@ -1873,7 +1876,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1873
1876
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
1874
1877
|
continue;
|
|
1875
1878
|
}
|
|
1876
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1879
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _79 => _79.localizations, 'optionalAccess', _80 => _80[locale]]);
|
|
1877
1880
|
if (langTranslationEntity) {
|
|
1878
1881
|
if ("stringUnit" in langTranslationEntity) {
|
|
1879
1882
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1882,7 +1885,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1882
1885
|
resultData[translationKey] = {};
|
|
1883
1886
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1884
1887
|
for (const form in pluralForms) {
|
|
1885
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1888
|
+
if (_optionalChain([pluralForms, 'access', _81 => _81[form], 'optionalAccess', _82 => _82.stringUnit, 'optionalAccess', _83 => _83.value])) {
|
|
1886
1889
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1887
1890
|
}
|
|
1888
1891
|
}
|
|
@@ -1905,7 +1908,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1905
1908
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
1906
1909
|
if (typeof value === "string") {
|
|
1907
1910
|
langDataToMerge.strings[key] = {
|
|
1908
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
1911
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _84 => _84.strings, 'optionalAccess', _85 => _85[key], 'optionalAccess', _86 => _86.extractionState]),
|
|
1909
1912
|
localizations: {
|
|
1910
1913
|
[locale]: {
|
|
1911
1914
|
stringUnit: {
|
|
@@ -2043,10 +2046,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
2043
2046
|
}
|
|
2044
2047
|
}
|
|
2045
2048
|
return false;
|
|
2046
|
-
}).map(([key,
|
|
2047
|
-
const result = _lodash2.default.omitBy(input2, (
|
|
2049
|
+
}).map(([key, _29]) => key);
|
|
2050
|
+
const result = _lodash2.default.omitBy(input2, (_29, key) => passthroughKeys.includes(key));
|
|
2048
2051
|
if (returnUnlocalizedKeys) {
|
|
2049
|
-
result.unlocalizable = _lodash2.default.omitBy(input2, (
|
|
2052
|
+
result.unlocalizable = _lodash2.default.omitBy(input2, (_29, key) => !passthroughKeys.includes(key));
|
|
2050
2053
|
}
|
|
2051
2054
|
return result;
|
|
2052
2055
|
},
|
|
@@ -2085,7 +2088,7 @@ function createPoDataLoader(params) {
|
|
|
2085
2088
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
2086
2089
|
if (msgid && entry.msgid) {
|
|
2087
2090
|
const context = entry.msgctxt || "";
|
|
2088
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
2091
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _87 => _87.translations, 'access', _88 => _88[context], 'optionalAccess', _89 => _89[msgid]]);
|
|
2089
2092
|
if (fullEntry) {
|
|
2090
2093
|
result[msgid] = fullEntry;
|
|
2091
2094
|
}
|
|
@@ -2095,8 +2098,8 @@ function createPoDataLoader(params) {
|
|
|
2095
2098
|
return result;
|
|
2096
2099
|
},
|
|
2097
2100
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
2098
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
2099
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
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)]) || [];
|
|
2100
2103
|
const result = originalSections.map((section) => {
|
|
2101
2104
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
2102
2105
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -2161,8 +2164,8 @@ function createPoContentLoader() {
|
|
|
2161
2164
|
{
|
|
2162
2165
|
...entry,
|
|
2163
2166
|
msgstr: [
|
|
2164
|
-
_optionalChain([data, 'access',
|
|
2165
|
-
_optionalChain([data, 'access',
|
|
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
|
|
2166
2169
|
].filter(Boolean)
|
|
2167
2170
|
}
|
|
2168
2171
|
]).fromPairs().value();
|
|
@@ -2409,7 +2412,7 @@ function createDatoClient(params) {
|
|
|
2409
2412
|
only_valid: "true",
|
|
2410
2413
|
ids: !records.length ? void 0 : records.join(",")
|
|
2411
2414
|
}
|
|
2412
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2415
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _102 => _102.response, 'optionalAccess', _103 => _103.body, 'optionalAccess', _104 => _104.data, 'optionalAccess', _105 => _105[0]]) || error));
|
|
2413
2416
|
},
|
|
2414
2417
|
findRecordsForModel: async (modelId, records) => {
|
|
2415
2418
|
try {
|
|
@@ -2419,9 +2422,9 @@ function createDatoClient(params) {
|
|
|
2419
2422
|
filter: {
|
|
2420
2423
|
type: modelId,
|
|
2421
2424
|
only_valid: "true",
|
|
2422
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2425
|
+
ids: !_optionalChain([records, 'optionalAccess', _106 => _106.length]) ? void 0 : records.join(",")
|
|
2423
2426
|
}
|
|
2424
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2427
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _107 => _107.response, 'optionalAccess', _108 => _108.body, 'optionalAccess', _109 => _109.data, 'optionalAccess', _110 => _110[0]]) || error));
|
|
2425
2428
|
return result;
|
|
2426
2429
|
} catch (_error) {
|
|
2427
2430
|
throw new Error(
|
|
@@ -2435,9 +2438,9 @@ function createDatoClient(params) {
|
|
|
2435
2438
|
},
|
|
2436
2439
|
updateRecord: async (id, payload) => {
|
|
2437
2440
|
try {
|
|
2438
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
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));
|
|
2439
2442
|
} catch (_error) {
|
|
2440
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2443
|
+
if (_optionalChain([_error, 'optionalAccess', _115 => _115.attributes, 'optionalAccess', _116 => _116.details, 'optionalAccess', _117 => _117.message])) {
|
|
2441
2444
|
throw new Error(
|
|
2442
2445
|
[
|
|
2443
2446
|
`${_error.attributes.details.message}`,
|
|
@@ -2458,9 +2461,9 @@ function createDatoClient(params) {
|
|
|
2458
2461
|
},
|
|
2459
2462
|
enableFieldLocalization: async (args) => {
|
|
2460
2463
|
try {
|
|
2461
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
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));
|
|
2462
2465
|
} catch (_error) {
|
|
2463
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2466
|
+
if (_optionalChain([_error, 'optionalAccess', _122 => _122.attributes, 'optionalAccess', _123 => _123.code]) === "NOT_FOUND") {
|
|
2464
2467
|
throw new Error(
|
|
2465
2468
|
[
|
|
2466
2469
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2468,7 +2471,7 @@ function createDatoClient(params) {
|
|
|
2468
2471
|
].join("\n\n")
|
|
2469
2472
|
);
|
|
2470
2473
|
}
|
|
2471
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2474
|
+
if (_optionalChain([_error, 'optionalAccess', _124 => _124.attributes, 'optionalAccess', _125 => _125.details, 'optionalAccess', _126 => _126.message])) {
|
|
2472
2475
|
throw new Error(
|
|
2473
2476
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2474
2477
|
);
|
|
@@ -2534,7 +2537,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2534
2537
|
}
|
|
2535
2538
|
}
|
|
2536
2539
|
const records = await dato.findRecordsForModel(modelId);
|
|
2537
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2540
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _127 => _127.models, 'access', _128 => _128[modelId], 'optionalAccess', _129 => _129.records]) || [], project);
|
|
2538
2541
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2539
2542
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2540
2543
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2546,14 +2549,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2546
2549
|
},
|
|
2547
2550
|
async pull(locale, input2, initCtx) {
|
|
2548
2551
|
const result = {};
|
|
2549
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2550
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
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]) || [];
|
|
2551
2554
|
const recordIds = records.map((record) => record.id);
|
|
2552
2555
|
records = await dato.findRecords(recordIds);
|
|
2553
2556
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2554
2557
|
if (records.length > 0) {
|
|
2555
2558
|
result[modelId] = {
|
|
2556
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2559
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _134 => _134.models, 'optionalAccess', _135 => _135[modelId], 'optionalAccess', _136 => _136.fields]) || [],
|
|
2557
2560
|
records
|
|
2558
2561
|
};
|
|
2559
2562
|
}
|
|
@@ -2612,7 +2615,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2612
2615
|
return records.map((record) => ({
|
|
2613
2616
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2614
2617
|
value: record.id,
|
|
2615
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2618
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _137 => _137.includes, 'call', _138 => _138(record.id)])
|
|
2616
2619
|
}));
|
|
2617
2620
|
}
|
|
2618
2621
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2879,7 +2882,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2879
2882
|
function createVttLoader() {
|
|
2880
2883
|
return createLoader({
|
|
2881
2884
|
async pull(locale, input2) {
|
|
2882
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2885
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _139 => _139.parse, 'call', _140 => _140(input2), 'optionalAccess', _141 => _141.cues]);
|
|
2883
2886
|
if (Object.keys(vtt).length === 0) {
|
|
2884
2887
|
return {};
|
|
2885
2888
|
} else {
|
|
@@ -2932,7 +2935,7 @@ function variableExtractLoader(params) {
|
|
|
2932
2935
|
for (let i = 0; i < matches.length; i++) {
|
|
2933
2936
|
const match = matches[i];
|
|
2934
2937
|
const currentValue = result[key].value;
|
|
2935
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2938
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _142 => _142.replace, 'call', _143 => _143(match, `{variable:${i}}`)]);
|
|
2936
2939
|
result[key].value = newValue;
|
|
2937
2940
|
result[key].variables[i] = match;
|
|
2938
2941
|
}
|
|
@@ -2946,7 +2949,7 @@ function variableExtractLoader(params) {
|
|
|
2946
2949
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2947
2950
|
const variable = valueObj.variables[i];
|
|
2948
2951
|
const currentValue = result[key];
|
|
2949
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2952
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _144 => _144.replace, 'call', _145 => _145(`{variable:${i}}`, variable)]);
|
|
2950
2953
|
result[key] = newValue;
|
|
2951
2954
|
}
|
|
2952
2955
|
}
|
|
@@ -3127,7 +3130,7 @@ function createVueJsonLoader() {
|
|
|
3127
3130
|
return createLoader({
|
|
3128
3131
|
pull: async (locale, input2, ctx) => {
|
|
3129
3132
|
const parsed = parseVueFile(input2);
|
|
3130
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
3133
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _146 => _146.i18n, 'optionalAccess', _147 => _147[locale]]), () => ( {}));
|
|
3131
3134
|
},
|
|
3132
3135
|
push: async (locale, data, originalInput) => {
|
|
3133
3136
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -3308,7 +3311,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
3308
3311
|
objectExpression.properties.forEach((prop) => {
|
|
3309
3312
|
if (!t.isObjectProperty(prop)) return;
|
|
3310
3313
|
const key = getPropertyKey(prop);
|
|
3311
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
3314
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _148 => _148[key]]);
|
|
3312
3315
|
if (incomingVal === void 0) {
|
|
3313
3316
|
return;
|
|
3314
3317
|
}
|
|
@@ -3344,7 +3347,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
3344
3347
|
let modified = false;
|
|
3345
3348
|
arrayExpression.elements.forEach((element, index) => {
|
|
3346
3349
|
if (!element) return;
|
|
3347
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
3350
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _149 => _149[index]]);
|
|
3348
3351
|
if (incomingVal === void 0) return;
|
|
3349
3352
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
3350
3353
|
if (element.value !== incomingVal) {
|
|
@@ -3620,7 +3623,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3620
3623
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
3621
3624
|
const result = {
|
|
3622
3625
|
frontmatter: data.frontmatter,
|
|
3623
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
3626
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _150 => _150.codePlaceholders]) || {},
|
|
3624
3627
|
content
|
|
3625
3628
|
};
|
|
3626
3629
|
return result;
|
|
@@ -3968,6 +3971,10 @@ var _diff = require('diff');
|
|
|
3968
3971
|
|
|
3969
3972
|
var _externaleditor = require('external-editor'); var _externaleditor2 = _interopRequireDefault(_externaleditor);
|
|
3970
3973
|
|
|
3974
|
+
// src/cli/processor/index.ts
|
|
3975
|
+
|
|
3976
|
+
var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
|
|
3977
|
+
|
|
3971
3978
|
// src/cli/processor/lingo.ts
|
|
3972
3979
|
var __sdk = require('@lingo.dev/_sdk');
|
|
3973
3980
|
function createLingoLocalizer(params) {
|
|
@@ -4002,9 +4009,6 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
4002
4009
|
if (!Object.keys(input2.processableData).length) {
|
|
4003
4010
|
return input2.processableData;
|
|
4004
4011
|
}
|
|
4005
|
-
if (!process.env.OPENAI_API_KEY) {
|
|
4006
|
-
throw new Error("OPENAI_API_KEY is not set");
|
|
4007
|
-
}
|
|
4008
4012
|
const response = await _ai.generateText.call(void 0, {
|
|
4009
4013
|
model,
|
|
4010
4014
|
messages: [
|
|
@@ -4046,15 +4050,27 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
4046
4050
|
]
|
|
4047
4051
|
});
|
|
4048
4052
|
const result = JSON.parse(response.text);
|
|
4049
|
-
return _optionalChain([result, 'optionalAccess',
|
|
4053
|
+
return _optionalChain([result, 'optionalAccess', _151 => _151.data]) || {};
|
|
4050
4054
|
};
|
|
4051
4055
|
}
|
|
4052
4056
|
|
|
4053
4057
|
// src/cli/processor/index.ts
|
|
4054
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
|
|
4055
4071
|
var _anthropic = require('@ai-sdk/anthropic');
|
|
4056
4072
|
function createProcessor(provider, params) {
|
|
4057
|
-
if (!provider
|
|
4073
|
+
if (!provider) {
|
|
4058
4074
|
const result = createLingoLocalizer(params);
|
|
4059
4075
|
return result;
|
|
4060
4076
|
} else {
|
|
@@ -4064,10 +4080,30 @@ function createProcessor(provider, params) {
|
|
|
4064
4080
|
}
|
|
4065
4081
|
}
|
|
4066
4082
|
function getPureModelProvider(provider) {
|
|
4067
|
-
|
|
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])) {
|
|
4068
4102
|
case "openai":
|
|
4069
4103
|
if (!process.env.OPENAI_API_KEY) {
|
|
4070
|
-
throw new Error(
|
|
4104
|
+
throw new Error(
|
|
4105
|
+
createMissingKeyErrorMessage("OpenAI", "OPENAI_API_KEY")
|
|
4106
|
+
);
|
|
4071
4107
|
}
|
|
4072
4108
|
return _openai.createOpenAI.call(void 0, {
|
|
4073
4109
|
apiKey: process.env.OPENAI_API_KEY,
|
|
@@ -4075,13 +4111,15 @@ function getPureModelProvider(provider) {
|
|
|
4075
4111
|
})(provider.model);
|
|
4076
4112
|
case "anthropic":
|
|
4077
4113
|
if (!process.env.ANTHROPIC_API_KEY) {
|
|
4078
|
-
throw new Error(
|
|
4114
|
+
throw new Error(
|
|
4115
|
+
createMissingKeyErrorMessage("Anthropic", "ANTHROPIC_API_KEY")
|
|
4116
|
+
);
|
|
4079
4117
|
}
|
|
4080
4118
|
return _anthropic.createAnthropic.call(void 0, {
|
|
4081
4119
|
apiKey: process.env.ANTHROPIC_API_KEY
|
|
4082
4120
|
})(provider.model);
|
|
4083
4121
|
default:
|
|
4084
|
-
throw new Error(
|
|
4122
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _153 => _153.id])));
|
|
4085
4123
|
}
|
|
4086
4124
|
}
|
|
4087
4125
|
|
|
@@ -4306,7 +4344,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4306
4344
|
validateParams(i18nConfig, flags);
|
|
4307
4345
|
ora.succeed("Localization configuration is valid");
|
|
4308
4346
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
4309
|
-
const isByokMode = _optionalChain([i18nConfig, 'optionalAccess',
|
|
4347
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _154 => _154.provider]);
|
|
4310
4348
|
if (isByokMode) {
|
|
4311
4349
|
authId = null;
|
|
4312
4350
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -4320,16 +4358,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4320
4358
|
flags
|
|
4321
4359
|
});
|
|
4322
4360
|
let buckets = getBuckets(i18nConfig);
|
|
4323
|
-
if (_optionalChain([flags, 'access',
|
|
4361
|
+
if (_optionalChain([flags, 'access', _155 => _155.bucket, 'optionalAccess', _156 => _156.length])) {
|
|
4324
4362
|
buckets = buckets.filter(
|
|
4325
4363
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
4326
4364
|
);
|
|
4327
4365
|
}
|
|
4328
4366
|
ora.succeed("Buckets retrieved");
|
|
4329
|
-
if (_optionalChain([flags, 'access',
|
|
4367
|
+
if (_optionalChain([flags, 'access', _157 => _157.file, 'optionalAccess', _158 => _158.length])) {
|
|
4330
4368
|
buckets = buckets.map((bucket) => {
|
|
4331
4369
|
const paths = bucket.paths.filter(
|
|
4332
|
-
(path17) => flags.file.find((file) => _optionalChain([path17, 'access',
|
|
4370
|
+
(path17) => flags.file.find((file) => _optionalChain([path17, 'access', _159 => _159.pathPattern, 'optionalAccess', _160 => _160.includes, 'call', _161 => _161(file)]))
|
|
4333
4371
|
);
|
|
4334
4372
|
return { ...bucket, paths };
|
|
4335
4373
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4348,7 +4386,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4348
4386
|
});
|
|
4349
4387
|
}
|
|
4350
4388
|
}
|
|
4351
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
4389
|
+
const targetLocales = _optionalChain([flags, 'access', _162 => _162.locale, 'optionalAccess', _163 => _163.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
4352
4390
|
ora.start("Setting up localization cache...");
|
|
4353
4391
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
4354
4392
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -4589,7 +4627,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4589
4627
|
if (flags.key) {
|
|
4590
4628
|
processableData = _lodash2.default.pickBy(
|
|
4591
4629
|
processableData,
|
|
4592
|
-
(
|
|
4630
|
+
(_29, key) => key === flags.key
|
|
4593
4631
|
);
|
|
4594
4632
|
}
|
|
4595
4633
|
if (flags.verbose) {
|
|
@@ -4616,15 +4654,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4616
4654
|
targetData
|
|
4617
4655
|
},
|
|
4618
4656
|
(progress, sourceChunk, processedChunk) => {
|
|
4619
|
-
|
|
4620
|
-
if (flags.verbose) {
|
|
4621
|
-
bucketOra.info(progressLog);
|
|
4622
|
-
bucketOra.info(
|
|
4623
|
-
`(${progress}%) Caching chunk ${JSON.stringify(sourceChunk, null, 2)} -> ${JSON.stringify(processedChunk, null, 2)}`
|
|
4624
|
-
);
|
|
4625
|
-
} else {
|
|
4626
|
-
bucketOra.text = progressLog;
|
|
4627
|
-
}
|
|
4657
|
+
bucketOra.text = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
|
|
4628
4658
|
}
|
|
4629
4659
|
);
|
|
4630
4660
|
if (flags.verbose) {
|
|
@@ -4758,12 +4788,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
4758
4788
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
4759
4789
|
docUrl: "bucketNotFound"
|
|
4760
4790
|
});
|
|
4761
|
-
} else if (_optionalChain([flags, 'access',
|
|
4791
|
+
} else if (_optionalChain([flags, 'access', _164 => _164.locale, 'optionalAccess', _165 => _165.some, 'call', _166 => _166((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
4762
4792
|
throw new CLIError({
|
|
4763
4793
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
4764
4794
|
docUrl: "localeTargetNotFound"
|
|
4765
4795
|
});
|
|
4766
|
-
} else if (_optionalChain([flags, 'access',
|
|
4796
|
+
} else if (_optionalChain([flags, 'access', _167 => _167.bucket, 'optionalAccess', _168 => _168.some, 'call', _169 => _169(
|
|
4767
4797
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
4768
4798
|
)])) {
|
|
4769
4799
|
throw new CLIError({
|
|
@@ -5091,7 +5121,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
5091
5121
|
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
5092
5122
|
|
|
5093
5123
|
|
|
5094
|
-
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 (
|
|
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) => {
|
|
5095
5125
|
const apiKey = program.args[0];
|
|
5096
5126
|
const settings = getSettings(apiKey);
|
|
5097
5127
|
if (!settings.auth.apiKey) {
|
|
@@ -5228,7 +5258,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5228
5258
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
5229
5259
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
5230
5260
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
5231
|
-
_optionalChain([this, 'access',
|
|
5261
|
+
_optionalChain([this, 'access', _170 => _170.platformKit, 'optionalAccess', _171 => _171.gitConfig, 'call', _172 => _172()]);
|
|
5232
5262
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
5233
5263
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
5234
5264
|
if (!processOwnCommits) {
|
|
@@ -5260,7 +5290,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5260
5290
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
5261
5291
|
var PullRequestFlow = class extends InBranchFlow {
|
|
5262
5292
|
async preRun() {
|
|
5263
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
5293
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _173 => _173()]);
|
|
5264
5294
|
if (!canContinue) {
|
|
5265
5295
|
return false;
|
|
5266
5296
|
}
|
|
@@ -5512,10 +5542,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5512
5542
|
repo_slug: this.platformConfig.repositoryName,
|
|
5513
5543
|
state: "OPEN"
|
|
5514
5544
|
}).then(({ data: { values } }) => {
|
|
5515
|
-
return _optionalChain([values, 'optionalAccess',
|
|
5516
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
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
|
|
5517
5547
|
)]);
|
|
5518
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5548
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _180 => _180.id]));
|
|
5519
5549
|
}
|
|
5520
5550
|
async closePullRequest({ pullRequestNumber }) {
|
|
5521
5551
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -5611,7 +5641,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5611
5641
|
repo: this.platformConfig.repositoryName,
|
|
5612
5642
|
base: this.platformConfig.baseBranchName,
|
|
5613
5643
|
state: "open"
|
|
5614
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5644
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _181 => _181.number]));
|
|
5615
5645
|
}
|
|
5616
5646
|
async closePullRequest({ pullRequestNumber }) {
|
|
5617
5647
|
await this.octokit.rest.pulls.update({
|
|
@@ -5738,7 +5768,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5738
5768
|
sourceBranch: branch,
|
|
5739
5769
|
state: "opened"
|
|
5740
5770
|
});
|
|
5741
|
-
return _optionalChain([mergeRequests, 'access',
|
|
5771
|
+
return _optionalChain([mergeRequests, 'access', _182 => _182[0], 'optionalAccess', _183 => _183.iid]);
|
|
5742
5772
|
}
|
|
5743
5773
|
async closePullRequest({
|
|
5744
5774
|
pullRequestNumber
|
|
@@ -5822,7 +5852,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5822
5852
|
}
|
|
5823
5853
|
const env = {
|
|
5824
5854
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
5825
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5855
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _184 => _184.pullRequest, 'optionalAccess', _185 => _185.toString, 'call', _186 => _186()]) || "false",
|
|
5826
5856
|
...options.commitMessage && {
|
|
5827
5857
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
5828
5858
|
},
|
|
@@ -5842,7 +5872,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5842
5872
|
const { isPullRequestMode } = platformKit.config;
|
|
5843
5873
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5844
5874
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5845
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
5875
|
+
const canRun = await _optionalChain([flow, 'access', _187 => _187.preRun, 'optionalCall', _188 => _188()]);
|
|
5846
5876
|
if (canRun === false) {
|
|
5847
5877
|
return;
|
|
5848
5878
|
}
|
|
@@ -5850,7 +5880,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5850
5880
|
if (!hasChanges) {
|
|
5851
5881
|
return;
|
|
5852
5882
|
}
|
|
5853
|
-
await _optionalChain([flow, 'access',
|
|
5883
|
+
await _optionalChain([flow, 'access', _189 => _189.postRun, 'optionalCall', _190 => _190()]);
|
|
5854
5884
|
});
|
|
5855
5885
|
|
|
5856
5886
|
// src/cli/cmd/status.ts
|
|
@@ -5894,13 +5924,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5894
5924
|
flags
|
|
5895
5925
|
});
|
|
5896
5926
|
let buckets = getBuckets(i18nConfig);
|
|
5897
|
-
if (_optionalChain([flags, 'access',
|
|
5927
|
+
if (_optionalChain([flags, 'access', _191 => _191.bucket, 'optionalAccess', _192 => _192.length])) {
|
|
5898
5928
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
5899
5929
|
}
|
|
5900
5930
|
ora.succeed("Buckets retrieved");
|
|
5901
|
-
if (_optionalChain([flags, 'access',
|
|
5931
|
+
if (_optionalChain([flags, 'access', _193 => _193.file, 'optionalAccess', _194 => _194.length])) {
|
|
5902
5932
|
buckets = buckets.map((bucket) => {
|
|
5903
|
-
const paths = bucket.paths.filter((path17) => flags.file.find((file) => _optionalChain([path17, 'access',
|
|
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)])));
|
|
5904
5934
|
return { ...bucket, paths };
|
|
5905
5935
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5906
5936
|
if (buckets.length === 0) {
|
|
@@ -5916,7 +5946,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5916
5946
|
});
|
|
5917
5947
|
}
|
|
5918
5948
|
}
|
|
5919
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
5949
|
+
const targetLocales = _optionalChain([flags, 'access', _198 => _198.locale, 'optionalAccess', _199 => _199.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
5920
5950
|
let totalSourceKeyCount = 0;
|
|
5921
5951
|
let uniqueKeysToTranslate = 0;
|
|
5922
5952
|
let totalExistingTranslations = 0;
|
|
@@ -6257,12 +6287,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6257
6287
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
6258
6288
|
docUrl: "bucketNotFound"
|
|
6259
6289
|
});
|
|
6260
|
-
} else if (_optionalChain([flags, 'access',
|
|
6290
|
+
} else if (_optionalChain([flags, 'access', _200 => _200.locale, 'optionalAccess', _201 => _201.some, 'call', _202 => _202((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
6261
6291
|
throw new CLIError({
|
|
6262
6292
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
6263
6293
|
docUrl: "localeTargetNotFound"
|
|
6264
6294
|
});
|
|
6265
|
-
} else if (_optionalChain([flags, 'access',
|
|
6295
|
+
} else if (_optionalChain([flags, 'access', _203 => _203.bucket, 'optionalAccess', _204 => _204.some, 'call', _205 => _205((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
6266
6296
|
throw new CLIError({
|
|
6267
6297
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
6268
6298
|
docUrl: "bucketNotFound"
|
|
@@ -6276,7 +6306,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6276
6306
|
|
|
6277
6307
|
|
|
6278
6308
|
|
|
6279
|
-
var
|
|
6309
|
+
var colors2 = {
|
|
6280
6310
|
orange: "#ff6600",
|
|
6281
6311
|
green: "#6ae300",
|
|
6282
6312
|
blue: "#0090ff",
|
|
@@ -6288,7 +6318,7 @@ var may_the_fourth_default = new (0, _interactivecommander.Command)().command("m
|
|
|
6288
6318
|
await renderClear();
|
|
6289
6319
|
await renderBanner();
|
|
6290
6320
|
await renderSpacer();
|
|
6291
|
-
console.log(_chalk2.default.hex(
|
|
6321
|
+
console.log(_chalk2.default.hex(colors2.yellow)("Loading the Star Wars movie..."));
|
|
6292
6322
|
await renderSpacer();
|
|
6293
6323
|
await new Promise((resolve, reject) => {
|
|
6294
6324
|
const ssh = cp.spawn("ssh", ["starwarstel.net"], {
|
|
@@ -6307,7 +6337,7 @@ var may_the_fourth_default = new (0, _interactivecommander.Command)().command("m
|
|
|
6307
6337
|
});
|
|
6308
6338
|
await renderSpacer();
|
|
6309
6339
|
console.log(
|
|
6310
|
-
`${_chalk2.default.hex(
|
|
6340
|
+
`${_chalk2.default.hex(colors2.green)("We hope you enjoyed it! :)")} ${_chalk2.default.hex(colors2.blue)("May the Fourth be with you! \u{1F680}")}`
|
|
6311
6341
|
);
|
|
6312
6342
|
await renderSpacer();
|
|
6313
6343
|
console.log(_chalk2.default.dim(`---`));
|
|
@@ -6333,19 +6363,19 @@ async function renderBanner() {
|
|
|
6333
6363
|
}
|
|
6334
6364
|
async function renderHero() {
|
|
6335
6365
|
console.log(
|
|
6336
|
-
`\u26A1\uFE0F ${_chalk2.default.hex(
|
|
6366
|
+
`\u26A1\uFE0F ${_chalk2.default.hex(colors2.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
6337
6367
|
);
|
|
6338
6368
|
console.log(" ");
|
|
6339
6369
|
console.log(
|
|
6340
|
-
_chalk2.default.hex(
|
|
6370
|
+
_chalk2.default.hex(colors2.blue)("\u2B50 GitHub Repo: https://lingo.dev/go/gh")
|
|
6341
6371
|
);
|
|
6342
|
-
console.log(_chalk2.default.hex(
|
|
6372
|
+
console.log(_chalk2.default.hex(colors2.blue)("\u{1F4AC} 24/7 Support: hi@lingo.dev"));
|
|
6343
6373
|
}
|
|
6344
6374
|
|
|
6345
6375
|
// package.json
|
|
6346
6376
|
var package_default = {
|
|
6347
6377
|
name: "lingo.dev",
|
|
6348
|
-
version: "0.92.
|
|
6378
|
+
version: "0.92.10",
|
|
6349
6379
|
description: "Lingo.dev CLI",
|
|
6350
6380
|
private: false,
|
|
6351
6381
|
publishConfig: {
|
|
@@ -6402,22 +6432,24 @@ var package_default = {
|
|
|
6402
6432
|
author: "",
|
|
6403
6433
|
license: "Apache-2.0",
|
|
6404
6434
|
dependencies: {
|
|
6405
|
-
"@ai-sdk/anthropic": "^1.2.
|
|
6406
|
-
"@ai-sdk/openai": "^1.3.
|
|
6435
|
+
"@ai-sdk/anthropic": "^1.2.11",
|
|
6436
|
+
"@ai-sdk/openai": "^1.3.22",
|
|
6407
6437
|
"@babel/generator": "^7.27.1",
|
|
6408
6438
|
"@babel/parser": "^7.27.1",
|
|
6409
6439
|
"@babel/traverse": "^7.27.1",
|
|
6410
6440
|
"@babel/types": "^7.27.1",
|
|
6411
6441
|
"@datocms/cma-client-node": "^4.0.1",
|
|
6412
6442
|
"@gitbeaker/rest": "^39.34.3",
|
|
6443
|
+
"@inkjs/ui": "^2.0.0",
|
|
6413
6444
|
"@inquirer/prompts": "^7.4.1",
|
|
6414
6445
|
"@lingo.dev/_sdk": "workspace:*",
|
|
6415
6446
|
"@lingo.dev/_spec": "workspace:*",
|
|
6416
6447
|
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
6417
6448
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
6418
|
-
ai: "^4.3.
|
|
6449
|
+
ai: "^4.3.15",
|
|
6419
6450
|
bitbucket: "^2.12.0",
|
|
6420
6451
|
chalk: "^5.4.1",
|
|
6452
|
+
"cli-progress": "^3.12.0",
|
|
6421
6453
|
"cli-table3": "^0.6.5",
|
|
6422
6454
|
cors: "^2.8.5",
|
|
6423
6455
|
"csv-parse": "^5.6.0",
|
|
@@ -6435,12 +6467,16 @@ var package_default = {
|
|
|
6435
6467
|
"gradient-string": "^3.0.0",
|
|
6436
6468
|
"gray-matter": "^4.0.3",
|
|
6437
6469
|
ini: "^5.0.0",
|
|
6470
|
+
ink: "^4.2.0",
|
|
6471
|
+
"ink-progress-bar": "^3.0.0",
|
|
6472
|
+
"ink-spinner": "^5.0.0",
|
|
6438
6473
|
inquirer: "^12.6.0",
|
|
6439
6474
|
"interactive-commander": "^0.5.194",
|
|
6440
6475
|
"is-url": "^1.2.4",
|
|
6441
6476
|
jsdom: "^25.0.1",
|
|
6442
6477
|
json5: "^2.2.3",
|
|
6443
6478
|
jsonrepair: "^3.11.2",
|
|
6479
|
+
listr2: "^8.3.2",
|
|
6444
6480
|
lodash: "^4.17.21",
|
|
6445
6481
|
marked: "^15.0.6",
|
|
6446
6482
|
"mdast-util-from-markdown": "^2.0.2",
|
|
@@ -6457,6 +6493,7 @@ var package_default = {
|
|
|
6457
6493
|
plist: "^3.1.0",
|
|
6458
6494
|
"posthog-node": "^4.17.0",
|
|
6459
6495
|
prettier: "^3.4.2",
|
|
6496
|
+
react: "^18.3.1",
|
|
6460
6497
|
"rehype-stringify": "^10.0.1",
|
|
6461
6498
|
"remark-disable-tokenizers": "^1.1.1",
|
|
6462
6499
|
"remark-frontmatter": "^5.0.0",
|
|
@@ -6478,6 +6515,7 @@ var package_default = {
|
|
|
6478
6515
|
},
|
|
6479
6516
|
devDependencies: {
|
|
6480
6517
|
"@types/babel__generator": "^7.27.0",
|
|
6518
|
+
"@types/cli-progress": "^3.11.6",
|
|
6481
6519
|
"@types/cors": "^2.8.17",
|
|
6482
6520
|
"@types/diff": "^7.0.0",
|
|
6483
6521
|
"@types/express": "^5.0.1",
|
|
@@ -6493,6 +6531,7 @@ var package_default = {
|
|
|
6493
6531
|
"@types/node-gettext": "^3.0.6",
|
|
6494
6532
|
"@types/object-hash": "^3.0.6",
|
|
6495
6533
|
"@types/plist": "^3.0.5",
|
|
6534
|
+
"@types/react": "^18.3.20",
|
|
6496
6535
|
"@types/xml2js": "^0.4.14",
|
|
6497
6536
|
tsup: "^8.3.5",
|
|
6498
6537
|
typescript: "^5.8.3",
|
|
@@ -6503,6 +6542,741 @@ var package_default = {
|
|
|
6503
6542
|
}
|
|
6504
6543
|
};
|
|
6505
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 ioLimiter = _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
|
+
ioLimiter,
|
|
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 args.ioLimiter(async () => {
|
|
7104
|
+
await bucketLoader.pull(assignedTask.sourceLocale);
|
|
7105
|
+
await bucketLoader.push(
|
|
7106
|
+
assignedTask.targetLocale,
|
|
7107
|
+
finalTargetData
|
|
7108
|
+
);
|
|
7109
|
+
const checksums2 = await deltaProcessor.createChecksums(sourceData);
|
|
7110
|
+
await deltaProcessor.saveChecksums(checksums2);
|
|
7111
|
+
});
|
|
7112
|
+
return { status: "success" };
|
|
7113
|
+
} catch (error) {
|
|
7114
|
+
return {
|
|
7115
|
+
status: "error",
|
|
7116
|
+
error
|
|
7117
|
+
};
|
|
7118
|
+
}
|
|
7119
|
+
});
|
|
7120
|
+
args.ctx.results.set(assignedTask, taskResult);
|
|
7121
|
+
}
|
|
7122
|
+
subTask.title = "Done";
|
|
7123
|
+
}
|
|
7124
|
+
};
|
|
7125
|
+
}
|
|
7126
|
+
function countTasks(ctx, predicate) {
|
|
7127
|
+
return Array.from(ctx.results.entries()).filter(
|
|
7128
|
+
([task, result]) => predicate(task, result)
|
|
7129
|
+
).length;
|
|
7130
|
+
}
|
|
7131
|
+
|
|
7132
|
+
// src/cli/cmd/run/_types.ts
|
|
7133
|
+
|
|
7134
|
+
|
|
7135
|
+
|
|
7136
|
+
|
|
7137
|
+
|
|
7138
|
+
var flagsSchema2 = _zod.z.object({
|
|
7139
|
+
locale: _zod.z.array(__spec.localeCodeSchema).optional(),
|
|
7140
|
+
bucket: _zod.z.array(__spec.bucketTypeSchema).optional(),
|
|
7141
|
+
key: _zod.z.array(_zod.z.string()).optional(),
|
|
7142
|
+
file: _zod.z.array(_zod.z.string()).optional(),
|
|
7143
|
+
apiKey: _zod.z.string().optional(),
|
|
7144
|
+
force: _zod.z.boolean().optional(),
|
|
7145
|
+
frozen: _zod.z.boolean().optional(),
|
|
7146
|
+
verbose: _zod.z.boolean().optional(),
|
|
7147
|
+
strict: _zod.z.boolean().optional(),
|
|
7148
|
+
interactive: _zod.z.boolean().default(false),
|
|
7149
|
+
concurrency: _zod.z.number().positive().default(10),
|
|
7150
|
+
debug: _zod.z.boolean().default(false)
|
|
7151
|
+
});
|
|
7152
|
+
|
|
7153
|
+
// src/cli/cmd/run/_render.ts
|
|
7154
|
+
|
|
7155
|
+
|
|
7156
|
+
|
|
7157
|
+
var _readline = require('readline'); var _readline2 = _interopRequireDefault(_readline);
|
|
7158
|
+
async function renderClear2() {
|
|
7159
|
+
console.log("\x1Bc");
|
|
7160
|
+
}
|
|
7161
|
+
async function renderSpacer2() {
|
|
7162
|
+
console.log(" ");
|
|
7163
|
+
}
|
|
7164
|
+
async function renderBanner2() {
|
|
7165
|
+
console.log(
|
|
7166
|
+
_gradientstring.vice.call(void 0,
|
|
7167
|
+
_figlet2.default.textSync("LINGO.DEV", {
|
|
7168
|
+
font: "ANSI Shadow",
|
|
7169
|
+
horizontalLayout: "default",
|
|
7170
|
+
verticalLayout: "default"
|
|
7171
|
+
})
|
|
7172
|
+
)
|
|
7173
|
+
);
|
|
7174
|
+
}
|
|
7175
|
+
async function renderHero2() {
|
|
7176
|
+
console.log(
|
|
7177
|
+
`\u26A1\uFE0F ${_chalk2.default.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
7178
|
+
);
|
|
7179
|
+
console.log("");
|
|
7180
|
+
const label1 = "\u2B50 GitHub Repo:";
|
|
7181
|
+
const label2 = "\u{1F4DA} Docs:";
|
|
7182
|
+
const label3 = "\u{1F4AC} 24/7 Support:";
|
|
7183
|
+
const maxLabelWidth = 17;
|
|
7184
|
+
console.log(
|
|
7185
|
+
`${_chalk2.default.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${_chalk2.default.hex(colors.blue)("https://lingo.dev/go/gh")}`
|
|
7186
|
+
);
|
|
7187
|
+
console.log(
|
|
7188
|
+
`${_chalk2.default.hex(colors.blue)(label2.padEnd(maxLabelWidth + 1))} ${_chalk2.default.hex(colors.blue)("https://lingo.dev/go/docs")}`
|
|
7189
|
+
);
|
|
7190
|
+
console.log(
|
|
7191
|
+
`${_chalk2.default.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${_chalk2.default.hex(colors.blue)("hi@lingo.dev")}`
|
|
7192
|
+
);
|
|
7193
|
+
}
|
|
7194
|
+
async function pauseIfDebug(debug) {
|
|
7195
|
+
if (debug) {
|
|
7196
|
+
await waitForUserPrompt("Press Enter to continue...");
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
async function waitForUserPrompt(message) {
|
|
7200
|
+
const rl = _readline2.default.createInterface({
|
|
7201
|
+
input: process.stdin,
|
|
7202
|
+
output: process.stdout
|
|
7203
|
+
});
|
|
7204
|
+
return new Promise((resolve) => {
|
|
7205
|
+
rl.question(_chalk2.default.dim(`[${message}]
|
|
7206
|
+
`), () => {
|
|
7207
|
+
rl.close();
|
|
7208
|
+
resolve();
|
|
7209
|
+
});
|
|
7210
|
+
});
|
|
7211
|
+
}
|
|
7212
|
+
async function renderSummary(ctx) {
|
|
7213
|
+
console.log(_chalk2.default.hex(colors.green)("[Done]"));
|
|
7214
|
+
const skippedTasksCount = ctx.results.values().filter((r) => r.status === "skipped").toArray().length;
|
|
7215
|
+
console.log(`\u2022 ${_chalk2.default.hex(colors.yellow)(skippedTasksCount)} from cache`);
|
|
7216
|
+
const succeededTasksCount = ctx.results.values().filter((r) => r.status === "success").toArray().length;
|
|
7217
|
+
console.log(`\u2022 ${_chalk2.default.hex(colors.yellow)(succeededTasksCount)} processed`);
|
|
7218
|
+
const failedTasksCount = ctx.results.values().filter((r) => r.status === "error").toArray().length;
|
|
7219
|
+
console.log(`\u2022 ${_chalk2.default.hex(colors.yellow)(failedTasksCount)} failed`);
|
|
7220
|
+
}
|
|
7221
|
+
|
|
7222
|
+
// src/cli/cmd/run/index.ts
|
|
7223
|
+
var run_default = new (0, _interactivecommander.Command)().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
|
|
7224
|
+
"--locale <locale>",
|
|
7225
|
+
"Locale to process",
|
|
7226
|
+
(val, prev) => prev ? [...prev, val] : [val]
|
|
7227
|
+
).option(
|
|
7228
|
+
"--bucket <bucket>",
|
|
7229
|
+
"Bucket to process",
|
|
7230
|
+
(val, prev) => prev ? [...prev, val] : [val]
|
|
7231
|
+
).option(
|
|
7232
|
+
"--file <file>",
|
|
7233
|
+
"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.",
|
|
7234
|
+
(val, prev) => prev ? [...prev, val] : [val]
|
|
7235
|
+
).option(
|
|
7236
|
+
"--key <key>",
|
|
7237
|
+
"Key to process. Process only a specific translation key, useful for updating a single entry",
|
|
7238
|
+
(val, prev) => prev ? [...prev, val] : [val]
|
|
7239
|
+
).option(
|
|
7240
|
+
"--force",
|
|
7241
|
+
"Ignore lockfile and process all keys, useful for full re-translation"
|
|
7242
|
+
).option(
|
|
7243
|
+
"--api-key <api-key>",
|
|
7244
|
+
"Explicitly set the API key to use, override the default API key from settings"
|
|
7245
|
+
).option(
|
|
7246
|
+
"--debug",
|
|
7247
|
+
"Pause execution at start for debugging purposes, waits for user confirmation before proceeding"
|
|
7248
|
+
).option(
|
|
7249
|
+
"--concurrency <concurrency>",
|
|
7250
|
+
"Number of concurrent tasks to run",
|
|
7251
|
+
(val) => parseInt(val)
|
|
7252
|
+
).action(async (args) => {
|
|
7253
|
+
try {
|
|
7254
|
+
const ctx = {
|
|
7255
|
+
flags: flagsSchema2.parse(args),
|
|
7256
|
+
config: null,
|
|
7257
|
+
results: /* @__PURE__ */ new Map(),
|
|
7258
|
+
tasks: [],
|
|
7259
|
+
localizer: null
|
|
7260
|
+
};
|
|
7261
|
+
await pauseIfDebug(ctx.flags.debug);
|
|
7262
|
+
await renderClear2();
|
|
7263
|
+
await renderSpacer2();
|
|
7264
|
+
await renderBanner2();
|
|
7265
|
+
await renderHero2();
|
|
7266
|
+
await renderSpacer2();
|
|
7267
|
+
await setup(ctx);
|
|
7268
|
+
await renderSpacer2();
|
|
7269
|
+
await plan(ctx);
|
|
7270
|
+
await renderSpacer2();
|
|
7271
|
+
await execute(ctx);
|
|
7272
|
+
await renderSpacer2();
|
|
7273
|
+
await renderSummary(ctx);
|
|
7274
|
+
await renderSpacer2();
|
|
7275
|
+
} catch (error) {
|
|
7276
|
+
process.exit(1);
|
|
7277
|
+
}
|
|
7278
|
+
});
|
|
7279
|
+
|
|
6506
7280
|
// src/cli/index.ts
|
|
6507
7281
|
_dotenv2.default.config();
|
|
6508
7282
|
var cli_default = new (0, _interactivecommander.InteractiveCommand)().name("lingo.dev").description("Lingo.dev CLI").helpOption("-h, --help", "Show help").addHelpText(
|
|
@@ -6520,11 +7294,11 @@ ${_gradientstring.vice.call(void 0,
|
|
|
6520
7294
|
|
|
6521
7295
|
Star the the repo :) https://github.com/LingoDotDev/lingo.dev
|
|
6522
7296
|
`
|
|
6523
|
-
).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) => {
|
|
7297
|
+
).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) => {
|
|
6524
7298
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
|
|
6525
7299
|
process.exit(0);
|
|
6526
7300
|
}
|
|
6527
|
-
|
|
7301
|
+
process.exit(1);
|
|
6528
7302
|
});
|
|
6529
7303
|
|
|
6530
7304
|
|