lingo.dev 0.108.0 → 0.109.1
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 +407 -102
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +317 -12
- package/build/cli.mjs.map +1 -1
- package/package.json +5 -4
package/build/cli.cjs
CHANGED
|
@@ -1525,6 +1525,16 @@ function composeLoaders(...loaders) {
|
|
|
1525
1525
|
result = await loaders[i].push(locale, result);
|
|
1526
1526
|
}
|
|
1527
1527
|
return result;
|
|
1528
|
+
},
|
|
1529
|
+
pullHints: async (originalInput) => {
|
|
1530
|
+
let result = originalInput;
|
|
1531
|
+
for (let i = 0; i < loaders.length; i++) {
|
|
1532
|
+
const subResult = await _optionalChain([loaders, 'access', _79 => _79[i], 'access', _80 => _80.pullHints, 'optionalCall', _81 => _81(result)]);
|
|
1533
|
+
if (subResult) {
|
|
1534
|
+
result = subResult;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
return result;
|
|
1528
1538
|
}
|
|
1529
1539
|
};
|
|
1530
1540
|
}
|
|
@@ -1541,7 +1551,7 @@ function createLoader(lDefinition) {
|
|
|
1541
1551
|
if (state.initCtx) {
|
|
1542
1552
|
return state.initCtx;
|
|
1543
1553
|
}
|
|
1544
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1554
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _82 => _82.init, 'optionalCall', _83 => _83()]);
|
|
1545
1555
|
return state.initCtx;
|
|
1546
1556
|
},
|
|
1547
1557
|
setDefaultLocale(locale) {
|
|
@@ -1551,6 +1561,9 @@ function createLoader(lDefinition) {
|
|
|
1551
1561
|
state.defaultLocale = locale;
|
|
1552
1562
|
return this;
|
|
1553
1563
|
},
|
|
1564
|
+
async pullHints() {
|
|
1565
|
+
return _optionalChain([lDefinition, 'access', _84 => _84.pullHints, 'optionalCall', _85 => _85(state.originalInput)]);
|
|
1566
|
+
},
|
|
1554
1567
|
async pull(locale, input2) {
|
|
1555
1568
|
if (!state.defaultLocale) {
|
|
1556
1569
|
throw new Error("Default locale not set");
|
|
@@ -1613,12 +1626,220 @@ function createJsonLoader() {
|
|
|
1613
1626
|
});
|
|
1614
1627
|
}
|
|
1615
1628
|
|
|
1629
|
+
// src/cli/loaders/json5.ts
|
|
1630
|
+
var _json5 = require('json5'); var _json52 = _interopRequireDefault(_json5);
|
|
1631
|
+
function createJson5Loader() {
|
|
1632
|
+
return createLoader({
|
|
1633
|
+
pull: async (locale, input2) => {
|
|
1634
|
+
const json5String = input2 || "{}";
|
|
1635
|
+
return _json52.default.parse(json5String);
|
|
1636
|
+
},
|
|
1637
|
+
push: async (locale, data) => {
|
|
1638
|
+
const serializedData = _json52.default.stringify(data, null, 2);
|
|
1639
|
+
return serializedData;
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
// src/cli/loaders/jsonc.ts
|
|
1645
|
+
var _jsoncparser = require('jsonc-parser');
|
|
1646
|
+
function extractCommentsFromJsonc(jsoncString) {
|
|
1647
|
+
const lines = jsoncString.split("\n");
|
|
1648
|
+
const comments = {};
|
|
1649
|
+
const errors = [];
|
|
1650
|
+
const result = _jsoncparser.parse.call(void 0, jsoncString, errors, {
|
|
1651
|
+
allowTrailingComma: true,
|
|
1652
|
+
disallowComments: false,
|
|
1653
|
+
allowEmptyContent: true
|
|
1654
|
+
});
|
|
1655
|
+
if (errors.length > 0) {
|
|
1656
|
+
return {};
|
|
1657
|
+
}
|
|
1658
|
+
const contextStack = [];
|
|
1659
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1660
|
+
const line = lines[i];
|
|
1661
|
+
const trimmedLine = line.trim();
|
|
1662
|
+
if (!trimmedLine) continue;
|
|
1663
|
+
const commentData = extractCommentFromLine(line, lines, i);
|
|
1664
|
+
if (commentData.hint) {
|
|
1665
|
+
let keyInfo;
|
|
1666
|
+
if (commentData.isInline) {
|
|
1667
|
+
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1668
|
+
if (keyMatch) {
|
|
1669
|
+
const key = keyMatch[1];
|
|
1670
|
+
const path17 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1671
|
+
keyInfo = { key, path: path17 };
|
|
1672
|
+
}
|
|
1673
|
+
} else {
|
|
1674
|
+
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack);
|
|
1675
|
+
}
|
|
1676
|
+
if (keyInfo && keyInfo.key) {
|
|
1677
|
+
setCommentAtPath(comments, keyInfo.path, keyInfo.key, commentData.hint);
|
|
1678
|
+
}
|
|
1679
|
+
i = commentData.endIndex;
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
updateContext(contextStack, line, result);
|
|
1683
|
+
}
|
|
1684
|
+
return comments;
|
|
1685
|
+
}
|
|
1686
|
+
function extractCommentFromLine(line, lines, lineIndex) {
|
|
1687
|
+
const trimmed = line.trim();
|
|
1688
|
+
if (trimmed.startsWith("//")) {
|
|
1689
|
+
const hint = trimmed.replace(/^\/\/\s*/, "").trim();
|
|
1690
|
+
return { hint, lineIndex, endIndex: lineIndex, isInline: false };
|
|
1691
|
+
}
|
|
1692
|
+
if (trimmed.startsWith("/*")) {
|
|
1693
|
+
const blockResult = extractBlockComment(lines, lineIndex);
|
|
1694
|
+
return { ...blockResult, isInline: false };
|
|
1695
|
+
}
|
|
1696
|
+
const singleInlineMatch = line.match(/^(.+?)\s*\/\/\s*(.+)$/);
|
|
1697
|
+
if (singleInlineMatch && singleInlineMatch[1].includes(":")) {
|
|
1698
|
+
const hint = singleInlineMatch[2].trim();
|
|
1699
|
+
return { hint, lineIndex, endIndex: lineIndex, isInline: true };
|
|
1700
|
+
}
|
|
1701
|
+
const blockInlineMatch = line.match(/^(.+?)\s*\/\*\s*(.*?)\s*\*\/.*$/);
|
|
1702
|
+
if (blockInlineMatch && blockInlineMatch[1].includes(":")) {
|
|
1703
|
+
const hint = blockInlineMatch[2].trim();
|
|
1704
|
+
return { hint, lineIndex, endIndex: lineIndex, isInline: true };
|
|
1705
|
+
}
|
|
1706
|
+
return { hint: null, lineIndex, endIndex: lineIndex, isInline: false };
|
|
1707
|
+
}
|
|
1708
|
+
function extractBlockComment(lines, startIndex) {
|
|
1709
|
+
const startLine = lines[startIndex];
|
|
1710
|
+
const singleMatch = startLine.match(/\/\*\s*(.*?)\s*\*\//);
|
|
1711
|
+
if (singleMatch) {
|
|
1712
|
+
return {
|
|
1713
|
+
hint: singleMatch[1].trim(),
|
|
1714
|
+
lineIndex: startIndex,
|
|
1715
|
+
endIndex: startIndex
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
const commentParts = [];
|
|
1719
|
+
let endIndex = startIndex;
|
|
1720
|
+
const firstContent = startLine.replace(/.*?\/\*\s*/, "").trim();
|
|
1721
|
+
if (firstContent && !firstContent.includes("*/")) {
|
|
1722
|
+
commentParts.push(firstContent);
|
|
1723
|
+
}
|
|
1724
|
+
for (let i = startIndex + 1; i < lines.length; i++) {
|
|
1725
|
+
const line = lines[i];
|
|
1726
|
+
endIndex = i;
|
|
1727
|
+
if (line.includes("*/")) {
|
|
1728
|
+
const lastContent = line.replace(/\*\/.*$/, "").replace(/^\s*\*?\s*/, "").trim();
|
|
1729
|
+
if (lastContent) {
|
|
1730
|
+
commentParts.push(lastContent);
|
|
1731
|
+
}
|
|
1732
|
+
break;
|
|
1733
|
+
} else {
|
|
1734
|
+
const content = line.replace(/^\s*\*?\s*/, "").trim();
|
|
1735
|
+
if (content) {
|
|
1736
|
+
commentParts.push(content);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
hint: commentParts.join(" ").trim() || null,
|
|
1742
|
+
lineIndex: startIndex,
|
|
1743
|
+
endIndex
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function findAssociatedKey(lines, commentLineIndex, contextStack) {
|
|
1747
|
+
for (let i = commentLineIndex + 1; i < lines.length; i++) {
|
|
1748
|
+
const line = lines[i].trim();
|
|
1749
|
+
if (!line || line.startsWith("//") || line.startsWith("/*") || line === "{" || line === "}") {
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1753
|
+
if (keyMatch) {
|
|
1754
|
+
const key = keyMatch[1];
|
|
1755
|
+
const path17 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1756
|
+
return { key, path: path17 };
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return { key: null, path: [] };
|
|
1760
|
+
}
|
|
1761
|
+
function updateContext(contextStack, line, parsedJson) {
|
|
1762
|
+
const openBraces = (line.match(/\{/g) || []).length;
|
|
1763
|
+
const closeBraces = (line.match(/\}/g) || []).length;
|
|
1764
|
+
if (openBraces > closeBraces) {
|
|
1765
|
+
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:\s*\{/);
|
|
1766
|
+
if (keyMatch) {
|
|
1767
|
+
contextStack.push({ key: keyMatch[1], isArray: false });
|
|
1768
|
+
}
|
|
1769
|
+
} else if (closeBraces > openBraces) {
|
|
1770
|
+
for (let i = 0; i < closeBraces - openBraces; i++) {
|
|
1771
|
+
contextStack.pop();
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function setCommentAtPath(comments, path17, key, hint) {
|
|
1776
|
+
let current = comments;
|
|
1777
|
+
for (const pathKey of path17) {
|
|
1778
|
+
if (!current[pathKey]) {
|
|
1779
|
+
current[pathKey] = {};
|
|
1780
|
+
}
|
|
1781
|
+
current = current[pathKey];
|
|
1782
|
+
}
|
|
1783
|
+
if (!current[key]) {
|
|
1784
|
+
current[key] = {};
|
|
1785
|
+
}
|
|
1786
|
+
if (typeof current[key] === "object" && current[key] !== null) {
|
|
1787
|
+
current[key].hint = hint;
|
|
1788
|
+
} else {
|
|
1789
|
+
current[key] = { hint };
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function createJsoncLoader() {
|
|
1793
|
+
return createLoader({
|
|
1794
|
+
pull: async (locale, input2) => {
|
|
1795
|
+
const jsoncString = input2 || "{}";
|
|
1796
|
+
const errors = [];
|
|
1797
|
+
const result = _jsoncparser.parse.call(void 0, jsoncString, errors, {
|
|
1798
|
+
allowTrailingComma: true,
|
|
1799
|
+
disallowComments: false,
|
|
1800
|
+
allowEmptyContent: true
|
|
1801
|
+
});
|
|
1802
|
+
if (errors.length > 0) {
|
|
1803
|
+
throw new Error(`Failed to parse JSONC: ${errors[0].error}`);
|
|
1804
|
+
}
|
|
1805
|
+
return result || {};
|
|
1806
|
+
},
|
|
1807
|
+
push: async (locale, data) => {
|
|
1808
|
+
const serializedData = JSON.stringify(data, null, 2);
|
|
1809
|
+
return serializedData;
|
|
1810
|
+
},
|
|
1811
|
+
pullHints: async (input2) => {
|
|
1812
|
+
if (!input2 || typeof input2 !== "string") {
|
|
1813
|
+
return {};
|
|
1814
|
+
}
|
|
1815
|
+
try {
|
|
1816
|
+
return extractCommentsFromJsonc(input2);
|
|
1817
|
+
} catch (error) {
|
|
1818
|
+
console.warn("Failed to extract comments from JSONC:", error);
|
|
1819
|
+
return {};
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1616
1825
|
// src/cli/loaders/flat.ts
|
|
1617
1826
|
var _flat = require('flat');
|
|
1618
1827
|
|
|
1619
1828
|
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
1620
1829
|
function createFlatLoader() {
|
|
1621
|
-
|
|
1830
|
+
const composedLoader = composeLoaders(
|
|
1831
|
+
createDenormalizeLoader(),
|
|
1832
|
+
createNormalizeLoader()
|
|
1833
|
+
);
|
|
1834
|
+
return {
|
|
1835
|
+
...composedLoader,
|
|
1836
|
+
pullHints: async (input2) => {
|
|
1837
|
+
if (!input2 || typeof input2 !== "object") {
|
|
1838
|
+
return {};
|
|
1839
|
+
}
|
|
1840
|
+
return flattenHints(input2);
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1622
1843
|
}
|
|
1623
1844
|
function createDenormalizeLoader() {
|
|
1624
1845
|
return createLoader({
|
|
@@ -1646,7 +1867,7 @@ function createNormalizeLoader() {
|
|
|
1646
1867
|
return normalized;
|
|
1647
1868
|
},
|
|
1648
1869
|
push: async (locale, data, originalInput) => {
|
|
1649
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1870
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _86 => _86.keysMap]), () => ( {}));
|
|
1650
1871
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1651
1872
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1652
1873
|
delimiter: "/",
|
|
@@ -1709,6 +1930,33 @@ function normalizeObjectKeys(obj) {
|
|
|
1709
1930
|
return obj;
|
|
1710
1931
|
}
|
|
1711
1932
|
}
|
|
1933
|
+
function flattenHints(obj, parentHints = [], parentPath = "") {
|
|
1934
|
+
const result = {};
|
|
1935
|
+
for (const [key, _value] of Object.entries(obj)) {
|
|
1936
|
+
if (_lodash2.default.isObject(_value) && !_lodash2.default.isArray(_value)) {
|
|
1937
|
+
const value = _value;
|
|
1938
|
+
const currentHints = [...parentHints];
|
|
1939
|
+
const currentPath = parentPath ? `${parentPath}/${key}` : key;
|
|
1940
|
+
if (value.hint && typeof value.hint === "string") {
|
|
1941
|
+
currentHints.push(value.hint);
|
|
1942
|
+
}
|
|
1943
|
+
const nestedObj = _lodash2.default.omit(value, "hint");
|
|
1944
|
+
if (Object.keys(nestedObj).length === 0) {
|
|
1945
|
+
if (currentHints.length > 0) {
|
|
1946
|
+
result[currentPath] = currentHints;
|
|
1947
|
+
}
|
|
1948
|
+
} else {
|
|
1949
|
+
const nestedComments = flattenHints(
|
|
1950
|
+
nestedObj,
|
|
1951
|
+
currentHints,
|
|
1952
|
+
currentPath
|
|
1953
|
+
);
|
|
1954
|
+
Object.assign(result, nestedComments);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return result;
|
|
1959
|
+
}
|
|
1712
1960
|
|
|
1713
1961
|
// src/cli/loaders/text-file.ts
|
|
1714
1962
|
var _promises3 = require('fs/promises'); var _promises4 = _interopRequireDefault(_promises3);
|
|
@@ -1753,8 +2001,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1753
2001
|
if (!templateData) {
|
|
1754
2002
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1755
2003
|
}
|
|
1756
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1757
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
2004
|
+
if (_optionalChain([templateData, 'optionalAccess', _87 => _87.match, 'call', _88 => _88(/[\r\n]$/)])) {
|
|
2005
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _89 => _89.includes, 'call', _90 => _90("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _91 => _91.includes, 'call', _92 => _92("\r")]) ? "\r" : "\n";
|
|
1758
2006
|
return ending;
|
|
1759
2007
|
}
|
|
1760
2008
|
return "";
|
|
@@ -2025,7 +2273,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
2025
2273
|
|
|
2026
2274
|
function detectKeyColumnName(csvString) {
|
|
2027
2275
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
2028
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
2276
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _93 => _93[0], 'optionalAccess', _94 => _94.trim, 'call', _95 => _95()]);
|
|
2029
2277
|
return firstColumn || "KEY";
|
|
2030
2278
|
}
|
|
2031
2279
|
function createCsvLoader() {
|
|
@@ -2127,7 +2375,7 @@ function createHtmlLoader() {
|
|
|
2127
2375
|
break;
|
|
2128
2376
|
}
|
|
2129
2377
|
const siblings = Array.from(parent.childNodes).filter(
|
|
2130
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2378
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _96 => _96.textContent, 'optionalAccess', _97 => _97.trim, 'call', _98 => _98()])
|
|
2131
2379
|
);
|
|
2132
2380
|
const index = siblings.indexOf(current);
|
|
2133
2381
|
if (index !== -1) {
|
|
@@ -2163,15 +2411,15 @@ function createHtmlLoader() {
|
|
|
2163
2411
|
}
|
|
2164
2412
|
});
|
|
2165
2413
|
Array.from(element.childNodes).filter(
|
|
2166
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2414
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _99 => _99.textContent, 'optionalAccess', _100 => _100.trim, 'call', _101 => _101()])
|
|
2167
2415
|
).forEach(processNode);
|
|
2168
2416
|
}
|
|
2169
2417
|
};
|
|
2170
2418
|
Array.from(document.head.childNodes).filter(
|
|
2171
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2419
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _102 => _102.textContent, 'optionalAccess', _103 => _103.trim, 'call', _104 => _104()])
|
|
2172
2420
|
).forEach(processNode);
|
|
2173
2421
|
Array.from(document.body.childNodes).filter(
|
|
2174
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2422
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _105 => _105.textContent, 'optionalAccess', _106 => _106.trim, 'call', _107 => _107()])
|
|
2175
2423
|
).forEach(processNode);
|
|
2176
2424
|
return result;
|
|
2177
2425
|
},
|
|
@@ -2196,7 +2444,7 @@ function createHtmlLoader() {
|
|
|
2196
2444
|
for (let i = 0; i < indices.length; i++) {
|
|
2197
2445
|
const index = parseInt(indices[i]);
|
|
2198
2446
|
const siblings = Array.from(parent.childNodes).filter(
|
|
2199
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2447
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _108 => _108.textContent, 'optionalAccess', _109 => _109.trim, 'call', _110 => _110()])
|
|
2200
2448
|
);
|
|
2201
2449
|
if (index >= siblings.length) {
|
|
2202
2450
|
if (i === indices.length - 1) {
|
|
@@ -2247,7 +2495,7 @@ function createMarkdownLoader() {
|
|
|
2247
2495
|
yaml: yamlEngine
|
|
2248
2496
|
}
|
|
2249
2497
|
});
|
|
2250
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
2498
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _111 => _111.trim, 'call', _112 => _112()]), () => ( ""))).filter(Boolean);
|
|
2251
2499
|
return {
|
|
2252
2500
|
...Object.fromEntries(
|
|
2253
2501
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -2266,7 +2514,7 @@ function createMarkdownLoader() {
|
|
|
2266
2514
|
);
|
|
2267
2515
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
2268
2516
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
2269
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
2517
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
2270
2518
|
if (Object.keys(frontmatter).length > 0) {
|
|
2271
2519
|
content = `
|
|
2272
2520
|
${content}`;
|
|
@@ -2310,7 +2558,7 @@ function isSkippableLine(line) {
|
|
|
2310
2558
|
function parsePropertyLine(line) {
|
|
2311
2559
|
const [key, ...valueParts] = line.split("=");
|
|
2312
2560
|
return {
|
|
2313
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
2561
|
+
key: _optionalChain([key, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()]) || "",
|
|
2314
2562
|
value: valueParts.join("=").trim()
|
|
2315
2563
|
};
|
|
2316
2564
|
}
|
|
@@ -2398,7 +2646,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2398
2646
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
2399
2647
|
continue;
|
|
2400
2648
|
}
|
|
2401
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
2649
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _117 => _117.localizations, 'optionalAccess', _118 => _118[locale]]);
|
|
2402
2650
|
if (langTranslationEntity) {
|
|
2403
2651
|
if ("stringUnit" in langTranslationEntity) {
|
|
2404
2652
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -2407,7 +2655,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2407
2655
|
resultData[translationKey] = {};
|
|
2408
2656
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
2409
2657
|
for (const form in pluralForms) {
|
|
2410
|
-
if (_optionalChain([pluralForms, 'access',
|
|
2658
|
+
if (_optionalChain([pluralForms, 'access', _119 => _119[form], 'optionalAccess', _120 => _120.stringUnit, 'optionalAccess', _121 => _121.value])) {
|
|
2411
2659
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
2412
2660
|
}
|
|
2413
2661
|
}
|
|
@@ -2433,7 +2681,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2433
2681
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
2434
2682
|
if (typeof value === "string") {
|
|
2435
2683
|
langDataToMerge.strings[key] = {
|
|
2436
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
2684
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _122 => _122.strings, 'optionalAccess', _123 => _123[key], 'optionalAccess', _124 => _124.extractionState]),
|
|
2437
2685
|
localizations: {
|
|
2438
2686
|
[locale]: {
|
|
2439
2687
|
stringUnit: {
|
|
@@ -2474,6 +2722,36 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2474
2722
|
const originalInputWithoutLocale = originalInput ? _removeLocale(originalInput, locale) : {};
|
|
2475
2723
|
const result = _lodash2.default.merge({}, originalInputWithoutLocale, langDataToMerge);
|
|
2476
2724
|
return result;
|
|
2725
|
+
},
|
|
2726
|
+
async pullHints(originalInput) {
|
|
2727
|
+
if (!originalInput || !originalInput.strings) {
|
|
2728
|
+
return {};
|
|
2729
|
+
}
|
|
2730
|
+
const hints = {};
|
|
2731
|
+
for (const [translationKey, translationEntity] of Object.entries(
|
|
2732
|
+
originalInput.strings
|
|
2733
|
+
)) {
|
|
2734
|
+
const entity = translationEntity;
|
|
2735
|
+
if (entity.comment && typeof entity.comment === "string") {
|
|
2736
|
+
hints[translationKey] = { hint: entity.comment };
|
|
2737
|
+
}
|
|
2738
|
+
if (entity.localizations) {
|
|
2739
|
+
for (const [locale, localization] of Object.entries(
|
|
2740
|
+
entity.localizations
|
|
2741
|
+
)) {
|
|
2742
|
+
if (_optionalChain([localization, 'access', _125 => _125.variations, 'optionalAccess', _126 => _126.plural])) {
|
|
2743
|
+
const pluralForms = localization.variations.plural;
|
|
2744
|
+
for (const form in pluralForms) {
|
|
2745
|
+
const pluralKey = `${translationKey}/${form}`;
|
|
2746
|
+
if (entity.comment && typeof entity.comment === "string") {
|
|
2747
|
+
hints[pluralKey] = { hint: entity.comment };
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
return hints;
|
|
2477
2755
|
}
|
|
2478
2756
|
});
|
|
2479
2757
|
}
|
|
@@ -2481,7 +2759,7 @@ function _removeLocale(input2, locale) {
|
|
|
2481
2759
|
const { strings } = input2;
|
|
2482
2760
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
2483
2761
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
2484
|
-
if (_optionalChain([value, 'access',
|
|
2762
|
+
if (_optionalChain([value, 'access', _127 => _127.localizations, 'optionalAccess', _128 => _128[locale]])) {
|
|
2485
2763
|
delete value.localizations[locale];
|
|
2486
2764
|
}
|
|
2487
2765
|
}
|
|
@@ -2641,7 +2919,7 @@ function createPoDataLoader(params) {
|
|
|
2641
2919
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
2642
2920
|
if (msgid && entry.msgid) {
|
|
2643
2921
|
const context = entry.msgctxt || "";
|
|
2644
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
2922
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _129 => _129.translations, 'access', _130 => _130[context], 'optionalAccess', _131 => _131[msgid]]);
|
|
2645
2923
|
if (fullEntry) {
|
|
2646
2924
|
result[msgid] = fullEntry;
|
|
2647
2925
|
}
|
|
@@ -2651,8 +2929,8 @@ function createPoDataLoader(params) {
|
|
|
2651
2929
|
return result;
|
|
2652
2930
|
},
|
|
2653
2931
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
2654
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
2655
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
2932
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _132 => _132.split, 'call', _133 => _133("\n\n"), 'access', _134 => _134.filter, 'call', _135 => _135(Boolean)]) || [];
|
|
2933
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _136 => _136.split, 'call', _137 => _137("\n\n"), 'access', _138 => _138.filter, 'call', _139 => _139(Boolean)]) || [];
|
|
2656
2934
|
const result = originalSections.map((section) => {
|
|
2657
2935
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
2658
2936
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -2721,8 +2999,8 @@ function createPoContentLoader() {
|
|
|
2721
2999
|
{
|
|
2722
3000
|
...entry,
|
|
2723
3001
|
msgstr: [
|
|
2724
|
-
_optionalChain([data, 'access',
|
|
2725
|
-
_optionalChain([data, 'access',
|
|
3002
|
+
_optionalChain([data, 'access', _140 => _140[entry.msgid], 'optionalAccess', _141 => _141.singular]),
|
|
3003
|
+
_optionalChain([data, 'access', _142 => _142[entry.msgid], 'optionalAccess', _143 => _143.plural]) || null
|
|
2726
3004
|
].filter(Boolean)
|
|
2727
3005
|
}
|
|
2728
3006
|
]).fromPairs().value();
|
|
@@ -2844,7 +3122,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
2844
3122
|
let key = getTransUnitKey(unit);
|
|
2845
3123
|
if (!key) return;
|
|
2846
3124
|
if (seenKeys.has(key)) {
|
|
2847
|
-
const id = _optionalChain([unit, 'access',
|
|
3125
|
+
const id = _optionalChain([unit, 'access', _144 => _144.getAttribute, 'call', _145 => _145("id"), 'optionalAccess', _146 => _146.trim, 'call', _147 => _147()]);
|
|
2848
3126
|
if (id) {
|
|
2849
3127
|
key = `${key}#${id}`;
|
|
2850
3128
|
} else {
|
|
@@ -2892,7 +3170,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
2892
3170
|
let key = getTransUnitKey(unit);
|
|
2893
3171
|
if (!key) return;
|
|
2894
3172
|
if (seenKeys.has(key)) {
|
|
2895
|
-
const id = _optionalChain([unit, 'access',
|
|
3173
|
+
const id = _optionalChain([unit, 'access', _148 => _148.getAttribute, 'call', _149 => _149("id"), 'optionalAccess', _150 => _150.trim, 'call', _151 => _151()]);
|
|
2896
3174
|
if (id) {
|
|
2897
3175
|
key = `${key}#${id}`;
|
|
2898
3176
|
} else {
|
|
@@ -2934,7 +3212,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
2934
3212
|
const translationKeys = new Set(Object.keys(translations));
|
|
2935
3213
|
existingUnits.forEach((unit, key) => {
|
|
2936
3214
|
if (!translationKeys.has(key)) {
|
|
2937
|
-
_optionalChain([unit, 'access',
|
|
3215
|
+
_optionalChain([unit, 'access', _152 => _152.parentNode, 'optionalAccess', _153 => _153.removeChild, 'call', _154 => _154(unit)]);
|
|
2938
3216
|
}
|
|
2939
3217
|
});
|
|
2940
3218
|
return serializeWithDeclaration(
|
|
@@ -2977,18 +3255,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
2977
3255
|
Array.from(container.children).forEach((child) => {
|
|
2978
3256
|
const tagName = child.tagName;
|
|
2979
3257
|
if (tagName === "unit") {
|
|
2980
|
-
const unitId = _optionalChain([child, 'access',
|
|
3258
|
+
const unitId = _optionalChain([child, 'access', _155 => _155.getAttribute, 'call', _156 => _156("id"), 'optionalAccess', _157 => _157.trim, 'call', _158 => _158()]);
|
|
2981
3259
|
if (!unitId) return;
|
|
2982
3260
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
2983
3261
|
const segment = child.querySelector("segment");
|
|
2984
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
3262
|
+
const source = _optionalChain([segment, 'optionalAccess', _159 => _159.querySelector, 'call', _160 => _160("source")]);
|
|
2985
3263
|
if (source) {
|
|
2986
3264
|
result[key] = extractTextContent(source);
|
|
2987
3265
|
} else {
|
|
2988
3266
|
result[key] = unitId;
|
|
2989
3267
|
}
|
|
2990
3268
|
} else if (tagName === "group") {
|
|
2991
|
-
const groupId = _optionalChain([child, 'access',
|
|
3269
|
+
const groupId = _optionalChain([child, 'access', _161 => _161.getAttribute, 'call', _162 => _162("id"), 'optionalAccess', _163 => _163.trim, 'call', _164 => _164()]);
|
|
2992
3270
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
2993
3271
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
2994
3272
|
}
|
|
@@ -3024,12 +3302,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
3024
3302
|
Array.from(container.children).forEach((child) => {
|
|
3025
3303
|
const tagName = child.tagName;
|
|
3026
3304
|
if (tagName === "unit") {
|
|
3027
|
-
const unitId = _optionalChain([child, 'access',
|
|
3305
|
+
const unitId = _optionalChain([child, 'access', _165 => _165.getAttribute, 'call', _166 => _166("id"), 'optionalAccess', _167 => _167.trim, 'call', _168 => _168()]);
|
|
3028
3306
|
if (!unitId) return;
|
|
3029
3307
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
3030
3308
|
index.set(key, child);
|
|
3031
3309
|
} else if (tagName === "group") {
|
|
3032
|
-
const groupId = _optionalChain([child, 'access',
|
|
3310
|
+
const groupId = _optionalChain([child, 'access', _169 => _169.getAttribute, 'call', _170 => _170("id"), 'optionalAccess', _171 => _171.trim, 'call', _172 => _172()]);
|
|
3033
3311
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
3034
3312
|
indexUnitsV2(child, fileId, newPath, index);
|
|
3035
3313
|
}
|
|
@@ -3050,9 +3328,9 @@ function updateUnitV2(unit, value) {
|
|
|
3050
3328
|
setTextContent(source, value);
|
|
3051
3329
|
}
|
|
3052
3330
|
function getTransUnitKey(transUnit) {
|
|
3053
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
3331
|
+
const resname = _optionalChain([transUnit, 'access', _173 => _173.getAttribute, 'call', _174 => _174("resname"), 'optionalAccess', _175 => _175.trim, 'call', _176 => _176()]);
|
|
3054
3332
|
if (resname) return resname;
|
|
3055
|
-
const id = _optionalChain([transUnit, 'access',
|
|
3333
|
+
const id = _optionalChain([transUnit, 'access', _177 => _177.getAttribute, 'call', _178 => _178("id"), 'optionalAccess', _179 => _179.trim, 'call', _180 => _180()]);
|
|
3056
3334
|
if (id) return id;
|
|
3057
3335
|
const sourceElement = transUnit.querySelector("source");
|
|
3058
3336
|
if (sourceElement) {
|
|
@@ -3109,7 +3387,7 @@ function formatXml(xml) {
|
|
|
3109
3387
|
if (cdataNode) {
|
|
3110
3388
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
3111
3389
|
}
|
|
3112
|
-
const textContent = _optionalChain([element, 'access',
|
|
3390
|
+
const textContent = _optionalChain([element, 'access', _181 => _181.textContent, 'optionalAccess', _182 => _182.trim, 'call', _183 => _183()]) || "";
|
|
3113
3391
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
3114
3392
|
if (hasOnlyText && textContent) {
|
|
3115
3393
|
return `${indent2}${openTag}${textContent}</${tagName}>`;
|
|
@@ -3238,7 +3516,7 @@ function createSrtLoader() {
|
|
|
3238
3516
|
|
|
3239
3517
|
// src/cli/loaders/dato/index.ts
|
|
3240
3518
|
|
|
3241
|
-
|
|
3519
|
+
|
|
3242
3520
|
|
|
3243
3521
|
// src/cli/loaders/dato/_base.ts
|
|
3244
3522
|
|
|
@@ -3402,7 +3680,7 @@ function createDatoClient(params) {
|
|
|
3402
3680
|
ids: !records.length ? void 0 : records.join(",")
|
|
3403
3681
|
}
|
|
3404
3682
|
}).catch(
|
|
3405
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3683
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _184 => _184.response, 'optionalAccess', _185 => _185.body, 'optionalAccess', _186 => _186.data, 'optionalAccess', _187 => _187[0]]) || error)
|
|
3406
3684
|
);
|
|
3407
3685
|
},
|
|
3408
3686
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -3413,10 +3691,10 @@ function createDatoClient(params) {
|
|
|
3413
3691
|
filter: {
|
|
3414
3692
|
type: modelId,
|
|
3415
3693
|
only_valid: "true",
|
|
3416
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
3694
|
+
ids: !_optionalChain([records, 'optionalAccess', _188 => _188.length]) ? void 0 : records.join(",")
|
|
3417
3695
|
}
|
|
3418
3696
|
}).catch(
|
|
3419
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3697
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _189 => _189.response, 'optionalAccess', _190 => _190.body, 'optionalAccess', _191 => _191.data, 'optionalAccess', _192 => _192[0]]) || error)
|
|
3420
3698
|
);
|
|
3421
3699
|
return result;
|
|
3422
3700
|
} catch (_error) {
|
|
@@ -3432,10 +3710,10 @@ function createDatoClient(params) {
|
|
|
3432
3710
|
updateRecord: async (id, payload) => {
|
|
3433
3711
|
try {
|
|
3434
3712
|
await dato.items.update(id, payload).catch(
|
|
3435
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3713
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _193 => _193.response, 'optionalAccess', _194 => _194.body, 'optionalAccess', _195 => _195.data, 'optionalAccess', _196 => _196[0]]) || error)
|
|
3436
3714
|
);
|
|
3437
3715
|
} catch (_error) {
|
|
3438
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
3716
|
+
if (_optionalChain([_error, 'optionalAccess', _197 => _197.attributes, 'optionalAccess', _198 => _198.details, 'optionalAccess', _199 => _199.message])) {
|
|
3439
3717
|
throw new Error(
|
|
3440
3718
|
[
|
|
3441
3719
|
`${_error.attributes.details.message}`,
|
|
@@ -3457,10 +3735,10 @@ function createDatoClient(params) {
|
|
|
3457
3735
|
enableFieldLocalization: async (args) => {
|
|
3458
3736
|
try {
|
|
3459
3737
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
3460
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3738
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _200 => _200.response, 'optionalAccess', _201 => _201.body, 'optionalAccess', _202 => _202.data, 'optionalAccess', _203 => _203[0]]) || error)
|
|
3461
3739
|
);
|
|
3462
3740
|
} catch (_error) {
|
|
3463
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
3741
|
+
if (_optionalChain([_error, 'optionalAccess', _204 => _204.attributes, 'optionalAccess', _205 => _205.code]) === "NOT_FOUND") {
|
|
3464
3742
|
throw new Error(
|
|
3465
3743
|
[
|
|
3466
3744
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -3468,7 +3746,7 @@ function createDatoClient(params) {
|
|
|
3468
3746
|
].join("\n\n")
|
|
3469
3747
|
);
|
|
3470
3748
|
}
|
|
3471
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
3749
|
+
if (_optionalChain([_error, 'optionalAccess', _206 => _206.attributes, 'optionalAccess', _207 => _207.details, 'optionalAccess', _208 => _208.message])) {
|
|
3472
3750
|
throw new Error(
|
|
3473
3751
|
[
|
|
3474
3752
|
`${_error.attributes.details.message}`,
|
|
@@ -3546,7 +3824,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
3546
3824
|
const records = await dato.findRecordsForModel(modelId);
|
|
3547
3825
|
const recordChoices = createRecordChoices(
|
|
3548
3826
|
records,
|
|
3549
|
-
_optionalChain([config, 'access',
|
|
3827
|
+
_optionalChain([config, 'access', _209 => _209.models, 'access', _210 => _210[modelId], 'optionalAccess', _211 => _211.records]) || [],
|
|
3550
3828
|
project
|
|
3551
3829
|
);
|
|
3552
3830
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -3565,14 +3843,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
3565
3843
|
},
|
|
3566
3844
|
async pull(locale, input2, initCtx) {
|
|
3567
3845
|
const result = {};
|
|
3568
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
3569
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
3846
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _212 => _212.models]) || {})) {
|
|
3847
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _213 => _213.models, 'access', _214 => _214[modelId], 'access', _215 => _215.records]) || [];
|
|
3570
3848
|
const recordIds = records.map((record) => record.id);
|
|
3571
3849
|
records = await dato.findRecords(recordIds);
|
|
3572
3850
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
3573
3851
|
if (records.length > 0) {
|
|
3574
3852
|
result[modelId] = {
|
|
3575
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
3853
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _216 => _216.models, 'optionalAccess', _217 => _217[modelId], 'optionalAccess', _218 => _218.fields]) || [],
|
|
3576
3854
|
records
|
|
3577
3855
|
};
|
|
3578
3856
|
}
|
|
@@ -3635,7 +3913,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
3635
3913
|
return records.map((record) => ({
|
|
3636
3914
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
3637
3915
|
value: record.id,
|
|
3638
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
3916
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _219 => _219.includes, 'call', _220 => _220(record.id)])
|
|
3639
3917
|
}));
|
|
3640
3918
|
}
|
|
3641
3919
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -3954,7 +4232,7 @@ function createVttLoader() {
|
|
|
3954
4232
|
if (!input2) {
|
|
3955
4233
|
return "";
|
|
3956
4234
|
}
|
|
3957
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
4235
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _221 => _221.parse, 'call', _222 => _222(input2), 'optionalAccess', _223 => _223.cues]);
|
|
3958
4236
|
if (Object.keys(vtt).length === 0) {
|
|
3959
4237
|
return {};
|
|
3960
4238
|
} else {
|
|
@@ -4008,7 +4286,7 @@ function variableExtractLoader(params) {
|
|
|
4008
4286
|
for (let i = 0; i < matches.length; i++) {
|
|
4009
4287
|
const match2 = matches[i];
|
|
4010
4288
|
const currentValue = result[key].value;
|
|
4011
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
4289
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _224 => _224.replace, 'call', _225 => _225(match2, `{variable:${i}}`)]);
|
|
4012
4290
|
result[key].value = newValue;
|
|
4013
4291
|
result[key].variables[i] = match2;
|
|
4014
4292
|
}
|
|
@@ -4022,7 +4300,7 @@ function variableExtractLoader(params) {
|
|
|
4022
4300
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
4023
4301
|
const variable = valueObj.variables[i];
|
|
4024
4302
|
const currentValue = result[key];
|
|
4025
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
4303
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _226 => _226.replace, 'call', _227 => _227(`{variable:${i}}`, variable)]);
|
|
4026
4304
|
result[key] = newValue;
|
|
4027
4305
|
}
|
|
4028
4306
|
}
|
|
@@ -4222,7 +4500,7 @@ function createVueJsonLoader() {
|
|
|
4222
4500
|
return createLoader({
|
|
4223
4501
|
pull: async (locale, input2, ctx) => {
|
|
4224
4502
|
const parsed = parseVueFile(input2);
|
|
4225
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
4503
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _228 => _228.i18n, 'optionalAccess', _229 => _229[locale]]), () => ( {}));
|
|
4226
4504
|
},
|
|
4227
4505
|
push: async (locale, data, originalInput) => {
|
|
4228
4506
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -4407,7 +4685,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
4407
4685
|
objectExpression.properties.forEach((prop) => {
|
|
4408
4686
|
if (!t.isObjectProperty(prop)) return;
|
|
4409
4687
|
const key = getPropertyKey(prop);
|
|
4410
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
4688
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _230 => _230[key]]);
|
|
4411
4689
|
if (incomingVal === void 0) {
|
|
4412
4690
|
return;
|
|
4413
4691
|
}
|
|
@@ -4443,7 +4721,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
4443
4721
|
let modified = false;
|
|
4444
4722
|
arrayExpression.elements.forEach((element, index) => {
|
|
4445
4723
|
if (!element) return;
|
|
4446
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
4724
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _231 => _231[index]]);
|
|
4447
4725
|
if (incomingVal === void 0) return;
|
|
4448
4726
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
4449
4727
|
if (element.value !== incomingVal) {
|
|
@@ -4934,7 +5212,7 @@ var AST = class _AST {
|
|
|
4934
5212
|
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
4935
5213
|
if (this.isStart() && !this.type)
|
|
4936
5214
|
ret.unshift([]);
|
|
4937
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
5215
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _232 => _232.#parent, 'optionalAccess', _233 => _233.type]) === "!")) {
|
|
4938
5216
|
ret.push({});
|
|
4939
5217
|
}
|
|
4940
5218
|
return ret;
|
|
@@ -4942,7 +5220,7 @@ var AST = class _AST {
|
|
|
4942
5220
|
isStart() {
|
|
4943
5221
|
if (this.#root === this)
|
|
4944
5222
|
return true;
|
|
4945
|
-
if (!_optionalChain([this, 'access',
|
|
5223
|
+
if (!_optionalChain([this, 'access', _234 => _234.#parent, 'optionalAccess', _235 => _235.isStart, 'call', _236 => _236()]))
|
|
4946
5224
|
return false;
|
|
4947
5225
|
if (this.#parentIndex === 0)
|
|
4948
5226
|
return true;
|
|
@@ -4958,12 +5236,12 @@ var AST = class _AST {
|
|
|
4958
5236
|
isEnd() {
|
|
4959
5237
|
if (this.#root === this)
|
|
4960
5238
|
return true;
|
|
4961
|
-
if (_optionalChain([this, 'access',
|
|
5239
|
+
if (_optionalChain([this, 'access', _237 => _237.#parent, 'optionalAccess', _238 => _238.type]) === "!")
|
|
4962
5240
|
return true;
|
|
4963
|
-
if (!_optionalChain([this, 'access',
|
|
5241
|
+
if (!_optionalChain([this, 'access', _239 => _239.#parent, 'optionalAccess', _240 => _240.isEnd, 'call', _241 => _241()]))
|
|
4964
5242
|
return false;
|
|
4965
5243
|
if (!this.type)
|
|
4966
|
-
return _optionalChain([this, 'access',
|
|
5244
|
+
return _optionalChain([this, 'access', _242 => _242.#parent, 'optionalAccess', _243 => _243.isEnd, 'call', _244 => _244()]);
|
|
4967
5245
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
4968
5246
|
return this.#parentIndex === pl - 1;
|
|
4969
5247
|
}
|
|
@@ -5208,7 +5486,7 @@ var AST = class _AST {
|
|
|
5208
5486
|
}
|
|
5209
5487
|
}
|
|
5210
5488
|
let end = "";
|
|
5211
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
5489
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _245 => _245.#parent, 'optionalAccess', _246 => _246.type]) === "!") {
|
|
5212
5490
|
end = "(?:$|\\/)";
|
|
5213
5491
|
}
|
|
5214
5492
|
const final2 = start2 + src + end;
|
|
@@ -6285,7 +6563,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
6285
6563
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
6286
6564
|
const result = {
|
|
6287
6565
|
frontmatter: data.frontmatter,
|
|
6288
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
6566
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _247 => _247.codePlaceholders]) || {},
|
|
6289
6567
|
content
|
|
6290
6568
|
};
|
|
6291
6569
|
return result;
|
|
@@ -6702,6 +6980,28 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
6702
6980
|
createSyncLoader(),
|
|
6703
6981
|
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
6704
6982
|
);
|
|
6983
|
+
case "json5":
|
|
6984
|
+
return composeLoaders(
|
|
6985
|
+
createTextFileLoader(bucketPathPattern),
|
|
6986
|
+
createJson5Loader(),
|
|
6987
|
+
createEnsureKeyOrderLoader(),
|
|
6988
|
+
createFlatLoader(),
|
|
6989
|
+
createInjectLocaleLoader(options.injectLocale),
|
|
6990
|
+
createLockedKeysLoader(lockedKeys || []),
|
|
6991
|
+
createSyncLoader(),
|
|
6992
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
6993
|
+
);
|
|
6994
|
+
case "jsonc":
|
|
6995
|
+
return composeLoaders(
|
|
6996
|
+
createTextFileLoader(bucketPathPattern),
|
|
6997
|
+
createJsoncLoader(),
|
|
6998
|
+
createEnsureKeyOrderLoader(),
|
|
6999
|
+
createFlatLoader(),
|
|
7000
|
+
createInjectLocaleLoader(options.injectLocale),
|
|
7001
|
+
createLockedKeysLoader(lockedKeys || []),
|
|
7002
|
+
createSyncLoader(),
|
|
7003
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
7004
|
+
);
|
|
6705
7005
|
case "markdown":
|
|
6706
7006
|
return composeLoaders(
|
|
6707
7007
|
createTextFileLoader(bucketPathPattern),
|
|
@@ -7000,7 +7300,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
7000
7300
|
]
|
|
7001
7301
|
});
|
|
7002
7302
|
const result = JSON.parse(response.text);
|
|
7003
|
-
return _optionalChain([result, 'optionalAccess',
|
|
7303
|
+
return _optionalChain([result, 'optionalAccess', _248 => _248.data]) || {};
|
|
7004
7304
|
}
|
|
7005
7305
|
}
|
|
7006
7306
|
function extractPayloadChunks(payload) {
|
|
@@ -7082,7 +7382,7 @@ function getPureModelProvider(provider) {
|
|
|
7082
7382
|
|
|
7083
7383
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
7084
7384
|
`;
|
|
7085
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
7385
|
+
switch (_optionalChain([provider, 'optionalAccess', _249 => _249.id])) {
|
|
7086
7386
|
case "openai": {
|
|
7087
7387
|
if (!process.env.OPENAI_API_KEY) {
|
|
7088
7388
|
throw new Error(
|
|
@@ -7140,7 +7440,7 @@ function getPureModelProvider(provider) {
|
|
|
7140
7440
|
})(provider.model);
|
|
7141
7441
|
}
|
|
7142
7442
|
default: {
|
|
7143
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
7443
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _250 => _250.id])));
|
|
7144
7444
|
}
|
|
7145
7445
|
}
|
|
7146
7446
|
}
|
|
@@ -7380,7 +7680,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7380
7680
|
validateParams(i18nConfig, flags);
|
|
7381
7681
|
ora.succeed("Localization configuration is valid");
|
|
7382
7682
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
7383
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
7683
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _251 => _251.provider]);
|
|
7384
7684
|
if (isByokMode) {
|
|
7385
7685
|
authId = null;
|
|
7386
7686
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -7394,16 +7694,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7394
7694
|
flags
|
|
7395
7695
|
});
|
|
7396
7696
|
let buckets = getBuckets(i18nConfig);
|
|
7397
|
-
if (_optionalChain([flags, 'access',
|
|
7697
|
+
if (_optionalChain([flags, 'access', _252 => _252.bucket, 'optionalAccess', _253 => _253.length])) {
|
|
7398
7698
|
buckets = buckets.filter(
|
|
7399
7699
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
7400
7700
|
);
|
|
7401
7701
|
}
|
|
7402
7702
|
ora.succeed("Buckets retrieved");
|
|
7403
|
-
if (_optionalChain([flags, 'access',
|
|
7703
|
+
if (_optionalChain([flags, 'access', _254 => _254.file, 'optionalAccess', _255 => _255.length])) {
|
|
7404
7704
|
buckets = buckets.map((bucket) => {
|
|
7405
7705
|
const paths = bucket.paths.filter(
|
|
7406
|
-
(path17) => flags.file.find((file) => _optionalChain([path17, 'access',
|
|
7706
|
+
(path17) => flags.file.find((file) => _optionalChain([path17, 'access', _256 => _256.pathPattern, 'optionalAccess', _257 => _257.includes, 'call', _258 => _258(file)]))
|
|
7407
7707
|
);
|
|
7408
7708
|
return { ...bucket, paths };
|
|
7409
7709
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -7422,7 +7722,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7422
7722
|
});
|
|
7423
7723
|
}
|
|
7424
7724
|
}
|
|
7425
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
7725
|
+
const targetLocales = _optionalChain([flags, 'access', _259 => _259.locale, 'optionalAccess', _260 => _260.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
7426
7726
|
ora.start("Setting up localization cache...");
|
|
7427
7727
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
7428
7728
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -7681,7 +7981,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7681
7981
|
}
|
|
7682
7982
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
7683
7983
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
7684
|
-
if (!_optionalChain([flags, 'access',
|
|
7984
|
+
if (!_optionalChain([flags, 'access', _261 => _261.locale, 'optionalAccess', _262 => _262.length])) {
|
|
7685
7985
|
await deltaProcessor.saveChecksums(checksums);
|
|
7686
7986
|
}
|
|
7687
7987
|
}
|
|
@@ -7765,12 +8065,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
7765
8065
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
7766
8066
|
docUrl: "bucketNotFound"
|
|
7767
8067
|
});
|
|
7768
|
-
} else if (_optionalChain([flags, 'access',
|
|
8068
|
+
} else if (_optionalChain([flags, 'access', _263 => _263.locale, 'optionalAccess', _264 => _264.some, 'call', _265 => _265((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
7769
8069
|
throw new CLIError({
|
|
7770
8070
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
7771
8071
|
docUrl: "localeTargetNotFound"
|
|
7772
8072
|
});
|
|
7773
|
-
} else if (_optionalChain([flags, 'access',
|
|
8073
|
+
} else if (_optionalChain([flags, 'access', _266 => _266.bucket, 'optionalAccess', _267 => _267.some, 'call', _268 => _268(
|
|
7774
8074
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
7775
8075
|
)])) {
|
|
7776
8076
|
throw new CLIError({
|
|
@@ -8274,7 +8574,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
8274
8574
|
const response = await engine.whoami();
|
|
8275
8575
|
return {
|
|
8276
8576
|
authenticated: !!response,
|
|
8277
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
8577
|
+
username: _optionalChain([response, 'optionalAccess', _269 => _269.email])
|
|
8278
8578
|
};
|
|
8279
8579
|
} catch (e2) {
|
|
8280
8580
|
return { authenticated: false };
|
|
@@ -8292,7 +8592,8 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
8292
8592
|
reference: {
|
|
8293
8593
|
[input2.sourceLocale]: input2.sourceData,
|
|
8294
8594
|
[input2.targetLocale]: input2.targetData
|
|
8295
|
-
}
|
|
8595
|
+
},
|
|
8596
|
+
hints: input2.hints
|
|
8296
8597
|
},
|
|
8297
8598
|
onProgress
|
|
8298
8599
|
);
|
|
@@ -8381,7 +8682,7 @@ function createExplicitLocalizer(provider) {
|
|
|
8381
8682
|
}
|
|
8382
8683
|
function createAiSdkLocalizer(params) {
|
|
8383
8684
|
const skipAuth = params.skipAuth === true;
|
|
8384
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
8685
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _270 => _270.apiKeyName]), () => ( ""))];
|
|
8385
8686
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
8386
8687
|
throw new Error(
|
|
8387
8688
|
_dedent2.default`
|
|
@@ -8506,8 +8807,8 @@ async function setup(input2) {
|
|
|
8506
8807
|
throw new Error(
|
|
8507
8808
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
8508
8809
|
);
|
|
8509
|
-
} else if (_optionalChain([ctx, 'access',
|
|
8510
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
8810
|
+
} else if (_optionalChain([ctx, 'access', _271 => _271.flags, 'access', _272 => _272.bucket, 'optionalAccess', _273 => _273.some, 'call', _274 => _274(
|
|
8811
|
+
(bucket) => !_optionalChain([ctx, 'access', _275 => _275.config, 'optionalAccess', _276 => _276.buckets, 'access', _277 => _277[bucket]])
|
|
8511
8812
|
)])) {
|
|
8512
8813
|
throw new Error(
|
|
8513
8814
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -8520,7 +8821,7 @@ async function setup(input2) {
|
|
|
8520
8821
|
title: "Selecting localization provider",
|
|
8521
8822
|
task: async (ctx, task) => {
|
|
8522
8823
|
ctx.localizer = createLocalizer(
|
|
8523
|
-
_optionalChain([ctx, 'access',
|
|
8824
|
+
_optionalChain([ctx, 'access', _278 => _278.config, 'optionalAccess', _279 => _279.provider]),
|
|
8524
8825
|
ctx.flags.apiKey
|
|
8525
8826
|
);
|
|
8526
8827
|
if (!ctx.localizer) {
|
|
@@ -8826,6 +9127,7 @@ function createWorkerTask(args) {
|
|
|
8826
9127
|
const sourceData = await bucketLoader.pull(
|
|
8827
9128
|
assignedTask.sourceLocale
|
|
8828
9129
|
);
|
|
9130
|
+
const hints = await bucketLoader.pullHints();
|
|
8829
9131
|
const targetData = await bucketLoader.pull(
|
|
8830
9132
|
assignedTask.targetLocale
|
|
8831
9133
|
);
|
|
@@ -8838,7 +9140,7 @@ function createWorkerTask(args) {
|
|
|
8838
9140
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
8839
9141
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
8840
9142
|
).filter(
|
|
8841
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
9143
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _280 => _280.onlyKeys, 'optionalAccess', _281 => _281.some, 'call', _282 => _282(
|
|
8842
9144
|
(pattern) => minimatch(key, pattern)
|
|
8843
9145
|
)])
|
|
8844
9146
|
).fromPairs().value();
|
|
@@ -8848,13 +9150,15 @@ function createWorkerTask(args) {
|
|
|
8848
9150
|
});
|
|
8849
9151
|
return { status: "skipped" };
|
|
8850
9152
|
}
|
|
9153
|
+
const relevantHints = _lodash2.default.pick(hints, Object.keys(processableData));
|
|
8851
9154
|
const processedTargetData = await args.ctx.localizer.localize(
|
|
8852
9155
|
{
|
|
8853
9156
|
sourceLocale: assignedTask.sourceLocale,
|
|
8854
9157
|
targetLocale: assignedTask.targetLocale,
|
|
8855
9158
|
sourceData,
|
|
8856
9159
|
targetData,
|
|
8857
|
-
processableData
|
|
9160
|
+
processableData,
|
|
9161
|
+
hints: relevantHints
|
|
8858
9162
|
},
|
|
8859
9163
|
async (progress, _sourceChunk, processedChunk) => {
|
|
8860
9164
|
await args.ioLimiter(async () => {
|
|
@@ -8899,7 +9203,7 @@ function createWorkerTask(args) {
|
|
|
8899
9203
|
finalRenamedTargetData
|
|
8900
9204
|
);
|
|
8901
9205
|
const checksums2 = await deltaProcessor.createChecksums(sourceData);
|
|
8902
|
-
if (!_optionalChain([args, 'access',
|
|
9206
|
+
if (!_optionalChain([args, 'access', _283 => _283.ctx, 'access', _284 => _284.flags, 'access', _285 => _285.targetLocale, 'optionalAccess', _286 => _286.length])) {
|
|
8903
9207
|
await deltaProcessor.saveChecksums(checksums2);
|
|
8904
9208
|
}
|
|
8905
9209
|
});
|
|
@@ -9089,13 +9393,13 @@ var flagsSchema2 = _zod.z.object({
|
|
|
9089
9393
|
|
|
9090
9394
|
// src/cli/cmd/run/_utils.ts
|
|
9091
9395
|
async function determineAuthId(ctx) {
|
|
9092
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
9396
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _287 => _287.config, 'optionalAccess', _288 => _288.provider]);
|
|
9093
9397
|
if (isByokMode) {
|
|
9094
9398
|
return null;
|
|
9095
9399
|
} else {
|
|
9096
9400
|
try {
|
|
9097
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
9098
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
9401
|
+
const authStatus = await _optionalChain([ctx, 'access', _289 => _289.localizer, 'optionalAccess', _290 => _290.checkAuth, 'call', _291 => _291()]);
|
|
9402
|
+
return _optionalChain([authStatus, 'optionalAccess', _292 => _292.username]) || null;
|
|
9099
9403
|
} catch (e3) {
|
|
9100
9404
|
return null;
|
|
9101
9405
|
}
|
|
@@ -9255,7 +9559,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
9255
9559
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
9256
9560
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
9257
9561
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
9258
|
-
_optionalChain([this, 'access',
|
|
9562
|
+
_optionalChain([this, 'access', _293 => _293.platformKit, 'optionalAccess', _294 => _294.gitConfig, 'call', _295 => _295()]);
|
|
9259
9563
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
9260
9564
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
9261
9565
|
if (!processOwnCommits) {
|
|
@@ -9287,7 +9591,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
9287
9591
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
9288
9592
|
var PullRequestFlow = class extends InBranchFlow {
|
|
9289
9593
|
async preRun() {
|
|
9290
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
9594
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _296 => _296()]);
|
|
9291
9595
|
if (!canContinue) {
|
|
9292
9596
|
return false;
|
|
9293
9597
|
}
|
|
@@ -9550,10 +9854,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
9550
9854
|
repo_slug: this.platformConfig.repositoryName,
|
|
9551
9855
|
state: "OPEN"
|
|
9552
9856
|
}).then(({ data: { values } }) => {
|
|
9553
|
-
return _optionalChain([values, 'optionalAccess',
|
|
9554
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
9857
|
+
return _optionalChain([values, 'optionalAccess', _297 => _297.find, 'call', _298 => _298(
|
|
9858
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _299 => _299.branch, 'optionalAccess', _300 => _300.name]) === branch && _optionalChain([destination, 'optionalAccess', _301 => _301.branch, 'optionalAccess', _302 => _302.name]) === this.platformConfig.baseBranchName
|
|
9555
9859
|
)]);
|
|
9556
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
9860
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _303 => _303.id]));
|
|
9557
9861
|
}
|
|
9558
9862
|
async closePullRequest({ pullRequestNumber }) {
|
|
9559
9863
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -9649,7 +9953,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
9649
9953
|
repo: this.platformConfig.repositoryName,
|
|
9650
9954
|
base: this.platformConfig.baseBranchName,
|
|
9651
9955
|
state: "open"
|
|
9652
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
9956
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _304 => _304.number]));
|
|
9653
9957
|
}
|
|
9654
9958
|
async closePullRequest({ pullRequestNumber }) {
|
|
9655
9959
|
await this.octokit.rest.pulls.update({
|
|
@@ -9776,7 +10080,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
9776
10080
|
sourceBranch: branch,
|
|
9777
10081
|
state: "opened"
|
|
9778
10082
|
});
|
|
9779
|
-
return _optionalChain([mergeRequests, 'access',
|
|
10083
|
+
return _optionalChain([mergeRequests, 'access', _305 => _305[0], 'optionalAccess', _306 => _306.iid]);
|
|
9780
10084
|
}
|
|
9781
10085
|
async closePullRequest({
|
|
9782
10086
|
pullRequestNumber
|
|
@@ -9866,7 +10170,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
9866
10170
|
}
|
|
9867
10171
|
const env = {
|
|
9868
10172
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
9869
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
10173
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _307 => _307.pullRequest, 'optionalAccess', _308 => _308.toString, 'call', _309 => _309()]) || "false",
|
|
9870
10174
|
...options.commitMessage && {
|
|
9871
10175
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
9872
10176
|
},
|
|
@@ -9886,7 +10190,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
9886
10190
|
const { isPullRequestMode } = platformKit.config;
|
|
9887
10191
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
9888
10192
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
9889
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
10193
|
+
const canRun = await _optionalChain([flow, 'access', _310 => _310.preRun, 'optionalCall', _311 => _311()]);
|
|
9890
10194
|
if (canRun === false) {
|
|
9891
10195
|
return;
|
|
9892
10196
|
}
|
|
@@ -9896,7 +10200,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
9896
10200
|
if (!hasChanges) {
|
|
9897
10201
|
return;
|
|
9898
10202
|
}
|
|
9899
|
-
await _optionalChain([flow, 'access',
|
|
10203
|
+
await _optionalChain([flow, 'access', _312 => _312.postRun, 'optionalCall', _313 => _313()]);
|
|
9900
10204
|
});
|
|
9901
10205
|
function parseBooleanArg(val) {
|
|
9902
10206
|
if (val === true) return true;
|
|
@@ -9965,17 +10269,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
9965
10269
|
flags
|
|
9966
10270
|
});
|
|
9967
10271
|
let buckets = getBuckets(i18nConfig);
|
|
9968
|
-
if (_optionalChain([flags, 'access',
|
|
10272
|
+
if (_optionalChain([flags, 'access', _314 => _314.bucket, 'optionalAccess', _315 => _315.length])) {
|
|
9969
10273
|
buckets = buckets.filter(
|
|
9970
10274
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
9971
10275
|
);
|
|
9972
10276
|
}
|
|
9973
10277
|
ora.succeed("Buckets retrieved");
|
|
9974
|
-
if (_optionalChain([flags, 'access',
|
|
10278
|
+
if (_optionalChain([flags, 'access', _316 => _316.file, 'optionalAccess', _317 => _317.length])) {
|
|
9975
10279
|
buckets = buckets.map((bucket) => {
|
|
9976
10280
|
const paths = bucket.paths.filter(
|
|
9977
10281
|
(path17) => flags.file.find(
|
|
9978
|
-
(file) => _optionalChain([path17, 'access',
|
|
10282
|
+
(file) => _optionalChain([path17, 'access', _318 => _318.pathPattern, 'optionalAccess', _319 => _319.includes, 'call', _320 => _320(file)]) || _optionalChain([path17, 'access', _321 => _321.pathPattern, 'optionalAccess', _322 => _322.match, 'call', _323 => _323(file)]) || minimatch(path17.pathPattern, file)
|
|
9979
10283
|
)
|
|
9980
10284
|
);
|
|
9981
10285
|
return { ...bucket, paths };
|
|
@@ -9995,7 +10299,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
9995
10299
|
});
|
|
9996
10300
|
}
|
|
9997
10301
|
}
|
|
9998
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
10302
|
+
const targetLocales = _optionalChain([flags, 'access', _324 => _324.locale, 'optionalAccess', _325 => _325.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
9999
10303
|
let totalSourceKeyCount = 0;
|
|
10000
10304
|
let uniqueKeysToTranslate = 0;
|
|
10001
10305
|
let totalExistingTranslations = 0;
|
|
@@ -10399,12 +10703,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
10399
10703
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
10400
10704
|
docUrl: "bucketNotFound"
|
|
10401
10705
|
});
|
|
10402
|
-
} else if (_optionalChain([flags, 'access',
|
|
10706
|
+
} else if (_optionalChain([flags, 'access', _326 => _326.locale, 'optionalAccess', _327 => _327.some, 'call', _328 => _328((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
10403
10707
|
throw new CLIError({
|
|
10404
10708
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
10405
10709
|
docUrl: "localeTargetNotFound"
|
|
10406
10710
|
});
|
|
10407
|
-
} else if (_optionalChain([flags, 'access',
|
|
10711
|
+
} else if (_optionalChain([flags, 'access', _329 => _329.bucket, 'optionalAccess', _330 => _330.some, 'call', _331 => _331(
|
|
10408
10712
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
10409
10713
|
)])) {
|
|
10410
10714
|
throw new CLIError({
|
|
@@ -10496,7 +10800,7 @@ async function renderHero2() {
|
|
|
10496
10800
|
// package.json
|
|
10497
10801
|
var package_default = {
|
|
10498
10802
|
name: "lingo.dev",
|
|
10499
|
-
version: "0.
|
|
10803
|
+
version: "0.109.1",
|
|
10500
10804
|
description: "Lingo.dev CLI",
|
|
10501
10805
|
private: false,
|
|
10502
10806
|
publishConfig: {
|
|
@@ -10660,6 +10964,7 @@ var package_default = {
|
|
|
10660
10964
|
"is-url": "^1.2.4",
|
|
10661
10965
|
jsdom: "^25.0.1",
|
|
10662
10966
|
json5: "^2.2.3",
|
|
10967
|
+
"jsonc-parser": "^3.3.1",
|
|
10663
10968
|
jsonrepair: "^3.11.2",
|
|
10664
10969
|
listr2: "^8.3.2",
|
|
10665
10970
|
lodash: "^4.17.21",
|
|
@@ -10772,7 +11077,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
10772
11077
|
if (options.file && options.file.length) {
|
|
10773
11078
|
buckets = buckets.map((bucket) => {
|
|
10774
11079
|
const paths = bucket.paths.filter(
|
|
10775
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
11080
|
+
(bucketPath) => _optionalChain([options, 'access', _332 => _332.file, 'optionalAccess', _333 => _333.some, 'call', _334 => _334((f) => bucketPath.pathPattern.includes(f))])
|
|
10776
11081
|
);
|
|
10777
11082
|
return { ...bucket, paths };
|
|
10778
11083
|
}).filter((bucket) => bucket.paths.length > 0);
|