lingo.dev 0.74.12 → 0.74.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 +114 -52
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +175 -113
- package/build/cli.mjs.map +1 -1
- package/package.json +2 -1
package/build/cli.cjs
CHANGED
|
@@ -25,9 +25,9 @@ function getSettings(explicitApiKey) {
|
|
|
25
25
|
_legacyEnvVarWarning();
|
|
26
26
|
return {
|
|
27
27
|
auth: {
|
|
28
|
-
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access',
|
|
29
|
-
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access',
|
|
30
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access',
|
|
28
|
+
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _21 => _21.auth, 'optionalAccess', _22 => _22.apiKey]) || defaults.auth.apiKey,
|
|
29
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _23 => _23.auth, 'optionalAccess', _24 => _24.apiUrl]) || defaults.auth.apiUrl,
|
|
30
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _25 => _25.auth, 'optionalAccess', _26 => _26.webUrl]) || defaults.auth.webUrl
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -137,7 +137,7 @@ function createAuthenticator(params) {
|
|
|
137
137
|
});
|
|
138
138
|
if (res.ok) {
|
|
139
139
|
const payload = await res.json();
|
|
140
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
140
|
+
if (!_optionalChain([payload, 'optionalAccess', _27 => _27.email])) {
|
|
141
141
|
return null;
|
|
142
142
|
}
|
|
143
143
|
return {
|
|
@@ -373,7 +373,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
373
373
|
});
|
|
374
374
|
const auth2 = await newAuthenticator.whoami();
|
|
375
375
|
if (auth2) {
|
|
376
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
376
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _28 => _28.email])}`);
|
|
377
377
|
} else {
|
|
378
378
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
379
379
|
}
|
|
@@ -452,7 +452,7 @@ var _glob = require('glob'); var glob = _interopRequireWildcard(_glob);
|
|
|
452
452
|
function getBuckets(i18nConfig) {
|
|
453
453
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
454
454
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
455
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
455
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _29 => _29.exclude, 'optionalAccess', _30 => _30.map, 'call', _31 => _31((item) => resolveBucketItem(item))]);
|
|
456
456
|
return {
|
|
457
457
|
type: bucketType,
|
|
458
458
|
config: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
@@ -469,7 +469,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
469
469
|
})
|
|
470
470
|
)
|
|
471
471
|
);
|
|
472
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
472
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _32 => _32.flatMap, 'call', _33 => _33(
|
|
473
473
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
474
474
|
(pathPattern) => ({
|
|
475
475
|
pathPattern,
|
|
@@ -503,7 +503,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
503
503
|
}
|
|
504
504
|
const pathPatternChunks = pathPattern.split(_path2.default.sep);
|
|
505
505
|
const localeSegmentIndex = pathPatternChunks.findIndex((segment) => segment.includes("[locale]"));
|
|
506
|
-
const localePlaceholderIndex = _nullishCoalesce(_optionalChain([pathPatternChunks, 'access',
|
|
506
|
+
const localePlaceholderIndex = _nullishCoalesce(_optionalChain([pathPatternChunks, 'access', _34 => _34[localeSegmentIndex], 'optionalAccess', _35 => _35.indexOf, 'call', _36 => _36("[locale]")]), () => ( -1));
|
|
507
507
|
const sourcePathPattern = pathPattern.replace(/\[locale\]/g, sourceLocale);
|
|
508
508
|
const sourcePaths = 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));
|
|
509
509
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
@@ -588,12 +588,12 @@ function composeLoaders(...loaders) {
|
|
|
588
588
|
return {
|
|
589
589
|
init: async () => {
|
|
590
590
|
for (const loader of loaders) {
|
|
591
|
-
await _optionalChain([loader, 'access',
|
|
591
|
+
await _optionalChain([loader, 'access', _37 => _37.init, 'optionalCall', _38 => _38()]);
|
|
592
592
|
}
|
|
593
593
|
},
|
|
594
594
|
setDefaultLocale(locale) {
|
|
595
595
|
for (const loader of loaders) {
|
|
596
|
-
_optionalChain([loader, 'access',
|
|
596
|
+
_optionalChain([loader, 'access', _39 => _39.setDefaultLocale, 'optionalCall', _40 => _40(locale)]);
|
|
597
597
|
}
|
|
598
598
|
return this;
|
|
599
599
|
},
|
|
@@ -624,7 +624,7 @@ function createLoader(lDefinition) {
|
|
|
624
624
|
if (state.initCtx) {
|
|
625
625
|
return state.initCtx;
|
|
626
626
|
}
|
|
627
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
627
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _41 => _41.init, 'optionalCall', _42 => _42()]);
|
|
628
628
|
return state.initCtx;
|
|
629
629
|
},
|
|
630
630
|
setDefaultLocale(locale) {
|
|
@@ -682,26 +682,87 @@ function createJsonLoader() {
|
|
|
682
682
|
|
|
683
683
|
// src/cli/loaders/flat.ts
|
|
684
684
|
var _flat = require('flat');
|
|
685
|
+
|
|
686
|
+
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
685
687
|
function createFlatLoader() {
|
|
688
|
+
let denormalizedKeysMap = {};
|
|
686
689
|
return createLoader({
|
|
687
690
|
pull: async (locale, input) => {
|
|
688
|
-
|
|
691
|
+
const denormalized = denormalizeObjectKeys(input || {});
|
|
692
|
+
const flattened = _flat.flatten.call(void 0, denormalized, {
|
|
689
693
|
delimiter: "/",
|
|
690
694
|
transformKey(key) {
|
|
691
695
|
return encodeURIComponent(String(key));
|
|
692
696
|
}
|
|
693
697
|
});
|
|
698
|
+
denormalizedKeysMap = { ...denormalizedKeysMap, ...buildDenormalizedKeysMap(flattened) };
|
|
699
|
+
const normalized = normalizeObjectKeys(flattened);
|
|
700
|
+
return normalized;
|
|
694
701
|
},
|
|
695
702
|
push: async (locale, data) => {
|
|
696
|
-
|
|
703
|
+
const denormalized = mapDenormalizedKeys(data, denormalizedKeysMap);
|
|
704
|
+
const unflattened = _flat.unflatten.call(void 0, denormalized || {}, {
|
|
697
705
|
delimiter: "/",
|
|
698
706
|
transformKey(key) {
|
|
699
707
|
return decodeURIComponent(String(key));
|
|
700
708
|
}
|
|
701
709
|
});
|
|
710
|
+
const normalized = normalizeObjectKeys(unflattened);
|
|
711
|
+
return normalized;
|
|
702
712
|
}
|
|
703
713
|
});
|
|
704
714
|
}
|
|
715
|
+
function buildDenormalizedKeysMap(obj) {
|
|
716
|
+
if (!obj) return {};
|
|
717
|
+
return Object.keys(obj).reduce(
|
|
718
|
+
(acc, key) => {
|
|
719
|
+
if (key) {
|
|
720
|
+
const normalizedKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
721
|
+
acc[normalizedKey] = key;
|
|
722
|
+
}
|
|
723
|
+
return acc;
|
|
724
|
+
},
|
|
725
|
+
{}
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
function mapDenormalizedKeys(obj, denormalizedKeysMap) {
|
|
729
|
+
return Object.keys(obj).reduce(
|
|
730
|
+
(acc, key) => {
|
|
731
|
+
const denormalizedKey = denormalizedKeysMap[key];
|
|
732
|
+
acc[denormalizedKey] = obj[key];
|
|
733
|
+
return acc;
|
|
734
|
+
},
|
|
735
|
+
{}
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
function denormalizeObjectKeys(obj) {
|
|
739
|
+
if (_lodash2.default.isObject(obj) && !_lodash2.default.isArray(obj)) {
|
|
740
|
+
return _lodash2.default.transform(
|
|
741
|
+
obj,
|
|
742
|
+
(result, value, key) => {
|
|
743
|
+
const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
|
|
744
|
+
result[newKey] = _lodash2.default.isObject(value) ? denormalizeObjectKeys(value) : value;
|
|
745
|
+
},
|
|
746
|
+
{}
|
|
747
|
+
);
|
|
748
|
+
} else {
|
|
749
|
+
return obj;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function normalizeObjectKeys(obj) {
|
|
753
|
+
if (_lodash2.default.isObject(obj) && !_lodash2.default.isArray(obj)) {
|
|
754
|
+
return _lodash2.default.transform(
|
|
755
|
+
obj,
|
|
756
|
+
(result, value, key) => {
|
|
757
|
+
const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
758
|
+
result[newKey] = _lodash2.default.isObject(value) ? normalizeObjectKeys(value) : value;
|
|
759
|
+
},
|
|
760
|
+
{}
|
|
761
|
+
);
|
|
762
|
+
} else {
|
|
763
|
+
return obj;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
705
766
|
|
|
706
767
|
// src/cli/loaders/text-file.ts
|
|
707
768
|
var _promises3 = require('fs/promises'); var _promises4 = _interopRequireDefault(_promises3);
|
|
@@ -713,7 +774,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
713
774
|
const trimmedResult = result.trim();
|
|
714
775
|
return trimmedResult;
|
|
715
776
|
},
|
|
716
|
-
async push(locale, data,
|
|
777
|
+
async push(locale, data, _20, originalLocale) {
|
|
717
778
|
const draftPath = pathPattern.replace("[locale]", locale);
|
|
718
779
|
const finalPath = _path2.default.resolve(draftPath);
|
|
719
780
|
const dirPath = _path2.default.dirname(finalPath);
|
|
@@ -742,8 +803,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
742
803
|
if (!templateData) {
|
|
743
804
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
744
805
|
}
|
|
745
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
746
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
806
|
+
if (_optionalChain([templateData, 'optionalAccess', _43 => _43.match, 'call', _44 => _44(/[\r\n]$/)])) {
|
|
807
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _45 => _45.includes, 'call', _46 => _46("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _47 => _47.includes, 'call', _48 => _48("\r")]) ? "\r" : "\n";
|
|
747
808
|
return ending;
|
|
748
809
|
}
|
|
749
810
|
return "";
|
|
@@ -961,7 +1022,7 @@ function createHtmlLoader() {
|
|
|
961
1022
|
break;
|
|
962
1023
|
}
|
|
963
1024
|
const siblings = Array.from(parent.childNodes).filter(
|
|
964
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1025
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _49 => _49.textContent, 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()])
|
|
965
1026
|
);
|
|
966
1027
|
const index = siblings.indexOf(current);
|
|
967
1028
|
if (index !== -1) {
|
|
@@ -996,11 +1057,11 @@ function createHtmlLoader() {
|
|
|
996
1057
|
result[getPath(element, attr)] = value;
|
|
997
1058
|
}
|
|
998
1059
|
});
|
|
999
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1060
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _52 => _52.textContent, 'optionalAccess', _53 => _53.trim, 'call', _54 => _54()])).forEach(processNode);
|
|
1000
1061
|
}
|
|
1001
1062
|
};
|
|
1002
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1003
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1063
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _55 => _55.textContent, 'optionalAccess', _56 => _56.trim, 'call', _57 => _57()])).forEach(processNode);
|
|
1064
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _58 => _58.textContent, 'optionalAccess', _59 => _59.trim, 'call', _60 => _60()])).forEach(processNode);
|
|
1004
1065
|
return result;
|
|
1005
1066
|
},
|
|
1006
1067
|
async push(locale, data, originalInput) {
|
|
@@ -1022,7 +1083,7 @@ function createHtmlLoader() {
|
|
|
1022
1083
|
for (let i = 0; i < indices.length; i++) {
|
|
1023
1084
|
const index = parseInt(indices[i]);
|
|
1024
1085
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1025
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1086
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _61 => _61.textContent, 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()])
|
|
1026
1087
|
);
|
|
1027
1088
|
if (index >= siblings.length) {
|
|
1028
1089
|
if (i === indices.length - 1) {
|
|
@@ -1118,7 +1179,7 @@ function createPropertiesLoader() {
|
|
|
1118
1179
|
return result;
|
|
1119
1180
|
},
|
|
1120
1181
|
async push(locale, payload) {
|
|
1121
|
-
const result = Object.entries(payload).filter(([
|
|
1182
|
+
const result = Object.entries(payload).filter(([_20, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1122
1183
|
return result;
|
|
1123
1184
|
}
|
|
1124
1185
|
});
|
|
@@ -1129,7 +1190,7 @@ function isSkippableLine(line) {
|
|
|
1129
1190
|
function parsePropertyLine(line) {
|
|
1130
1191
|
const [key, ...valueParts] = line.split("=");
|
|
1131
1192
|
return {
|
|
1132
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1193
|
+
key: _optionalChain([key, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || "",
|
|
1133
1194
|
value: valueParts.join("=").trim()
|
|
1134
1195
|
};
|
|
1135
1196
|
}
|
|
@@ -1211,7 +1272,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1211
1272
|
const resultData = {};
|
|
1212
1273
|
for (const [translationKey, _translationEntity] of Object.entries(input.strings)) {
|
|
1213
1274
|
const rootTranslationEntity = _translationEntity;
|
|
1214
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1275
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _66 => _66.localizations, 'optionalAccess', _67 => _67[locale]]);
|
|
1215
1276
|
if (langTranslationEntity) {
|
|
1216
1277
|
if ("stringUnit" in langTranslationEntity) {
|
|
1217
1278
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1220,7 +1281,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1220
1281
|
resultData[translationKey] = {};
|
|
1221
1282
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1222
1283
|
for (const form in pluralForms) {
|
|
1223
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1284
|
+
if (_optionalChain([pluralForms, 'access', _68 => _68[form], 'optionalAccess', _69 => _69.stringUnit, 'optionalAccess', _70 => _70.value])) {
|
|
1224
1285
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1225
1286
|
}
|
|
1226
1287
|
}
|
|
@@ -1331,8 +1392,8 @@ function createUnlocalizableLoader() {
|
|
|
1331
1392
|
}
|
|
1332
1393
|
}
|
|
1333
1394
|
return false;
|
|
1334
|
-
}).map(([key,
|
|
1335
|
-
const result = _lodash2.default.omitBy(input, (
|
|
1395
|
+
}).map(([key, _20]) => key);
|
|
1396
|
+
const result = _lodash2.default.omitBy(input, (_20, key) => passthroughKeys.includes(key));
|
|
1336
1397
|
return result;
|
|
1337
1398
|
},
|
|
1338
1399
|
async push(locale, data, originalInput) {
|
|
@@ -1367,7 +1428,7 @@ function createPoDataLoader(params) {
|
|
|
1367
1428
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1368
1429
|
if (msgid && entry.msgid) {
|
|
1369
1430
|
const context = entry.msgctxt || "";
|
|
1370
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1431
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _71 => _71.translations, 'access', _72 => _72[context], 'optionalAccess', _73 => _73[msgid]]);
|
|
1371
1432
|
if (fullEntry) {
|
|
1372
1433
|
result[msgid] = fullEntry;
|
|
1373
1434
|
}
|
|
@@ -1377,7 +1438,7 @@ function createPoDataLoader(params) {
|
|
|
1377
1438
|
return result;
|
|
1378
1439
|
},
|
|
1379
1440
|
async push(locale, data, originalInput) {
|
|
1380
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1441
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _74 => _74.split, 'call', _75 => _75("\n\n"), 'access', _76 => _76.filter, 'call', _77 => _77(Boolean)]) || [];
|
|
1381
1442
|
const result = sections.map((section) => {
|
|
1382
1443
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1383
1444
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1419,7 +1480,7 @@ function createPoContentLoader() {
|
|
|
1419
1480
|
entry.msgid,
|
|
1420
1481
|
{
|
|
1421
1482
|
...entry,
|
|
1422
|
-
msgstr: [_optionalChain([data, 'access',
|
|
1483
|
+
msgstr: [_optionalChain([data, 'access', _78 => _78[entry.msgid], 'optionalAccess', _79 => _79.singular]), _optionalChain([data, 'access', _80 => _80[entry.msgid], 'optionalAccess', _81 => _81.plural]) || null].filter(Boolean)
|
|
1423
1484
|
}
|
|
1424
1485
|
]).fromPairs().value();
|
|
1425
1486
|
return result;
|
|
@@ -1665,7 +1726,7 @@ function createDatoClient(params) {
|
|
|
1665
1726
|
only_valid: "true",
|
|
1666
1727
|
ids: !records.length ? void 0 : records.join(",")
|
|
1667
1728
|
}
|
|
1668
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1729
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _82 => _82.response, 'optionalAccess', _83 => _83.body, 'optionalAccess', _84 => _84.data, 'optionalAccess', _85 => _85[0]]) || error));
|
|
1669
1730
|
},
|
|
1670
1731
|
findRecordsForModel: async (modelId, records) => {
|
|
1671
1732
|
try {
|
|
@@ -1675,9 +1736,9 @@ function createDatoClient(params) {
|
|
|
1675
1736
|
filter: {
|
|
1676
1737
|
type: modelId,
|
|
1677
1738
|
only_valid: "true",
|
|
1678
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
1739
|
+
ids: !_optionalChain([records, 'optionalAccess', _86 => _86.length]) ? void 0 : records.join(",")
|
|
1679
1740
|
}
|
|
1680
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1741
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _87 => _87.response, 'optionalAccess', _88 => _88.body, 'optionalAccess', _89 => _89.data, 'optionalAccess', _90 => _90[0]]) || error));
|
|
1681
1742
|
return result;
|
|
1682
1743
|
} catch (_error) {
|
|
1683
1744
|
throw new Error(
|
|
@@ -1691,9 +1752,9 @@ function createDatoClient(params) {
|
|
|
1691
1752
|
},
|
|
1692
1753
|
updateRecord: async (id, payload) => {
|
|
1693
1754
|
try {
|
|
1694
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1755
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _91 => _91.response, 'optionalAccess', _92 => _92.body, 'optionalAccess', _93 => _93.data, 'optionalAccess', _94 => _94[0]]) || error));
|
|
1695
1756
|
} catch (_error) {
|
|
1696
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1757
|
+
if (_optionalChain([_error, 'optionalAccess', _95 => _95.attributes, 'optionalAccess', _96 => _96.details, 'optionalAccess', _97 => _97.message])) {
|
|
1697
1758
|
throw new Error(
|
|
1698
1759
|
[
|
|
1699
1760
|
`${_error.attributes.details.message}`,
|
|
@@ -1714,9 +1775,9 @@ function createDatoClient(params) {
|
|
|
1714
1775
|
},
|
|
1715
1776
|
enableFieldLocalization: async (args) => {
|
|
1716
1777
|
try {
|
|
1717
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1778
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _98 => _98.response, 'optionalAccess', _99 => _99.body, 'optionalAccess', _100 => _100.data, 'optionalAccess', _101 => _101[0]]) || error));
|
|
1718
1779
|
} catch (_error) {
|
|
1719
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1780
|
+
if (_optionalChain([_error, 'optionalAccess', _102 => _102.attributes, 'optionalAccess', _103 => _103.code]) === "NOT_FOUND") {
|
|
1720
1781
|
throw new Error(
|
|
1721
1782
|
[
|
|
1722
1783
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -1724,7 +1785,7 @@ function createDatoClient(params) {
|
|
|
1724
1785
|
].join("\n\n")
|
|
1725
1786
|
);
|
|
1726
1787
|
}
|
|
1727
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1788
|
+
if (_optionalChain([_error, 'optionalAccess', _104 => _104.attributes, 'optionalAccess', _105 => _105.details, 'optionalAccess', _106 => _106.message])) {
|
|
1728
1789
|
throw new Error(
|
|
1729
1790
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
1730
1791
|
);
|
|
@@ -1790,7 +1851,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1790
1851
|
}
|
|
1791
1852
|
}
|
|
1792
1853
|
const records = await dato.findRecordsForModel(modelId);
|
|
1793
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
1854
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _107 => _107.models, 'access', _108 => _108[modelId], 'optionalAccess', _109 => _109.records]) || [], project);
|
|
1794
1855
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
1795
1856
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
1796
1857
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -1802,14 +1863,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1802
1863
|
},
|
|
1803
1864
|
async pull(locale, input, initCtx) {
|
|
1804
1865
|
const result = {};
|
|
1805
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
1806
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
1866
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _110 => _110.models]) || {})) {
|
|
1867
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _111 => _111.models, 'access', _112 => _112[modelId], 'access', _113 => _113.records]) || [];
|
|
1807
1868
|
const recordIds = records.map((record) => record.id);
|
|
1808
1869
|
records = await dato.findRecords(recordIds);
|
|
1809
1870
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
1810
1871
|
if (records.length > 0) {
|
|
1811
1872
|
result[modelId] = {
|
|
1812
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
1873
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _114 => _114.models, 'optionalAccess', _115 => _115[modelId], 'optionalAccess', _116 => _116.fields]) || [],
|
|
1813
1874
|
records
|
|
1814
1875
|
};
|
|
1815
1876
|
}
|
|
@@ -1868,7 +1929,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
1868
1929
|
return records.map((record) => ({
|
|
1869
1930
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
1870
1931
|
value: record.id,
|
|
1871
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
1932
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _117 => _117.includes, 'call', _118 => _118(record.id)])
|
|
1872
1933
|
}));
|
|
1873
1934
|
}
|
|
1874
1935
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2135,7 +2196,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2135
2196
|
function createVttLoader() {
|
|
2136
2197
|
return createLoader({
|
|
2137
2198
|
async pull(locale, input) {
|
|
2138
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2199
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _119 => _119.parse, 'call', _120 => _120(input), 'optionalAccess', _121 => _121.cues]);
|
|
2139
2200
|
if (Object.keys(vtt).length === 0) {
|
|
2140
2201
|
return {};
|
|
2141
2202
|
} else {
|
|
@@ -2187,7 +2248,7 @@ function variableExtractLoader(params) {
|
|
|
2187
2248
|
for (let i = 0; i < matches.length; i++) {
|
|
2188
2249
|
const match = matches[i];
|
|
2189
2250
|
const currentValue = result[key].value;
|
|
2190
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2251
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _122 => _122.replace, 'call', _123 => _123(match, `{variable:${i}}`)]);
|
|
2191
2252
|
result[key].value = newValue;
|
|
2192
2253
|
result[key].variables[i] = match;
|
|
2193
2254
|
}
|
|
@@ -2201,7 +2262,7 @@ function variableExtractLoader(params) {
|
|
|
2201
2262
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2202
2263
|
const variable = valueObj.variables[i];
|
|
2203
2264
|
const currentValue = result[key];
|
|
2204
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2265
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _124 => _124.replace, 'call', _125 => _125(`{variable:${i}}`, variable)]);
|
|
2205
2266
|
result[key] = newValue;
|
|
2206
2267
|
}
|
|
2207
2268
|
}
|
|
@@ -2641,11 +2702,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2641
2702
|
const auth = await validateAuth(settings);
|
|
2642
2703
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
2643
2704
|
let buckets = getBuckets(i18nConfig);
|
|
2644
|
-
if (_optionalChain([flags, 'access',
|
|
2705
|
+
if (_optionalChain([flags, 'access', _126 => _126.bucket, 'optionalAccess', _127 => _127.length])) {
|
|
2645
2706
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
2646
2707
|
}
|
|
2647
2708
|
ora.succeed("Buckets retrieved");
|
|
2648
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
2709
|
+
const targetLocales = _optionalChain([flags, 'access', _128 => _128.locale, 'optionalAccess', _129 => _129.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
2649
2710
|
const lockfileHelper = createLockfileHelper();
|
|
2650
2711
|
ora.start("Ensuring i18n.lock exists...");
|
|
2651
2712
|
if (!lockfileHelper.isLockfileExists()) {
|
|
@@ -2753,7 +2814,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2753
2814
|
targetData
|
|
2754
2815
|
});
|
|
2755
2816
|
if (flags.key) {
|
|
2756
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
2817
|
+
processableData = _lodash2.default.pickBy(processableData, (_20, key) => key === flags.key);
|
|
2757
2818
|
}
|
|
2758
2819
|
if (flags.verbose) {
|
|
2759
2820
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -2931,12 +2992,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
2931
2992
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2932
2993
|
docUrl: "bucketNotFound"
|
|
2933
2994
|
});
|
|
2934
|
-
} else if (_optionalChain([flags, 'access',
|
|
2995
|
+
} else if (_optionalChain([flags, 'access', _130 => _130.locale, 'optionalAccess', _131 => _131.some, 'call', _132 => _132((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
2935
2996
|
throw new CLIError({
|
|
2936
2997
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
2937
2998
|
docUrl: "localeTargetNotFound"
|
|
2938
2999
|
});
|
|
2939
|
-
} else if (_optionalChain([flags, 'access',
|
|
3000
|
+
} else if (_optionalChain([flags, 'access', _133 => _133.bucket, 'optionalAccess', _134 => _134.some, 'call', _135 => _135((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
2940
3001
|
throw new CLIError({
|
|
2941
3002
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
2942
3003
|
docUrl: "bucketNotFound"
|
|
@@ -3163,7 +3224,7 @@ function displaySummary(results) {
|
|
|
3163
3224
|
// package.json
|
|
3164
3225
|
var package_default = {
|
|
3165
3226
|
name: "lingo.dev",
|
|
3166
|
-
version: "0.74.
|
|
3227
|
+
version: "0.74.13",
|
|
3167
3228
|
description: "Lingo.dev CLI",
|
|
3168
3229
|
private: false,
|
|
3169
3230
|
publishConfig: {
|
|
@@ -3200,6 +3261,7 @@ var package_default = {
|
|
|
3200
3261
|
dev: "tsup --watch",
|
|
3201
3262
|
build: "tsc --noEmit && tsup",
|
|
3202
3263
|
test: "vitest run",
|
|
3264
|
+
"test:watch": "vitest",
|
|
3203
3265
|
clean: "rm -rf build"
|
|
3204
3266
|
},
|
|
3205
3267
|
keywords: [],
|