lingo.dev 0.78.11 → 0.78.13
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 +99 -49
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +67 -17
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -23,6 +23,7 @@ function getSettings(explicitApiKey) {
|
|
|
23
23
|
const systemFile = _loadSystemFile();
|
|
24
24
|
const defaults = _loadDefaults();
|
|
25
25
|
_legacyEnvVarWarning();
|
|
26
|
+
_envVarsInfo();
|
|
26
27
|
return {
|
|
27
28
|
auth: {
|
|
28
29
|
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _22 => _22.auth, 'optionalAccess', _23 => _23.apiKey]) || defaults.auth.apiKey,
|
|
@@ -95,6 +96,22 @@ Please use LINGODOTDEV_API_KEY instead.
|
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
function _envVarsInfo() {
|
|
100
|
+
const env = _loadEnv();
|
|
101
|
+
const systemFile = _loadSystemFile();
|
|
102
|
+
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _28 => _28.auth, 'optionalAccess', _29 => _29.apiKey])) {
|
|
103
|
+
console.info(
|
|
104
|
+
"\x1B[36m%s\x1B[0m",
|
|
105
|
+
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
if (env.LINGODOTDEV_API_URL) {
|
|
109
|
+
console.info("\x1B[36m%s\x1B[0m", `\u2139\uFE0F Using LINGODOTDEV_API_URL: ${env.LINGODOTDEV_API_URL}`);
|
|
110
|
+
}
|
|
111
|
+
if (env.LINGODOTDEV_WEB_URL) {
|
|
112
|
+
console.info("\x1B[36m%s\x1B[0m", `\u2139\uFE0F Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
98
115
|
|
|
99
116
|
// src/cli/utils/errors.ts
|
|
100
117
|
var docLinks = {
|
|
@@ -137,7 +154,7 @@ function createAuthenticator(params) {
|
|
|
137
154
|
});
|
|
138
155
|
if (res.ok) {
|
|
139
156
|
const payload = await res.json();
|
|
140
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
157
|
+
if (!_optionalChain([payload, 'optionalAccess', _30 => _30.email])) {
|
|
141
158
|
return null;
|
|
142
159
|
}
|
|
143
160
|
return {
|
|
@@ -755,7 +772,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
755
772
|
});
|
|
756
773
|
const auth2 = await newAuthenticator.whoami();
|
|
757
774
|
if (auth2) {
|
|
758
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
775
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _31 => _31.email])}`);
|
|
759
776
|
} else {
|
|
760
777
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
761
778
|
}
|
|
@@ -835,7 +852,7 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
835
852
|
function getBuckets(i18nConfig) {
|
|
836
853
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
837
854
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
838
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
855
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _32 => _32.exclude, 'optionalAccess', _33 => _33.map, 'call', _34 => _34((item) => resolveBucketItem(item))]);
|
|
839
856
|
return {
|
|
840
857
|
type: bucketType,
|
|
841
858
|
config: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
@@ -852,7 +869,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
852
869
|
})
|
|
853
870
|
)
|
|
854
871
|
);
|
|
855
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
872
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _35 => _35.flatMap, 'call', _36 => _36(
|
|
856
873
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
857
874
|
(pathPattern) => ({
|
|
858
875
|
pathPattern,
|
|
@@ -977,12 +994,12 @@ function composeLoaders(...loaders) {
|
|
|
977
994
|
return {
|
|
978
995
|
init: async () => {
|
|
979
996
|
for (const loader of loaders) {
|
|
980
|
-
await _optionalChain([loader, 'access',
|
|
997
|
+
await _optionalChain([loader, 'access', _37 => _37.init, 'optionalCall', _38 => _38()]);
|
|
981
998
|
}
|
|
982
999
|
},
|
|
983
1000
|
setDefaultLocale(locale) {
|
|
984
1001
|
for (const loader of loaders) {
|
|
985
|
-
_optionalChain([loader, 'access',
|
|
1002
|
+
_optionalChain([loader, 'access', _39 => _39.setDefaultLocale, 'optionalCall', _40 => _40(locale)]);
|
|
986
1003
|
}
|
|
987
1004
|
return this;
|
|
988
1005
|
},
|
|
@@ -1013,7 +1030,7 @@ function createLoader(lDefinition) {
|
|
|
1013
1030
|
if (state.initCtx) {
|
|
1014
1031
|
return state.initCtx;
|
|
1015
1032
|
}
|
|
1016
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1033
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _41 => _41.init, 'optionalCall', _42 => _42()]);
|
|
1017
1034
|
return state.initCtx;
|
|
1018
1035
|
},
|
|
1019
1036
|
setDefaultLocale(locale) {
|
|
@@ -1102,7 +1119,7 @@ function createNormalizeLoader() {
|
|
|
1102
1119
|
return normalized;
|
|
1103
1120
|
},
|
|
1104
1121
|
push: async (locale, data, originalInput) => {
|
|
1105
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1122
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _43 => _43.keysMap]), () => ( {}));
|
|
1106
1123
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1107
1124
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1108
1125
|
delimiter: "/",
|
|
@@ -1205,8 +1222,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1205
1222
|
if (!templateData) {
|
|
1206
1223
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1207
1224
|
}
|
|
1208
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1209
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1225
|
+
if (_optionalChain([templateData, 'optionalAccess', _44 => _44.match, 'call', _45 => _45(/[\r\n]$/)])) {
|
|
1226
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _46 => _46.includes, 'call', _47 => _47("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _48 => _48.includes, 'call', _49 => _49("\r")]) ? "\r" : "\n";
|
|
1210
1227
|
return ending;
|
|
1211
1228
|
}
|
|
1212
1229
|
return "";
|
|
@@ -1461,7 +1478,7 @@ function createHtmlLoader() {
|
|
|
1461
1478
|
break;
|
|
1462
1479
|
}
|
|
1463
1480
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1464
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1481
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _50 => _50.textContent, 'optionalAccess', _51 => _51.trim, 'call', _52 => _52()])
|
|
1465
1482
|
);
|
|
1466
1483
|
const index = siblings.indexOf(current);
|
|
1467
1484
|
if (index !== -1) {
|
|
@@ -1496,11 +1513,11 @@ function createHtmlLoader() {
|
|
|
1496
1513
|
result[getPath(element, attr)] = value;
|
|
1497
1514
|
}
|
|
1498
1515
|
});
|
|
1499
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1516
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _53 => _53.textContent, 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()])).forEach(processNode);
|
|
1500
1517
|
}
|
|
1501
1518
|
};
|
|
1502
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1503
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1519
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _56 => _56.textContent, 'optionalAccess', _57 => _57.trim, 'call', _58 => _58()])).forEach(processNode);
|
|
1520
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _59 => _59.textContent, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()])).forEach(processNode);
|
|
1504
1521
|
return result;
|
|
1505
1522
|
},
|
|
1506
1523
|
async push(locale, data, originalInput) {
|
|
@@ -1522,7 +1539,7 @@ function createHtmlLoader() {
|
|
|
1522
1539
|
for (let i = 0; i < indices.length; i++) {
|
|
1523
1540
|
const index = parseInt(indices[i]);
|
|
1524
1541
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1525
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1542
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _62 => _62.textContent, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()])
|
|
1526
1543
|
);
|
|
1527
1544
|
if (index >= siblings.length) {
|
|
1528
1545
|
if (i === indices.length - 1) {
|
|
@@ -1573,7 +1590,7 @@ function createMarkdownLoader() {
|
|
|
1573
1590
|
yaml: yamlEngine
|
|
1574
1591
|
}
|
|
1575
1592
|
});
|
|
1576
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
1593
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _65 => _65.trim, 'call', _66 => _66()]), () => ( ""))).filter(Boolean);
|
|
1577
1594
|
return {
|
|
1578
1595
|
...Object.fromEntries(
|
|
1579
1596
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -1585,7 +1602,7 @@ function createMarkdownLoader() {
|
|
|
1585
1602
|
const frontmatter = Object.fromEntries(
|
|
1586
1603
|
Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
|
|
1587
1604
|
);
|
|
1588
|
-
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',
|
|
1605
|
+
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', _67 => _67.trim, 'call', _68 => _68()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
1589
1606
|
if (Object.keys(frontmatter).length > 0) {
|
|
1590
1607
|
content = `
|
|
1591
1608
|
${content}`;
|
|
@@ -1629,7 +1646,7 @@ function isSkippableLine(line) {
|
|
|
1629
1646
|
function parsePropertyLine(line) {
|
|
1630
1647
|
const [key, ...valueParts] = line.split("=");
|
|
1631
1648
|
return {
|
|
1632
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1649
|
+
key: _optionalChain([key, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()]) || "",
|
|
1633
1650
|
value: valueParts.join("=").trim()
|
|
1634
1651
|
};
|
|
1635
1652
|
}
|
|
@@ -1715,7 +1732,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1715
1732
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
1716
1733
|
continue;
|
|
1717
1734
|
}
|
|
1718
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1735
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _71 => _71.localizations, 'optionalAccess', _72 => _72[locale]]);
|
|
1719
1736
|
if (langTranslationEntity) {
|
|
1720
1737
|
if ("stringUnit" in langTranslationEntity) {
|
|
1721
1738
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1724,7 +1741,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1724
1741
|
resultData[translationKey] = {};
|
|
1725
1742
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1726
1743
|
for (const form in pluralForms) {
|
|
1727
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1744
|
+
if (_optionalChain([pluralForms, 'access', _73 => _73[form], 'optionalAccess', _74 => _74.stringUnit, 'optionalAccess', _75 => _75.value])) {
|
|
1728
1745
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1729
1746
|
}
|
|
1730
1747
|
}
|
|
@@ -1748,7 +1765,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1748
1765
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
1749
1766
|
if (typeof value === "string") {
|
|
1750
1767
|
langDataToMerge.strings[key] = {
|
|
1751
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
1768
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _76 => _76.strings, 'optionalAccess', _77 => _77[key], 'optionalAccess', _78 => _78.extractionState]),
|
|
1752
1769
|
localizations: {
|
|
1753
1770
|
[locale]: {
|
|
1754
1771
|
stringUnit: {
|
|
@@ -1794,7 +1811,9 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1794
1811
|
|
|
1795
1812
|
// src/cli/loaders/prettier.ts
|
|
1796
1813
|
|
|
1814
|
+
|
|
1797
1815
|
var _prettier = require('prettier'); var _prettier2 = _interopRequireDefault(_prettier);
|
|
1816
|
+
var _child_process = require('child_process');
|
|
1798
1817
|
function createPrettierLoader(options) {
|
|
1799
1818
|
return createLoader({
|
|
1800
1819
|
async pull(locale, data) {
|
|
@@ -1807,7 +1826,7 @@ function createPrettierLoader(options) {
|
|
|
1807
1826
|
if (!prettierConfig) {
|
|
1808
1827
|
return data;
|
|
1809
1828
|
}
|
|
1810
|
-
const
|
|
1829
|
+
const config = {
|
|
1811
1830
|
...prettierConfig || { printWidth: 2500, bracketSameLine: false },
|
|
1812
1831
|
parser: options.parser,
|
|
1813
1832
|
// For HTML parser, preserve comments and quotes
|
|
@@ -1816,8 +1835,22 @@ function createPrettierLoader(options) {
|
|
|
1816
1835
|
singleQuote: false,
|
|
1817
1836
|
embeddedLanguageFormatting: "off"
|
|
1818
1837
|
} : {}
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1838
|
+
};
|
|
1839
|
+
try {
|
|
1840
|
+
const result = await _prettier2.default.format(data, config);
|
|
1841
|
+
return result;
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
if (error instanceof Error && error.message.startsWith("Cannot find package")) {
|
|
1844
|
+
console.log();
|
|
1845
|
+
console.log("Prettier is missing some dependecies - installing all project dependencies");
|
|
1846
|
+
installDependencies();
|
|
1847
|
+
await _prettier2.default.clearConfigCache();
|
|
1848
|
+
const result = await _prettier2.default.format(data, config);
|
|
1849
|
+
return result;
|
|
1850
|
+
} else {
|
|
1851
|
+
throw error;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1821
1854
|
}
|
|
1822
1855
|
});
|
|
1823
1856
|
}
|
|
@@ -1829,6 +1862,23 @@ async function loadPrettierConfig(filePath) {
|
|
|
1829
1862
|
return {};
|
|
1830
1863
|
}
|
|
1831
1864
|
}
|
|
1865
|
+
async function installDependencies() {
|
|
1866
|
+
const packageManager = await getPackageManager();
|
|
1867
|
+
console.log(`Installing dependencies using ${packageManager}`);
|
|
1868
|
+
_child_process.execSync.call(void 0, `${packageManager} install --frozen-lockfile`, { stdio: "inherit" });
|
|
1869
|
+
console.log(`Dependencies installed`);
|
|
1870
|
+
}
|
|
1871
|
+
async function getPackageManager() {
|
|
1872
|
+
const yarnLockfile = _path2.default.resolve(process.cwd(), "yarn.lock");
|
|
1873
|
+
const pnpmLockfile = _path2.default.resolve(process.cwd(), "pnpm-lock.yaml");
|
|
1874
|
+
if (_fs2.default.existsSync(yarnLockfile)) {
|
|
1875
|
+
return "yarn";
|
|
1876
|
+
}
|
|
1877
|
+
if (_fs2.default.existsSync(pnpmLockfile)) {
|
|
1878
|
+
return "pnpm";
|
|
1879
|
+
}
|
|
1880
|
+
return "npm";
|
|
1881
|
+
}
|
|
1832
1882
|
|
|
1833
1883
|
// src/cli/loaders/unlocalizable.ts
|
|
1834
1884
|
|
|
@@ -1894,7 +1944,7 @@ function createPoDataLoader(params) {
|
|
|
1894
1944
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1895
1945
|
if (msgid && entry.msgid) {
|
|
1896
1946
|
const context = entry.msgctxt || "";
|
|
1897
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1947
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _79 => _79.translations, 'access', _80 => _80[context], 'optionalAccess', _81 => _81[msgid]]);
|
|
1898
1948
|
if (fullEntry) {
|
|
1899
1949
|
result[msgid] = fullEntry;
|
|
1900
1950
|
}
|
|
@@ -1904,7 +1954,7 @@ function createPoDataLoader(params) {
|
|
|
1904
1954
|
return result;
|
|
1905
1955
|
},
|
|
1906
1956
|
async push(locale, data, originalInput) {
|
|
1907
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1957
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _82 => _82.split, 'call', _83 => _83("\n\n"), 'access', _84 => _84.filter, 'call', _85 => _85(Boolean)]) || [];
|
|
1908
1958
|
const result = sections.map((section) => {
|
|
1909
1959
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1910
1960
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1946,7 +1996,7 @@ function createPoContentLoader() {
|
|
|
1946
1996
|
entry.msgid,
|
|
1947
1997
|
{
|
|
1948
1998
|
...entry,
|
|
1949
|
-
msgstr: [_optionalChain([data, 'access',
|
|
1999
|
+
msgstr: [_optionalChain([data, 'access', _86 => _86[entry.msgid], 'optionalAccess', _87 => _87.singular]), _optionalChain([data, 'access', _88 => _88[entry.msgid], 'optionalAccess', _89 => _89.plural]) || null].filter(Boolean)
|
|
1950
2000
|
}
|
|
1951
2001
|
]).fromPairs().value();
|
|
1952
2002
|
return result;
|
|
@@ -2192,7 +2242,7 @@ function createDatoClient(params) {
|
|
|
2192
2242
|
only_valid: "true",
|
|
2193
2243
|
ids: !records.length ? void 0 : records.join(",")
|
|
2194
2244
|
}
|
|
2195
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2245
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _90 => _90.response, 'optionalAccess', _91 => _91.body, 'optionalAccess', _92 => _92.data, 'optionalAccess', _93 => _93[0]]) || error));
|
|
2196
2246
|
},
|
|
2197
2247
|
findRecordsForModel: async (modelId, records) => {
|
|
2198
2248
|
try {
|
|
@@ -2202,9 +2252,9 @@ function createDatoClient(params) {
|
|
|
2202
2252
|
filter: {
|
|
2203
2253
|
type: modelId,
|
|
2204
2254
|
only_valid: "true",
|
|
2205
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2255
|
+
ids: !_optionalChain([records, 'optionalAccess', _94 => _94.length]) ? void 0 : records.join(",")
|
|
2206
2256
|
}
|
|
2207
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2257
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _95 => _95.response, 'optionalAccess', _96 => _96.body, 'optionalAccess', _97 => _97.data, 'optionalAccess', _98 => _98[0]]) || error));
|
|
2208
2258
|
return result;
|
|
2209
2259
|
} catch (_error) {
|
|
2210
2260
|
throw new Error(
|
|
@@ -2218,9 +2268,9 @@ function createDatoClient(params) {
|
|
|
2218
2268
|
},
|
|
2219
2269
|
updateRecord: async (id, payload) => {
|
|
2220
2270
|
try {
|
|
2221
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2271
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _99 => _99.response, 'optionalAccess', _100 => _100.body, 'optionalAccess', _101 => _101.data, 'optionalAccess', _102 => _102[0]]) || error));
|
|
2222
2272
|
} catch (_error) {
|
|
2223
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2273
|
+
if (_optionalChain([_error, 'optionalAccess', _103 => _103.attributes, 'optionalAccess', _104 => _104.details, 'optionalAccess', _105 => _105.message])) {
|
|
2224
2274
|
throw new Error(
|
|
2225
2275
|
[
|
|
2226
2276
|
`${_error.attributes.details.message}`,
|
|
@@ -2241,9 +2291,9 @@ function createDatoClient(params) {
|
|
|
2241
2291
|
},
|
|
2242
2292
|
enableFieldLocalization: async (args) => {
|
|
2243
2293
|
try {
|
|
2244
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2294
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _106 => _106.response, 'optionalAccess', _107 => _107.body, 'optionalAccess', _108 => _108.data, 'optionalAccess', _109 => _109[0]]) || error));
|
|
2245
2295
|
} catch (_error) {
|
|
2246
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2296
|
+
if (_optionalChain([_error, 'optionalAccess', _110 => _110.attributes, 'optionalAccess', _111 => _111.code]) === "NOT_FOUND") {
|
|
2247
2297
|
throw new Error(
|
|
2248
2298
|
[
|
|
2249
2299
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2251,7 +2301,7 @@ function createDatoClient(params) {
|
|
|
2251
2301
|
].join("\n\n")
|
|
2252
2302
|
);
|
|
2253
2303
|
}
|
|
2254
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2304
|
+
if (_optionalChain([_error, 'optionalAccess', _112 => _112.attributes, 'optionalAccess', _113 => _113.details, 'optionalAccess', _114 => _114.message])) {
|
|
2255
2305
|
throw new Error(
|
|
2256
2306
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2257
2307
|
);
|
|
@@ -2317,7 +2367,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2317
2367
|
}
|
|
2318
2368
|
}
|
|
2319
2369
|
const records = await dato.findRecordsForModel(modelId);
|
|
2320
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2370
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _115 => _115.models, 'access', _116 => _116[modelId], 'optionalAccess', _117 => _117.records]) || [], project);
|
|
2321
2371
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2322
2372
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2323
2373
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2329,14 +2379,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2329
2379
|
},
|
|
2330
2380
|
async pull(locale, input2, initCtx) {
|
|
2331
2381
|
const result = {};
|
|
2332
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2333
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2382
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _118 => _118.models]) || {})) {
|
|
2383
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _119 => _119.models, 'access', _120 => _120[modelId], 'access', _121 => _121.records]) || [];
|
|
2334
2384
|
const recordIds = records.map((record) => record.id);
|
|
2335
2385
|
records = await dato.findRecords(recordIds);
|
|
2336
2386
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2337
2387
|
if (records.length > 0) {
|
|
2338
2388
|
result[modelId] = {
|
|
2339
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2389
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _122 => _122.models, 'optionalAccess', _123 => _123[modelId], 'optionalAccess', _124 => _124.fields]) || [],
|
|
2340
2390
|
records
|
|
2341
2391
|
};
|
|
2342
2392
|
}
|
|
@@ -2395,7 +2445,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2395
2445
|
return records.map((record) => ({
|
|
2396
2446
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2397
2447
|
value: record.id,
|
|
2398
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2448
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _125 => _125.includes, 'call', _126 => _126(record.id)])
|
|
2399
2449
|
}));
|
|
2400
2450
|
}
|
|
2401
2451
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2662,7 +2712,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2662
2712
|
function createVttLoader() {
|
|
2663
2713
|
return createLoader({
|
|
2664
2714
|
async pull(locale, input2) {
|
|
2665
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2715
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _127 => _127.parse, 'call', _128 => _128(input2), 'optionalAccess', _129 => _129.cues]);
|
|
2666
2716
|
if (Object.keys(vtt).length === 0) {
|
|
2667
2717
|
return {};
|
|
2668
2718
|
} else {
|
|
@@ -2714,7 +2764,7 @@ function variableExtractLoader(params) {
|
|
|
2714
2764
|
for (let i = 0; i < matches.length; i++) {
|
|
2715
2765
|
const match = matches[i];
|
|
2716
2766
|
const currentValue = result[key].value;
|
|
2717
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2767
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _130 => _130.replace, 'call', _131 => _131(match, `{variable:${i}}`)]);
|
|
2718
2768
|
result[key].value = newValue;
|
|
2719
2769
|
result[key].variables[i] = match;
|
|
2720
2770
|
}
|
|
@@ -2728,7 +2778,7 @@ function variableExtractLoader(params) {
|
|
|
2728
2778
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2729
2779
|
const variable = valueObj.variables[i];
|
|
2730
2780
|
const currentValue = result[key];
|
|
2731
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2781
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _132 => _132.replace, 'call', _133 => _133(`{variable:${i}}`, variable)]);
|
|
2732
2782
|
result[key] = newValue;
|
|
2733
2783
|
}
|
|
2734
2784
|
}
|
|
@@ -2909,7 +2959,7 @@ function createVueJsonLoader() {
|
|
|
2909
2959
|
return createLoader({
|
|
2910
2960
|
pull: async (locale, input2, ctx) => {
|
|
2911
2961
|
const parsed = parseVueFile(input2);
|
|
2912
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
2962
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _134 => _134.i18n, 'optionalAccess', _135 => _135[locale]]), () => ( {}));
|
|
2913
2963
|
},
|
|
2914
2964
|
push: async (locale, data, originalInput) => {
|
|
2915
2965
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -3280,11 +3330,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3280
3330
|
const auth = await validateAuth(settings);
|
|
3281
3331
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
3282
3332
|
let buckets = getBuckets(i18nConfig);
|
|
3283
|
-
if (_optionalChain([flags, 'access',
|
|
3333
|
+
if (_optionalChain([flags, 'access', _136 => _136.bucket, 'optionalAccess', _137 => _137.length])) {
|
|
3284
3334
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
3285
3335
|
}
|
|
3286
3336
|
ora.succeed("Buckets retrieved");
|
|
3287
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
3337
|
+
const targetLocales = _optionalChain([flags, 'access', _138 => _138.locale, 'optionalAccess', _139 => _139.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
3288
3338
|
const lockfileHelper = createLockfileHelper();
|
|
3289
3339
|
ora.start("Ensuring i18n.lock exists...");
|
|
3290
3340
|
if (!lockfileHelper.isLockfileExists()) {
|
|
@@ -3614,12 +3664,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
3614
3664
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
3615
3665
|
docUrl: "bucketNotFound"
|
|
3616
3666
|
});
|
|
3617
|
-
} else if (_optionalChain([flags, 'access',
|
|
3667
|
+
} else if (_optionalChain([flags, 'access', _140 => _140.locale, 'optionalAccess', _141 => _141.some, 'call', _142 => _142((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
3618
3668
|
throw new CLIError({
|
|
3619
3669
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
3620
3670
|
docUrl: "localeTargetNotFound"
|
|
3621
3671
|
});
|
|
3622
|
-
} else if (_optionalChain([flags, 'access',
|
|
3672
|
+
} else if (_optionalChain([flags, 'access', _143 => _143.bucket, 'optionalAccess', _144 => _144.some, 'call', _145 => _145((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
3623
3673
|
throw new CLIError({
|
|
3624
3674
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
3625
3675
|
docUrl: "bucketNotFound"
|
|
@@ -3899,7 +3949,7 @@ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").descri
|
|
|
3899
3949
|
// package.json
|
|
3900
3950
|
var package_default = {
|
|
3901
3951
|
name: "lingo.dev",
|
|
3902
|
-
version: "0.78.
|
|
3952
|
+
version: "0.78.13",
|
|
3903
3953
|
description: "Lingo.dev CLI",
|
|
3904
3954
|
private: false,
|
|
3905
3955
|
publishConfig: {
|