lingo.dev 0.74.9 → 0.74.11
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 +137 -73
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +214 -150
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -2
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 {
|
|
@@ -265,12 +265,13 @@ function _getConfigFilePath() {
|
|
|
265
265
|
// src/cli/cmd/init.ts
|
|
266
266
|
|
|
267
267
|
|
|
268
|
+
|
|
268
269
|
var _child_process = require('child_process');
|
|
269
270
|
|
|
270
271
|
var _prompts = require('@inquirer/prompts');
|
|
271
|
-
var openUrl = (
|
|
272
|
+
var openUrl = (path9) => {
|
|
272
273
|
const settings = getSettings(void 0);
|
|
273
|
-
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${
|
|
274
|
+
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path9}`]);
|
|
274
275
|
};
|
|
275
276
|
var throwHelpError = (option, value) => {
|
|
276
277
|
if (value === "help") {
|
|
@@ -311,20 +312,22 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
311
312
|
return value;
|
|
312
313
|
}).default("json")
|
|
313
314
|
).addOption(
|
|
314
|
-
new (0, _interactivecommander.InteractiveOption)("-p, --paths
|
|
315
|
+
new (0, _interactivecommander.InteractiveOption)("-p, --paths [path...]", "List of paths for the bucket").argParser((value) => {
|
|
316
|
+
if (!value || value.length === 0) return [];
|
|
315
317
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
316
|
-
for (const
|
|
318
|
+
for (const p of values) {
|
|
317
319
|
try {
|
|
318
|
-
const
|
|
320
|
+
const dirPath = _path2.default.dirname(p);
|
|
321
|
+
const stats = _fs2.default.statSync(dirPath);
|
|
319
322
|
if (!stats.isDirectory()) {
|
|
320
|
-
throw new Error(`${
|
|
323
|
+
throw new Error(`${dirPath} is not a directory`);
|
|
321
324
|
}
|
|
322
325
|
} catch (err) {
|
|
323
|
-
throw new Error(`Invalid
|
|
326
|
+
throw new Error(`Invalid path: ${p}`);
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
return values;
|
|
327
|
-
}).default(
|
|
330
|
+
}).default([])
|
|
328
331
|
).action(async (options) => {
|
|
329
332
|
const settings = getSettings(void 0);
|
|
330
333
|
const spinner = _ora2.default.call(void 0, ).start("Initializing Lingo.dev project");
|
|
@@ -337,7 +340,9 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
337
340
|
newConfig.locale.source = options.source;
|
|
338
341
|
newConfig.locale.targets = options.targets;
|
|
339
342
|
newConfig.buckets = {
|
|
340
|
-
[options.bucket]:
|
|
343
|
+
[options.bucket]: {
|
|
344
|
+
include: options.paths || []
|
|
345
|
+
}
|
|
341
346
|
};
|
|
342
347
|
await saveConfig(newConfig);
|
|
343
348
|
spinner.succeed("Lingo.dev project initialized");
|
|
@@ -368,7 +373,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
368
373
|
});
|
|
369
374
|
const auth2 = await newAuthenticator.whoami();
|
|
370
375
|
if (auth2) {
|
|
371
|
-
_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])}`);
|
|
372
377
|
} else {
|
|
373
378
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
374
379
|
}
|
|
@@ -447,7 +452,7 @@ var _glob = require('glob'); var glob = _interopRequireWildcard(_glob);
|
|
|
447
452
|
function getBuckets(i18nConfig) {
|
|
448
453
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
449
454
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
450
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
455
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _29 => _29.exclude, 'optionalAccess', _30 => _30.map, 'call', _31 => _31((item) => resolveBucketItem(item))]);
|
|
451
456
|
return {
|
|
452
457
|
type: bucketType,
|
|
453
458
|
config: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
@@ -464,7 +469,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
464
469
|
})
|
|
465
470
|
)
|
|
466
471
|
);
|
|
467
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
472
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _32 => _32.flatMap, 'call', _33 => _33(
|
|
468
473
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
469
474
|
(pathPattern) => ({
|
|
470
475
|
pathPattern,
|
|
@@ -498,7 +503,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
498
503
|
}
|
|
499
504
|
const pathPatternChunks = pathPattern.split(_path2.default.sep);
|
|
500
505
|
const localeSegmentIndex = pathPatternChunks.findIndex((segment) => segment.includes("[locale]"));
|
|
501
|
-
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));
|
|
502
507
|
const sourcePathPattern = pathPattern.replace(/\[locale\]/g, sourceLocale);
|
|
503
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));
|
|
504
509
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
@@ -550,8 +555,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
550
555
|
} else if (type.target) {
|
|
551
556
|
result.push(...targetPaths);
|
|
552
557
|
}
|
|
553
|
-
result.forEach((
|
|
554
|
-
console.log(
|
|
558
|
+
result.forEach((path9) => {
|
|
559
|
+
console.log(path9);
|
|
555
560
|
});
|
|
556
561
|
}
|
|
557
562
|
}
|
|
@@ -583,12 +588,12 @@ function composeLoaders(...loaders) {
|
|
|
583
588
|
return {
|
|
584
589
|
init: async () => {
|
|
585
590
|
for (const loader of loaders) {
|
|
586
|
-
await _optionalChain([loader, 'access',
|
|
591
|
+
await _optionalChain([loader, 'access', _37 => _37.init, 'optionalCall', _38 => _38()]);
|
|
587
592
|
}
|
|
588
593
|
},
|
|
589
594
|
setDefaultLocale(locale) {
|
|
590
595
|
for (const loader of loaders) {
|
|
591
|
-
_optionalChain([loader, 'access',
|
|
596
|
+
_optionalChain([loader, 'access', _39 => _39.setDefaultLocale, 'optionalCall', _40 => _40(locale)]);
|
|
592
597
|
}
|
|
593
598
|
return this;
|
|
594
599
|
},
|
|
@@ -619,7 +624,7 @@ function createLoader(lDefinition) {
|
|
|
619
624
|
if (state.initCtx) {
|
|
620
625
|
return state.initCtx;
|
|
621
626
|
}
|
|
622
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
627
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _41 => _41.init, 'optionalCall', _42 => _42()]);
|
|
623
628
|
return state.initCtx;
|
|
624
629
|
},
|
|
625
630
|
setDefaultLocale(locale) {
|
|
@@ -677,26 +682,84 @@ function createJsonLoader() {
|
|
|
677
682
|
|
|
678
683
|
// src/cli/loaders/flat.ts
|
|
679
684
|
var _flat = require('flat');
|
|
685
|
+
|
|
686
|
+
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
680
687
|
function createFlatLoader() {
|
|
688
|
+
let denormalizedKeysMap;
|
|
681
689
|
return createLoader({
|
|
682
690
|
pull: async (locale, input) => {
|
|
683
|
-
|
|
691
|
+
const denormalized = denormalizeObjectKeys(input || {});
|
|
692
|
+
const flattened = _flat.flatten.call(void 0, denormalized, {
|
|
684
693
|
delimiter: "/",
|
|
685
694
|
transformKey(key) {
|
|
686
695
|
return encodeURIComponent(String(key));
|
|
687
696
|
}
|
|
688
697
|
});
|
|
698
|
+
denormalizedKeysMap = buildDenormalizedKeysMap(flattened);
|
|
699
|
+
const normalized = normalizeObjectKeys(flattened);
|
|
700
|
+
return normalized;
|
|
689
701
|
},
|
|
690
702
|
push: async (locale, data) => {
|
|
691
|
-
|
|
703
|
+
const denormalized = mapDeormalizedKeys(data, denormalizedKeysMap);
|
|
704
|
+
const unflattened = _flat.unflatten.call(void 0, denormalized || {}, {
|
|
692
705
|
delimiter: "/",
|
|
693
706
|
transformKey(key) {
|
|
694
707
|
return decodeURIComponent(String(key));
|
|
695
708
|
}
|
|
696
709
|
});
|
|
710
|
+
const normalized = normalizeObjectKeys(unflattened);
|
|
711
|
+
return normalized;
|
|
697
712
|
}
|
|
698
713
|
});
|
|
699
714
|
}
|
|
715
|
+
function buildDenormalizedKeysMap(obj) {
|
|
716
|
+
return Object.keys(obj).reduce(
|
|
717
|
+
(acc, key) => {
|
|
718
|
+
const normalizedKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
719
|
+
acc[normalizedKey] = key;
|
|
720
|
+
return acc;
|
|
721
|
+
},
|
|
722
|
+
{}
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
function mapDeormalizedKeys(obj, denormalizedKeysMap) {
|
|
726
|
+
return Object.keys(obj).reduce(
|
|
727
|
+
(acc, key) => {
|
|
728
|
+
const denormalizedKey = denormalizedKeysMap[key];
|
|
729
|
+
acc[denormalizedKey] = obj[key];
|
|
730
|
+
return acc;
|
|
731
|
+
},
|
|
732
|
+
{}
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
function denormalizeObjectKeys(obj) {
|
|
736
|
+
if (_lodash2.default.isObject(obj) && !_lodash2.default.isArray(obj)) {
|
|
737
|
+
return _lodash2.default.transform(
|
|
738
|
+
obj,
|
|
739
|
+
(result, value, key) => {
|
|
740
|
+
const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
|
|
741
|
+
result[newKey] = _lodash2.default.isObject(value) ? denormalizeObjectKeys(value) : value;
|
|
742
|
+
},
|
|
743
|
+
{}
|
|
744
|
+
);
|
|
745
|
+
} else {
|
|
746
|
+
return obj;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
function normalizeObjectKeys(obj) {
|
|
750
|
+
if (_lodash2.default.isObject(obj) && !_lodash2.default.isArray(obj)) {
|
|
751
|
+
return _lodash2.default.transform(
|
|
752
|
+
obj,
|
|
753
|
+
(result, value, key) => {
|
|
754
|
+
const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
755
|
+
result[newKey] = _lodash2.default.isObject(value) ? normalizeObjectKeys(value) : value;
|
|
756
|
+
},
|
|
757
|
+
{}
|
|
758
|
+
);
|
|
759
|
+
} else {
|
|
760
|
+
return obj;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
700
763
|
|
|
701
764
|
// src/cli/loaders/text-file.ts
|
|
702
765
|
var _promises3 = require('fs/promises'); var _promises4 = _interopRequireDefault(_promises3);
|
|
@@ -708,7 +771,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
708
771
|
const trimmedResult = result.trim();
|
|
709
772
|
return trimmedResult;
|
|
710
773
|
},
|
|
711
|
-
async push(locale, data,
|
|
774
|
+
async push(locale, data, _20, originalLocale) {
|
|
712
775
|
const draftPath = pathPattern.replace("[locale]", locale);
|
|
713
776
|
const finalPath = _path2.default.resolve(draftPath);
|
|
714
777
|
const dirPath = _path2.default.dirname(finalPath);
|
|
@@ -737,8 +800,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
737
800
|
if (!templateData) {
|
|
738
801
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
739
802
|
}
|
|
740
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
741
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
803
|
+
if (_optionalChain([templateData, 'optionalAccess', _43 => _43.match, 'call', _44 => _44(/[\r\n]$/)])) {
|
|
804
|
+
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";
|
|
742
805
|
return ending;
|
|
743
806
|
}
|
|
744
807
|
return "";
|
|
@@ -956,7 +1019,7 @@ function createHtmlLoader() {
|
|
|
956
1019
|
break;
|
|
957
1020
|
}
|
|
958
1021
|
const siblings = Array.from(parent.childNodes).filter(
|
|
959
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1022
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _49 => _49.textContent, 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()])
|
|
960
1023
|
);
|
|
961
1024
|
const index = siblings.indexOf(current);
|
|
962
1025
|
if (index !== -1) {
|
|
@@ -991,11 +1054,11 @@ function createHtmlLoader() {
|
|
|
991
1054
|
result[getPath(element, attr)] = value;
|
|
992
1055
|
}
|
|
993
1056
|
});
|
|
994
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1057
|
+
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);
|
|
995
1058
|
}
|
|
996
1059
|
};
|
|
997
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
998
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1060
|
+
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);
|
|
1061
|
+
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);
|
|
999
1062
|
return result;
|
|
1000
1063
|
},
|
|
1001
1064
|
async push(locale, data, originalInput) {
|
|
@@ -1008,16 +1071,16 @@ function createHtmlLoader() {
|
|
|
1008
1071
|
const bDepth = b.split("/").length;
|
|
1009
1072
|
return aDepth - bDepth;
|
|
1010
1073
|
});
|
|
1011
|
-
paths.forEach((
|
|
1012
|
-
const value = data[
|
|
1013
|
-
const [nodePath, attribute] =
|
|
1074
|
+
paths.forEach((path9) => {
|
|
1075
|
+
const value = data[path9];
|
|
1076
|
+
const [nodePath, attribute] = path9.split("#");
|
|
1014
1077
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1015
1078
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1016
1079
|
let current = parent;
|
|
1017
1080
|
for (let i = 0; i < indices.length; i++) {
|
|
1018
1081
|
const index = parseInt(indices[i]);
|
|
1019
1082
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1020
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1083
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _61 => _61.textContent, 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()])
|
|
1021
1084
|
);
|
|
1022
1085
|
if (index >= siblings.length) {
|
|
1023
1086
|
if (i === indices.length - 1) {
|
|
@@ -1113,7 +1176,7 @@ function createPropertiesLoader() {
|
|
|
1113
1176
|
return result;
|
|
1114
1177
|
},
|
|
1115
1178
|
async push(locale, payload) {
|
|
1116
|
-
const result = Object.entries(payload).filter(([
|
|
1179
|
+
const result = Object.entries(payload).filter(([_20, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1117
1180
|
return result;
|
|
1118
1181
|
}
|
|
1119
1182
|
});
|
|
@@ -1124,7 +1187,7 @@ function isSkippableLine(line) {
|
|
|
1124
1187
|
function parsePropertyLine(line) {
|
|
1125
1188
|
const [key, ...valueParts] = line.split("=");
|
|
1126
1189
|
return {
|
|
1127
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1190
|
+
key: _optionalChain([key, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || "",
|
|
1128
1191
|
value: valueParts.join("=").trim()
|
|
1129
1192
|
};
|
|
1130
1193
|
}
|
|
@@ -1206,7 +1269,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1206
1269
|
const resultData = {};
|
|
1207
1270
|
for (const [translationKey, _translationEntity] of Object.entries(input.strings)) {
|
|
1208
1271
|
const rootTranslationEntity = _translationEntity;
|
|
1209
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1272
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _66 => _66.localizations, 'optionalAccess', _67 => _67[locale]]);
|
|
1210
1273
|
if (langTranslationEntity) {
|
|
1211
1274
|
if ("stringUnit" in langTranslationEntity) {
|
|
1212
1275
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1215,7 +1278,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1215
1278
|
resultData[translationKey] = {};
|
|
1216
1279
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1217
1280
|
for (const form in pluralForms) {
|
|
1218
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1281
|
+
if (_optionalChain([pluralForms, 'access', _68 => _68[form], 'optionalAccess', _69 => _69.stringUnit, 'optionalAccess', _70 => _70.value])) {
|
|
1219
1282
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1220
1283
|
}
|
|
1221
1284
|
}
|
|
@@ -1326,8 +1389,8 @@ function createUnlocalizableLoader() {
|
|
|
1326
1389
|
}
|
|
1327
1390
|
}
|
|
1328
1391
|
return false;
|
|
1329
|
-
}).map(([key,
|
|
1330
|
-
const result = _lodash2.default.omitBy(input, (
|
|
1392
|
+
}).map(([key, _20]) => key);
|
|
1393
|
+
const result = _lodash2.default.omitBy(input, (_20, key) => passthroughKeys.includes(key));
|
|
1331
1394
|
return result;
|
|
1332
1395
|
},
|
|
1333
1396
|
async push(locale, data, originalInput) {
|
|
@@ -1362,7 +1425,7 @@ function createPoDataLoader(params) {
|
|
|
1362
1425
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1363
1426
|
if (msgid && entry.msgid) {
|
|
1364
1427
|
const context = entry.msgctxt || "";
|
|
1365
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1428
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _71 => _71.translations, 'access', _72 => _72[context], 'optionalAccess', _73 => _73[msgid]]);
|
|
1366
1429
|
if (fullEntry) {
|
|
1367
1430
|
result[msgid] = fullEntry;
|
|
1368
1431
|
}
|
|
@@ -1372,7 +1435,7 @@ function createPoDataLoader(params) {
|
|
|
1372
1435
|
return result;
|
|
1373
1436
|
},
|
|
1374
1437
|
async push(locale, data, originalInput) {
|
|
1375
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1438
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _74 => _74.split, 'call', _75 => _75("\n\n"), 'access', _76 => _76.filter, 'call', _77 => _77(Boolean)]) || [];
|
|
1376
1439
|
const result = sections.map((section) => {
|
|
1377
1440
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1378
1441
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1414,7 +1477,7 @@ function createPoContentLoader() {
|
|
|
1414
1477
|
entry.msgid,
|
|
1415
1478
|
{
|
|
1416
1479
|
...entry,
|
|
1417
|
-
msgstr: [_optionalChain([data, 'access',
|
|
1480
|
+
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)
|
|
1418
1481
|
}
|
|
1419
1482
|
]).fromPairs().value();
|
|
1420
1483
|
return result;
|
|
@@ -1660,7 +1723,7 @@ function createDatoClient(params) {
|
|
|
1660
1723
|
only_valid: "true",
|
|
1661
1724
|
ids: !records.length ? void 0 : records.join(",")
|
|
1662
1725
|
}
|
|
1663
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1726
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _82 => _82.response, 'optionalAccess', _83 => _83.body, 'optionalAccess', _84 => _84.data, 'optionalAccess', _85 => _85[0]]) || error));
|
|
1664
1727
|
},
|
|
1665
1728
|
findRecordsForModel: async (modelId, records) => {
|
|
1666
1729
|
try {
|
|
@@ -1670,9 +1733,9 @@ function createDatoClient(params) {
|
|
|
1670
1733
|
filter: {
|
|
1671
1734
|
type: modelId,
|
|
1672
1735
|
only_valid: "true",
|
|
1673
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
1736
|
+
ids: !_optionalChain([records, 'optionalAccess', _86 => _86.length]) ? void 0 : records.join(",")
|
|
1674
1737
|
}
|
|
1675
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1738
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _87 => _87.response, 'optionalAccess', _88 => _88.body, 'optionalAccess', _89 => _89.data, 'optionalAccess', _90 => _90[0]]) || error));
|
|
1676
1739
|
return result;
|
|
1677
1740
|
} catch (_error) {
|
|
1678
1741
|
throw new Error(
|
|
@@ -1686,9 +1749,9 @@ function createDatoClient(params) {
|
|
|
1686
1749
|
},
|
|
1687
1750
|
updateRecord: async (id, payload) => {
|
|
1688
1751
|
try {
|
|
1689
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1752
|
+
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));
|
|
1690
1753
|
} catch (_error) {
|
|
1691
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1754
|
+
if (_optionalChain([_error, 'optionalAccess', _95 => _95.attributes, 'optionalAccess', _96 => _96.details, 'optionalAccess', _97 => _97.message])) {
|
|
1692
1755
|
throw new Error(
|
|
1693
1756
|
[
|
|
1694
1757
|
`${_error.attributes.details.message}`,
|
|
@@ -1709,9 +1772,9 @@ function createDatoClient(params) {
|
|
|
1709
1772
|
},
|
|
1710
1773
|
enableFieldLocalization: async (args) => {
|
|
1711
1774
|
try {
|
|
1712
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1775
|
+
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));
|
|
1713
1776
|
} catch (_error) {
|
|
1714
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1777
|
+
if (_optionalChain([_error, 'optionalAccess', _102 => _102.attributes, 'optionalAccess', _103 => _103.code]) === "NOT_FOUND") {
|
|
1715
1778
|
throw new Error(
|
|
1716
1779
|
[
|
|
1717
1780
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -1719,7 +1782,7 @@ function createDatoClient(params) {
|
|
|
1719
1782
|
].join("\n\n")
|
|
1720
1783
|
);
|
|
1721
1784
|
}
|
|
1722
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1785
|
+
if (_optionalChain([_error, 'optionalAccess', _104 => _104.attributes, 'optionalAccess', _105 => _105.details, 'optionalAccess', _106 => _106.message])) {
|
|
1723
1786
|
throw new Error(
|
|
1724
1787
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
1725
1788
|
);
|
|
@@ -1785,7 +1848,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1785
1848
|
}
|
|
1786
1849
|
}
|
|
1787
1850
|
const records = await dato.findRecordsForModel(modelId);
|
|
1788
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
1851
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _107 => _107.models, 'access', _108 => _108[modelId], 'optionalAccess', _109 => _109.records]) || [], project);
|
|
1789
1852
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
1790
1853
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
1791
1854
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -1797,14 +1860,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1797
1860
|
},
|
|
1798
1861
|
async pull(locale, input, initCtx) {
|
|
1799
1862
|
const result = {};
|
|
1800
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
1801
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
1863
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _110 => _110.models]) || {})) {
|
|
1864
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _111 => _111.models, 'access', _112 => _112[modelId], 'access', _113 => _113.records]) || [];
|
|
1802
1865
|
const recordIds = records.map((record) => record.id);
|
|
1803
1866
|
records = await dato.findRecords(recordIds);
|
|
1804
1867
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
1805
1868
|
if (records.length > 0) {
|
|
1806
1869
|
result[modelId] = {
|
|
1807
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
1870
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _114 => _114.models, 'optionalAccess', _115 => _115[modelId], 'optionalAccess', _116 => _116.fields]) || [],
|
|
1808
1871
|
records
|
|
1809
1872
|
};
|
|
1810
1873
|
}
|
|
@@ -1863,7 +1926,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
1863
1926
|
return records.map((record) => ({
|
|
1864
1927
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
1865
1928
|
value: record.id,
|
|
1866
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
1929
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _117 => _117.includes, 'call', _118 => _118(record.id)])
|
|
1867
1930
|
}));
|
|
1868
1931
|
}
|
|
1869
1932
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2014,18 +2077,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2014
2077
|
}
|
|
2015
2078
|
function serializeStructuredText(rawStructuredText) {
|
|
2016
2079
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2017
|
-
function serializeStructuredTextNode(node,
|
|
2080
|
+
function serializeStructuredTextNode(node, path9 = [], acc = {}) {
|
|
2018
2081
|
if ("document" in node) {
|
|
2019
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2082
|
+
return serializeStructuredTextNode(node.document, [...path9, "document"], acc);
|
|
2020
2083
|
}
|
|
2021
2084
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2022
|
-
acc[[...
|
|
2085
|
+
acc[[...path9, "value"].join(".")] = node.value;
|
|
2023
2086
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2024
|
-
acc[[...
|
|
2087
|
+
acc[[...path9, "item"].join(".")] = serializeBlock(node.item);
|
|
2025
2088
|
}
|
|
2026
2089
|
if (node.children) {
|
|
2027
2090
|
for (let i = 0; i < node.children.length; i++) {
|
|
2028
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2091
|
+
serializeStructuredTextNode(node.children[i], [...path9, i.toString()], acc);
|
|
2029
2092
|
}
|
|
2030
2093
|
}
|
|
2031
2094
|
return acc;
|
|
@@ -2084,8 +2147,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2084
2147
|
}
|
|
2085
2148
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2086
2149
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2087
|
-
for (const [
|
|
2088
|
-
const realPath = _lodash2.default.chain(
|
|
2150
|
+
for (const [path9, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2151
|
+
const realPath = _lodash2.default.chain(path9.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2089
2152
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2090
2153
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2091
2154
|
}
|
|
@@ -2130,7 +2193,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2130
2193
|
function createVttLoader() {
|
|
2131
2194
|
return createLoader({
|
|
2132
2195
|
async pull(locale, input) {
|
|
2133
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2196
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _119 => _119.parse, 'call', _120 => _120(input), 'optionalAccess', _121 => _121.cues]);
|
|
2134
2197
|
if (Object.keys(vtt).length === 0) {
|
|
2135
2198
|
return {};
|
|
2136
2199
|
} else {
|
|
@@ -2182,7 +2245,7 @@ function variableExtractLoader(params) {
|
|
|
2182
2245
|
for (let i = 0; i < matches.length; i++) {
|
|
2183
2246
|
const match = matches[i];
|
|
2184
2247
|
const currentValue = result[key].value;
|
|
2185
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2248
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _122 => _122.replace, 'call', _123 => _123(match, `{variable:${i}}`)]);
|
|
2186
2249
|
result[key].value = newValue;
|
|
2187
2250
|
result[key].variables[i] = match;
|
|
2188
2251
|
}
|
|
@@ -2196,7 +2259,7 @@ function variableExtractLoader(params) {
|
|
|
2196
2259
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2197
2260
|
const variable = valueObj.variables[i];
|
|
2198
2261
|
const currentValue = result[key];
|
|
2199
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2262
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _124 => _124.replace, 'call', _125 => _125(`{variable:${i}}`, variable)]);
|
|
2200
2263
|
result[key] = newValue;
|
|
2201
2264
|
}
|
|
2202
2265
|
}
|
|
@@ -2636,11 +2699,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2636
2699
|
const auth = await validateAuth(settings);
|
|
2637
2700
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
2638
2701
|
let buckets = getBuckets(i18nConfig);
|
|
2639
|
-
if (_optionalChain([flags, 'access',
|
|
2702
|
+
if (_optionalChain([flags, 'access', _126 => _126.bucket, 'optionalAccess', _127 => _127.length])) {
|
|
2640
2703
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
2641
2704
|
}
|
|
2642
2705
|
ora.succeed("Buckets retrieved");
|
|
2643
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
2706
|
+
const targetLocales = _optionalChain([flags, 'access', _128 => _128.locale, 'optionalAccess', _129 => _129.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
2644
2707
|
const lockfileHelper = createLockfileHelper();
|
|
2645
2708
|
ora.start("Ensuring i18n.lock exists...");
|
|
2646
2709
|
if (!lockfileHelper.isLockfileExists()) {
|
|
@@ -2748,7 +2811,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2748
2811
|
targetData
|
|
2749
2812
|
});
|
|
2750
2813
|
if (flags.key) {
|
|
2751
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
2814
|
+
processableData = _lodash2.default.pickBy(processableData, (_20, key) => key === flags.key);
|
|
2752
2815
|
}
|
|
2753
2816
|
if (flags.verbose) {
|
|
2754
2817
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -2926,12 +2989,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
2926
2989
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
2927
2990
|
docUrl: "bucketNotFound"
|
|
2928
2991
|
});
|
|
2929
|
-
} else if (_optionalChain([flags, 'access',
|
|
2992
|
+
} else if (_optionalChain([flags, 'access', _130 => _130.locale, 'optionalAccess', _131 => _131.some, 'call', _132 => _132((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
2930
2993
|
throw new CLIError({
|
|
2931
2994
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
2932
2995
|
docUrl: "localeTargetNotFound"
|
|
2933
2996
|
});
|
|
2934
|
-
} else if (_optionalChain([flags, 'access',
|
|
2997
|
+
} else if (_optionalChain([flags, 'access', _133 => _133.bucket, 'optionalAccess', _134 => _134.some, 'call', _135 => _135((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
2935
2998
|
throw new CLIError({
|
|
2936
2999
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
2937
3000
|
docUrl: "bucketNotFound"
|
|
@@ -3158,7 +3221,7 @@ function displaySummary(results) {
|
|
|
3158
3221
|
// package.json
|
|
3159
3222
|
var package_default = {
|
|
3160
3223
|
name: "lingo.dev",
|
|
3161
|
-
version: "0.74.
|
|
3224
|
+
version: "0.74.11",
|
|
3162
3225
|
description: "Lingo.dev CLI",
|
|
3163
3226
|
private: false,
|
|
3164
3227
|
publishConfig: {
|
|
@@ -3195,6 +3258,7 @@ var package_default = {
|
|
|
3195
3258
|
dev: "tsup --watch",
|
|
3196
3259
|
build: "tsc --noEmit && tsup",
|
|
3197
3260
|
test: "vitest run",
|
|
3261
|
+
"test:watch": "vitest",
|
|
3198
3262
|
clean: "rm -rf build"
|
|
3199
3263
|
},
|
|
3200
3264
|
keywords: [],
|