lingo.dev 0.82.1 → 0.84.0
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 +245 -94
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +302 -151
- package/build/cli.mjs.map +1 -1
- package/package.json +18 -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', _26 => _26.auth, 'optionalAccess', _27 => _27.apiKey]) || defaults.auth.apiKey,
|
|
30
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _28 => _28.auth, 'optionalAccess', _29 => _29.apiUrl]) || defaults.auth.apiUrl,
|
|
31
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _30 => _30.auth, 'optionalAccess', _31 => _31.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', _32 => _32.auth, 'optionalAccess', _33 => _33.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', _34 => _34.email])) {
|
|
158
158
|
return null;
|
|
159
159
|
}
|
|
160
160
|
return {
|
|
@@ -774,7 +774,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
774
774
|
});
|
|
775
775
|
const auth2 = await newAuthenticator.whoami();
|
|
776
776
|
if (auth2) {
|
|
777
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
777
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _35 => _35.email])}`);
|
|
778
778
|
} else {
|
|
779
779
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
780
780
|
}
|
|
@@ -854,7 +854,7 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
854
854
|
function getBuckets(i18nConfig) {
|
|
855
855
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
856
856
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
857
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
857
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _36 => _36.exclude, 'optionalAccess', _37 => _37.map, 'call', _38 => _38((item) => resolveBucketItem(item))]);
|
|
858
858
|
const config = {
|
|
859
859
|
type: bucketType,
|
|
860
860
|
paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
@@ -878,7 +878,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
878
878
|
})
|
|
879
879
|
)
|
|
880
880
|
);
|
|
881
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
881
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _39 => _39.flatMap, 'call', _40 => _40(
|
|
882
882
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
883
883
|
(pathPattern) => ({
|
|
884
884
|
pathPattern,
|
|
@@ -1003,12 +1003,12 @@ function composeLoaders(...loaders) {
|
|
|
1003
1003
|
return {
|
|
1004
1004
|
init: async () => {
|
|
1005
1005
|
for (const loader of loaders) {
|
|
1006
|
-
await _optionalChain([loader, 'access',
|
|
1006
|
+
await _optionalChain([loader, 'access', _41 => _41.init, 'optionalCall', _42 => _42()]);
|
|
1007
1007
|
}
|
|
1008
1008
|
},
|
|
1009
1009
|
setDefaultLocale(locale) {
|
|
1010
1010
|
for (const loader of loaders) {
|
|
1011
|
-
_optionalChain([loader, 'access',
|
|
1011
|
+
_optionalChain([loader, 'access', _43 => _43.setDefaultLocale, 'optionalCall', _44 => _44(locale)]);
|
|
1012
1012
|
}
|
|
1013
1013
|
return this;
|
|
1014
1014
|
},
|
|
@@ -1039,7 +1039,7 @@ function createLoader(lDefinition) {
|
|
|
1039
1039
|
if (state.initCtx) {
|
|
1040
1040
|
return state.initCtx;
|
|
1041
1041
|
}
|
|
1042
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1042
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _45 => _45.init, 'optionalCall', _46 => _46()]);
|
|
1043
1043
|
return state.initCtx;
|
|
1044
1044
|
},
|
|
1045
1045
|
setDefaultLocale(locale) {
|
|
@@ -1128,7 +1128,7 @@ function createNormalizeLoader() {
|
|
|
1128
1128
|
return normalized;
|
|
1129
1129
|
},
|
|
1130
1130
|
push: async (locale, data, originalInput) => {
|
|
1131
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1131
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _47 => _47.keysMap]), () => ( {}));
|
|
1132
1132
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1133
1133
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1134
1134
|
delimiter: "/",
|
|
@@ -1202,7 +1202,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1202
1202
|
const trimmedResult = result.trim();
|
|
1203
1203
|
return trimmedResult;
|
|
1204
1204
|
},
|
|
1205
|
-
async push(locale, data,
|
|
1205
|
+
async push(locale, data, _25, originalLocale) {
|
|
1206
1206
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1207
1207
|
const finalPath = path15.default.resolve(draftPath);
|
|
1208
1208
|
const dirPath = path15.default.dirname(finalPath);
|
|
@@ -1231,8 +1231,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1231
1231
|
if (!templateData) {
|
|
1232
1232
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1233
1233
|
}
|
|
1234
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1235
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1234
|
+
if (_optionalChain([templateData, 'optionalAccess', _48 => _48.match, 'call', _49 => _49(/[\r\n]$/)])) {
|
|
1235
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _50 => _50.includes, 'call', _51 => _51("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _52 => _52.includes, 'call', _53 => _53("\r")]) ? "\r" : "\n";
|
|
1236
1236
|
return ending;
|
|
1237
1237
|
}
|
|
1238
1238
|
return "";
|
|
@@ -1487,7 +1487,7 @@ function createHtmlLoader() {
|
|
|
1487
1487
|
break;
|
|
1488
1488
|
}
|
|
1489
1489
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1490
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1490
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _54 => _54.textContent, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()])
|
|
1491
1491
|
);
|
|
1492
1492
|
const index = siblings.indexOf(current);
|
|
1493
1493
|
if (index !== -1) {
|
|
@@ -1522,11 +1522,11 @@ function createHtmlLoader() {
|
|
|
1522
1522
|
result[getPath(element, attr)] = value;
|
|
1523
1523
|
}
|
|
1524
1524
|
});
|
|
1525
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1525
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _57 => _57.textContent, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()])).forEach(processNode);
|
|
1526
1526
|
}
|
|
1527
1527
|
};
|
|
1528
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1529
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1528
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _60 => _60.textContent, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()])).forEach(processNode);
|
|
1529
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _63 => _63.textContent, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()])).forEach(processNode);
|
|
1530
1530
|
return result;
|
|
1531
1531
|
},
|
|
1532
1532
|
async push(locale, data, originalInput) {
|
|
@@ -1548,7 +1548,7 @@ function createHtmlLoader() {
|
|
|
1548
1548
|
for (let i = 0; i < indices.length; i++) {
|
|
1549
1549
|
const index = parseInt(indices[i]);
|
|
1550
1550
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1551
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1551
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _66 => _66.textContent, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()])
|
|
1552
1552
|
);
|
|
1553
1553
|
if (index >= siblings.length) {
|
|
1554
1554
|
if (i === indices.length - 1) {
|
|
@@ -1599,7 +1599,7 @@ function createMarkdownLoader() {
|
|
|
1599
1599
|
yaml: yamlEngine
|
|
1600
1600
|
}
|
|
1601
1601
|
});
|
|
1602
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
1602
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()]), () => ( ""))).filter(Boolean);
|
|
1603
1603
|
return {
|
|
1604
1604
|
...Object.fromEntries(
|
|
1605
1605
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -1611,7 +1611,7 @@ function createMarkdownLoader() {
|
|
|
1611
1611
|
const frontmatter = Object.fromEntries(
|
|
1612
1612
|
Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
|
|
1613
1613
|
);
|
|
1614
|
-
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',
|
|
1614
|
+
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', _71 => _71.trim, 'call', _72 => _72()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
1615
1615
|
if (Object.keys(frontmatter).length > 0) {
|
|
1616
1616
|
content = `
|
|
1617
1617
|
${content}`;
|
|
@@ -1625,6 +1625,58 @@ ${content}`;
|
|
|
1625
1625
|
});
|
|
1626
1626
|
}
|
|
1627
1627
|
|
|
1628
|
+
// src/cli/loaders/mdx.ts
|
|
1629
|
+
|
|
1630
|
+
var _unified = require('unified');
|
|
1631
|
+
var _remarkparse = require('remark-parse'); var _remarkparse2 = _interopRequireDefault(_remarkparse);
|
|
1632
|
+
var _remarkmdx = require('remark-mdx'); var _remarkmdx2 = _interopRequireDefault(_remarkmdx);
|
|
1633
|
+
var _remarkfrontmatter = require('remark-frontmatter'); var _remarkfrontmatter2 = _interopRequireDefault(_remarkfrontmatter);
|
|
1634
|
+
var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
|
|
1635
|
+
var _remarkstringify = require('remark-stringify'); var _remarkstringify2 = _interopRequireDefault(_remarkstringify);
|
|
1636
|
+
var _remarkmdxfrontmatter = require('remark-mdx-frontmatter'); var _remarkmdxfrontmatter2 = _interopRequireDefault(_remarkmdxfrontmatter);
|
|
1637
|
+
var _vfile = require('vfile');
|
|
1638
|
+
var parser = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkmdx2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkmdxfrontmatter2.default).use(_remarkgfm2.default);
|
|
1639
|
+
var serializer = _unified.unified.call(void 0, ).use(_remarkstringify2.default).use(_remarkmdx2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkmdxfrontmatter2.default).use(_remarkgfm2.default);
|
|
1640
|
+
function createMdxFormatLoader() {
|
|
1641
|
+
return createLoader({
|
|
1642
|
+
async pull(locale, input2) {
|
|
1643
|
+
const file = new (0, _vfile.VFile)(input2);
|
|
1644
|
+
const ast = parser.parse(file);
|
|
1645
|
+
return JSON.parse(JSON.stringify(ast));
|
|
1646
|
+
},
|
|
1647
|
+
async push(locale, data) {
|
|
1648
|
+
const ast = data;
|
|
1649
|
+
const content = String(serializer.stringify(ast));
|
|
1650
|
+
return content;
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
function createDoubleSerializationLoader() {
|
|
1655
|
+
return createLoader({
|
|
1656
|
+
async pull(locale, input2) {
|
|
1657
|
+
return input2;
|
|
1658
|
+
},
|
|
1659
|
+
async push(locale, data) {
|
|
1660
|
+
const file = new (0, _vfile.VFile)(data);
|
|
1661
|
+
const ast = parser.parse(file);
|
|
1662
|
+
const finalContent = String(serializer.stringify(ast));
|
|
1663
|
+
return finalContent;
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
function createMdxStructureLoader() {
|
|
1668
|
+
return createLoader({
|
|
1669
|
+
async pull(locale, input2) {
|
|
1670
|
+
const result = _lodash2.default.chain(input2).pickBy((value, key) => key.endsWith("/value")).value();
|
|
1671
|
+
return result;
|
|
1672
|
+
},
|
|
1673
|
+
async push(locale, data, originalInput) {
|
|
1674
|
+
const result = _lodash2.default.merge({}, originalInput, data);
|
|
1675
|
+
return result;
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1628
1680
|
// src/cli/loaders/properties.ts
|
|
1629
1681
|
function createPropertiesLoader() {
|
|
1630
1682
|
return createLoader({
|
|
@@ -1644,7 +1696,7 @@ function createPropertiesLoader() {
|
|
|
1644
1696
|
return result;
|
|
1645
1697
|
},
|
|
1646
1698
|
async push(locale, payload) {
|
|
1647
|
-
const result = Object.entries(payload).filter(([
|
|
1699
|
+
const result = Object.entries(payload).filter(([_25, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1648
1700
|
return result;
|
|
1649
1701
|
}
|
|
1650
1702
|
});
|
|
@@ -1655,7 +1707,7 @@ function isSkippableLine(line) {
|
|
|
1655
1707
|
function parsePropertyLine(line) {
|
|
1656
1708
|
const [key, ...valueParts] = line.split("=");
|
|
1657
1709
|
return {
|
|
1658
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1710
|
+
key: _optionalChain([key, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]) || "",
|
|
1659
1711
|
value: valueParts.join("=").trim()
|
|
1660
1712
|
};
|
|
1661
1713
|
}
|
|
@@ -1741,7 +1793,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1741
1793
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
1742
1794
|
continue;
|
|
1743
1795
|
}
|
|
1744
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1796
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _75 => _75.localizations, 'optionalAccess', _76 => _76[locale]]);
|
|
1745
1797
|
if (langTranslationEntity) {
|
|
1746
1798
|
if ("stringUnit" in langTranslationEntity) {
|
|
1747
1799
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1750,7 +1802,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1750
1802
|
resultData[translationKey] = {};
|
|
1751
1803
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1752
1804
|
for (const form in pluralForms) {
|
|
1753
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1805
|
+
if (_optionalChain([pluralForms, 'access', _77 => _77[form], 'optionalAccess', _78 => _78.stringUnit, 'optionalAccess', _79 => _79.value])) {
|
|
1754
1806
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1755
1807
|
}
|
|
1756
1808
|
}
|
|
@@ -1774,7 +1826,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1774
1826
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
1775
1827
|
if (typeof value === "string") {
|
|
1776
1828
|
langDataToMerge.strings[key] = {
|
|
1777
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
1829
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _80 => _80.strings, 'optionalAccess', _81 => _81[key], 'optionalAccess', _82 => _82.extractionState]),
|
|
1778
1830
|
localizations: {
|
|
1779
1831
|
[locale]: {
|
|
1780
1832
|
stringUnit: {
|
|
@@ -1893,10 +1945,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
1893
1945
|
}
|
|
1894
1946
|
}
|
|
1895
1947
|
return false;
|
|
1896
|
-
}).map(([key,
|
|
1897
|
-
const result = _lodash2.default.omitBy(input2, (
|
|
1948
|
+
}).map(([key, _25]) => key);
|
|
1949
|
+
const result = _lodash2.default.omitBy(input2, (_25, key) => passthroughKeys.includes(key));
|
|
1898
1950
|
if (returnUnlocalizedKeys) {
|
|
1899
|
-
result.unlocalizable = _lodash2.default.omitBy(input2, (
|
|
1951
|
+
result.unlocalizable = _lodash2.default.omitBy(input2, (_25, key) => !passthroughKeys.includes(key));
|
|
1900
1952
|
}
|
|
1901
1953
|
return result;
|
|
1902
1954
|
},
|
|
@@ -1935,7 +1987,7 @@ function createPoDataLoader(params) {
|
|
|
1935
1987
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1936
1988
|
if (msgid && entry.msgid) {
|
|
1937
1989
|
const context = entry.msgctxt || "";
|
|
1938
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1990
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _83 => _83.translations, 'access', _84 => _84[context], 'optionalAccess', _85 => _85[msgid]]);
|
|
1939
1991
|
if (fullEntry) {
|
|
1940
1992
|
result[msgid] = fullEntry;
|
|
1941
1993
|
}
|
|
@@ -1945,7 +1997,7 @@ function createPoDataLoader(params) {
|
|
|
1945
1997
|
return result;
|
|
1946
1998
|
},
|
|
1947
1999
|
async push(locale, data, originalInput) {
|
|
1948
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
2000
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _86 => _86.split, 'call', _87 => _87("\n\n"), 'access', _88 => _88.filter, 'call', _89 => _89(Boolean)]) || [];
|
|
1949
2001
|
const result = sections.map((section) => {
|
|
1950
2002
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1951
2003
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1987,7 +2039,7 @@ function createPoContentLoader() {
|
|
|
1987
2039
|
entry.msgid,
|
|
1988
2040
|
{
|
|
1989
2041
|
...entry,
|
|
1990
|
-
msgstr: [_optionalChain([data, 'access',
|
|
2042
|
+
msgstr: [_optionalChain([data, 'access', _90 => _90[entry.msgid], 'optionalAccess', _91 => _91.singular]), _optionalChain([data, 'access', _92 => _92[entry.msgid], 'optionalAccess', _93 => _93.plural]) || null].filter(Boolean)
|
|
1991
2043
|
}
|
|
1992
2044
|
]).fromPairs().value();
|
|
1993
2045
|
return result;
|
|
@@ -2053,10 +2105,10 @@ function createXmlLoader() {
|
|
|
2053
2105
|
// src/cli/loaders/srt.ts
|
|
2054
2106
|
var _srtparser2 = require('srt-parser-2'); var _srtparser22 = _interopRequireDefault(_srtparser2);
|
|
2055
2107
|
function createSrtLoader() {
|
|
2056
|
-
const
|
|
2108
|
+
const parser2 = new (0, _srtparser22.default)();
|
|
2057
2109
|
return createLoader({
|
|
2058
2110
|
async pull(locale, input2) {
|
|
2059
|
-
const parsed =
|
|
2111
|
+
const parsed = parser2.fromSrt(input2) || [];
|
|
2060
2112
|
const result = {};
|
|
2061
2113
|
parsed.forEach((entry) => {
|
|
2062
2114
|
const key = `${entry.id}#${entry.startTime}-${entry.endTime}`;
|
|
@@ -2077,7 +2129,7 @@ function createSrtLoader() {
|
|
|
2077
2129
|
text
|
|
2078
2130
|
};
|
|
2079
2131
|
});
|
|
2080
|
-
const srtContent =
|
|
2132
|
+
const srtContent = parser2.toSrt(output).trim().replace(/\r?\n/g, "\n");
|
|
2081
2133
|
return srtContent;
|
|
2082
2134
|
}
|
|
2083
2135
|
});
|
|
@@ -2233,7 +2285,7 @@ function createDatoClient(params) {
|
|
|
2233
2285
|
only_valid: "true",
|
|
2234
2286
|
ids: !records.length ? void 0 : records.join(",")
|
|
2235
2287
|
}
|
|
2236
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2288
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _94 => _94.response, 'optionalAccess', _95 => _95.body, 'optionalAccess', _96 => _96.data, 'optionalAccess', _97 => _97[0]]) || error));
|
|
2237
2289
|
},
|
|
2238
2290
|
findRecordsForModel: async (modelId, records) => {
|
|
2239
2291
|
try {
|
|
@@ -2243,9 +2295,9 @@ function createDatoClient(params) {
|
|
|
2243
2295
|
filter: {
|
|
2244
2296
|
type: modelId,
|
|
2245
2297
|
only_valid: "true",
|
|
2246
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2298
|
+
ids: !_optionalChain([records, 'optionalAccess', _98 => _98.length]) ? void 0 : records.join(",")
|
|
2247
2299
|
}
|
|
2248
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2300
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _99 => _99.response, 'optionalAccess', _100 => _100.body, 'optionalAccess', _101 => _101.data, 'optionalAccess', _102 => _102[0]]) || error));
|
|
2249
2301
|
return result;
|
|
2250
2302
|
} catch (_error) {
|
|
2251
2303
|
throw new Error(
|
|
@@ -2259,9 +2311,9 @@ function createDatoClient(params) {
|
|
|
2259
2311
|
},
|
|
2260
2312
|
updateRecord: async (id, payload) => {
|
|
2261
2313
|
try {
|
|
2262
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2314
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _103 => _103.response, 'optionalAccess', _104 => _104.body, 'optionalAccess', _105 => _105.data, 'optionalAccess', _106 => _106[0]]) || error));
|
|
2263
2315
|
} catch (_error) {
|
|
2264
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2316
|
+
if (_optionalChain([_error, 'optionalAccess', _107 => _107.attributes, 'optionalAccess', _108 => _108.details, 'optionalAccess', _109 => _109.message])) {
|
|
2265
2317
|
throw new Error(
|
|
2266
2318
|
[
|
|
2267
2319
|
`${_error.attributes.details.message}`,
|
|
@@ -2282,9 +2334,9 @@ function createDatoClient(params) {
|
|
|
2282
2334
|
},
|
|
2283
2335
|
enableFieldLocalization: async (args) => {
|
|
2284
2336
|
try {
|
|
2285
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2337
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _110 => _110.response, 'optionalAccess', _111 => _111.body, 'optionalAccess', _112 => _112.data, 'optionalAccess', _113 => _113[0]]) || error));
|
|
2286
2338
|
} catch (_error) {
|
|
2287
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2339
|
+
if (_optionalChain([_error, 'optionalAccess', _114 => _114.attributes, 'optionalAccess', _115 => _115.code]) === "NOT_FOUND") {
|
|
2288
2340
|
throw new Error(
|
|
2289
2341
|
[
|
|
2290
2342
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2292,7 +2344,7 @@ function createDatoClient(params) {
|
|
|
2292
2344
|
].join("\n\n")
|
|
2293
2345
|
);
|
|
2294
2346
|
}
|
|
2295
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2347
|
+
if (_optionalChain([_error, 'optionalAccess', _116 => _116.attributes, 'optionalAccess', _117 => _117.details, 'optionalAccess', _118 => _118.message])) {
|
|
2296
2348
|
throw new Error(
|
|
2297
2349
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2298
2350
|
);
|
|
@@ -2358,7 +2410,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2358
2410
|
}
|
|
2359
2411
|
}
|
|
2360
2412
|
const records = await dato.findRecordsForModel(modelId);
|
|
2361
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2413
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _119 => _119.models, 'access', _120 => _120[modelId], 'optionalAccess', _121 => _121.records]) || [], project);
|
|
2362
2414
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2363
2415
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2364
2416
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2370,14 +2422,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2370
2422
|
},
|
|
2371
2423
|
async pull(locale, input2, initCtx) {
|
|
2372
2424
|
const result = {};
|
|
2373
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2374
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2425
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _122 => _122.models]) || {})) {
|
|
2426
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _123 => _123.models, 'access', _124 => _124[modelId], 'access', _125 => _125.records]) || [];
|
|
2375
2427
|
const recordIds = records.map((record) => record.id);
|
|
2376
2428
|
records = await dato.findRecords(recordIds);
|
|
2377
2429
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2378
2430
|
if (records.length > 0) {
|
|
2379
2431
|
result[modelId] = {
|
|
2380
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2432
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _126 => _126.models, 'optionalAccess', _127 => _127[modelId], 'optionalAccess', _128 => _128.fields]) || [],
|
|
2381
2433
|
records
|
|
2382
2434
|
};
|
|
2383
2435
|
}
|
|
@@ -2436,7 +2488,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2436
2488
|
return records.map((record) => ({
|
|
2437
2489
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2438
2490
|
value: record.id,
|
|
2439
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2491
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _129 => _129.includes, 'call', _130 => _130(record.id)])
|
|
2440
2492
|
}));
|
|
2441
2493
|
}
|
|
2442
2494
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2703,7 +2755,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2703
2755
|
function createVttLoader() {
|
|
2704
2756
|
return createLoader({
|
|
2705
2757
|
async pull(locale, input2) {
|
|
2706
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2758
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _131 => _131.parse, 'call', _132 => _132(input2), 'optionalAccess', _133 => _133.cues]);
|
|
2707
2759
|
if (Object.keys(vtt).length === 0) {
|
|
2708
2760
|
return {};
|
|
2709
2761
|
} else {
|
|
@@ -2756,7 +2808,7 @@ function variableExtractLoader(params) {
|
|
|
2756
2808
|
for (let i = 0; i < matches.length; i++) {
|
|
2757
2809
|
const match = matches[i];
|
|
2758
2810
|
const currentValue = result[key].value;
|
|
2759
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2811
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _134 => _134.replace, 'call', _135 => _135(match, `{variable:${i}}`)]);
|
|
2760
2812
|
result[key].value = newValue;
|
|
2761
2813
|
result[key].variables[i] = match;
|
|
2762
2814
|
}
|
|
@@ -2770,7 +2822,7 @@ function variableExtractLoader(params) {
|
|
|
2770
2822
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2771
2823
|
const variable = valueObj.variables[i];
|
|
2772
2824
|
const currentValue = result[key];
|
|
2773
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2825
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _136 => _136.replace, 'call', _137 => _137(`{variable:${i}}`, variable)]);
|
|
2774
2826
|
result[key] = newValue;
|
|
2775
2827
|
}
|
|
2776
2828
|
}
|
|
@@ -2951,7 +3003,7 @@ function createVueJsonLoader() {
|
|
|
2951
3003
|
return createLoader({
|
|
2952
3004
|
pull: async (locale, input2, ctx) => {
|
|
2953
3005
|
const parsed = parseVueFile(input2);
|
|
2954
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
3006
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _138 => _138.i18n, 'optionalAccess', _139 => _139[locale]]), () => ( {}));
|
|
2955
3007
|
},
|
|
2956
3008
|
push: async (locale, data, originalInput) => {
|
|
2957
3009
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -3036,7 +3088,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3036
3088
|
createAndroidLoader(),
|
|
3037
3089
|
createFlatLoader(),
|
|
3038
3090
|
createSyncLoader(),
|
|
3039
|
-
createUnlocalizableLoader(
|
|
3091
|
+
createUnlocalizableLoader(
|
|
3092
|
+
options.isCacheRestore,
|
|
3093
|
+
options.returnUnlocalizedKeys
|
|
3094
|
+
)
|
|
3040
3095
|
);
|
|
3041
3096
|
case "csv":
|
|
3042
3097
|
return composeLoaders(
|
|
@@ -3044,7 +3099,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3044
3099
|
createCsvLoader(),
|
|
3045
3100
|
createFlatLoader(),
|
|
3046
3101
|
createSyncLoader(),
|
|
3047
|
-
createUnlocalizableLoader(
|
|
3102
|
+
createUnlocalizableLoader(
|
|
3103
|
+
options.isCacheRestore,
|
|
3104
|
+
options.returnUnlocalizedKeys
|
|
3105
|
+
)
|
|
3048
3106
|
);
|
|
3049
3107
|
case "html":
|
|
3050
3108
|
return composeLoaders(
|
|
@@ -3052,7 +3110,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3052
3110
|
createPrettierLoader({ parser: "html", bucketPathPattern }),
|
|
3053
3111
|
createHtmlLoader(),
|
|
3054
3112
|
createSyncLoader(),
|
|
3055
|
-
createUnlocalizableLoader(
|
|
3113
|
+
createUnlocalizableLoader(
|
|
3114
|
+
options.isCacheRestore,
|
|
3115
|
+
options.returnUnlocalizedKeys
|
|
3116
|
+
)
|
|
3056
3117
|
);
|
|
3057
3118
|
case "json":
|
|
3058
3119
|
return composeLoaders(
|
|
@@ -3063,7 +3124,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3063
3124
|
createFlatLoader(),
|
|
3064
3125
|
createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
|
|
3065
3126
|
createSyncLoader(),
|
|
3066
|
-
createUnlocalizableLoader(
|
|
3127
|
+
createUnlocalizableLoader(
|
|
3128
|
+
options.isCacheRestore,
|
|
3129
|
+
options.returnUnlocalizedKeys
|
|
3130
|
+
)
|
|
3067
3131
|
);
|
|
3068
3132
|
case "markdown":
|
|
3069
3133
|
return composeLoaders(
|
|
@@ -3071,6 +3135,33 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3071
3135
|
createPrettierLoader({ parser: "markdown", bucketPathPattern }),
|
|
3072
3136
|
createMarkdownLoader(),
|
|
3073
3137
|
createSyncLoader(),
|
|
3138
|
+
createUnlocalizableLoader(
|
|
3139
|
+
options.isCacheRestore,
|
|
3140
|
+
options.returnUnlocalizedKeys
|
|
3141
|
+
)
|
|
3142
|
+
);
|
|
3143
|
+
case "mdx":
|
|
3144
|
+
return composeLoaders(
|
|
3145
|
+
createTextFileLoader(bucketPathPattern),
|
|
3146
|
+
createDoubleSerializationLoader(),
|
|
3147
|
+
createPrettierLoader({ parser: "mdx", bucketPathPattern }),
|
|
3148
|
+
createMdxFormatLoader(),
|
|
3149
|
+
createFlatLoader(),
|
|
3150
|
+
createMdxStructureLoader(),
|
|
3151
|
+
createSyncLoader(),
|
|
3152
|
+
createUnlocalizableLoader(
|
|
3153
|
+
options.isCacheRestore,
|
|
3154
|
+
options.returnUnlocalizedKeys
|
|
3155
|
+
)
|
|
3156
|
+
);
|
|
3157
|
+
case "mdx":
|
|
3158
|
+
return composeLoaders(
|
|
3159
|
+
createTextFileLoader(bucketPathPattern),
|
|
3160
|
+
createPrettierLoader({ parser: "mdx", bucketPathPattern }),
|
|
3161
|
+
createMdxFormatLoader(),
|
|
3162
|
+
createFlatLoader(),
|
|
3163
|
+
createMdxStructureLoader(),
|
|
3164
|
+
createSyncLoader(),
|
|
3074
3165
|
createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
|
|
3075
3166
|
);
|
|
3076
3167
|
case "po":
|
|
@@ -3080,21 +3171,30 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3080
3171
|
createFlatLoader(),
|
|
3081
3172
|
createSyncLoader(),
|
|
3082
3173
|
createVariableLoader({ type: "python" }),
|
|
3083
|
-
createUnlocalizableLoader(
|
|
3174
|
+
createUnlocalizableLoader(
|
|
3175
|
+
options.isCacheRestore,
|
|
3176
|
+
options.returnUnlocalizedKeys
|
|
3177
|
+
)
|
|
3084
3178
|
);
|
|
3085
3179
|
case "properties":
|
|
3086
3180
|
return composeLoaders(
|
|
3087
3181
|
createTextFileLoader(bucketPathPattern),
|
|
3088
3182
|
createPropertiesLoader(),
|
|
3089
3183
|
createSyncLoader(),
|
|
3090
|
-
createUnlocalizableLoader(
|
|
3184
|
+
createUnlocalizableLoader(
|
|
3185
|
+
options.isCacheRestore,
|
|
3186
|
+
options.returnUnlocalizedKeys
|
|
3187
|
+
)
|
|
3091
3188
|
);
|
|
3092
3189
|
case "xcode-strings":
|
|
3093
3190
|
return composeLoaders(
|
|
3094
3191
|
createTextFileLoader(bucketPathPattern),
|
|
3095
3192
|
createXcodeStringsLoader(),
|
|
3096
3193
|
createSyncLoader(),
|
|
3097
|
-
createUnlocalizableLoader(
|
|
3194
|
+
createUnlocalizableLoader(
|
|
3195
|
+
options.isCacheRestore,
|
|
3196
|
+
options.returnUnlocalizedKeys
|
|
3197
|
+
)
|
|
3098
3198
|
);
|
|
3099
3199
|
case "xcode-stringsdict":
|
|
3100
3200
|
return composeLoaders(
|
|
@@ -3102,7 +3202,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3102
3202
|
createXcodeStringsdictLoader(),
|
|
3103
3203
|
createFlatLoader(),
|
|
3104
3204
|
createSyncLoader(),
|
|
3105
|
-
createUnlocalizableLoader(
|
|
3205
|
+
createUnlocalizableLoader(
|
|
3206
|
+
options.isCacheRestore,
|
|
3207
|
+
options.returnUnlocalizedKeys
|
|
3208
|
+
)
|
|
3106
3209
|
);
|
|
3107
3210
|
case "xcode-xcstrings":
|
|
3108
3211
|
return composeLoaders(
|
|
@@ -3113,7 +3216,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3113
3216
|
createFlatLoader(),
|
|
3114
3217
|
createSyncLoader(),
|
|
3115
3218
|
createVariableLoader({ type: "ieee" }),
|
|
3116
|
-
createUnlocalizableLoader(
|
|
3219
|
+
createUnlocalizableLoader(
|
|
3220
|
+
options.isCacheRestore,
|
|
3221
|
+
options.returnUnlocalizedKeys
|
|
3222
|
+
)
|
|
3117
3223
|
);
|
|
3118
3224
|
case "yaml":
|
|
3119
3225
|
return composeLoaders(
|
|
@@ -3123,7 +3229,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3123
3229
|
createFlatLoader(),
|
|
3124
3230
|
createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
|
|
3125
3231
|
createSyncLoader(),
|
|
3126
|
-
createUnlocalizableLoader(
|
|
3232
|
+
createUnlocalizableLoader(
|
|
3233
|
+
options.isCacheRestore,
|
|
3234
|
+
options.returnUnlocalizedKeys
|
|
3235
|
+
)
|
|
3127
3236
|
);
|
|
3128
3237
|
case "yaml-root-key":
|
|
3129
3238
|
return composeLoaders(
|
|
@@ -3133,7 +3242,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3133
3242
|
createRootKeyLoader(true),
|
|
3134
3243
|
createFlatLoader(),
|
|
3135
3244
|
createSyncLoader(),
|
|
3136
|
-
createUnlocalizableLoader(
|
|
3245
|
+
createUnlocalizableLoader(
|
|
3246
|
+
options.isCacheRestore,
|
|
3247
|
+
options.returnUnlocalizedKeys
|
|
3248
|
+
)
|
|
3137
3249
|
);
|
|
3138
3250
|
case "flutter":
|
|
3139
3251
|
return composeLoaders(
|
|
@@ -3143,7 +3255,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3143
3255
|
createFlutterLoader(),
|
|
3144
3256
|
createFlatLoader(),
|
|
3145
3257
|
createSyncLoader(),
|
|
3146
|
-
createUnlocalizableLoader(
|
|
3258
|
+
createUnlocalizableLoader(
|
|
3259
|
+
options.isCacheRestore,
|
|
3260
|
+
options.returnUnlocalizedKeys
|
|
3261
|
+
)
|
|
3147
3262
|
);
|
|
3148
3263
|
case "xliff":
|
|
3149
3264
|
return composeLoaders(
|
|
@@ -3151,7 +3266,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3151
3266
|
createXliffLoader(),
|
|
3152
3267
|
createFlatLoader(),
|
|
3153
3268
|
createSyncLoader(),
|
|
3154
|
-
createUnlocalizableLoader(
|
|
3269
|
+
createUnlocalizableLoader(
|
|
3270
|
+
options.isCacheRestore,
|
|
3271
|
+
options.returnUnlocalizedKeys
|
|
3272
|
+
)
|
|
3155
3273
|
);
|
|
3156
3274
|
case "xml":
|
|
3157
3275
|
return composeLoaders(
|
|
@@ -3159,28 +3277,40 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3159
3277
|
createXmlLoader(),
|
|
3160
3278
|
createFlatLoader(),
|
|
3161
3279
|
createSyncLoader(),
|
|
3162
|
-
createUnlocalizableLoader(
|
|
3280
|
+
createUnlocalizableLoader(
|
|
3281
|
+
options.isCacheRestore,
|
|
3282
|
+
options.returnUnlocalizedKeys
|
|
3283
|
+
)
|
|
3163
3284
|
);
|
|
3164
3285
|
case "srt":
|
|
3165
3286
|
return composeLoaders(
|
|
3166
3287
|
createTextFileLoader(bucketPathPattern),
|
|
3167
3288
|
createSrtLoader(),
|
|
3168
3289
|
createSyncLoader(),
|
|
3169
|
-
createUnlocalizableLoader(
|
|
3290
|
+
createUnlocalizableLoader(
|
|
3291
|
+
options.isCacheRestore,
|
|
3292
|
+
options.returnUnlocalizedKeys
|
|
3293
|
+
)
|
|
3170
3294
|
);
|
|
3171
3295
|
case "dato":
|
|
3172
3296
|
return composeLoaders(
|
|
3173
3297
|
createDatoLoader(bucketPathPattern),
|
|
3174
3298
|
createSyncLoader(),
|
|
3175
3299
|
createFlatLoader(),
|
|
3176
|
-
createUnlocalizableLoader(
|
|
3300
|
+
createUnlocalizableLoader(
|
|
3301
|
+
options.isCacheRestore,
|
|
3302
|
+
options.returnUnlocalizedKeys
|
|
3303
|
+
)
|
|
3177
3304
|
);
|
|
3178
3305
|
case "vtt":
|
|
3179
3306
|
return composeLoaders(
|
|
3180
3307
|
createTextFileLoader(bucketPathPattern),
|
|
3181
3308
|
createVttLoader(),
|
|
3182
3309
|
createSyncLoader(),
|
|
3183
|
-
createUnlocalizableLoader(
|
|
3310
|
+
createUnlocalizableLoader(
|
|
3311
|
+
options.isCacheRestore,
|
|
3312
|
+
options.returnUnlocalizedKeys
|
|
3313
|
+
)
|
|
3184
3314
|
);
|
|
3185
3315
|
case "php":
|
|
3186
3316
|
return composeLoaders(
|
|
@@ -3188,7 +3318,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3188
3318
|
createPhpLoader(),
|
|
3189
3319
|
createSyncLoader(),
|
|
3190
3320
|
createFlatLoader(),
|
|
3191
|
-
createUnlocalizableLoader(
|
|
3321
|
+
createUnlocalizableLoader(
|
|
3322
|
+
options.isCacheRestore,
|
|
3323
|
+
options.returnUnlocalizedKeys
|
|
3324
|
+
)
|
|
3192
3325
|
);
|
|
3193
3326
|
case "vue-json":
|
|
3194
3327
|
return composeLoaders(
|
|
@@ -3196,7 +3329,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3196
3329
|
createVueJsonLoader(),
|
|
3197
3330
|
createSyncLoader(),
|
|
3198
3331
|
createFlatLoader(),
|
|
3199
|
-
createUnlocalizableLoader(
|
|
3332
|
+
createUnlocalizableLoader(
|
|
3333
|
+
options.isCacheRestore,
|
|
3334
|
+
options.returnUnlocalizedKeys
|
|
3335
|
+
)
|
|
3200
3336
|
);
|
|
3201
3337
|
}
|
|
3202
3338
|
}
|
|
@@ -3352,7 +3488,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
3352
3488
|
]
|
|
3353
3489
|
});
|
|
3354
3490
|
const result = JSON.parse(response.text);
|
|
3355
|
-
return _optionalChain([result, 'optionalAccess',
|
|
3491
|
+
return _optionalChain([result, 'optionalAccess', _140 => _140.data]) || {};
|
|
3356
3492
|
};
|
|
3357
3493
|
}
|
|
3358
3494
|
|
|
@@ -3370,7 +3506,7 @@ function createProcessor(provider, params) {
|
|
|
3370
3506
|
}
|
|
3371
3507
|
}
|
|
3372
3508
|
function getPureModelProvider(provider) {
|
|
3373
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
3509
|
+
switch (_optionalChain([provider, 'optionalAccess', _141 => _141.id])) {
|
|
3374
3510
|
case "openai":
|
|
3375
3511
|
if (!process.env.OPENAI_API_KEY) {
|
|
3376
3512
|
throw new Error("OPENAI_API_KEY is not set.");
|
|
@@ -3387,7 +3523,7 @@ function getPureModelProvider(provider) {
|
|
|
3387
3523
|
apiKey: process.env.ANTHROPIC_API_KEY
|
|
3388
3524
|
})(provider.model);
|
|
3389
3525
|
default:
|
|
3390
|
-
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess',
|
|
3526
|
+
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _142 => _142.id])}`);
|
|
3391
3527
|
}
|
|
3392
3528
|
}
|
|
3393
3529
|
|
|
@@ -3589,13 +3725,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3589
3725
|
flags
|
|
3590
3726
|
});
|
|
3591
3727
|
let buckets = getBuckets(i18nConfig);
|
|
3592
|
-
if (_optionalChain([flags, 'access',
|
|
3728
|
+
if (_optionalChain([flags, 'access', _143 => _143.bucket, 'optionalAccess', _144 => _144.length])) {
|
|
3593
3729
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
3594
3730
|
}
|
|
3595
3731
|
ora.succeed("Buckets retrieved");
|
|
3596
|
-
if (_optionalChain([flags, 'access',
|
|
3732
|
+
if (_optionalChain([flags, 'access', _145 => _145.file, 'optionalAccess', _146 => _146.length])) {
|
|
3597
3733
|
buckets = buckets.map((bucket) => {
|
|
3598
|
-
const paths = bucket.paths.filter((path18) => flags.file.find((file) => _optionalChain([path18, 'access',
|
|
3734
|
+
const paths = bucket.paths.filter((path18) => flags.file.find((file) => _optionalChain([path18, 'access', _147 => _147.pathPattern, 'optionalAccess', _148 => _148.match, 'call', _149 => _149(file)])));
|
|
3599
3735
|
return { ...bucket, paths };
|
|
3600
3736
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
3601
3737
|
if (buckets.length === 0) {
|
|
@@ -3611,7 +3747,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3611
3747
|
});
|
|
3612
3748
|
}
|
|
3613
3749
|
}
|
|
3614
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
3750
|
+
const targetLocales = _optionalChain([flags, 'access', _150 => _150.locale, 'optionalAccess', _151 => _151.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
3615
3751
|
ora.start("Setting up localization cache...");
|
|
3616
3752
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
3617
3753
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -3848,7 +3984,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3848
3984
|
});
|
|
3849
3985
|
let processableData = _lodash2.default.chain(sourceData).entries().filter(([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force).fromPairs().value();
|
|
3850
3986
|
if (flags.key) {
|
|
3851
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
3987
|
+
processableData = _lodash2.default.pickBy(processableData, (_25, key) => key === flags.key);
|
|
3852
3988
|
}
|
|
3853
3989
|
if (flags.verbose) {
|
|
3854
3990
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -3999,12 +4135,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
3999
4135
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
4000
4136
|
docUrl: "bucketNotFound"
|
|
4001
4137
|
});
|
|
4002
|
-
} else if (_optionalChain([flags, 'access',
|
|
4138
|
+
} else if (_optionalChain([flags, 'access', _152 => _152.locale, 'optionalAccess', _153 => _153.some, 'call', _154 => _154((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
4003
4139
|
throw new CLIError({
|
|
4004
4140
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
4005
4141
|
docUrl: "localeTargetNotFound"
|
|
4006
4142
|
});
|
|
4007
|
-
} else if (_optionalChain([flags, 'access',
|
|
4143
|
+
} else if (_optionalChain([flags, 'access', _155 => _155.bucket, 'optionalAccess', _156 => _156.some, 'call', _157 => _157((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
4008
4144
|
throw new CLIError({
|
|
4009
4145
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
4010
4146
|
docUrl: "bucketNotFound"
|
|
@@ -4314,7 +4450,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
4314
4450
|
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
4315
4451
|
|
|
4316
4452
|
|
|
4317
|
-
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 (
|
|
4453
|
+
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 (_25, program) => {
|
|
4318
4454
|
const apiKey = program.args[0];
|
|
4319
4455
|
const settings = getSettings(apiKey);
|
|
4320
4456
|
if (!settings.auth.apiKey) {
|
|
@@ -4437,7 +4573,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4437
4573
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
4438
4574
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
4439
4575
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
4440
|
-
_optionalChain([this, 'access',
|
|
4576
|
+
_optionalChain([this, 'access', _158 => _158.platformKit, 'optionalAccess', _159 => _159.gitConfig, 'call', _160 => _160()]);
|
|
4441
4577
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
4442
4578
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
4443
4579
|
if (!processOwnCommits) {
|
|
@@ -4462,7 +4598,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4462
4598
|
// ../../action/src/flows/pull-request.ts
|
|
4463
4599
|
var PullRequestFlow = class extends InBranchFlow {
|
|
4464
4600
|
async preRun() {
|
|
4465
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
4601
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _161 => _161()]);
|
|
4466
4602
|
if (!canContinue) {
|
|
4467
4603
|
return false;
|
|
4468
4604
|
}
|
|
@@ -4680,10 +4816,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
4680
4816
|
repo_slug: this.platformConfig.repositoryName,
|
|
4681
4817
|
state: "OPEN"
|
|
4682
4818
|
}).then(({ data: { values } }) => {
|
|
4683
|
-
return _optionalChain([values, 'optionalAccess',
|
|
4684
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
4819
|
+
return _optionalChain([values, 'optionalAccess', _162 => _162.find, 'call', _163 => _163(
|
|
4820
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _164 => _164.branch, 'optionalAccess', _165 => _165.name]) === branch && _optionalChain([destination, 'optionalAccess', _166 => _166.branch, 'optionalAccess', _167 => _167.name]) === this.platformConfig.baseBranchName
|
|
4685
4821
|
)]);
|
|
4686
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4822
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _168 => _168.id]));
|
|
4687
4823
|
}
|
|
4688
4824
|
async closePullRequest({ pullRequestNumber }) {
|
|
4689
4825
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -4769,7 +4905,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
4769
4905
|
repo: this.platformConfig.repositoryName,
|
|
4770
4906
|
base: this.platformConfig.baseBranchName,
|
|
4771
4907
|
state: "open"
|
|
4772
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4908
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _169 => _169.number]));
|
|
4773
4909
|
}
|
|
4774
4910
|
async closePullRequest({ pullRequestNumber }) {
|
|
4775
4911
|
await this.octokit.rest.pulls.update({
|
|
@@ -4882,7 +5018,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
4882
5018
|
sourceBranch: branch,
|
|
4883
5019
|
state: "opened"
|
|
4884
5020
|
});
|
|
4885
|
-
return _optionalChain([mergeRequests, 'access',
|
|
5021
|
+
return _optionalChain([mergeRequests, 'access', _170 => _170[0], 'optionalAccess', _171 => _171.iid]);
|
|
4886
5022
|
}
|
|
4887
5023
|
async closePullRequest({ pullRequestNumber }) {
|
|
4888
5024
|
await this.gitlab.MergeRequests.edit(this.platformConfig.gitlabProjectId, pullRequestNumber, {
|
|
@@ -4935,7 +5071,7 @@ async function main() {
|
|
|
4935
5071
|
const { isPullRequestMode } = platformKit.config;
|
|
4936
5072
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
4937
5073
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
4938
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
5074
|
+
const canRun = await _optionalChain([flow, 'access', _172 => _172.preRun, 'optionalCall', _173 => _173()]);
|
|
4939
5075
|
if (canRun === false) {
|
|
4940
5076
|
return;
|
|
4941
5077
|
}
|
|
@@ -4943,7 +5079,7 @@ async function main() {
|
|
|
4943
5079
|
if (!hasChanges) {
|
|
4944
5080
|
return;
|
|
4945
5081
|
}
|
|
4946
|
-
await _optionalChain([flow, 'access',
|
|
5082
|
+
await _optionalChain([flow, 'access', _174 => _174.postRun, 'optionalCall', _175 => _175()]);
|
|
4947
5083
|
}
|
|
4948
5084
|
|
|
4949
5085
|
// src/cli/cmd/ci.ts
|
|
@@ -4965,7 +5101,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
4965
5101
|
}
|
|
4966
5102
|
const env = {
|
|
4967
5103
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
4968
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5104
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _176 => _176.pullRequest, 'optionalAccess', _177 => _177.toString, 'call', _178 => _178()]) || "false",
|
|
4969
5105
|
...options.commitMessage && { LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage },
|
|
4970
5106
|
...options.pullRequestTitle && { LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle },
|
|
4971
5107
|
...options.workingDirectory && { LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory },
|
|
@@ -4978,7 +5114,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
4978
5114
|
// package.json
|
|
4979
5115
|
var package_default = {
|
|
4980
5116
|
name: "lingo.dev",
|
|
4981
|
-
version: "0.
|
|
5117
|
+
version: "0.84.0",
|
|
4982
5118
|
description: "Lingo.dev CLI",
|
|
4983
5119
|
private: false,
|
|
4984
5120
|
publishConfig: {
|
|
@@ -5044,6 +5180,7 @@ var package_default = {
|
|
|
5044
5180
|
"@lingo.dev/_spec": "workspace:*",
|
|
5045
5181
|
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
5046
5182
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
5183
|
+
"@types/mdast": "^4.0.4",
|
|
5047
5184
|
ai: "^4.3.2",
|
|
5048
5185
|
bitbucket: "^2.12.0",
|
|
5049
5186
|
chalk: "^5.4.1",
|
|
@@ -5073,6 +5210,11 @@ var package_default = {
|
|
|
5073
5210
|
"markdown-it": "^14.1.0",
|
|
5074
5211
|
"markdown-it-front-matter": "^0.2.4",
|
|
5075
5212
|
marked: "^15.0.6",
|
|
5213
|
+
"mdast-util-from-markdown": "^2.0.2",
|
|
5214
|
+
"mdast-util-frontmatter": "^2.0.1",
|
|
5215
|
+
"mdast-util-gfm": "^3.1.0",
|
|
5216
|
+
"mdast-util-mdx": "^3.0.0",
|
|
5217
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
5076
5218
|
"node-webvtt": "^1.9.4",
|
|
5077
5219
|
"object-hash": "^3.0.0",
|
|
5078
5220
|
octokit: "^4.0.2",
|
|
@@ -5084,9 +5226,18 @@ var package_default = {
|
|
|
5084
5226
|
"posthog-node": "^4.11.2",
|
|
5085
5227
|
prettier: "^3.4.2",
|
|
5086
5228
|
"properties-parser": "^0.6.0",
|
|
5229
|
+
"remark-frontmatter": "^5.0.0",
|
|
5230
|
+
"remark-gfm": "^4.0.1",
|
|
5231
|
+
"remark-mdx": "^3.1.0",
|
|
5232
|
+
"remark-mdx-frontmatter": "^5.1.0",
|
|
5233
|
+
"remark-parse": "^11.0.0",
|
|
5234
|
+
"remark-stringify": "^11.0.0",
|
|
5087
5235
|
slugify: "^1.6.6",
|
|
5088
5236
|
"srt-parser-2": "^1.2.3",
|
|
5089
5237
|
typescript: "^5.7.2",
|
|
5238
|
+
unified: "^11.0.5",
|
|
5239
|
+
"unist-util-visit": "^5.0.0",
|
|
5240
|
+
vfile: "^6.0.3",
|
|
5090
5241
|
vitest: "^2.1.8",
|
|
5091
5242
|
xliff: "^6.2.1",
|
|
5092
5243
|
xml2js: "^0.6.2",
|