lingo.dev 0.79.0 → 0.79.2
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 +180 -126
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +139 -85
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
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', _23 => _23.auth, 'optionalAccess', _24 => _24.apiKey]) || defaults.auth.apiKey,
|
|
30
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _25 => _25.auth, 'optionalAccess', _26 => _26.apiUrl]) || defaults.auth.apiUrl,
|
|
31
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _27 => _27.auth, 'optionalAccess', _28 => _28.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', _29 => _29.auth, 'optionalAccess', _30 => _30.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', _31 => _31.email])) {
|
|
158
158
|
return null;
|
|
159
159
|
}
|
|
160
160
|
return {
|
|
@@ -773,7 +773,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
773
773
|
});
|
|
774
774
|
const auth2 = await newAuthenticator.whoami();
|
|
775
775
|
if (auth2) {
|
|
776
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
776
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _32 => _32.email])}`);
|
|
777
777
|
} else {
|
|
778
778
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
779
779
|
}
|
|
@@ -853,11 +853,15 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
853
853
|
function getBuckets(i18nConfig) {
|
|
854
854
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
855
855
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
856
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
857
|
-
|
|
856
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _33 => _33.exclude, 'optionalAccess', _34 => _34.map, 'call', _35 => _35((item) => resolveBucketItem(item))]);
|
|
857
|
+
const config = {
|
|
858
858
|
type: bucketType,
|
|
859
|
-
|
|
859
|
+
paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
860
860
|
};
|
|
861
|
+
if (bucketEntry.injectLocale) {
|
|
862
|
+
config.injectLocale = bucketEntry.injectLocale;
|
|
863
|
+
}
|
|
864
|
+
return config;
|
|
861
865
|
});
|
|
862
866
|
return result;
|
|
863
867
|
}
|
|
@@ -870,7 +874,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
870
874
|
})
|
|
871
875
|
)
|
|
872
876
|
);
|
|
873
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
877
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _36 => _36.flatMap, 'call', _37 => _37(
|
|
874
878
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
875
879
|
(pathPattern) => ({
|
|
876
880
|
pathPattern,
|
|
@@ -947,7 +951,7 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
947
951
|
}
|
|
948
952
|
const buckets = getBuckets(i18nConfig);
|
|
949
953
|
for (const bucket of buckets) {
|
|
950
|
-
for (const bucketConfig of bucket.
|
|
954
|
+
for (const bucketConfig of bucket.paths) {
|
|
951
955
|
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
952
956
|
const sourcePath = bucketConfig.pathPattern.replace(/\[locale\]/g, sourceLocale);
|
|
953
957
|
const targetPaths = i18nConfig.locale.targets.map((_targetLocale) => {
|
|
@@ -995,12 +999,12 @@ function composeLoaders(...loaders) {
|
|
|
995
999
|
return {
|
|
996
1000
|
init: async () => {
|
|
997
1001
|
for (const loader of loaders) {
|
|
998
|
-
await _optionalChain([loader, 'access',
|
|
1002
|
+
await _optionalChain([loader, 'access', _38 => _38.init, 'optionalCall', _39 => _39()]);
|
|
999
1003
|
}
|
|
1000
1004
|
},
|
|
1001
1005
|
setDefaultLocale(locale) {
|
|
1002
1006
|
for (const loader of loaders) {
|
|
1003
|
-
_optionalChain([loader, 'access',
|
|
1007
|
+
_optionalChain([loader, 'access', _40 => _40.setDefaultLocale, 'optionalCall', _41 => _41(locale)]);
|
|
1004
1008
|
}
|
|
1005
1009
|
return this;
|
|
1006
1010
|
},
|
|
@@ -1031,7 +1035,7 @@ function createLoader(lDefinition) {
|
|
|
1031
1035
|
if (state.initCtx) {
|
|
1032
1036
|
return state.initCtx;
|
|
1033
1037
|
}
|
|
1034
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1038
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _42 => _42.init, 'optionalCall', _43 => _43()]);
|
|
1035
1039
|
return state.initCtx;
|
|
1036
1040
|
},
|
|
1037
1041
|
setDefaultLocale(locale) {
|
|
@@ -1120,7 +1124,7 @@ function createNormalizeLoader() {
|
|
|
1120
1124
|
return normalized;
|
|
1121
1125
|
},
|
|
1122
1126
|
push: async (locale, data, originalInput) => {
|
|
1123
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1127
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _44 => _44.keysMap]), () => ( {}));
|
|
1124
1128
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1125
1129
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1126
1130
|
delimiter: "/",
|
|
@@ -1194,7 +1198,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1194
1198
|
const trimmedResult = result.trim();
|
|
1195
1199
|
return trimmedResult;
|
|
1196
1200
|
},
|
|
1197
|
-
async push(locale, data,
|
|
1201
|
+
async push(locale, data, _22, originalLocale) {
|
|
1198
1202
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1199
1203
|
const finalPath = _path2.default.resolve(draftPath);
|
|
1200
1204
|
const dirPath = _path2.default.dirname(finalPath);
|
|
@@ -1223,8 +1227,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1223
1227
|
if (!templateData) {
|
|
1224
1228
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1225
1229
|
}
|
|
1226
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1227
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1230
|
+
if (_optionalChain([templateData, 'optionalAccess', _45 => _45.match, 'call', _46 => _46(/[\r\n]$/)])) {
|
|
1231
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _47 => _47.includes, 'call', _48 => _48("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _49 => _49.includes, 'call', _50 => _50("\r")]) ? "\r" : "\n";
|
|
1228
1232
|
return ending;
|
|
1229
1233
|
}
|
|
1230
1234
|
return "";
|
|
@@ -1479,7 +1483,7 @@ function createHtmlLoader() {
|
|
|
1479
1483
|
break;
|
|
1480
1484
|
}
|
|
1481
1485
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1482
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1486
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _51 => _51.textContent, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()])
|
|
1483
1487
|
);
|
|
1484
1488
|
const index = siblings.indexOf(current);
|
|
1485
1489
|
if (index !== -1) {
|
|
@@ -1514,11 +1518,11 @@ function createHtmlLoader() {
|
|
|
1514
1518
|
result[getPath(element, attr)] = value;
|
|
1515
1519
|
}
|
|
1516
1520
|
});
|
|
1517
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1521
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _54 => _54.textContent, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()])).forEach(processNode);
|
|
1518
1522
|
}
|
|
1519
1523
|
};
|
|
1520
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1521
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1524
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _57 => _57.textContent, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()])).forEach(processNode);
|
|
1525
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _60 => _60.textContent, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()])).forEach(processNode);
|
|
1522
1526
|
return result;
|
|
1523
1527
|
},
|
|
1524
1528
|
async push(locale, data, originalInput) {
|
|
@@ -1540,7 +1544,7 @@ function createHtmlLoader() {
|
|
|
1540
1544
|
for (let i = 0; i < indices.length; i++) {
|
|
1541
1545
|
const index = parseInt(indices[i]);
|
|
1542
1546
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1543
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1547
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _63 => _63.textContent, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()])
|
|
1544
1548
|
);
|
|
1545
1549
|
if (index >= siblings.length) {
|
|
1546
1550
|
if (i === indices.length - 1) {
|
|
@@ -1591,7 +1595,7 @@ function createMarkdownLoader() {
|
|
|
1591
1595
|
yaml: yamlEngine
|
|
1592
1596
|
}
|
|
1593
1597
|
});
|
|
1594
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
1598
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()]), () => ( ""))).filter(Boolean);
|
|
1595
1599
|
return {
|
|
1596
1600
|
...Object.fromEntries(
|
|
1597
1601
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -1603,7 +1607,7 @@ function createMarkdownLoader() {
|
|
|
1603
1607
|
const frontmatter = Object.fromEntries(
|
|
1604
1608
|
Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
|
|
1605
1609
|
);
|
|
1606
|
-
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',
|
|
1610
|
+
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', _68 => _68.trim, 'call', _69 => _69()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
1607
1611
|
if (Object.keys(frontmatter).length > 0) {
|
|
1608
1612
|
content = `
|
|
1609
1613
|
${content}`;
|
|
@@ -1636,7 +1640,7 @@ function createPropertiesLoader() {
|
|
|
1636
1640
|
return result;
|
|
1637
1641
|
},
|
|
1638
1642
|
async push(locale, payload) {
|
|
1639
|
-
const result = Object.entries(payload).filter(([
|
|
1643
|
+
const result = Object.entries(payload).filter(([_22, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1640
1644
|
return result;
|
|
1641
1645
|
}
|
|
1642
1646
|
});
|
|
@@ -1647,7 +1651,7 @@ function isSkippableLine(line) {
|
|
|
1647
1651
|
function parsePropertyLine(line) {
|
|
1648
1652
|
const [key, ...valueParts] = line.split("=");
|
|
1649
1653
|
return {
|
|
1650
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1654
|
+
key: _optionalChain([key, 'optionalAccess', _70 => _70.trim, 'call', _71 => _71()]) || "",
|
|
1651
1655
|
value: valueParts.join("=").trim()
|
|
1652
1656
|
};
|
|
1653
1657
|
}
|
|
@@ -1733,7 +1737,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1733
1737
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
1734
1738
|
continue;
|
|
1735
1739
|
}
|
|
1736
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1740
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _72 => _72.localizations, 'optionalAccess', _73 => _73[locale]]);
|
|
1737
1741
|
if (langTranslationEntity) {
|
|
1738
1742
|
if ("stringUnit" in langTranslationEntity) {
|
|
1739
1743
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1742,7 +1746,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1742
1746
|
resultData[translationKey] = {};
|
|
1743
1747
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1744
1748
|
for (const form in pluralForms) {
|
|
1745
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1749
|
+
if (_optionalChain([pluralForms, 'access', _74 => _74[form], 'optionalAccess', _75 => _75.stringUnit, 'optionalAccess', _76 => _76.value])) {
|
|
1746
1750
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1747
1751
|
}
|
|
1748
1752
|
}
|
|
@@ -1766,7 +1770,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1766
1770
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
1767
1771
|
if (typeof value === "string") {
|
|
1768
1772
|
langDataToMerge.strings[key] = {
|
|
1769
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
1773
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _77 => _77.strings, 'optionalAccess', _78 => _78[key], 'optionalAccess', _79 => _79.extractionState]),
|
|
1770
1774
|
localizations: {
|
|
1771
1775
|
[locale]: {
|
|
1772
1776
|
stringUnit: {
|
|
@@ -1903,10 +1907,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
1903
1907
|
}
|
|
1904
1908
|
}
|
|
1905
1909
|
return false;
|
|
1906
|
-
}).map(([key,
|
|
1907
|
-
const result = _lodash2.default.omitBy(input2, (
|
|
1910
|
+
}).map(([key, _22]) => key);
|
|
1911
|
+
const result = _lodash2.default.omitBy(input2, (_22, key) => passthroughKeys.includes(key));
|
|
1908
1912
|
if (returnUnlocalizedKeys) {
|
|
1909
|
-
result.unlocalizable = _lodash2.default.omitBy(input2, (
|
|
1913
|
+
result.unlocalizable = _lodash2.default.omitBy(input2, (_22, key) => !passthroughKeys.includes(key));
|
|
1910
1914
|
}
|
|
1911
1915
|
return result;
|
|
1912
1916
|
},
|
|
@@ -1945,7 +1949,7 @@ function createPoDataLoader(params) {
|
|
|
1945
1949
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1946
1950
|
if (msgid && entry.msgid) {
|
|
1947
1951
|
const context = entry.msgctxt || "";
|
|
1948
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1952
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _80 => _80.translations, 'access', _81 => _81[context], 'optionalAccess', _82 => _82[msgid]]);
|
|
1949
1953
|
if (fullEntry) {
|
|
1950
1954
|
result[msgid] = fullEntry;
|
|
1951
1955
|
}
|
|
@@ -1955,7 +1959,7 @@ function createPoDataLoader(params) {
|
|
|
1955
1959
|
return result;
|
|
1956
1960
|
},
|
|
1957
1961
|
async push(locale, data, originalInput) {
|
|
1958
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1962
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _83 => _83.split, 'call', _84 => _84("\n\n"), 'access', _85 => _85.filter, 'call', _86 => _86(Boolean)]) || [];
|
|
1959
1963
|
const result = sections.map((section) => {
|
|
1960
1964
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1961
1965
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1997,7 +2001,7 @@ function createPoContentLoader() {
|
|
|
1997
2001
|
entry.msgid,
|
|
1998
2002
|
{
|
|
1999
2003
|
...entry,
|
|
2000
|
-
msgstr: [_optionalChain([data, 'access',
|
|
2004
|
+
msgstr: [_optionalChain([data, 'access', _87 => _87[entry.msgid], 'optionalAccess', _88 => _88.singular]), _optionalChain([data, 'access', _89 => _89[entry.msgid], 'optionalAccess', _90 => _90.plural]) || null].filter(Boolean)
|
|
2001
2005
|
}
|
|
2002
2006
|
]).fromPairs().value();
|
|
2003
2007
|
return result;
|
|
@@ -2243,7 +2247,7 @@ function createDatoClient(params) {
|
|
|
2243
2247
|
only_valid: "true",
|
|
2244
2248
|
ids: !records.length ? void 0 : records.join(",")
|
|
2245
2249
|
}
|
|
2246
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2250
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _91 => _91.response, 'optionalAccess', _92 => _92.body, 'optionalAccess', _93 => _93.data, 'optionalAccess', _94 => _94[0]]) || error));
|
|
2247
2251
|
},
|
|
2248
2252
|
findRecordsForModel: async (modelId, records) => {
|
|
2249
2253
|
try {
|
|
@@ -2253,9 +2257,9 @@ function createDatoClient(params) {
|
|
|
2253
2257
|
filter: {
|
|
2254
2258
|
type: modelId,
|
|
2255
2259
|
only_valid: "true",
|
|
2256
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2260
|
+
ids: !_optionalChain([records, 'optionalAccess', _95 => _95.length]) ? void 0 : records.join(",")
|
|
2257
2261
|
}
|
|
2258
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2262
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _96 => _96.response, 'optionalAccess', _97 => _97.body, 'optionalAccess', _98 => _98.data, 'optionalAccess', _99 => _99[0]]) || error));
|
|
2259
2263
|
return result;
|
|
2260
2264
|
} catch (_error) {
|
|
2261
2265
|
throw new Error(
|
|
@@ -2269,9 +2273,9 @@ function createDatoClient(params) {
|
|
|
2269
2273
|
},
|
|
2270
2274
|
updateRecord: async (id, payload) => {
|
|
2271
2275
|
try {
|
|
2272
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2276
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _100 => _100.response, 'optionalAccess', _101 => _101.body, 'optionalAccess', _102 => _102.data, 'optionalAccess', _103 => _103[0]]) || error));
|
|
2273
2277
|
} catch (_error) {
|
|
2274
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2278
|
+
if (_optionalChain([_error, 'optionalAccess', _104 => _104.attributes, 'optionalAccess', _105 => _105.details, 'optionalAccess', _106 => _106.message])) {
|
|
2275
2279
|
throw new Error(
|
|
2276
2280
|
[
|
|
2277
2281
|
`${_error.attributes.details.message}`,
|
|
@@ -2292,9 +2296,9 @@ function createDatoClient(params) {
|
|
|
2292
2296
|
},
|
|
2293
2297
|
enableFieldLocalization: async (args) => {
|
|
2294
2298
|
try {
|
|
2295
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2299
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _107 => _107.response, 'optionalAccess', _108 => _108.body, 'optionalAccess', _109 => _109.data, 'optionalAccess', _110 => _110[0]]) || error));
|
|
2296
2300
|
} catch (_error) {
|
|
2297
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2301
|
+
if (_optionalChain([_error, 'optionalAccess', _111 => _111.attributes, 'optionalAccess', _112 => _112.code]) === "NOT_FOUND") {
|
|
2298
2302
|
throw new Error(
|
|
2299
2303
|
[
|
|
2300
2304
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2302,7 +2306,7 @@ function createDatoClient(params) {
|
|
|
2302
2306
|
].join("\n\n")
|
|
2303
2307
|
);
|
|
2304
2308
|
}
|
|
2305
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2309
|
+
if (_optionalChain([_error, 'optionalAccess', _113 => _113.attributes, 'optionalAccess', _114 => _114.details, 'optionalAccess', _115 => _115.message])) {
|
|
2306
2310
|
throw new Error(
|
|
2307
2311
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2308
2312
|
);
|
|
@@ -2368,7 +2372,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2368
2372
|
}
|
|
2369
2373
|
}
|
|
2370
2374
|
const records = await dato.findRecordsForModel(modelId);
|
|
2371
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2375
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _116 => _116.models, 'access', _117 => _117[modelId], 'optionalAccess', _118 => _118.records]) || [], project);
|
|
2372
2376
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2373
2377
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2374
2378
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2380,14 +2384,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2380
2384
|
},
|
|
2381
2385
|
async pull(locale, input2, initCtx) {
|
|
2382
2386
|
const result = {};
|
|
2383
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2384
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2387
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _119 => _119.models]) || {})) {
|
|
2388
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _120 => _120.models, 'access', _121 => _121[modelId], 'access', _122 => _122.records]) || [];
|
|
2385
2389
|
const recordIds = records.map((record) => record.id);
|
|
2386
2390
|
records = await dato.findRecords(recordIds);
|
|
2387
2391
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2388
2392
|
if (records.length > 0) {
|
|
2389
2393
|
result[modelId] = {
|
|
2390
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2394
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _123 => _123.models, 'optionalAccess', _124 => _124[modelId], 'optionalAccess', _125 => _125.fields]) || [],
|
|
2391
2395
|
records
|
|
2392
2396
|
};
|
|
2393
2397
|
}
|
|
@@ -2446,7 +2450,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2446
2450
|
return records.map((record) => ({
|
|
2447
2451
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2448
2452
|
value: record.id,
|
|
2449
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2453
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _126 => _126.includes, 'call', _127 => _127(record.id)])
|
|
2450
2454
|
}));
|
|
2451
2455
|
}
|
|
2452
2456
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2713,7 +2717,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2713
2717
|
function createVttLoader() {
|
|
2714
2718
|
return createLoader({
|
|
2715
2719
|
async pull(locale, input2) {
|
|
2716
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2720
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _128 => _128.parse, 'call', _129 => _129(input2), 'optionalAccess', _130 => _130.cues]);
|
|
2717
2721
|
if (Object.keys(vtt).length === 0) {
|
|
2718
2722
|
return {};
|
|
2719
2723
|
} else {
|
|
@@ -2765,7 +2769,7 @@ function variableExtractLoader(params) {
|
|
|
2765
2769
|
for (let i = 0; i < matches.length; i++) {
|
|
2766
2770
|
const match = matches[i];
|
|
2767
2771
|
const currentValue = result[key].value;
|
|
2768
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2772
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _131 => _131.replace, 'call', _132 => _132(match, `{variable:${i}}`)]);
|
|
2769
2773
|
result[key].value = newValue;
|
|
2770
2774
|
result[key].variables[i] = match;
|
|
2771
2775
|
}
|
|
@@ -2779,7 +2783,7 @@ function variableExtractLoader(params) {
|
|
|
2779
2783
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2780
2784
|
const variable = valueObj.variables[i];
|
|
2781
2785
|
const currentValue = result[key];
|
|
2782
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2786
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _133 => _133.replace, 'call', _134 => _134(`{variable:${i}}`, variable)]);
|
|
2783
2787
|
result[key] = newValue;
|
|
2784
2788
|
}
|
|
2785
2789
|
}
|
|
@@ -2960,7 +2964,7 @@ function createVueJsonLoader() {
|
|
|
2960
2964
|
return createLoader({
|
|
2961
2965
|
pull: async (locale, input2, ctx) => {
|
|
2962
2966
|
const parsed = parseVueFile(input2);
|
|
2963
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
2967
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _135 => _135.i18n, 'optionalAccess', _136 => _136[locale]]), () => ( {}));
|
|
2964
2968
|
},
|
|
2965
2969
|
push: async (locale, data, originalInput) => {
|
|
2966
2970
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -2989,6 +2993,34 @@ function parseVueFile(input2) {
|
|
|
2989
2993
|
return { before, after, i18n };
|
|
2990
2994
|
}
|
|
2991
2995
|
|
|
2996
|
+
// src/cli/loaders/inject-locale.ts
|
|
2997
|
+
|
|
2998
|
+
function createInjectLocaleLoader(injectLocaleKeys) {
|
|
2999
|
+
return createLoader({
|
|
3000
|
+
async pull(locale, data) {
|
|
3001
|
+
if (!injectLocaleKeys) {
|
|
3002
|
+
return data;
|
|
3003
|
+
}
|
|
3004
|
+
const omitKeys = injectLocaleKeys.filter((key) => {
|
|
3005
|
+
return _lodash2.default.get(data, key) === locale;
|
|
3006
|
+
});
|
|
3007
|
+
const result = _lodash2.default.omit(data, omitKeys);
|
|
3008
|
+
return result;
|
|
3009
|
+
},
|
|
3010
|
+
async push(locale, data, originalInput, originalLocale) {
|
|
3011
|
+
if (!injectLocaleKeys) {
|
|
3012
|
+
return data;
|
|
3013
|
+
}
|
|
3014
|
+
injectLocaleKeys.forEach((key) => {
|
|
3015
|
+
if (_lodash2.default.get(originalInput, key) === originalLocale) {
|
|
3016
|
+
_lodash2.default.set(data, key, locale);
|
|
3017
|
+
}
|
|
3018
|
+
});
|
|
3019
|
+
return data;
|
|
3020
|
+
}
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
|
|
2992
3024
|
// src/cli/loaders/index.ts
|
|
2993
3025
|
function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
2994
3026
|
switch (bucketType) {
|
|
@@ -3023,6 +3055,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
|
3023
3055
|
createTextFileLoader(bucketPathPattern),
|
|
3024
3056
|
createPrettierLoader({ parser: "json", bucketPathPattern }),
|
|
3025
3057
|
createJsonLoader(),
|
|
3058
|
+
createInjectLocaleLoader(options.injectLocale),
|
|
3026
3059
|
createFlatLoader(),
|
|
3027
3060
|
createSyncLoader(),
|
|
3028
3061
|
createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
|
|
@@ -3305,7 +3338,16 @@ function _tryParseJSON(line) {
|
|
|
3305
3338
|
}
|
|
3306
3339
|
|
|
3307
3340
|
// src/cli/cmd/i18n.ts
|
|
3308
|
-
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option(
|
|
3341
|
+
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option(
|
|
3342
|
+
"--key <key>",
|
|
3343
|
+
"Key to process. Process only a specific translation key, useful for debugging or updating a single entry"
|
|
3344
|
+
).option(
|
|
3345
|
+
"--file [files...]",
|
|
3346
|
+
"File to process. Process only a specific path, may contain asterisk * to match multiple files. Useful if you have a lot of files and want to focus on a specific one. Specify more files separated by commas or spaces."
|
|
3347
|
+
).option(
|
|
3348
|
+
"--frozen",
|
|
3349
|
+
`Run in read-only mode - fails if any translations need updating, useful for CI/CD pipelines to detect missing translations`
|
|
3350
|
+
).option("--force", "Ignore lockfile and process all keys, useful for full re-translation").option("--verbose", "Show detailed output including intermediate processing data and API communication details").option("--interactive", "Enable interactive mode for reviewing and editing translations before they are applied").option("--api-key <api-key>", "Explicitly set the API key to use, override the default API key from settings").option("--debug", "Pause execution at start for debugging purposes, waits for user confirmation before proceeding").option("--strict", "Stop processing on first error instead of continuing with other locales/buckets").action(async function(options) {
|
|
3309
3351
|
updateGitignore();
|
|
3310
3352
|
const ora = _ora2.default.call(void 0, );
|
|
3311
3353
|
const flags = parseFlags(options);
|
|
@@ -3331,26 +3373,45 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3331
3373
|
const auth = await validateAuth(settings);
|
|
3332
3374
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
3333
3375
|
let buckets = getBuckets(i18nConfig);
|
|
3334
|
-
if (_optionalChain([flags, 'access',
|
|
3376
|
+
if (_optionalChain([flags, 'access', _137 => _137.bucket, 'optionalAccess', _138 => _138.length])) {
|
|
3335
3377
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
3336
3378
|
}
|
|
3337
3379
|
ora.succeed("Buckets retrieved");
|
|
3338
|
-
|
|
3380
|
+
if (_optionalChain([flags, 'access', _139 => _139.file, 'optionalAccess', _140 => _140.length])) {
|
|
3381
|
+
buckets = buckets.map((bucket) => {
|
|
3382
|
+
const paths = bucket.paths.filter((path15) => flags.file.find((file) => _optionalChain([path15, 'access', _141 => _141.pathPattern, 'optionalAccess', _142 => _142.match, 'call', _143 => _143(file)])));
|
|
3383
|
+
return { ...bucket, paths };
|
|
3384
|
+
}).filter((bucket) => bucket.paths.length > 0);
|
|
3385
|
+
if (buckets.length === 0) {
|
|
3386
|
+
ora.fail("No buckets found. All buckets were filtered out by --file option.");
|
|
3387
|
+
process.exit(1);
|
|
3388
|
+
} else {
|
|
3389
|
+
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
3390
|
+
buckets.map((bucket) => {
|
|
3391
|
+
ora.info(` ${bucket.type}:`);
|
|
3392
|
+
bucket.paths.forEach((path15) => {
|
|
3393
|
+
ora.info(` - ${path15.pathPattern}`);
|
|
3394
|
+
});
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
const targetLocales = _optionalChain([flags, 'access', _144 => _144.locale, 'optionalAccess', _145 => _145.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
3339
3399
|
const lockfileHelper = createLockfileHelper();
|
|
3340
3400
|
ora.start("Ensuring i18n.lock exists...");
|
|
3341
3401
|
if (!lockfileHelper.isLockfileExists()) {
|
|
3342
3402
|
ora.start("Creating i18n.lock...");
|
|
3343
3403
|
for (const bucket of buckets) {
|
|
3344
|
-
for (const
|
|
3345
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3346
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3404
|
+
for (const bucketPath of bucket.paths) {
|
|
3405
|
+
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
|
|
3406
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3347
3407
|
isCacheRestore: false,
|
|
3348
|
-
defaultLocale: sourceLocale
|
|
3408
|
+
defaultLocale: sourceLocale,
|
|
3409
|
+
injectLocale: bucket.injectLocale
|
|
3349
3410
|
});
|
|
3350
3411
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3351
3412
|
await bucketLoader.init();
|
|
3352
3413
|
const sourceData = await bucketLoader.pull(i18nConfig.locale.source);
|
|
3353
|
-
lockfileHelper.registerSourceData(
|
|
3414
|
+
lockfileHelper.registerSourceData(bucketPath.pathPattern, sourceData);
|
|
3354
3415
|
}
|
|
3355
3416
|
}
|
|
3356
3417
|
ora.succeed("i18n.lock created");
|
|
@@ -3364,13 +3425,14 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3364
3425
|
const cacheOra = _ora2.default.call(void 0, { indent: 2 });
|
|
3365
3426
|
for (const bucket of buckets) {
|
|
3366
3427
|
cacheOra.info(`Processing bucket: ${bucket.type}`);
|
|
3367
|
-
for (const
|
|
3428
|
+
for (const bucketPath of bucket.paths) {
|
|
3368
3429
|
const bucketOra = _ora2.default.call(void 0, { indent: 4 });
|
|
3369
|
-
bucketOra.info(`Processing path: ${
|
|
3370
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3371
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3430
|
+
bucketOra.info(`Processing path: ${bucketPath.pathPattern}`);
|
|
3431
|
+
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
|
|
3432
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3372
3433
|
isCacheRestore: true,
|
|
3373
|
-
defaultLocale: sourceLocale
|
|
3434
|
+
defaultLocale: sourceLocale,
|
|
3435
|
+
injectLocale: bucket.injectLocale
|
|
3374
3436
|
});
|
|
3375
3437
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3376
3438
|
await bucketLoader.init();
|
|
@@ -3386,7 +3448,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3386
3448
|
}
|
|
3387
3449
|
}
|
|
3388
3450
|
await bucketLoader.push(targetLocale, targetData);
|
|
3389
|
-
lockfileHelper.registerPartialSourceData(
|
|
3451
|
+
lockfileHelper.registerPartialSourceData(bucketPath.pathPattern, cachedSourceData);
|
|
3390
3452
|
bucketOra.succeed(
|
|
3391
3453
|
`[${sourceLocale} -> ${targetLocale}] Recovered ${Object.keys(cachedSourceData).length} entries from cache`
|
|
3392
3454
|
);
|
|
@@ -3404,25 +3466,26 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3404
3466
|
ora.start("Checking for lockfile updates...");
|
|
3405
3467
|
let requiresUpdate = null;
|
|
3406
3468
|
bucketLoop: for (const bucket of buckets) {
|
|
3407
|
-
for (const
|
|
3408
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3409
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3469
|
+
for (const bucketPath of bucket.paths) {
|
|
3470
|
+
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
|
|
3471
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3410
3472
|
isCacheRestore: false,
|
|
3411
3473
|
defaultLocale: sourceLocale,
|
|
3412
|
-
returnUnlocalizedKeys: true
|
|
3474
|
+
returnUnlocalizedKeys: true,
|
|
3475
|
+
injectLocale: bucket.injectLocale
|
|
3413
3476
|
});
|
|
3414
3477
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3415
3478
|
await bucketLoader.init();
|
|
3416
3479
|
const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(
|
|
3417
3480
|
i18nConfig.locale.source
|
|
3418
3481
|
);
|
|
3419
|
-
const updatedSourceData = lockfileHelper.extractUpdatedData(
|
|
3482
|
+
const updatedSourceData = lockfileHelper.extractUpdatedData(bucketPath.pathPattern, sourceData);
|
|
3420
3483
|
if (Object.keys(updatedSourceData).length > 0) {
|
|
3421
3484
|
requiresUpdate = "updated";
|
|
3422
3485
|
break bucketLoop;
|
|
3423
3486
|
}
|
|
3424
3487
|
for (const _targetLocale of targetLocales) {
|
|
3425
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale,
|
|
3488
|
+
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
|
|
3426
3489
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
3427
3490
|
const missingKeys = _lodash2.default.difference(Object.keys(sourceData), Object.keys(targetData));
|
|
3428
3491
|
const extraKeys = _lodash2.default.difference(Object.keys(targetData), Object.keys(sourceData));
|
|
@@ -3460,22 +3523,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3460
3523
|
try {
|
|
3461
3524
|
console.log();
|
|
3462
3525
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3463
|
-
for (const
|
|
3464
|
-
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${
|
|
3465
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3466
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3526
|
+
for (const bucketPath of bucket.paths) {
|
|
3527
|
+
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketPath.pathPattern}`);
|
|
3528
|
+
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
|
|
3529
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3467
3530
|
isCacheRestore: false,
|
|
3468
|
-
defaultLocale: sourceLocale
|
|
3531
|
+
defaultLocale: sourceLocale,
|
|
3532
|
+
injectLocale: bucket.injectLocale
|
|
3469
3533
|
});
|
|
3470
3534
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3471
3535
|
await bucketLoader.init();
|
|
3472
3536
|
let sourceData = await bucketLoader.pull(sourceLocale);
|
|
3473
3537
|
for (const _targetLocale of targetLocales) {
|
|
3474
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale,
|
|
3538
|
+
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
|
|
3475
3539
|
try {
|
|
3476
3540
|
bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
|
|
3477
3541
|
sourceData = await bucketLoader.pull(sourceLocale);
|
|
3478
|
-
const updatedSourceData = flags.force ? sourceData : lockfileHelper.extractUpdatedData(
|
|
3542
|
+
const updatedSourceData = flags.force ? sourceData : lockfileHelper.extractUpdatedData(bucketPath.pathPattern, sourceData);
|
|
3479
3543
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
3480
3544
|
let processableData = calculateDataDelta({
|
|
3481
3545
|
sourceData,
|
|
@@ -3483,7 +3547,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3483
3547
|
targetData
|
|
3484
3548
|
});
|
|
3485
3549
|
if (flags.key) {
|
|
3486
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
3550
|
+
processableData = _lodash2.default.pickBy(processableData, (_22, key) => key === flags.key);
|
|
3487
3551
|
}
|
|
3488
3552
|
if (flags.verbose) {
|
|
3489
3553
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -3523,7 +3587,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3523
3587
|
if (flags.interactive) {
|
|
3524
3588
|
bucketOra.stop();
|
|
3525
3589
|
const reviewedData = await reviewChanges({
|
|
3526
|
-
pathPattern:
|
|
3590
|
+
pathPattern: bucketPath.pathPattern,
|
|
3527
3591
|
targetLocale,
|
|
3528
3592
|
currentData: targetData,
|
|
3529
3593
|
proposedData: finalTargetData,
|
|
@@ -3531,7 +3595,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3531
3595
|
force: flags.force
|
|
3532
3596
|
});
|
|
3533
3597
|
finalTargetData = reviewedData;
|
|
3534
|
-
bucketOra.start(`Applying changes to ${
|
|
3598
|
+
bucketOra.start(`Applying changes to ${bucketPath} (${targetLocale})`);
|
|
3535
3599
|
}
|
|
3536
3600
|
const finalDiffSize = _lodash2.default.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
3537
3601
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
@@ -3550,7 +3614,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3550
3614
|
}
|
|
3551
3615
|
}
|
|
3552
3616
|
}
|
|
3553
|
-
lockfileHelper.registerSourceData(
|
|
3617
|
+
lockfileHelper.registerSourceData(bucketPath.pathPattern, sourceData);
|
|
3554
3618
|
}
|
|
3555
3619
|
} catch (_error) {
|
|
3556
3620
|
const error = new Error(`Failed to process bucket ${bucket.type}: ${_error.message}`);
|
|
@@ -3630,6 +3694,7 @@ function parseFlags(options) {
|
|
|
3630
3694
|
verbose: _zod2.default.boolean().optional(),
|
|
3631
3695
|
strict: _zod2.default.boolean().optional(),
|
|
3632
3696
|
key: _zod2.default.string().optional(),
|
|
3697
|
+
file: _zod2.default.array(_zod2.default.string()).optional(),
|
|
3633
3698
|
interactive: _zod2.default.boolean().default(false),
|
|
3634
3699
|
debug: _zod2.default.boolean().default(false)
|
|
3635
3700
|
}).parse(options);
|
|
@@ -3665,12 +3730,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
3665
3730
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
3666
3731
|
docUrl: "bucketNotFound"
|
|
3667
3732
|
});
|
|
3668
|
-
} else if (_optionalChain([flags, 'access',
|
|
3733
|
+
} else if (_optionalChain([flags, 'access', _146 => _146.locale, 'optionalAccess', _147 => _147.some, 'call', _148 => _148((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
3669
3734
|
throw new CLIError({
|
|
3670
3735
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
3671
3736
|
docUrl: "localeTargetNotFound"
|
|
3672
3737
|
});
|
|
3673
|
-
} else if (_optionalChain([flags, 'access',
|
|
3738
|
+
} else if (_optionalChain([flags, 'access', _149 => _149.bucket, 'optionalAccess', _150 => _150.some, 'call', _151 => _151((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
3674
3739
|
throw new CLIError({
|
|
3675
3740
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
3676
3741
|
docUrl: "bucketNotFound"
|
|
@@ -3788,7 +3853,7 @@ var lockfile_default = new (0, _interactivecommander.Command)().command("lockfil
|
|
|
3788
3853
|
const i18nConfig = getConfig();
|
|
3789
3854
|
const buckets = getBuckets(i18nConfig);
|
|
3790
3855
|
for (const bucket of buckets) {
|
|
3791
|
-
for (const bucketConfig of bucket.
|
|
3856
|
+
for (const bucketConfig of bucket.paths) {
|
|
3792
3857
|
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3793
3858
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
3794
3859
|
isCacheRestore: false,
|
|
@@ -3811,7 +3876,10 @@ var flagsSchema = _zod2.default.object({
|
|
|
3811
3876
|
|
|
3812
3877
|
|
|
3813
3878
|
|
|
3814
|
-
var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup").description("Remove keys from target files that do not exist in the source file").helpOption("-h, --help", "Show help").option("--locale <locale>", "Specific locale to cleanup").option("--bucket <bucket>", "Specific bucket to cleanup").option("--dry-run", "Show what would be removed without making changes").option(
|
|
3879
|
+
var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup").description("Remove keys from target files that do not exist in the source file").helpOption("-h, --help", "Show help").option("--locale <locale>", "Specific locale to cleanup").option("--bucket <bucket>", "Specific bucket to cleanup").option("--dry-run", "Show what would be removed without making changes").option(
|
|
3880
|
+
"--verbose",
|
|
3881
|
+
"Show detailed output including:\n - List of keys that would be removed.\n - Processing steps."
|
|
3882
|
+
).action(async function(options) {
|
|
3815
3883
|
const ora = _ora2.default.call(void 0, );
|
|
3816
3884
|
const results = [];
|
|
3817
3885
|
try {
|
|
@@ -3827,7 +3895,7 @@ var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup"
|
|
|
3827
3895
|
for (const bucket of buckets) {
|
|
3828
3896
|
console.log();
|
|
3829
3897
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3830
|
-
for (const bucketConfig of bucket.
|
|
3898
|
+
for (const bucketConfig of bucket.paths) {
|
|
3831
3899
|
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3832
3900
|
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
3833
3901
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
@@ -3906,7 +3974,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
3906
3974
|
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
3907
3975
|
|
|
3908
3976
|
|
|
3909
|
-
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 (
|
|
3977
|
+
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 (_22, program) => {
|
|
3910
3978
|
const apiKey = program.args[0];
|
|
3911
3979
|
const settings = getSettings(apiKey);
|
|
3912
3980
|
if (!settings.auth.apiKey) {
|
|
@@ -4029,7 +4097,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4029
4097
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
4030
4098
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
4031
4099
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
4032
|
-
_optionalChain([this, 'access',
|
|
4100
|
+
_optionalChain([this, 'access', _152 => _152.platformKit, 'optionalAccess', _153 => _153.gitConfig, 'call', _154 => _154()]);
|
|
4033
4101
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
4034
4102
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
4035
4103
|
if (!processOwnCommits) {
|
|
@@ -4054,7 +4122,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4054
4122
|
// ../../action/src/flows/pull-request.ts
|
|
4055
4123
|
var PullRequestFlow = class extends InBranchFlow {
|
|
4056
4124
|
async preRun() {
|
|
4057
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
4125
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _155 => _155()]);
|
|
4058
4126
|
if (!canContinue) {
|
|
4059
4127
|
return false;
|
|
4060
4128
|
}
|
|
@@ -4101,35 +4169,21 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4101
4169
|
this.ora.start(
|
|
4102
4170
|
`Checking for existing PR with head ${i18nBranchName} and base ${this.platformKit.platformConfig.baseBranchName}`
|
|
4103
4171
|
);
|
|
4104
|
-
|
|
4172
|
+
let prNumber = await this.platformKit.getOpenPullRequestNumber({
|
|
4105
4173
|
branch: i18nBranchName
|
|
4106
4174
|
});
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
this.ora.start(`Creating new PR`);
|
|
4116
|
-
const newPrNumber = await this.platformKit.createPullRequest({
|
|
4117
|
-
head: i18nBranchName,
|
|
4118
|
-
title: this.platformKit.config.pullRequestTitle,
|
|
4119
|
-
body: this.getPrBodyContent()
|
|
4120
|
-
});
|
|
4121
|
-
this.ora.succeed(`Created new PR ${newPrNumber}`);
|
|
4122
|
-
if (existingPrNumber) {
|
|
4123
|
-
this.ora.start(`Posting comment about outdated PR ${existingPrNumber}`);
|
|
4124
|
-
await this.platformKit.commentOnPullRequest({
|
|
4125
|
-
pullRequestNumber: existingPrNumber,
|
|
4126
|
-
body: `This PR is now outdated. A new version has been created at ${this.platformKit.buildPullRequestUrl(
|
|
4127
|
-
newPrNumber
|
|
4128
|
-
)}`
|
|
4175
|
+
if (prNumber) {
|
|
4176
|
+
this.ora.succeed(`Existing PR found: #${prNumber}`);
|
|
4177
|
+
} else {
|
|
4178
|
+
this.ora.start(`Creating new PR`);
|
|
4179
|
+
prNumber = await this.platformKit.createPullRequest({
|
|
4180
|
+
head: i18nBranchName,
|
|
4181
|
+
title: this.platformKit.config.pullRequestTitle,
|
|
4182
|
+
body: this.getPrBodyContent()
|
|
4129
4183
|
});
|
|
4130
|
-
this.ora.succeed(`
|
|
4184
|
+
this.ora.succeed(`Created new PR: #${prNumber}`);
|
|
4131
4185
|
}
|
|
4132
|
-
return
|
|
4186
|
+
return prNumber;
|
|
4133
4187
|
}
|
|
4134
4188
|
checkoutI18nBranch(i18nBranchName) {
|
|
4135
4189
|
_child_process.execSync.call(void 0, `git fetch origin ${i18nBranchName}`, { stdio: "inherit" });
|
|
@@ -4280,10 +4334,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4280
4334
|
repo_slug: this.platformConfig.repositoryName,
|
|
4281
4335
|
state: "OPEN"
|
|
4282
4336
|
}).then(({ data: { values } }) => {
|
|
4283
|
-
return _optionalChain([values, 'optionalAccess',
|
|
4284
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
4337
|
+
return _optionalChain([values, 'optionalAccess', _156 => _156.find, 'call', _157 => _157(
|
|
4338
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _158 => _158.branch, 'optionalAccess', _159 => _159.name]) === branch && _optionalChain([destination, 'optionalAccess', _160 => _160.branch, 'optionalAccess', _161 => _161.name]) === this.platformConfig.baseBranchName
|
|
4285
4339
|
)]);
|
|
4286
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4340
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _162 => _162.id]));
|
|
4287
4341
|
}
|
|
4288
4342
|
async closePullRequest({ pullRequestNumber }) {
|
|
4289
4343
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -4370,7 +4424,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4370
4424
|
repo: this.platformConfig.repositoryName,
|
|
4371
4425
|
base: this.platformConfig.baseBranchName,
|
|
4372
4426
|
state: "open"
|
|
4373
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4427
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _163 => _163.number]));
|
|
4374
4428
|
}
|
|
4375
4429
|
async closePullRequest({ pullRequestNumber }) {
|
|
4376
4430
|
await this.octokit.rest.pulls.update({
|
|
@@ -4486,7 +4540,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
4486
4540
|
sourceBranch: branch,
|
|
4487
4541
|
state: "opened"
|
|
4488
4542
|
});
|
|
4489
|
-
return _optionalChain([mergeRequests, 'access',
|
|
4543
|
+
return _optionalChain([mergeRequests, 'access', _164 => _164[0], 'optionalAccess', _165 => _165.iid]);
|
|
4490
4544
|
}
|
|
4491
4545
|
async closePullRequest({ pullRequestNumber }) {
|
|
4492
4546
|
await this.gitlab.MergeRequests.edit(this.platformConfig.gitlabProjectId, pullRequestNumber, {
|
|
@@ -4540,7 +4594,7 @@ async function main() {
|
|
|
4540
4594
|
const { isPullRequestMode } = platformKit.config;
|
|
4541
4595
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
4542
4596
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
4543
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
4597
|
+
const canRun = await _optionalChain([flow, 'access', _166 => _166.preRun, 'optionalCall', _167 => _167()]);
|
|
4544
4598
|
if (canRun === false) {
|
|
4545
4599
|
return;
|
|
4546
4600
|
}
|
|
@@ -4548,7 +4602,7 @@ async function main() {
|
|
|
4548
4602
|
if (!hasChanges) {
|
|
4549
4603
|
return;
|
|
4550
4604
|
}
|
|
4551
|
-
await _optionalChain([flow, 'access',
|
|
4605
|
+
await _optionalChain([flow, 'access', _168 => _168.postRun, 'optionalCall', _169 => _169()]);
|
|
4552
4606
|
}
|
|
4553
4607
|
|
|
4554
4608
|
// src/cli/cmd/ci.ts
|
|
@@ -4570,7 +4624,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
4570
4624
|
}
|
|
4571
4625
|
const env = {
|
|
4572
4626
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
4573
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
4627
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _170 => _170.pullRequest, 'optionalAccess', _171 => _171.toString, 'call', _172 => _172()]) || "false",
|
|
4574
4628
|
...options.commitMessage && { LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage },
|
|
4575
4629
|
...options.pullRequestTitle && { LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle },
|
|
4576
4630
|
...options.workingDirectory && { LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory },
|
|
@@ -4583,7 +4637,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
4583
4637
|
// package.json
|
|
4584
4638
|
var package_default = {
|
|
4585
4639
|
name: "lingo.dev",
|
|
4586
|
-
version: "0.79.
|
|
4640
|
+
version: "0.79.2",
|
|
4587
4641
|
description: "Lingo.dev CLI",
|
|
4588
4642
|
private: false,
|
|
4589
4643
|
publishConfig: {
|