lingo.dev 0.79.1 → 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 +157 -133
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +115 -91
- 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)
|
|
@@ -3340,17 +3373,15 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3340
3373
|
const auth = await validateAuth(settings);
|
|
3341
3374
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
3342
3375
|
let buckets = getBuckets(i18nConfig);
|
|
3343
|
-
if (_optionalChain([flags, 'access',
|
|
3376
|
+
if (_optionalChain([flags, 'access', _137 => _137.bucket, 'optionalAccess', _138 => _138.length])) {
|
|
3344
3377
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
3345
3378
|
}
|
|
3346
3379
|
ora.succeed("Buckets retrieved");
|
|
3347
|
-
if (_optionalChain([flags, 'access',
|
|
3380
|
+
if (_optionalChain([flags, 'access', _139 => _139.file, 'optionalAccess', _140 => _140.length])) {
|
|
3348
3381
|
buckets = buckets.map((bucket) => {
|
|
3349
|
-
const
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
return { ...bucket, config };
|
|
3353
|
-
}).filter((bucket) => bucket.config.length > 0);
|
|
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);
|
|
3354
3385
|
if (buckets.length === 0) {
|
|
3355
3386
|
ora.fail("No buckets found. All buckets were filtered out by --file option.");
|
|
3356
3387
|
process.exit(1);
|
|
@@ -3358,28 +3389,29 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3358
3389
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
3359
3390
|
buckets.map((bucket) => {
|
|
3360
3391
|
ora.info(` ${bucket.type}:`);
|
|
3361
|
-
bucket.
|
|
3362
|
-
ora.info(` - ${
|
|
3392
|
+
bucket.paths.forEach((path15) => {
|
|
3393
|
+
ora.info(` - ${path15.pathPattern}`);
|
|
3363
3394
|
});
|
|
3364
3395
|
});
|
|
3365
3396
|
}
|
|
3366
3397
|
}
|
|
3367
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
3398
|
+
const targetLocales = _optionalChain([flags, 'access', _144 => _144.locale, 'optionalAccess', _145 => _145.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
3368
3399
|
const lockfileHelper = createLockfileHelper();
|
|
3369
3400
|
ora.start("Ensuring i18n.lock exists...");
|
|
3370
3401
|
if (!lockfileHelper.isLockfileExists()) {
|
|
3371
3402
|
ora.start("Creating i18n.lock...");
|
|
3372
3403
|
for (const bucket of buckets) {
|
|
3373
|
-
for (const
|
|
3374
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3375
|
-
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, {
|
|
3376
3407
|
isCacheRestore: false,
|
|
3377
|
-
defaultLocale: sourceLocale
|
|
3408
|
+
defaultLocale: sourceLocale,
|
|
3409
|
+
injectLocale: bucket.injectLocale
|
|
3378
3410
|
});
|
|
3379
3411
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3380
3412
|
await bucketLoader.init();
|
|
3381
3413
|
const sourceData = await bucketLoader.pull(i18nConfig.locale.source);
|
|
3382
|
-
lockfileHelper.registerSourceData(
|
|
3414
|
+
lockfileHelper.registerSourceData(bucketPath.pathPattern, sourceData);
|
|
3383
3415
|
}
|
|
3384
3416
|
}
|
|
3385
3417
|
ora.succeed("i18n.lock created");
|
|
@@ -3393,13 +3425,14 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3393
3425
|
const cacheOra = _ora2.default.call(void 0, { indent: 2 });
|
|
3394
3426
|
for (const bucket of buckets) {
|
|
3395
3427
|
cacheOra.info(`Processing bucket: ${bucket.type}`);
|
|
3396
|
-
for (const
|
|
3428
|
+
for (const bucketPath of bucket.paths) {
|
|
3397
3429
|
const bucketOra = _ora2.default.call(void 0, { indent: 4 });
|
|
3398
|
-
bucketOra.info(`Processing path: ${
|
|
3399
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3400
|
-
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, {
|
|
3401
3433
|
isCacheRestore: true,
|
|
3402
|
-
defaultLocale: sourceLocale
|
|
3434
|
+
defaultLocale: sourceLocale,
|
|
3435
|
+
injectLocale: bucket.injectLocale
|
|
3403
3436
|
});
|
|
3404
3437
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3405
3438
|
await bucketLoader.init();
|
|
@@ -3415,7 +3448,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3415
3448
|
}
|
|
3416
3449
|
}
|
|
3417
3450
|
await bucketLoader.push(targetLocale, targetData);
|
|
3418
|
-
lockfileHelper.registerPartialSourceData(
|
|
3451
|
+
lockfileHelper.registerPartialSourceData(bucketPath.pathPattern, cachedSourceData);
|
|
3419
3452
|
bucketOra.succeed(
|
|
3420
3453
|
`[${sourceLocale} -> ${targetLocale}] Recovered ${Object.keys(cachedSourceData).length} entries from cache`
|
|
3421
3454
|
);
|
|
@@ -3433,25 +3466,26 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3433
3466
|
ora.start("Checking for lockfile updates...");
|
|
3434
3467
|
let requiresUpdate = null;
|
|
3435
3468
|
bucketLoop: for (const bucket of buckets) {
|
|
3436
|
-
for (const
|
|
3437
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3438
|
-
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, {
|
|
3439
3472
|
isCacheRestore: false,
|
|
3440
3473
|
defaultLocale: sourceLocale,
|
|
3441
|
-
returnUnlocalizedKeys: true
|
|
3474
|
+
returnUnlocalizedKeys: true,
|
|
3475
|
+
injectLocale: bucket.injectLocale
|
|
3442
3476
|
});
|
|
3443
3477
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3444
3478
|
await bucketLoader.init();
|
|
3445
3479
|
const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(
|
|
3446
3480
|
i18nConfig.locale.source
|
|
3447
3481
|
);
|
|
3448
|
-
const updatedSourceData = lockfileHelper.extractUpdatedData(
|
|
3482
|
+
const updatedSourceData = lockfileHelper.extractUpdatedData(bucketPath.pathPattern, sourceData);
|
|
3449
3483
|
if (Object.keys(updatedSourceData).length > 0) {
|
|
3450
3484
|
requiresUpdate = "updated";
|
|
3451
3485
|
break bucketLoop;
|
|
3452
3486
|
}
|
|
3453
3487
|
for (const _targetLocale of targetLocales) {
|
|
3454
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale,
|
|
3488
|
+
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
|
|
3455
3489
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
3456
3490
|
const missingKeys = _lodash2.default.difference(Object.keys(sourceData), Object.keys(targetData));
|
|
3457
3491
|
const extraKeys = _lodash2.default.difference(Object.keys(targetData), Object.keys(sourceData));
|
|
@@ -3489,22 +3523,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3489
3523
|
try {
|
|
3490
3524
|
console.log();
|
|
3491
3525
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3492
|
-
for (const
|
|
3493
|
-
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${
|
|
3494
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source,
|
|
3495
|
-
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, {
|
|
3496
3530
|
isCacheRestore: false,
|
|
3497
|
-
defaultLocale: sourceLocale
|
|
3531
|
+
defaultLocale: sourceLocale,
|
|
3532
|
+
injectLocale: bucket.injectLocale
|
|
3498
3533
|
});
|
|
3499
3534
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3500
3535
|
await bucketLoader.init();
|
|
3501
3536
|
let sourceData = await bucketLoader.pull(sourceLocale);
|
|
3502
3537
|
for (const _targetLocale of targetLocales) {
|
|
3503
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale,
|
|
3538
|
+
const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
|
|
3504
3539
|
try {
|
|
3505
3540
|
bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
|
|
3506
3541
|
sourceData = await bucketLoader.pull(sourceLocale);
|
|
3507
|
-
const updatedSourceData = flags.force ? sourceData : lockfileHelper.extractUpdatedData(
|
|
3542
|
+
const updatedSourceData = flags.force ? sourceData : lockfileHelper.extractUpdatedData(bucketPath.pathPattern, sourceData);
|
|
3508
3543
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
3509
3544
|
let processableData = calculateDataDelta({
|
|
3510
3545
|
sourceData,
|
|
@@ -3512,7 +3547,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3512
3547
|
targetData
|
|
3513
3548
|
});
|
|
3514
3549
|
if (flags.key) {
|
|
3515
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
3550
|
+
processableData = _lodash2.default.pickBy(processableData, (_22, key) => key === flags.key);
|
|
3516
3551
|
}
|
|
3517
3552
|
if (flags.verbose) {
|
|
3518
3553
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -3552,7 +3587,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3552
3587
|
if (flags.interactive) {
|
|
3553
3588
|
bucketOra.stop();
|
|
3554
3589
|
const reviewedData = await reviewChanges({
|
|
3555
|
-
pathPattern:
|
|
3590
|
+
pathPattern: bucketPath.pathPattern,
|
|
3556
3591
|
targetLocale,
|
|
3557
3592
|
currentData: targetData,
|
|
3558
3593
|
proposedData: finalTargetData,
|
|
@@ -3560,7 +3595,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3560
3595
|
force: flags.force
|
|
3561
3596
|
});
|
|
3562
3597
|
finalTargetData = reviewedData;
|
|
3563
|
-
bucketOra.start(`Applying changes to ${
|
|
3598
|
+
bucketOra.start(`Applying changes to ${bucketPath} (${targetLocale})`);
|
|
3564
3599
|
}
|
|
3565
3600
|
const finalDiffSize = _lodash2.default.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
3566
3601
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
@@ -3579,7 +3614,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3579
3614
|
}
|
|
3580
3615
|
}
|
|
3581
3616
|
}
|
|
3582
|
-
lockfileHelper.registerSourceData(
|
|
3617
|
+
lockfileHelper.registerSourceData(bucketPath.pathPattern, sourceData);
|
|
3583
3618
|
}
|
|
3584
3619
|
} catch (_error) {
|
|
3585
3620
|
const error = new Error(`Failed to process bucket ${bucket.type}: ${_error.message}`);
|
|
@@ -3695,12 +3730,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
3695
3730
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
3696
3731
|
docUrl: "bucketNotFound"
|
|
3697
3732
|
});
|
|
3698
|
-
} 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))])) {
|
|
3699
3734
|
throw new CLIError({
|
|
3700
3735
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
3701
3736
|
docUrl: "localeTargetNotFound"
|
|
3702
3737
|
});
|
|
3703
|
-
} 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])])) {
|
|
3704
3739
|
throw new CLIError({
|
|
3705
3740
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
3706
3741
|
docUrl: "bucketNotFound"
|
|
@@ -3818,7 +3853,7 @@ var lockfile_default = new (0, _interactivecommander.Command)().command("lockfil
|
|
|
3818
3853
|
const i18nConfig = getConfig();
|
|
3819
3854
|
const buckets = getBuckets(i18nConfig);
|
|
3820
3855
|
for (const bucket of buckets) {
|
|
3821
|
-
for (const bucketConfig of bucket.
|
|
3856
|
+
for (const bucketConfig of bucket.paths) {
|
|
3822
3857
|
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3823
3858
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
3824
3859
|
isCacheRestore: false,
|
|
@@ -3841,7 +3876,10 @@ var flagsSchema = _zod2.default.object({
|
|
|
3841
3876
|
|
|
3842
3877
|
|
|
3843
3878
|
|
|
3844
|
-
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) {
|
|
3845
3883
|
const ora = _ora2.default.call(void 0, );
|
|
3846
3884
|
const results = [];
|
|
3847
3885
|
try {
|
|
@@ -3857,7 +3895,7 @@ var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup"
|
|
|
3857
3895
|
for (const bucket of buckets) {
|
|
3858
3896
|
console.log();
|
|
3859
3897
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3860
|
-
for (const bucketConfig of bucket.
|
|
3898
|
+
for (const bucketConfig of bucket.paths) {
|
|
3861
3899
|
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3862
3900
|
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
3863
3901
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
@@ -3936,7 +3974,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
3936
3974
|
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
3937
3975
|
|
|
3938
3976
|
|
|
3939
|
-
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) => {
|
|
3940
3978
|
const apiKey = program.args[0];
|
|
3941
3979
|
const settings = getSettings(apiKey);
|
|
3942
3980
|
if (!settings.auth.apiKey) {
|
|
@@ -4059,7 +4097,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4059
4097
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
4060
4098
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
4061
4099
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
4062
|
-
_optionalChain([this, 'access',
|
|
4100
|
+
_optionalChain([this, 'access', _152 => _152.platformKit, 'optionalAccess', _153 => _153.gitConfig, 'call', _154 => _154()]);
|
|
4063
4101
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
4064
4102
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
4065
4103
|
if (!processOwnCommits) {
|
|
@@ -4084,7 +4122,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4084
4122
|
// ../../action/src/flows/pull-request.ts
|
|
4085
4123
|
var PullRequestFlow = class extends InBranchFlow {
|
|
4086
4124
|
async preRun() {
|
|
4087
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
4125
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _155 => _155()]);
|
|
4088
4126
|
if (!canContinue) {
|
|
4089
4127
|
return false;
|
|
4090
4128
|
}
|
|
@@ -4131,35 +4169,21 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4131
4169
|
this.ora.start(
|
|
4132
4170
|
`Checking for existing PR with head ${i18nBranchName} and base ${this.platformKit.platformConfig.baseBranchName}`
|
|
4133
4171
|
);
|
|
4134
|
-
|
|
4172
|
+
let prNumber = await this.platformKit.getOpenPullRequestNumber({
|
|
4135
4173
|
branch: i18nBranchName
|
|
4136
4174
|
});
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
this.ora.start(`Creating new PR`);
|
|
4146
|
-
const newPrNumber = await this.platformKit.createPullRequest({
|
|
4147
|
-
head: i18nBranchName,
|
|
4148
|
-
title: this.platformKit.config.pullRequestTitle,
|
|
4149
|
-
body: this.getPrBodyContent()
|
|
4150
|
-
});
|
|
4151
|
-
this.ora.succeed(`Created new PR ${newPrNumber}`);
|
|
4152
|
-
if (existingPrNumber) {
|
|
4153
|
-
this.ora.start(`Posting comment about outdated PR ${existingPrNumber}`);
|
|
4154
|
-
await this.platformKit.commentOnPullRequest({
|
|
4155
|
-
pullRequestNumber: existingPrNumber,
|
|
4156
|
-
body: `This PR is now outdated. A new version has been created at ${this.platformKit.buildPullRequestUrl(
|
|
4157
|
-
newPrNumber
|
|
4158
|
-
)}`
|
|
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()
|
|
4159
4183
|
});
|
|
4160
|
-
this.ora.succeed(`
|
|
4184
|
+
this.ora.succeed(`Created new PR: #${prNumber}`);
|
|
4161
4185
|
}
|
|
4162
|
-
return
|
|
4186
|
+
return prNumber;
|
|
4163
4187
|
}
|
|
4164
4188
|
checkoutI18nBranch(i18nBranchName) {
|
|
4165
4189
|
_child_process.execSync.call(void 0, `git fetch origin ${i18nBranchName}`, { stdio: "inherit" });
|
|
@@ -4310,10 +4334,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4310
4334
|
repo_slug: this.platformConfig.repositoryName,
|
|
4311
4335
|
state: "OPEN"
|
|
4312
4336
|
}).then(({ data: { values } }) => {
|
|
4313
|
-
return _optionalChain([values, 'optionalAccess',
|
|
4314
|
-
({ 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
|
|
4315
4339
|
)]);
|
|
4316
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4340
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _162 => _162.id]));
|
|
4317
4341
|
}
|
|
4318
4342
|
async closePullRequest({ pullRequestNumber }) {
|
|
4319
4343
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -4400,7 +4424,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4400
4424
|
repo: this.platformConfig.repositoryName,
|
|
4401
4425
|
base: this.platformConfig.baseBranchName,
|
|
4402
4426
|
state: "open"
|
|
4403
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4427
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _163 => _163.number]));
|
|
4404
4428
|
}
|
|
4405
4429
|
async closePullRequest({ pullRequestNumber }) {
|
|
4406
4430
|
await this.octokit.rest.pulls.update({
|
|
@@ -4516,7 +4540,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
4516
4540
|
sourceBranch: branch,
|
|
4517
4541
|
state: "opened"
|
|
4518
4542
|
});
|
|
4519
|
-
return _optionalChain([mergeRequests, 'access',
|
|
4543
|
+
return _optionalChain([mergeRequests, 'access', _164 => _164[0], 'optionalAccess', _165 => _165.iid]);
|
|
4520
4544
|
}
|
|
4521
4545
|
async closePullRequest({ pullRequestNumber }) {
|
|
4522
4546
|
await this.gitlab.MergeRequests.edit(this.platformConfig.gitlabProjectId, pullRequestNumber, {
|
|
@@ -4570,7 +4594,7 @@ async function main() {
|
|
|
4570
4594
|
const { isPullRequestMode } = platformKit.config;
|
|
4571
4595
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
4572
4596
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
4573
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
4597
|
+
const canRun = await _optionalChain([flow, 'access', _166 => _166.preRun, 'optionalCall', _167 => _167()]);
|
|
4574
4598
|
if (canRun === false) {
|
|
4575
4599
|
return;
|
|
4576
4600
|
}
|
|
@@ -4578,7 +4602,7 @@ async function main() {
|
|
|
4578
4602
|
if (!hasChanges) {
|
|
4579
4603
|
return;
|
|
4580
4604
|
}
|
|
4581
|
-
await _optionalChain([flow, 'access',
|
|
4605
|
+
await _optionalChain([flow, 'access', _168 => _168.postRun, 'optionalCall', _169 => _169()]);
|
|
4582
4606
|
}
|
|
4583
4607
|
|
|
4584
4608
|
// src/cli/cmd/ci.ts
|
|
@@ -4600,7 +4624,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
4600
4624
|
}
|
|
4601
4625
|
const env = {
|
|
4602
4626
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
4603
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
4627
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _170 => _170.pullRequest, 'optionalAccess', _171 => _171.toString, 'call', _172 => _172()]) || "false",
|
|
4604
4628
|
...options.commitMessage && { LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage },
|
|
4605
4629
|
...options.pullRequestTitle && { LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle },
|
|
4606
4630
|
...options.workingDirectory && { LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory },
|
|
@@ -4613,7 +4637,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
4613
4637
|
// package.json
|
|
4614
4638
|
var package_default = {
|
|
4615
4639
|
name: "lingo.dev",
|
|
4616
|
-
version: "0.79.
|
|
4640
|
+
version: "0.79.2",
|
|
4617
4641
|
description: "Lingo.dev CLI",
|
|
4618
4642
|
private: false,
|
|
4619
4643
|
publishConfig: {
|