lingo.dev 0.77.2 → 0.77.4
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 +103 -59
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +107 -63
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/cli/index.ts
|
|
2
2
|
var _dotenv = require('dotenv'); var _dotenv2 = _interopRequireDefault(_dotenv);
|
|
3
3
|
var _interactivecommander = require('interactive-commander');
|
|
4
4
|
var _figlet = require('figlet'); var _figlet2 = _interopRequireDefault(_figlet);
|
|
@@ -272,7 +272,7 @@ var _prompts = require('@inquirer/prompts');
|
|
|
272
272
|
|
|
273
273
|
// src/cli/utils/find-locale-paths.ts
|
|
274
274
|
|
|
275
|
-
var _glob = require('glob');
|
|
275
|
+
var _glob = require('glob');
|
|
276
276
|
|
|
277
277
|
|
|
278
278
|
function findLocaleFiles(bucket) {
|
|
@@ -436,10 +436,47 @@ function getDefaultContent(ext, source) {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
// src/cli/utils/update-gitignore.ts
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
function updateGitignore() {
|
|
443
|
+
const cacheFile = "i18n.cache";
|
|
444
|
+
const projectRoot = findCurrentProjectRoot();
|
|
445
|
+
if (!projectRoot) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const gitignorePath = _path2.default.join(projectRoot, ".gitignore");
|
|
449
|
+
const gitignore = _fs2.default.readFileSync(gitignorePath, "utf8").split("\n");
|
|
450
|
+
const cacheIsIgnored = gitignore.includes(cacheFile);
|
|
451
|
+
if (!cacheIsIgnored) {
|
|
452
|
+
let content = "";
|
|
453
|
+
if (_fs2.default.existsSync(gitignorePath)) {
|
|
454
|
+
content = _fs2.default.readFileSync(gitignorePath, "utf8");
|
|
455
|
+
if (content !== "" && !content.endsWith("\n")) {
|
|
456
|
+
content += "\n";
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
content += `${cacheFile}
|
|
460
|
+
`;
|
|
461
|
+
_fs2.default.writeFileSync(gitignorePath, content);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function findCurrentProjectRoot() {
|
|
465
|
+
let currentDir = process.cwd();
|
|
466
|
+
while (currentDir !== _path2.default.parse(currentDir).root) {
|
|
467
|
+
const gitDirPath = _path2.default.join(currentDir, ".git");
|
|
468
|
+
if (_fs2.default.existsSync(gitDirPath) && _fs2.default.lstatSync(gitDirPath).isDirectory()) {
|
|
469
|
+
return currentDir;
|
|
470
|
+
}
|
|
471
|
+
currentDir = _path2.default.dirname(currentDir);
|
|
472
|
+
}
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
|
|
439
476
|
// src/cli/cmd/init.ts
|
|
440
|
-
var openUrl = (
|
|
477
|
+
var openUrl = (path12) => {
|
|
441
478
|
const settings = getSettings(void 0);
|
|
442
|
-
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${
|
|
479
|
+
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path12}`]);
|
|
443
480
|
};
|
|
444
481
|
var throwHelpError = (option, value) => {
|
|
445
482
|
if (value === "help") {
|
|
@@ -588,6 +625,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
588
625
|
} else {
|
|
589
626
|
_ora2.default.call(void 0, ).succeed(`Authenticated as ${auth.email}`);
|
|
590
627
|
}
|
|
628
|
+
updateGitignore();
|
|
591
629
|
if (!isInteractive) {
|
|
592
630
|
_ora2.default.call(void 0, ).info("Please see https://docs.lingo.dev/");
|
|
593
631
|
}
|
|
@@ -707,14 +745,19 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
707
745
|
return indexes;
|
|
708
746
|
}, []);
|
|
709
747
|
const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
|
|
710
|
-
const sourcePaths =
|
|
748
|
+
const sourcePaths = _glob.glob.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => _path2.default.relative(process.cwd(), fullpath));
|
|
711
749
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
712
750
|
const sourcePathChunks = sourcePath.split(_path2.default.sep);
|
|
713
751
|
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
752
|
+
const pathPatternChunk = pathPatternChunks[localeSegmentIndex];
|
|
753
|
+
const sourcePathChunk = sourcePathChunks[localeSegmentIndex];
|
|
754
|
+
const regexp = new RegExp(
|
|
755
|
+
"(" + pathPatternChunk.replaceAll(".", "\\.").replaceAll("*", ".*").replace("[locale]", `)${sourceLocale}(`) + ")"
|
|
756
|
+
);
|
|
757
|
+
const match = sourcePathChunk.match(regexp);
|
|
758
|
+
if (match) {
|
|
759
|
+
const [, prefix, suffix] = match;
|
|
760
|
+
const placeholderedSegment = prefix + "[locale]" + suffix;
|
|
718
761
|
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
719
762
|
}
|
|
720
763
|
});
|
|
@@ -760,8 +803,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
760
803
|
} else if (type.target) {
|
|
761
804
|
result.push(...targetPaths);
|
|
762
805
|
}
|
|
763
|
-
result.forEach((
|
|
764
|
-
console.log(
|
|
806
|
+
result.forEach((path12) => {
|
|
807
|
+
console.log(path12);
|
|
765
808
|
});
|
|
766
809
|
}
|
|
767
810
|
}
|
|
@@ -793,12 +836,12 @@ function composeLoaders(...loaders) {
|
|
|
793
836
|
return {
|
|
794
837
|
init: async () => {
|
|
795
838
|
for (const loader of loaders) {
|
|
796
|
-
await _optionalChain([loader, 'access',
|
|
839
|
+
await _optionalChain([loader, 'access', _35 => _35.init, 'optionalCall', _36 => _36()]);
|
|
797
840
|
}
|
|
798
841
|
},
|
|
799
842
|
setDefaultLocale(locale) {
|
|
800
843
|
for (const loader of loaders) {
|
|
801
|
-
_optionalChain([loader, 'access',
|
|
844
|
+
_optionalChain([loader, 'access', _37 => _37.setDefaultLocale, 'optionalCall', _38 => _38(locale)]);
|
|
802
845
|
}
|
|
803
846
|
return this;
|
|
804
847
|
},
|
|
@@ -829,7 +872,7 @@ function createLoader(lDefinition) {
|
|
|
829
872
|
if (state.initCtx) {
|
|
830
873
|
return state.initCtx;
|
|
831
874
|
}
|
|
832
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
875
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _39 => _39.init, 'optionalCall', _40 => _40()]);
|
|
833
876
|
return state.initCtx;
|
|
834
877
|
},
|
|
835
878
|
setDefaultLocale(locale) {
|
|
@@ -918,7 +961,7 @@ function createNormalizeLoader() {
|
|
|
918
961
|
return normalized;
|
|
919
962
|
},
|
|
920
963
|
push: async (locale, data, originalInput) => {
|
|
921
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
964
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _41 => _41.keysMap]), () => ( {}));
|
|
922
965
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
923
966
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
924
967
|
delimiter: "/",
|
|
@@ -1021,8 +1064,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1021
1064
|
if (!templateData) {
|
|
1022
1065
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1023
1066
|
}
|
|
1024
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1025
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1067
|
+
if (_optionalChain([templateData, 'optionalAccess', _42 => _42.match, 'call', _43 => _43(/[\r\n]$/)])) {
|
|
1068
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _44 => _44.includes, 'call', _45 => _45("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _46 => _46.includes, 'call', _47 => _47("\r")]) ? "\r" : "\n";
|
|
1026
1069
|
return ending;
|
|
1027
1070
|
}
|
|
1028
1071
|
return "";
|
|
@@ -1249,7 +1292,7 @@ function createHtmlLoader() {
|
|
|
1249
1292
|
break;
|
|
1250
1293
|
}
|
|
1251
1294
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1252
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1295
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _48 => _48.textContent, 'optionalAccess', _49 => _49.trim, 'call', _50 => _50()])
|
|
1253
1296
|
);
|
|
1254
1297
|
const index = siblings.indexOf(current);
|
|
1255
1298
|
if (index !== -1) {
|
|
@@ -1284,11 +1327,11 @@ function createHtmlLoader() {
|
|
|
1284
1327
|
result[getPath(element, attr)] = value;
|
|
1285
1328
|
}
|
|
1286
1329
|
});
|
|
1287
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1330
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _51 => _51.textContent, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()])).forEach(processNode);
|
|
1288
1331
|
}
|
|
1289
1332
|
};
|
|
1290
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1291
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1333
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _54 => _54.textContent, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()])).forEach(processNode);
|
|
1334
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _57 => _57.textContent, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()])).forEach(processNode);
|
|
1292
1335
|
return result;
|
|
1293
1336
|
},
|
|
1294
1337
|
async push(locale, data, originalInput) {
|
|
@@ -1301,16 +1344,16 @@ function createHtmlLoader() {
|
|
|
1301
1344
|
const bDepth = b.split("/").length;
|
|
1302
1345
|
return aDepth - bDepth;
|
|
1303
1346
|
});
|
|
1304
|
-
paths.forEach((
|
|
1305
|
-
const value = data[
|
|
1306
|
-
const [nodePath, attribute] =
|
|
1347
|
+
paths.forEach((path12) => {
|
|
1348
|
+
const value = data[path12];
|
|
1349
|
+
const [nodePath, attribute] = path12.split("#");
|
|
1307
1350
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1308
1351
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1309
1352
|
let current = parent;
|
|
1310
1353
|
for (let i = 0; i < indices.length; i++) {
|
|
1311
1354
|
const index = parseInt(indices[i]);
|
|
1312
1355
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1313
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1356
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _60 => _60.textContent, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()])
|
|
1314
1357
|
);
|
|
1315
1358
|
if (index >= siblings.length) {
|
|
1316
1359
|
if (i === indices.length - 1) {
|
|
@@ -1417,7 +1460,7 @@ function isSkippableLine(line) {
|
|
|
1417
1460
|
function parsePropertyLine(line) {
|
|
1418
1461
|
const [key, ...valueParts] = line.split("=");
|
|
1419
1462
|
return {
|
|
1420
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1463
|
+
key: _optionalChain([key, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()]) || "",
|
|
1421
1464
|
value: valueParts.join("=").trim()
|
|
1422
1465
|
};
|
|
1423
1466
|
}
|
|
@@ -1499,7 +1542,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1499
1542
|
const resultData = {};
|
|
1500
1543
|
for (const [translationKey, _translationEntity] of Object.entries(input2.strings)) {
|
|
1501
1544
|
const rootTranslationEntity = _translationEntity;
|
|
1502
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1545
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _65 => _65.localizations, 'optionalAccess', _66 => _66[locale]]);
|
|
1503
1546
|
if (langTranslationEntity) {
|
|
1504
1547
|
if ("stringUnit" in langTranslationEntity) {
|
|
1505
1548
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1508,7 +1551,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1508
1551
|
resultData[translationKey] = {};
|
|
1509
1552
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1510
1553
|
for (const form in pluralForms) {
|
|
1511
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1554
|
+
if (_optionalChain([pluralForms, 'access', _67 => _67[form], 'optionalAccess', _68 => _68.stringUnit, 'optionalAccess', _69 => _69.value])) {
|
|
1512
1555
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1513
1556
|
}
|
|
1514
1557
|
}
|
|
@@ -1658,7 +1701,7 @@ function createPoDataLoader(params) {
|
|
|
1658
1701
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1659
1702
|
if (msgid && entry.msgid) {
|
|
1660
1703
|
const context = entry.msgctxt || "";
|
|
1661
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1704
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _70 => _70.translations, 'access', _71 => _71[context], 'optionalAccess', _72 => _72[msgid]]);
|
|
1662
1705
|
if (fullEntry) {
|
|
1663
1706
|
result[msgid] = fullEntry;
|
|
1664
1707
|
}
|
|
@@ -1668,7 +1711,7 @@ function createPoDataLoader(params) {
|
|
|
1668
1711
|
return result;
|
|
1669
1712
|
},
|
|
1670
1713
|
async push(locale, data, originalInput) {
|
|
1671
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1714
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _73 => _73.split, 'call', _74 => _74("\n\n"), 'access', _75 => _75.filter, 'call', _76 => _76(Boolean)]) || [];
|
|
1672
1715
|
const result = sections.map((section) => {
|
|
1673
1716
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1674
1717
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1710,7 +1753,7 @@ function createPoContentLoader() {
|
|
|
1710
1753
|
entry.msgid,
|
|
1711
1754
|
{
|
|
1712
1755
|
...entry,
|
|
1713
|
-
msgstr: [_optionalChain([data, 'access',
|
|
1756
|
+
msgstr: [_optionalChain([data, 'access', _77 => _77[entry.msgid], 'optionalAccess', _78 => _78.singular]), _optionalChain([data, 'access', _79 => _79[entry.msgid], 'optionalAccess', _80 => _80.plural]) || null].filter(Boolean)
|
|
1714
1757
|
}
|
|
1715
1758
|
]).fromPairs().value();
|
|
1716
1759
|
return result;
|
|
@@ -1956,7 +1999,7 @@ function createDatoClient(params) {
|
|
|
1956
1999
|
only_valid: "true",
|
|
1957
2000
|
ids: !records.length ? void 0 : records.join(",")
|
|
1958
2001
|
}
|
|
1959
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2002
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _81 => _81.response, 'optionalAccess', _82 => _82.body, 'optionalAccess', _83 => _83.data, 'optionalAccess', _84 => _84[0]]) || error));
|
|
1960
2003
|
},
|
|
1961
2004
|
findRecordsForModel: async (modelId, records) => {
|
|
1962
2005
|
try {
|
|
@@ -1966,9 +2009,9 @@ function createDatoClient(params) {
|
|
|
1966
2009
|
filter: {
|
|
1967
2010
|
type: modelId,
|
|
1968
2011
|
only_valid: "true",
|
|
1969
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2012
|
+
ids: !_optionalChain([records, 'optionalAccess', _85 => _85.length]) ? void 0 : records.join(",")
|
|
1970
2013
|
}
|
|
1971
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2014
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _86 => _86.response, 'optionalAccess', _87 => _87.body, 'optionalAccess', _88 => _88.data, 'optionalAccess', _89 => _89[0]]) || error));
|
|
1972
2015
|
return result;
|
|
1973
2016
|
} catch (_error) {
|
|
1974
2017
|
throw new Error(
|
|
@@ -1982,9 +2025,9 @@ function createDatoClient(params) {
|
|
|
1982
2025
|
},
|
|
1983
2026
|
updateRecord: async (id, payload) => {
|
|
1984
2027
|
try {
|
|
1985
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2028
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _90 => _90.response, 'optionalAccess', _91 => _91.body, 'optionalAccess', _92 => _92.data, 'optionalAccess', _93 => _93[0]]) || error));
|
|
1986
2029
|
} catch (_error) {
|
|
1987
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2030
|
+
if (_optionalChain([_error, 'optionalAccess', _94 => _94.attributes, 'optionalAccess', _95 => _95.details, 'optionalAccess', _96 => _96.message])) {
|
|
1988
2031
|
throw new Error(
|
|
1989
2032
|
[
|
|
1990
2033
|
`${_error.attributes.details.message}`,
|
|
@@ -2005,9 +2048,9 @@ function createDatoClient(params) {
|
|
|
2005
2048
|
},
|
|
2006
2049
|
enableFieldLocalization: async (args) => {
|
|
2007
2050
|
try {
|
|
2008
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2051
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _97 => _97.response, 'optionalAccess', _98 => _98.body, 'optionalAccess', _99 => _99.data, 'optionalAccess', _100 => _100[0]]) || error));
|
|
2009
2052
|
} catch (_error) {
|
|
2010
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2053
|
+
if (_optionalChain([_error, 'optionalAccess', _101 => _101.attributes, 'optionalAccess', _102 => _102.code]) === "NOT_FOUND") {
|
|
2011
2054
|
throw new Error(
|
|
2012
2055
|
[
|
|
2013
2056
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2015,7 +2058,7 @@ function createDatoClient(params) {
|
|
|
2015
2058
|
].join("\n\n")
|
|
2016
2059
|
);
|
|
2017
2060
|
}
|
|
2018
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2061
|
+
if (_optionalChain([_error, 'optionalAccess', _103 => _103.attributes, 'optionalAccess', _104 => _104.details, 'optionalAccess', _105 => _105.message])) {
|
|
2019
2062
|
throw new Error(
|
|
2020
2063
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2021
2064
|
);
|
|
@@ -2081,7 +2124,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2081
2124
|
}
|
|
2082
2125
|
}
|
|
2083
2126
|
const records = await dato.findRecordsForModel(modelId);
|
|
2084
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2127
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _106 => _106.models, 'access', _107 => _107[modelId], 'optionalAccess', _108 => _108.records]) || [], project);
|
|
2085
2128
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2086
2129
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2087
2130
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2093,14 +2136,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2093
2136
|
},
|
|
2094
2137
|
async pull(locale, input2, initCtx) {
|
|
2095
2138
|
const result = {};
|
|
2096
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2097
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2139
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _109 => _109.models]) || {})) {
|
|
2140
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _110 => _110.models, 'access', _111 => _111[modelId], 'access', _112 => _112.records]) || [];
|
|
2098
2141
|
const recordIds = records.map((record) => record.id);
|
|
2099
2142
|
records = await dato.findRecords(recordIds);
|
|
2100
2143
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2101
2144
|
if (records.length > 0) {
|
|
2102
2145
|
result[modelId] = {
|
|
2103
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2146
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _113 => _113.models, 'optionalAccess', _114 => _114[modelId], 'optionalAccess', _115 => _115.fields]) || [],
|
|
2104
2147
|
records
|
|
2105
2148
|
};
|
|
2106
2149
|
}
|
|
@@ -2159,7 +2202,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2159
2202
|
return records.map((record) => ({
|
|
2160
2203
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2161
2204
|
value: record.id,
|
|
2162
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2205
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _116 => _116.includes, 'call', _117 => _117(record.id)])
|
|
2163
2206
|
}));
|
|
2164
2207
|
}
|
|
2165
2208
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2310,18 +2353,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2310
2353
|
}
|
|
2311
2354
|
function serializeStructuredText(rawStructuredText) {
|
|
2312
2355
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2313
|
-
function serializeStructuredTextNode(node,
|
|
2356
|
+
function serializeStructuredTextNode(node, path12 = [], acc = {}) {
|
|
2314
2357
|
if ("document" in node) {
|
|
2315
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2358
|
+
return serializeStructuredTextNode(node.document, [...path12, "document"], acc);
|
|
2316
2359
|
}
|
|
2317
2360
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2318
|
-
acc[[...
|
|
2361
|
+
acc[[...path12, "value"].join(".")] = node.value;
|
|
2319
2362
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2320
|
-
acc[[...
|
|
2363
|
+
acc[[...path12, "item"].join(".")] = serializeBlock(node.item);
|
|
2321
2364
|
}
|
|
2322
2365
|
if (node.children) {
|
|
2323
2366
|
for (let i = 0; i < node.children.length; i++) {
|
|
2324
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2367
|
+
serializeStructuredTextNode(node.children[i], [...path12, i.toString()], acc);
|
|
2325
2368
|
}
|
|
2326
2369
|
}
|
|
2327
2370
|
return acc;
|
|
@@ -2380,8 +2423,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2380
2423
|
}
|
|
2381
2424
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2382
2425
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2383
|
-
for (const [
|
|
2384
|
-
const realPath = _lodash2.default.chain(
|
|
2426
|
+
for (const [path12, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2427
|
+
const realPath = _lodash2.default.chain(path12.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2385
2428
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2386
2429
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2387
2430
|
}
|
|
@@ -2426,7 +2469,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2426
2469
|
function createVttLoader() {
|
|
2427
2470
|
return createLoader({
|
|
2428
2471
|
async pull(locale, input2) {
|
|
2429
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2472
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _118 => _118.parse, 'call', _119 => _119(input2), 'optionalAccess', _120 => _120.cues]);
|
|
2430
2473
|
if (Object.keys(vtt).length === 0) {
|
|
2431
2474
|
return {};
|
|
2432
2475
|
} else {
|
|
@@ -2478,7 +2521,7 @@ function variableExtractLoader(params) {
|
|
|
2478
2521
|
for (let i = 0; i < matches.length; i++) {
|
|
2479
2522
|
const match = matches[i];
|
|
2480
2523
|
const currentValue = result[key].value;
|
|
2481
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2524
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _121 => _121.replace, 'call', _122 => _122(match, `{variable:${i}}`)]);
|
|
2482
2525
|
result[key].value = newValue;
|
|
2483
2526
|
result[key].variables[i] = match;
|
|
2484
2527
|
}
|
|
@@ -2492,7 +2535,7 @@ function variableExtractLoader(params) {
|
|
|
2492
2535
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2493
2536
|
const variable = valueObj.variables[i];
|
|
2494
2537
|
const currentValue = result[key];
|
|
2495
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2538
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _123 => _123.replace, 'call', _124 => _124(`{variable:${i}}`, variable)]);
|
|
2496
2539
|
result[key] = newValue;
|
|
2497
2540
|
}
|
|
2498
2541
|
}
|
|
@@ -2976,6 +3019,7 @@ function _tryParseJSON(line) {
|
|
|
2976
3019
|
|
|
2977
3020
|
// src/cli/cmd/i18n.ts
|
|
2978
3021
|
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option("--key <key>", "Key to process").option("--frozen", `Don't update the translations and fail if an update is needed`).option("--force", "Ignore lockfile and process all keys").option("--verbose", "Show verbose output").option("--interactive", "Interactive mode").option("--api-key <api-key>", "Explicitly set the API key to use").option("--debug", "Debug mode").option("--strict", "Stop on first error").action(async function(options) {
|
|
3022
|
+
updateGitignore();
|
|
2979
3023
|
const ora = _ora2.default.call(void 0, );
|
|
2980
3024
|
const flags = parseFlags(options);
|
|
2981
3025
|
if (flags.debug) {
|
|
@@ -3000,11 +3044,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
3000
3044
|
const auth = await validateAuth(settings);
|
|
3001
3045
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
3002
3046
|
let buckets = getBuckets(i18nConfig);
|
|
3003
|
-
if (_optionalChain([flags, 'access',
|
|
3047
|
+
if (_optionalChain([flags, 'access', _125 => _125.bucket, 'optionalAccess', _126 => _126.length])) {
|
|
3004
3048
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
3005
3049
|
}
|
|
3006
3050
|
ora.succeed("Buckets retrieved");
|
|
3007
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
3051
|
+
const targetLocales = _optionalChain([flags, 'access', _127 => _127.locale, 'optionalAccess', _128 => _128.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
3008
3052
|
const lockfileHelper = createLockfileHelper();
|
|
3009
3053
|
ora.start("Ensuring i18n.lock exists...");
|
|
3010
3054
|
if (!lockfileHelper.isLockfileExists()) {
|
|
@@ -3294,12 +3338,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
3294
3338
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
3295
3339
|
docUrl: "bucketNotFound"
|
|
3296
3340
|
});
|
|
3297
|
-
} else if (_optionalChain([flags, 'access',
|
|
3341
|
+
} else if (_optionalChain([flags, 'access', _129 => _129.locale, 'optionalAccess', _130 => _130.some, 'call', _131 => _131((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
3298
3342
|
throw new CLIError({
|
|
3299
3343
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
3300
3344
|
docUrl: "localeTargetNotFound"
|
|
3301
3345
|
});
|
|
3302
|
-
} else if (_optionalChain([flags, 'access',
|
|
3346
|
+
} else if (_optionalChain([flags, 'access', _132 => _132.bucket, 'optionalAccess', _133 => _133.some, 'call', _134 => _134((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
3303
3347
|
throw new CLIError({
|
|
3304
3348
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
3305
3349
|
docUrl: "bucketNotFound"
|
|
@@ -3579,7 +3623,7 @@ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").descri
|
|
|
3579
3623
|
// package.json
|
|
3580
3624
|
var package_default = {
|
|
3581
3625
|
name: "lingo.dev",
|
|
3582
|
-
version: "0.77.
|
|
3626
|
+
version: "0.77.4",
|
|
3583
3627
|
description: "Lingo.dev CLI",
|
|
3584
3628
|
private: false,
|
|
3585
3629
|
publishConfig: {
|