lingo.dev 0.74.12 → 0.74.14
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 +131 -60
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +192 -121
- 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 "";
|
|
@@ -897,20 +958,24 @@ function createCsvLoader() {
|
|
|
897
958
|
return createLoader({
|
|
898
959
|
async pull(locale, _input) {
|
|
899
960
|
const input = _sync.parse.call(void 0, _input, {
|
|
900
|
-
columns: true
|
|
961
|
+
columns: true,
|
|
962
|
+
skip_empty_lines: true
|
|
901
963
|
});
|
|
902
964
|
const result = {};
|
|
903
965
|
_lodash2.default.forEach(input, (row) => {
|
|
904
966
|
const key = row.id;
|
|
905
|
-
if (key && row[locale]) {
|
|
967
|
+
if (key && row[locale] && row[locale].trim() !== "") {
|
|
906
968
|
result[key] = row[locale];
|
|
907
969
|
}
|
|
908
970
|
});
|
|
909
971
|
return result;
|
|
910
972
|
},
|
|
911
973
|
async push(locale, data, originalInput) {
|
|
912
|
-
const input = _sync.parse.call(void 0, originalInput || "", {
|
|
913
|
-
|
|
974
|
+
const input = _sync.parse.call(void 0, originalInput || "", {
|
|
975
|
+
columns: true,
|
|
976
|
+
skip_empty_lines: true
|
|
977
|
+
});
|
|
978
|
+
const columns = input.length > 0 ? Object.keys(input[0]) : ["id", locale];
|
|
914
979
|
const updatedRows = input.map((row) => ({
|
|
915
980
|
...row,
|
|
916
981
|
[locale]: data[row.id] || row[locale] || ""
|
|
@@ -918,13 +983,18 @@ function createCsvLoader() {
|
|
|
918
983
|
const existingKeys = new Set(input.map((row) => row.id));
|
|
919
984
|
Object.entries(data).forEach(([key, value]) => {
|
|
920
985
|
if (!existingKeys.has(key)) {
|
|
921
|
-
|
|
986
|
+
const newRow = {
|
|
922
987
|
id: key,
|
|
923
|
-
...Object.fromEntries(columns.map((column) => [column,
|
|
924
|
-
}
|
|
988
|
+
...Object.fromEntries(columns.map((column) => [column, ""]))
|
|
989
|
+
};
|
|
990
|
+
newRow[locale] = value;
|
|
991
|
+
updatedRows.push(newRow);
|
|
925
992
|
}
|
|
926
993
|
});
|
|
927
|
-
return _sync3.stringify.call(void 0, updatedRows, {
|
|
994
|
+
return _sync3.stringify.call(void 0, updatedRows, {
|
|
995
|
+
header: true,
|
|
996
|
+
columns
|
|
997
|
+
});
|
|
928
998
|
}
|
|
929
999
|
});
|
|
930
1000
|
}
|
|
@@ -961,7 +1031,7 @@ function createHtmlLoader() {
|
|
|
961
1031
|
break;
|
|
962
1032
|
}
|
|
963
1033
|
const siblings = Array.from(parent.childNodes).filter(
|
|
964
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1034
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _49 => _49.textContent, 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()])
|
|
965
1035
|
);
|
|
966
1036
|
const index = siblings.indexOf(current);
|
|
967
1037
|
if (index !== -1) {
|
|
@@ -996,11 +1066,11 @@ function createHtmlLoader() {
|
|
|
996
1066
|
result[getPath(element, attr)] = value;
|
|
997
1067
|
}
|
|
998
1068
|
});
|
|
999
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1069
|
+
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
1070
|
}
|
|
1001
1071
|
};
|
|
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',
|
|
1072
|
+
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);
|
|
1073
|
+
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
1074
|
return result;
|
|
1005
1075
|
},
|
|
1006
1076
|
async push(locale, data, originalInput) {
|
|
@@ -1022,7 +1092,7 @@ function createHtmlLoader() {
|
|
|
1022
1092
|
for (let i = 0; i < indices.length; i++) {
|
|
1023
1093
|
const index = parseInt(indices[i]);
|
|
1024
1094
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1025
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1095
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _61 => _61.textContent, 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()])
|
|
1026
1096
|
);
|
|
1027
1097
|
if (index >= siblings.length) {
|
|
1028
1098
|
if (i === indices.length - 1) {
|
|
@@ -1118,7 +1188,7 @@ function createPropertiesLoader() {
|
|
|
1118
1188
|
return result;
|
|
1119
1189
|
},
|
|
1120
1190
|
async push(locale, payload) {
|
|
1121
|
-
const result = Object.entries(payload).filter(([
|
|
1191
|
+
const result = Object.entries(payload).filter(([_20, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1122
1192
|
return result;
|
|
1123
1193
|
}
|
|
1124
1194
|
});
|
|
@@ -1129,7 +1199,7 @@ function isSkippableLine(line) {
|
|
|
1129
1199
|
function parsePropertyLine(line) {
|
|
1130
1200
|
const [key, ...valueParts] = line.split("=");
|
|
1131
1201
|
return {
|
|
1132
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1202
|
+
key: _optionalChain([key, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || "",
|
|
1133
1203
|
value: valueParts.join("=").trim()
|
|
1134
1204
|
};
|
|
1135
1205
|
}
|
|
@@ -1211,7 +1281,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1211
1281
|
const resultData = {};
|
|
1212
1282
|
for (const [translationKey, _translationEntity] of Object.entries(input.strings)) {
|
|
1213
1283
|
const rootTranslationEntity = _translationEntity;
|
|
1214
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1284
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _66 => _66.localizations, 'optionalAccess', _67 => _67[locale]]);
|
|
1215
1285
|
if (langTranslationEntity) {
|
|
1216
1286
|
if ("stringUnit" in langTranslationEntity) {
|
|
1217
1287
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1220,7 +1290,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1220
1290
|
resultData[translationKey] = {};
|
|
1221
1291
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1222
1292
|
for (const form in pluralForms) {
|
|
1223
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1293
|
+
if (_optionalChain([pluralForms, 'access', _68 => _68[form], 'optionalAccess', _69 => _69.stringUnit, 'optionalAccess', _70 => _70.value])) {
|
|
1224
1294
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1225
1295
|
}
|
|
1226
1296
|
}
|
|
@@ -1331,8 +1401,8 @@ function createUnlocalizableLoader() {
|
|
|
1331
1401
|
}
|
|
1332
1402
|
}
|
|
1333
1403
|
return false;
|
|
1334
|
-
}).map(([key,
|
|
1335
|
-
const result = _lodash2.default.omitBy(input, (
|
|
1404
|
+
}).map(([key, _20]) => key);
|
|
1405
|
+
const result = _lodash2.default.omitBy(input, (_20, key) => passthroughKeys.includes(key));
|
|
1336
1406
|
return result;
|
|
1337
1407
|
},
|
|
1338
1408
|
async push(locale, data, originalInput) {
|
|
@@ -1367,7 +1437,7 @@ function createPoDataLoader(params) {
|
|
|
1367
1437
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1368
1438
|
if (msgid && entry.msgid) {
|
|
1369
1439
|
const context = entry.msgctxt || "";
|
|
1370
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1440
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _71 => _71.translations, 'access', _72 => _72[context], 'optionalAccess', _73 => _73[msgid]]);
|
|
1371
1441
|
if (fullEntry) {
|
|
1372
1442
|
result[msgid] = fullEntry;
|
|
1373
1443
|
}
|
|
@@ -1377,7 +1447,7 @@ function createPoDataLoader(params) {
|
|
|
1377
1447
|
return result;
|
|
1378
1448
|
},
|
|
1379
1449
|
async push(locale, data, originalInput) {
|
|
1380
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1450
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _74 => _74.split, 'call', _75 => _75("\n\n"), 'access', _76 => _76.filter, 'call', _77 => _77(Boolean)]) || [];
|
|
1381
1451
|
const result = sections.map((section) => {
|
|
1382
1452
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1383
1453
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1419,7 +1489,7 @@ function createPoContentLoader() {
|
|
|
1419
1489
|
entry.msgid,
|
|
1420
1490
|
{
|
|
1421
1491
|
...entry,
|
|
1422
|
-
msgstr: [_optionalChain([data, 'access',
|
|
1492
|
+
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
1493
|
}
|
|
1424
1494
|
]).fromPairs().value();
|
|
1425
1495
|
return result;
|
|
@@ -1665,7 +1735,7 @@ function createDatoClient(params) {
|
|
|
1665
1735
|
only_valid: "true",
|
|
1666
1736
|
ids: !records.length ? void 0 : records.join(",")
|
|
1667
1737
|
}
|
|
1668
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1738
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _82 => _82.response, 'optionalAccess', _83 => _83.body, 'optionalAccess', _84 => _84.data, 'optionalAccess', _85 => _85[0]]) || error));
|
|
1669
1739
|
},
|
|
1670
1740
|
findRecordsForModel: async (modelId, records) => {
|
|
1671
1741
|
try {
|
|
@@ -1675,9 +1745,9 @@ function createDatoClient(params) {
|
|
|
1675
1745
|
filter: {
|
|
1676
1746
|
type: modelId,
|
|
1677
1747
|
only_valid: "true",
|
|
1678
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
1748
|
+
ids: !_optionalChain([records, 'optionalAccess', _86 => _86.length]) ? void 0 : records.join(",")
|
|
1679
1749
|
}
|
|
1680
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1750
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _87 => _87.response, 'optionalAccess', _88 => _88.body, 'optionalAccess', _89 => _89.data, 'optionalAccess', _90 => _90[0]]) || error));
|
|
1681
1751
|
return result;
|
|
1682
1752
|
} catch (_error) {
|
|
1683
1753
|
throw new Error(
|
|
@@ -1691,9 +1761,9 @@ function createDatoClient(params) {
|
|
|
1691
1761
|
},
|
|
1692
1762
|
updateRecord: async (id, payload) => {
|
|
1693
1763
|
try {
|
|
1694
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1764
|
+
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
1765
|
} catch (_error) {
|
|
1696
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1766
|
+
if (_optionalChain([_error, 'optionalAccess', _95 => _95.attributes, 'optionalAccess', _96 => _96.details, 'optionalAccess', _97 => _97.message])) {
|
|
1697
1767
|
throw new Error(
|
|
1698
1768
|
[
|
|
1699
1769
|
`${_error.attributes.details.message}`,
|
|
@@ -1714,9 +1784,9 @@ function createDatoClient(params) {
|
|
|
1714
1784
|
},
|
|
1715
1785
|
enableFieldLocalization: async (args) => {
|
|
1716
1786
|
try {
|
|
1717
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1787
|
+
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
1788
|
} catch (_error) {
|
|
1719
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1789
|
+
if (_optionalChain([_error, 'optionalAccess', _102 => _102.attributes, 'optionalAccess', _103 => _103.code]) === "NOT_FOUND") {
|
|
1720
1790
|
throw new Error(
|
|
1721
1791
|
[
|
|
1722
1792
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -1724,7 +1794,7 @@ function createDatoClient(params) {
|
|
|
1724
1794
|
].join("\n\n")
|
|
1725
1795
|
);
|
|
1726
1796
|
}
|
|
1727
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1797
|
+
if (_optionalChain([_error, 'optionalAccess', _104 => _104.attributes, 'optionalAccess', _105 => _105.details, 'optionalAccess', _106 => _106.message])) {
|
|
1728
1798
|
throw new Error(
|
|
1729
1799
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
1730
1800
|
);
|
|
@@ -1790,7 +1860,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1790
1860
|
}
|
|
1791
1861
|
}
|
|
1792
1862
|
const records = await dato.findRecordsForModel(modelId);
|
|
1793
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
1863
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _107 => _107.models, 'access', _108 => _108[modelId], 'optionalAccess', _109 => _109.records]) || [], project);
|
|
1794
1864
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
1795
1865
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
1796
1866
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -1802,14 +1872,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1802
1872
|
},
|
|
1803
1873
|
async pull(locale, input, initCtx) {
|
|
1804
1874
|
const result = {};
|
|
1805
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
1806
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
1875
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _110 => _110.models]) || {})) {
|
|
1876
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _111 => _111.models, 'access', _112 => _112[modelId], 'access', _113 => _113.records]) || [];
|
|
1807
1877
|
const recordIds = records.map((record) => record.id);
|
|
1808
1878
|
records = await dato.findRecords(recordIds);
|
|
1809
1879
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
1810
1880
|
if (records.length > 0) {
|
|
1811
1881
|
result[modelId] = {
|
|
1812
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
1882
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _114 => _114.models, 'optionalAccess', _115 => _115[modelId], 'optionalAccess', _116 => _116.fields]) || [],
|
|
1813
1883
|
records
|
|
1814
1884
|
};
|
|
1815
1885
|
}
|
|
@@ -1868,7 +1938,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
1868
1938
|
return records.map((record) => ({
|
|
1869
1939
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
1870
1940
|
value: record.id,
|
|
1871
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
1941
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _117 => _117.includes, 'call', _118 => _118(record.id)])
|
|
1872
1942
|
}));
|
|
1873
1943
|
}
|
|
1874
1944
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2135,7 +2205,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2135
2205
|
function createVttLoader() {
|
|
2136
2206
|
return createLoader({
|
|
2137
2207
|
async pull(locale, input) {
|
|
2138
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2208
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _119 => _119.parse, 'call', _120 => _120(input), 'optionalAccess', _121 => _121.cues]);
|
|
2139
2209
|
if (Object.keys(vtt).length === 0) {
|
|
2140
2210
|
return {};
|
|
2141
2211
|
} else {
|
|
@@ -2187,7 +2257,7 @@ function variableExtractLoader(params) {
|
|
|
2187
2257
|
for (let i = 0; i < matches.length; i++) {
|
|
2188
2258
|
const match = matches[i];
|
|
2189
2259
|
const currentValue = result[key].value;
|
|
2190
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2260
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _122 => _122.replace, 'call', _123 => _123(match, `{variable:${i}}`)]);
|
|
2191
2261
|
result[key].value = newValue;
|
|
2192
2262
|
result[key].variables[i] = match;
|
|
2193
2263
|
}
|
|
@@ -2201,7 +2271,7 @@ function variableExtractLoader(params) {
|
|
|
2201
2271
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2202
2272
|
const variable = valueObj.variables[i];
|
|
2203
2273
|
const currentValue = result[key];
|
|
2204
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2274
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _124 => _124.replace, 'call', _125 => _125(`{variable:${i}}`, variable)]);
|
|
2205
2275
|
result[key] = newValue;
|
|
2206
2276
|
}
|
|
2207
2277
|
}
|
|
@@ -2641,11 +2711,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2641
2711
|
const auth = await validateAuth(settings);
|
|
2642
2712
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
2643
2713
|
let buckets = getBuckets(i18nConfig);
|
|
2644
|
-
if (_optionalChain([flags, 'access',
|
|
2714
|
+
if (_optionalChain([flags, 'access', _126 => _126.bucket, 'optionalAccess', _127 => _127.length])) {
|
|
2645
2715
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
2646
2716
|
}
|
|
2647
2717
|
ora.succeed("Buckets retrieved");
|
|
2648
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
2718
|
+
const targetLocales = _optionalChain([flags, 'access', _128 => _128.locale, 'optionalAccess', _129 => _129.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
2649
2719
|
const lockfileHelper = createLockfileHelper();
|
|
2650
2720
|
ora.start("Ensuring i18n.lock exists...");
|
|
2651
2721
|
if (!lockfileHelper.isLockfileExists()) {
|
|
@@ -2753,7 +2823,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2753
2823
|
targetData
|
|
2754
2824
|
});
|
|
2755
2825
|
if (flags.key) {
|
|
2756
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
2826
|
+
processableData = _lodash2.default.pickBy(processableData, (_20, key) => key === flags.key);
|
|
2757
2827
|
}
|
|
2758
2828
|
if (flags.verbose) {
|
|
2759
2829
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -2931,12 +3001,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
2931
3001
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2932
3002
|
docUrl: "bucketNotFound"
|
|
2933
3003
|
});
|
|
2934
|
-
} else if (_optionalChain([flags, 'access',
|
|
3004
|
+
} else if (_optionalChain([flags, 'access', _130 => _130.locale, 'optionalAccess', _131 => _131.some, 'call', _132 => _132((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
2935
3005
|
throw new CLIError({
|
|
2936
3006
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
2937
3007
|
docUrl: "localeTargetNotFound"
|
|
2938
3008
|
});
|
|
2939
|
-
} else if (_optionalChain([flags, 'access',
|
|
3009
|
+
} else if (_optionalChain([flags, 'access', _133 => _133.bucket, 'optionalAccess', _134 => _134.some, 'call', _135 => _135((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
2940
3010
|
throw new CLIError({
|
|
2941
3011
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
2942
3012
|
docUrl: "bucketNotFound"
|
|
@@ -3163,7 +3233,7 @@ function displaySummary(results) {
|
|
|
3163
3233
|
// package.json
|
|
3164
3234
|
var package_default = {
|
|
3165
3235
|
name: "lingo.dev",
|
|
3166
|
-
version: "0.74.
|
|
3236
|
+
version: "0.74.14",
|
|
3167
3237
|
description: "Lingo.dev CLI",
|
|
3168
3238
|
private: false,
|
|
3169
3239
|
publishConfig: {
|
|
@@ -3200,6 +3270,7 @@ var package_default = {
|
|
|
3200
3270
|
dev: "tsup --watch",
|
|
3201
3271
|
build: "tsc --noEmit && tsup",
|
|
3202
3272
|
test: "vitest run",
|
|
3273
|
+
"test:watch": "vitest",
|
|
3203
3274
|
clean: "rm -rf build"
|
|
3204
3275
|
},
|
|
3205
3276
|
keywords: [],
|