lingo.dev 0.92.12 → 0.92.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 +219 -220
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +140 -141
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -14,7 +14,7 @@ var _promises = require('readline/promises'); var _promises2 = _interopRequireDe
|
|
|
14
14
|
|
|
15
15
|
// src/cli/utils/settings.ts
|
|
16
16
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
17
|
-
var _path = require('path'); var
|
|
17
|
+
var _path = require('path'); var path12 = _interopRequireWildcard(_path); var path13 = _interopRequireWildcard(_path);
|
|
18
18
|
var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);
|
|
19
19
|
var _fs = require('fs'); var fs10 = _interopRequireWildcard(_fs);
|
|
20
20
|
var _ini = require('ini'); var _ini2 = _interopRequireDefault(_ini);
|
|
@@ -26,9 +26,9 @@ function getSettings(explicitApiKey) {
|
|
|
26
26
|
_envVarsInfo();
|
|
27
27
|
return {
|
|
28
28
|
auth: {
|
|
29
|
-
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access',
|
|
30
|
-
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access',
|
|
31
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access',
|
|
29
|
+
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _31 => _31.auth, 'optionalAccess', _32 => _32.apiKey]) || defaults.auth.apiKey,
|
|
30
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _33 => _33.auth, 'optionalAccess', _34 => _34.apiUrl]) || defaults.auth.apiUrl,
|
|
31
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _35 => _35.auth, 'optionalAccess', _36 => _36.webUrl]) || defaults.auth.webUrl
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -78,7 +78,7 @@ function _saveSystemFile(settings) {
|
|
|
78
78
|
function _getSettingsFilePath() {
|
|
79
79
|
const settingsFile = ".lingodotdevrc";
|
|
80
80
|
const homedir = _os2.default.homedir();
|
|
81
|
-
const settingsFilePath =
|
|
81
|
+
const settingsFilePath = path12.default.join(homedir, settingsFile);
|
|
82
82
|
return settingsFilePath;
|
|
83
83
|
}
|
|
84
84
|
function _legacyEnvVarWarning() {
|
|
@@ -99,7 +99,7 @@ Please use LINGODOTDEV_API_KEY instead.
|
|
|
99
99
|
function _envVarsInfo() {
|
|
100
100
|
const env = _loadEnv();
|
|
101
101
|
const systemFile = _loadSystemFile();
|
|
102
|
-
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access',
|
|
102
|
+
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _37 => _37.auth, 'optionalAccess', _38 => _38.apiKey])) {
|
|
103
103
|
console.info(
|
|
104
104
|
"\x1B[36m%s\x1B[0m",
|
|
105
105
|
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
|
|
@@ -154,7 +154,7 @@ function createAuthenticator(params) {
|
|
|
154
154
|
});
|
|
155
155
|
if (res.ok) {
|
|
156
156
|
const payload = await res.json();
|
|
157
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
157
|
+
if (!_optionalChain([payload, 'optionalAccess', _39 => _39.email])) {
|
|
158
158
|
return null;
|
|
159
159
|
}
|
|
160
160
|
return {
|
|
@@ -277,7 +277,7 @@ function saveConfig(config) {
|
|
|
277
277
|
return config;
|
|
278
278
|
}
|
|
279
279
|
function _getConfigFilePath() {
|
|
280
|
-
return
|
|
280
|
+
return path12.default.join(process.cwd(), "i18n.json");
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
// src/cli/cmd/init.ts
|
|
@@ -362,7 +362,7 @@ function findLocaleFilesForFilename(fileName) {
|
|
|
362
362
|
});
|
|
363
363
|
const localeFilesAndPatterns = localeFiles.map((file) => ({
|
|
364
364
|
file,
|
|
365
|
-
pattern:
|
|
365
|
+
pattern: path12.default.join(path12.default.dirname(file), pattern)
|
|
366
366
|
}));
|
|
367
367
|
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
368
368
|
const patterns = Object.keys(grouppedFilesAndPatterns);
|
|
@@ -383,8 +383,8 @@ function ensurePatterns(patterns, source) {
|
|
|
383
383
|
patterns.forEach((pattern) => {
|
|
384
384
|
const filePath = pattern.replace("[locale]", source);
|
|
385
385
|
if (!fs10.default.existsSync(filePath)) {
|
|
386
|
-
const defaultContent = getDefaultContent(
|
|
387
|
-
fs10.default.mkdirSync(
|
|
386
|
+
const defaultContent = getDefaultContent(path12.default.extname(filePath), source);
|
|
387
|
+
fs10.default.mkdirSync(path12.default.dirname(filePath), { recursive: true });
|
|
388
388
|
fs10.default.writeFileSync(filePath, defaultContent);
|
|
389
389
|
}
|
|
390
390
|
});
|
|
@@ -464,7 +464,7 @@ function updateGitignore() {
|
|
|
464
464
|
if (!projectRoot) {
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const gitignorePath =
|
|
467
|
+
const gitignorePath = path12.default.join(projectRoot, ".gitignore");
|
|
468
468
|
if (!fs10.default.existsSync(gitignorePath)) {
|
|
469
469
|
return;
|
|
470
470
|
}
|
|
@@ -483,12 +483,12 @@ function updateGitignore() {
|
|
|
483
483
|
}
|
|
484
484
|
function findCurrentProjectRoot() {
|
|
485
485
|
let currentDir = process.cwd();
|
|
486
|
-
while (currentDir !==
|
|
487
|
-
const gitDirPath =
|
|
486
|
+
while (currentDir !== path12.default.parse(currentDir).root) {
|
|
487
|
+
const gitDirPath = path12.default.join(currentDir, ".git");
|
|
488
488
|
if (fs10.default.existsSync(gitDirPath) && fs10.default.lstatSync(gitDirPath).isDirectory()) {
|
|
489
489
|
return currentDir;
|
|
490
490
|
}
|
|
491
|
-
currentDir =
|
|
491
|
+
currentDir = path12.default.dirname(currentDir);
|
|
492
492
|
}
|
|
493
493
|
return null;
|
|
494
494
|
}
|
|
@@ -530,12 +530,12 @@ function makePlatformInitializer(config, spinner) {
|
|
|
530
530
|
return {
|
|
531
531
|
name: config.name,
|
|
532
532
|
isEnabled: () => {
|
|
533
|
-
const filePath =
|
|
533
|
+
const filePath = path12.default.join(process.cwd(), config.checkPath);
|
|
534
534
|
return fs10.default.existsSync(filePath);
|
|
535
535
|
},
|
|
536
536
|
init: async () => {
|
|
537
|
-
const filePath =
|
|
538
|
-
const dirPath =
|
|
537
|
+
const filePath = path12.default.join(process.cwd(), config.ciConfigPath);
|
|
538
|
+
const dirPath = path12.default.dirname(filePath);
|
|
539
539
|
if (!fs10.default.existsSync(dirPath)) {
|
|
540
540
|
fs10.default.mkdirSync(dirPath, { recursive: true });
|
|
541
541
|
}
|
|
@@ -621,9 +621,9 @@ function makeGitlabInitializer(spinner) {
|
|
|
621
621
|
|
|
622
622
|
// src/cli/cmd/init.ts
|
|
623
623
|
|
|
624
|
-
var openUrl = (
|
|
624
|
+
var openUrl = (path16) => {
|
|
625
625
|
const settings = getSettings(void 0);
|
|
626
|
-
_open2.default.call(void 0, `${settings.auth.webUrl}${
|
|
626
|
+
_open2.default.call(void 0, `${settings.auth.webUrl}${path16}`, { wait: false });
|
|
627
627
|
};
|
|
628
628
|
var throwHelpError = (option, value) => {
|
|
629
629
|
if (value === "help") {
|
|
@@ -669,7 +669,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
669
669
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
670
670
|
for (const p of values) {
|
|
671
671
|
try {
|
|
672
|
-
const dirPath =
|
|
672
|
+
const dirPath = path12.default.dirname(p);
|
|
673
673
|
const stats = fs10.default.statSync(dirPath);
|
|
674
674
|
if (!stats.isDirectory()) {
|
|
675
675
|
throw new Error(`${dirPath} is not a directory`);
|
|
@@ -774,7 +774,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
774
774
|
});
|
|
775
775
|
const auth2 = await newAuthenticator.whoami();
|
|
776
776
|
if (auth2) {
|
|
777
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
777
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _40 => _40.email])}`);
|
|
778
778
|
} else {
|
|
779
779
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
780
780
|
}
|
|
@@ -806,7 +806,7 @@ var config_default = new (0, _interactivecommander.Command)().command("config").
|
|
|
806
806
|
console.log(JSON.stringify(config, null, 2));
|
|
807
807
|
});
|
|
808
808
|
function loadReplexicaFileConfig() {
|
|
809
|
-
const replexicaConfigPath =
|
|
809
|
+
const replexicaConfigPath = path12.default.resolve(process.cwd(), "i18n.json");
|
|
810
810
|
const fileExists = fs10.default.existsSync(replexicaConfigPath);
|
|
811
811
|
if (!fileExists) {
|
|
812
812
|
return void 0;
|
|
@@ -859,7 +859,7 @@ function getBuckets(i18nConfig) {
|
|
|
859
859
|
const includeItems = bucketEntry.include.map(
|
|
860
860
|
(item) => resolveBucketItem(item)
|
|
861
861
|
);
|
|
862
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
862
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _41 => _41.exclude, 'optionalAccess', _42 => _42.map, 'call', _43 => _43(
|
|
863
863
|
(item) => resolveBucketItem(item)
|
|
864
864
|
)]);
|
|
865
865
|
const config = {
|
|
@@ -897,7 +897,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
897
897
|
delimiter: pattern.delimiter
|
|
898
898
|
}))
|
|
899
899
|
);
|
|
900
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
900
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _44 => _44.flatMap, 'call', _45 => _45(
|
|
901
901
|
(pattern) => expandPlaceholderedGlob(
|
|
902
902
|
pattern.path,
|
|
903
903
|
__spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
|
|
@@ -914,9 +914,9 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
914
914
|
return result;
|
|
915
915
|
}
|
|
916
916
|
function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
917
|
-
const absolutePathPattern =
|
|
918
|
-
const pathPattern =
|
|
919
|
-
if (
|
|
917
|
+
const absolutePathPattern = path12.default.resolve(_pathPattern);
|
|
918
|
+
const pathPattern = path12.default.relative(process.cwd(), absolutePathPattern);
|
|
919
|
+
if (path12.default.relative(process.cwd(), pathPattern).startsWith("..")) {
|
|
920
920
|
throw new CLIError({
|
|
921
921
|
message: `Invalid path pattern: ${pathPattern}. Path pattern must be within the current working directory.`,
|
|
922
922
|
docUrl: "invalidPathPattern"
|
|
@@ -928,7 +928,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
928
928
|
docUrl: "invalidPathPattern"
|
|
929
929
|
});
|
|
930
930
|
}
|
|
931
|
-
const pathPatternChunks = pathPattern.split(
|
|
931
|
+
const pathPatternChunks = pathPattern.split(path12.default.sep);
|
|
932
932
|
const localeSegmentIndexes = pathPatternChunks.reduce(
|
|
933
933
|
(indexes, segment, index) => {
|
|
934
934
|
if (segment.includes("[locale]")) {
|
|
@@ -939,9 +939,9 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
939
939
|
[]
|
|
940
940
|
);
|
|
941
941
|
const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
|
|
942
|
-
const sourcePaths = _glob.glob.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) =>
|
|
942
|
+
const sourcePaths = _glob.glob.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => path12.default.relative(process.cwd(), fullpath));
|
|
943
943
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
944
|
-
const sourcePathChunks = sourcePath.split(
|
|
944
|
+
const sourcePathChunks = sourcePath.split(path12.default.sep);
|
|
945
945
|
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
946
946
|
const pathPatternChunk = pathPatternChunks[localeSegmentIndex];
|
|
947
947
|
const sourcePathChunk = sourcePathChunks[localeSegmentIndex];
|
|
@@ -955,7 +955,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
955
955
|
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
956
956
|
}
|
|
957
957
|
});
|
|
958
|
-
const placeholderedPath = sourcePathChunks.join(
|
|
958
|
+
const placeholderedPath = sourcePathChunks.join(path12.default.sep);
|
|
959
959
|
return placeholderedPath;
|
|
960
960
|
});
|
|
961
961
|
return placeholderedPaths;
|
|
@@ -997,8 +997,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
997
997
|
} else if (type.target) {
|
|
998
998
|
result.push(...targetPaths);
|
|
999
999
|
}
|
|
1000
|
-
result.forEach((
|
|
1001
|
-
console.log(
|
|
1000
|
+
result.forEach((path16) => {
|
|
1001
|
+
console.log(path16);
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
@@ -1028,18 +1028,17 @@ var show_default = new (0, _interactivecommander.Command)().command("show").desc
|
|
|
1028
1028
|
|
|
1029
1029
|
|
|
1030
1030
|
|
|
1031
|
-
|
|
1032
1031
|
// src/cli/loaders/_utils.ts
|
|
1033
1032
|
function composeLoaders(...loaders) {
|
|
1034
1033
|
return {
|
|
1035
1034
|
init: async () => {
|
|
1036
1035
|
for (const loader of loaders) {
|
|
1037
|
-
await _optionalChain([loader, 'access',
|
|
1036
|
+
await _optionalChain([loader, 'access', _46 => _46.init, 'optionalCall', _47 => _47()]);
|
|
1038
1037
|
}
|
|
1039
1038
|
},
|
|
1040
1039
|
setDefaultLocale(locale) {
|
|
1041
1040
|
for (const loader of loaders) {
|
|
1042
|
-
_optionalChain([loader, 'access',
|
|
1041
|
+
_optionalChain([loader, 'access', _48 => _48.setDefaultLocale, 'optionalCall', _49 => _49(locale)]);
|
|
1043
1042
|
}
|
|
1044
1043
|
return this;
|
|
1045
1044
|
},
|
|
@@ -1072,7 +1071,7 @@ function createLoader(lDefinition) {
|
|
|
1072
1071
|
if (state.initCtx) {
|
|
1073
1072
|
return state.initCtx;
|
|
1074
1073
|
}
|
|
1075
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1074
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _50 => _50.init, 'optionalCall', _51 => _51()]);
|
|
1076
1075
|
return state.initCtx;
|
|
1077
1076
|
},
|
|
1078
1077
|
setDefaultLocale(locale) {
|
|
@@ -1176,7 +1175,7 @@ function createNormalizeLoader() {
|
|
|
1176
1175
|
return normalized;
|
|
1177
1176
|
},
|
|
1178
1177
|
push: async (locale, data, originalInput) => {
|
|
1179
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1178
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _52 => _52.keysMap]), () => ( {}));
|
|
1180
1179
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1181
1180
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1182
1181
|
delimiter: "/",
|
|
@@ -1250,10 +1249,10 @@ function createTextFileLoader(pathPattern) {
|
|
|
1250
1249
|
const trimmedResult = result.trim();
|
|
1251
1250
|
return trimmedResult;
|
|
1252
1251
|
},
|
|
1253
|
-
async push(locale, data,
|
|
1252
|
+
async push(locale, data, _30, originalLocale) {
|
|
1254
1253
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1255
|
-
const finalPath =
|
|
1256
|
-
const dirPath =
|
|
1254
|
+
const finalPath = path12.default.resolve(draftPath);
|
|
1255
|
+
const dirPath = path12.default.dirname(finalPath);
|
|
1257
1256
|
await _promises4.default.mkdir(dirPath, { recursive: true });
|
|
1258
1257
|
const trimmedPayload = data.trim();
|
|
1259
1258
|
const trailingNewLine = await getTrailingNewLine(pathPattern, locale, originalLocale);
|
|
@@ -1267,7 +1266,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1267
1266
|
}
|
|
1268
1267
|
async function readFileForLocale(pathPattern, locale) {
|
|
1269
1268
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1270
|
-
const finalPath =
|
|
1269
|
+
const finalPath = path12.default.resolve(draftPath);
|
|
1271
1270
|
const exists = await _promises4.default.access(finalPath).then(() => true).catch(() => false);
|
|
1272
1271
|
if (!exists) {
|
|
1273
1272
|
return "";
|
|
@@ -1279,8 +1278,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1279
1278
|
if (!templateData) {
|
|
1280
1279
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1281
1280
|
}
|
|
1282
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1283
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1281
|
+
if (_optionalChain([templateData, 'optionalAccess', _53 => _53.match, 'call', _54 => _54(/[\r\n]$/)])) {
|
|
1282
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _55 => _55.includes, 'call', _56 => _56("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _57 => _57.includes, 'call', _58 => _58("\r")]) ? "\r" : "\n";
|
|
1284
1283
|
return ending;
|
|
1285
1284
|
}
|
|
1286
1285
|
return "";
|
|
@@ -1622,7 +1621,7 @@ function createHtmlLoader() {
|
|
|
1622
1621
|
break;
|
|
1623
1622
|
}
|
|
1624
1623
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1625
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1624
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _59 => _59.textContent, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()])
|
|
1626
1625
|
);
|
|
1627
1626
|
const index = siblings.indexOf(current);
|
|
1628
1627
|
if (index !== -1) {
|
|
@@ -1657,11 +1656,11 @@ function createHtmlLoader() {
|
|
|
1657
1656
|
result[getPath(element, attr)] = value;
|
|
1658
1657
|
}
|
|
1659
1658
|
});
|
|
1660
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1659
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _62 => _62.textContent, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()])).forEach(processNode);
|
|
1661
1660
|
}
|
|
1662
1661
|
};
|
|
1663
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1664
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1662
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()])).forEach(processNode);
|
|
1663
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _68 => _68.textContent, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()])).forEach(processNode);
|
|
1665
1664
|
return result;
|
|
1666
1665
|
},
|
|
1667
1666
|
async push(locale, data, originalInput) {
|
|
@@ -1674,16 +1673,16 @@ function createHtmlLoader() {
|
|
|
1674
1673
|
const bDepth = b.split("/").length;
|
|
1675
1674
|
return aDepth - bDepth;
|
|
1676
1675
|
});
|
|
1677
|
-
paths.forEach((
|
|
1678
|
-
const value = data[
|
|
1679
|
-
const [nodePath, attribute] =
|
|
1676
|
+
paths.forEach((path16) => {
|
|
1677
|
+
const value = data[path16];
|
|
1678
|
+
const [nodePath, attribute] = path16.split("#");
|
|
1680
1679
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1681
1680
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1682
1681
|
let current = parent;
|
|
1683
1682
|
for (let i = 0; i < indices.length; i++) {
|
|
1684
1683
|
const index = parseInt(indices[i]);
|
|
1685
1684
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1686
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1685
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _71 => _71.textContent, 'optionalAccess', _72 => _72.trim, 'call', _73 => _73()])
|
|
1687
1686
|
);
|
|
1688
1687
|
if (index >= siblings.length) {
|
|
1689
1688
|
if (i === indices.length - 1) {
|
|
@@ -1734,7 +1733,7 @@ function createMarkdownLoader() {
|
|
|
1734
1733
|
yaml: yamlEngine
|
|
1735
1734
|
}
|
|
1736
1735
|
});
|
|
1737
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
1736
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _74 => _74.trim, 'call', _75 => _75()]), () => ( ""))).filter(Boolean);
|
|
1738
1737
|
return {
|
|
1739
1738
|
...Object.fromEntries(
|
|
1740
1739
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -1746,7 +1745,7 @@ function createMarkdownLoader() {
|
|
|
1746
1745
|
const frontmatter = Object.fromEntries(
|
|
1747
1746
|
Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
|
|
1748
1747
|
);
|
|
1749
|
-
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
1748
|
+
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _76 => _76.trim, 'call', _77 => _77()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
1750
1749
|
if (Object.keys(frontmatter).length > 0) {
|
|
1751
1750
|
content = `
|
|
1752
1751
|
${content}`;
|
|
@@ -1779,7 +1778,7 @@ function createPropertiesLoader() {
|
|
|
1779
1778
|
return result;
|
|
1780
1779
|
},
|
|
1781
1780
|
async push(locale, payload) {
|
|
1782
|
-
const result = Object.entries(payload).filter(([
|
|
1781
|
+
const result = Object.entries(payload).filter(([_30, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1783
1782
|
return result;
|
|
1784
1783
|
}
|
|
1785
1784
|
});
|
|
@@ -1790,7 +1789,7 @@ function isSkippableLine(line) {
|
|
|
1790
1789
|
function parsePropertyLine(line) {
|
|
1791
1790
|
const [key, ...valueParts] = line.split("=");
|
|
1792
1791
|
return {
|
|
1793
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1792
|
+
key: _optionalChain([key, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]) || "",
|
|
1794
1793
|
value: valueParts.join("=").trim()
|
|
1795
1794
|
};
|
|
1796
1795
|
}
|
|
@@ -1876,7 +1875,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1876
1875
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
1877
1876
|
continue;
|
|
1878
1877
|
}
|
|
1879
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1878
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _80 => _80.localizations, 'optionalAccess', _81 => _81[locale]]);
|
|
1880
1879
|
if (langTranslationEntity) {
|
|
1881
1880
|
if ("stringUnit" in langTranslationEntity) {
|
|
1882
1881
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1885,7 +1884,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1885
1884
|
resultData[translationKey] = {};
|
|
1886
1885
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1887
1886
|
for (const form in pluralForms) {
|
|
1888
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1887
|
+
if (_optionalChain([pluralForms, 'access', _82 => _82[form], 'optionalAccess', _83 => _83.stringUnit, 'optionalAccess', _84 => _84.value])) {
|
|
1889
1888
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1890
1889
|
}
|
|
1891
1890
|
}
|
|
@@ -1908,7 +1907,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1908
1907
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
1909
1908
|
if (typeof value === "string") {
|
|
1910
1909
|
langDataToMerge.strings[key] = {
|
|
1911
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
1910
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _85 => _85.strings, 'optionalAccess', _86 => _86[key], 'optionalAccess', _87 => _87.extractionState]),
|
|
1912
1911
|
localizations: {
|
|
1913
1912
|
[locale]: {
|
|
1914
1913
|
stringUnit: {
|
|
@@ -1966,7 +1965,7 @@ function createPrettierLoader(options) {
|
|
|
1966
1965
|
"[locale]",
|
|
1967
1966
|
locale
|
|
1968
1967
|
);
|
|
1969
|
-
const finalPath =
|
|
1968
|
+
const finalPath = path12.default.resolve(draftPath);
|
|
1970
1969
|
return await formatDataWithPrettier(data, finalPath, options);
|
|
1971
1970
|
},
|
|
1972
1971
|
async push(locale, data) {
|
|
@@ -1977,7 +1976,7 @@ function createPrettierLoader(options) {
|
|
|
1977
1976
|
"[locale]",
|
|
1978
1977
|
locale
|
|
1979
1978
|
);
|
|
1980
|
-
const finalPath =
|
|
1979
|
+
const finalPath = path12.default.resolve(draftPath);
|
|
1981
1980
|
return await formatDataWithPrettier(data, finalPath, options);
|
|
1982
1981
|
}
|
|
1983
1982
|
});
|
|
@@ -2046,10 +2045,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
2046
2045
|
}
|
|
2047
2046
|
}
|
|
2048
2047
|
return false;
|
|
2049
|
-
}).map(([key,
|
|
2050
|
-
const result = _lodash2.default.omitBy(input2, (
|
|
2048
|
+
}).map(([key, _30]) => key);
|
|
2049
|
+
const result = _lodash2.default.omitBy(input2, (_30, key) => passthroughKeys.includes(key));
|
|
2051
2050
|
if (returnUnlocalizedKeys) {
|
|
2052
|
-
result.unlocalizable = _lodash2.default.omitBy(input2, (
|
|
2051
|
+
result.unlocalizable = _lodash2.default.omitBy(input2, (_30, key) => !passthroughKeys.includes(key));
|
|
2053
2052
|
}
|
|
2054
2053
|
return result;
|
|
2055
2054
|
},
|
|
@@ -2088,7 +2087,7 @@ function createPoDataLoader(params) {
|
|
|
2088
2087
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
2089
2088
|
if (msgid && entry.msgid) {
|
|
2090
2089
|
const context = entry.msgctxt || "";
|
|
2091
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
2090
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _88 => _88.translations, 'access', _89 => _89[context], 'optionalAccess', _90 => _90[msgid]]);
|
|
2092
2091
|
if (fullEntry) {
|
|
2093
2092
|
result[msgid] = fullEntry;
|
|
2094
2093
|
}
|
|
@@ -2098,8 +2097,8 @@ function createPoDataLoader(params) {
|
|
|
2098
2097
|
return result;
|
|
2099
2098
|
},
|
|
2100
2099
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
2101
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
2102
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
2100
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _91 => _91.split, 'call', _92 => _92("\n\n"), 'access', _93 => _93.filter, 'call', _94 => _94(Boolean)]) || [];
|
|
2101
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _95 => _95.split, 'call', _96 => _96("\n\n"), 'access', _97 => _97.filter, 'call', _98 => _98(Boolean)]) || [];
|
|
2103
2102
|
const result = originalSections.map((section) => {
|
|
2104
2103
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
2105
2104
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -2164,8 +2163,8 @@ function createPoContentLoader() {
|
|
|
2164
2163
|
{
|
|
2165
2164
|
...entry,
|
|
2166
2165
|
msgstr: [
|
|
2167
|
-
_optionalChain([data, 'access',
|
|
2168
|
-
_optionalChain([data, 'access',
|
|
2166
|
+
_optionalChain([data, 'access', _99 => _99[entry.msgid], 'optionalAccess', _100 => _100.singular]),
|
|
2167
|
+
_optionalChain([data, 'access', _101 => _101[entry.msgid], 'optionalAccess', _102 => _102.plural]) || null
|
|
2169
2168
|
].filter(Boolean)
|
|
2170
2169
|
}
|
|
2171
2170
|
]).fromPairs().value();
|
|
@@ -2412,7 +2411,7 @@ function createDatoClient(params) {
|
|
|
2412
2411
|
only_valid: "true",
|
|
2413
2412
|
ids: !records.length ? void 0 : records.join(",")
|
|
2414
2413
|
}
|
|
2415
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2414
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _103 => _103.response, 'optionalAccess', _104 => _104.body, 'optionalAccess', _105 => _105.data, 'optionalAccess', _106 => _106[0]]) || error));
|
|
2416
2415
|
},
|
|
2417
2416
|
findRecordsForModel: async (modelId, records) => {
|
|
2418
2417
|
try {
|
|
@@ -2422,9 +2421,9 @@ function createDatoClient(params) {
|
|
|
2422
2421
|
filter: {
|
|
2423
2422
|
type: modelId,
|
|
2424
2423
|
only_valid: "true",
|
|
2425
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2424
|
+
ids: !_optionalChain([records, 'optionalAccess', _107 => _107.length]) ? void 0 : records.join(",")
|
|
2426
2425
|
}
|
|
2427
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2426
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _108 => _108.response, 'optionalAccess', _109 => _109.body, 'optionalAccess', _110 => _110.data, 'optionalAccess', _111 => _111[0]]) || error));
|
|
2428
2427
|
return result;
|
|
2429
2428
|
} catch (_error) {
|
|
2430
2429
|
throw new Error(
|
|
@@ -2438,9 +2437,9 @@ function createDatoClient(params) {
|
|
|
2438
2437
|
},
|
|
2439
2438
|
updateRecord: async (id, payload) => {
|
|
2440
2439
|
try {
|
|
2441
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2440
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _112 => _112.response, 'optionalAccess', _113 => _113.body, 'optionalAccess', _114 => _114.data, 'optionalAccess', _115 => _115[0]]) || error));
|
|
2442
2441
|
} catch (_error) {
|
|
2443
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2442
|
+
if (_optionalChain([_error, 'optionalAccess', _116 => _116.attributes, 'optionalAccess', _117 => _117.details, 'optionalAccess', _118 => _118.message])) {
|
|
2444
2443
|
throw new Error(
|
|
2445
2444
|
[
|
|
2446
2445
|
`${_error.attributes.details.message}`,
|
|
@@ -2461,9 +2460,9 @@ function createDatoClient(params) {
|
|
|
2461
2460
|
},
|
|
2462
2461
|
enableFieldLocalization: async (args) => {
|
|
2463
2462
|
try {
|
|
2464
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2463
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _119 => _119.response, 'optionalAccess', _120 => _120.body, 'optionalAccess', _121 => _121.data, 'optionalAccess', _122 => _122[0]]) || error));
|
|
2465
2464
|
} catch (_error) {
|
|
2466
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2465
|
+
if (_optionalChain([_error, 'optionalAccess', _123 => _123.attributes, 'optionalAccess', _124 => _124.code]) === "NOT_FOUND") {
|
|
2467
2466
|
throw new Error(
|
|
2468
2467
|
[
|
|
2469
2468
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2471,7 +2470,7 @@ function createDatoClient(params) {
|
|
|
2471
2470
|
].join("\n\n")
|
|
2472
2471
|
);
|
|
2473
2472
|
}
|
|
2474
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2473
|
+
if (_optionalChain([_error, 'optionalAccess', _125 => _125.attributes, 'optionalAccess', _126 => _126.details, 'optionalAccess', _127 => _127.message])) {
|
|
2475
2474
|
throw new Error(
|
|
2476
2475
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2477
2476
|
);
|
|
@@ -2537,7 +2536,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2537
2536
|
}
|
|
2538
2537
|
}
|
|
2539
2538
|
const records = await dato.findRecordsForModel(modelId);
|
|
2540
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2539
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _128 => _128.models, 'access', _129 => _129[modelId], 'optionalAccess', _130 => _130.records]) || [], project);
|
|
2541
2540
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2542
2541
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2543
2542
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2549,14 +2548,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2549
2548
|
},
|
|
2550
2549
|
async pull(locale, input2, initCtx) {
|
|
2551
2550
|
const result = {};
|
|
2552
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2553
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2551
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _131 => _131.models]) || {})) {
|
|
2552
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _132 => _132.models, 'access', _133 => _133[modelId], 'access', _134 => _134.records]) || [];
|
|
2554
2553
|
const recordIds = records.map((record) => record.id);
|
|
2555
2554
|
records = await dato.findRecords(recordIds);
|
|
2556
2555
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2557
2556
|
if (records.length > 0) {
|
|
2558
2557
|
result[modelId] = {
|
|
2559
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2558
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _135 => _135.models, 'optionalAccess', _136 => _136[modelId], 'optionalAccess', _137 => _137.fields]) || [],
|
|
2560
2559
|
records
|
|
2561
2560
|
};
|
|
2562
2561
|
}
|
|
@@ -2615,7 +2614,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2615
2614
|
return records.map((record) => ({
|
|
2616
2615
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2617
2616
|
value: record.id,
|
|
2618
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2617
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _138 => _138.includes, 'call', _139 => _139(record.id)])
|
|
2619
2618
|
}));
|
|
2620
2619
|
}
|
|
2621
2620
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2766,18 +2765,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2766
2765
|
}
|
|
2767
2766
|
function serializeStructuredText(rawStructuredText) {
|
|
2768
2767
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2769
|
-
function serializeStructuredTextNode(node,
|
|
2768
|
+
function serializeStructuredTextNode(node, path16 = [], acc = {}) {
|
|
2770
2769
|
if ("document" in node) {
|
|
2771
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2770
|
+
return serializeStructuredTextNode(node.document, [...path16, "document"], acc);
|
|
2772
2771
|
}
|
|
2773
2772
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2774
|
-
acc[[...
|
|
2773
|
+
acc[[...path16, "value"].join(".")] = node.value;
|
|
2775
2774
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2776
|
-
acc[[...
|
|
2775
|
+
acc[[...path16, "item"].join(".")] = serializeBlock(node.item);
|
|
2777
2776
|
}
|
|
2778
2777
|
if (node.children) {
|
|
2779
2778
|
for (let i = 0; i < node.children.length; i++) {
|
|
2780
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2779
|
+
serializeStructuredTextNode(node.children[i], [...path16, i.toString()], acc);
|
|
2781
2780
|
}
|
|
2782
2781
|
}
|
|
2783
2782
|
return acc;
|
|
@@ -2836,8 +2835,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2836
2835
|
}
|
|
2837
2836
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2838
2837
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2839
|
-
for (const [
|
|
2840
|
-
const realPath = _lodash2.default.chain(
|
|
2838
|
+
for (const [path16, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2839
|
+
const realPath = _lodash2.default.chain(path16.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2841
2840
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2842
2841
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2843
2842
|
}
|
|
@@ -2882,7 +2881,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2882
2881
|
function createVttLoader() {
|
|
2883
2882
|
return createLoader({
|
|
2884
2883
|
async pull(locale, input2) {
|
|
2885
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2884
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _140 => _140.parse, 'call', _141 => _141(input2), 'optionalAccess', _142 => _142.cues]);
|
|
2886
2885
|
if (Object.keys(vtt).length === 0) {
|
|
2887
2886
|
return {};
|
|
2888
2887
|
} else {
|
|
@@ -2935,7 +2934,7 @@ function variableExtractLoader(params) {
|
|
|
2935
2934
|
for (let i = 0; i < matches.length; i++) {
|
|
2936
2935
|
const match = matches[i];
|
|
2937
2936
|
const currentValue = result[key].value;
|
|
2938
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2937
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _143 => _143.replace, 'call', _144 => _144(match, `{variable:${i}}`)]);
|
|
2939
2938
|
result[key].value = newValue;
|
|
2940
2939
|
result[key].variables[i] = match;
|
|
2941
2940
|
}
|
|
@@ -2949,7 +2948,7 @@ function variableExtractLoader(params) {
|
|
|
2949
2948
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2950
2949
|
const variable = valueObj.variables[i];
|
|
2951
2950
|
const currentValue = result[key];
|
|
2952
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2951
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _145 => _145.replace, 'call', _146 => _146(`{variable:${i}}`, variable)]);
|
|
2953
2952
|
result[key] = newValue;
|
|
2954
2953
|
}
|
|
2955
2954
|
}
|
|
@@ -3132,7 +3131,7 @@ function createVueJsonLoader() {
|
|
|
3132
3131
|
return createLoader({
|
|
3133
3132
|
pull: async (locale, input2, ctx) => {
|
|
3134
3133
|
const parsed = parseVueFile(input2);
|
|
3135
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
3134
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _147 => _147.i18n, 'optionalAccess', _148 => _148[locale]]), () => ( {}));
|
|
3136
3135
|
},
|
|
3137
3136
|
push: async (locale, data, originalInput) => {
|
|
3138
3137
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -3219,15 +3218,15 @@ function parseTypeScript(input2) {
|
|
|
3219
3218
|
function extractStringsFromDefaultExport(ast) {
|
|
3220
3219
|
let extracted = {};
|
|
3221
3220
|
traverse(ast, {
|
|
3222
|
-
ExportDefaultDeclaration(
|
|
3223
|
-
const { declaration } =
|
|
3221
|
+
ExportDefaultDeclaration(path16) {
|
|
3222
|
+
const { declaration } = path16.node;
|
|
3224
3223
|
const decl = unwrapTSAsExpression(declaration);
|
|
3225
3224
|
if (t.isObjectExpression(decl)) {
|
|
3226
3225
|
extracted = objectExpressionToObject(decl);
|
|
3227
3226
|
} else if (t.isArrayExpression(decl)) {
|
|
3228
3227
|
extracted = arrayExpressionToArray(decl);
|
|
3229
3228
|
} else if (t.isIdentifier(decl)) {
|
|
3230
|
-
const binding =
|
|
3229
|
+
const binding = path16.scope.bindings[decl.name];
|
|
3231
3230
|
if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
3232
3231
|
const initRaw = binding.path.node.init;
|
|
3233
3232
|
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
@@ -3292,8 +3291,8 @@ function arrayExpressionToArray(arrayExpression) {
|
|
|
3292
3291
|
function updateStringsInDefaultExport(ast, data) {
|
|
3293
3292
|
let modified = false;
|
|
3294
3293
|
traverse(ast, {
|
|
3295
|
-
ExportDefaultDeclaration(
|
|
3296
|
-
const { declaration } =
|
|
3294
|
+
ExportDefaultDeclaration(path16) {
|
|
3295
|
+
const { declaration } = path16.node;
|
|
3297
3296
|
const decl = unwrapTSAsExpression(declaration);
|
|
3298
3297
|
if (t.isObjectExpression(decl)) {
|
|
3299
3298
|
modified = updateStringsInObjectExpression(decl, data) || modified;
|
|
@@ -3302,7 +3301,7 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
3302
3301
|
modified = updateStringsInArrayExpression(decl, data) || modified;
|
|
3303
3302
|
}
|
|
3304
3303
|
} else if (t.isIdentifier(decl)) {
|
|
3305
|
-
modified = updateStringsInExportedIdentifier(
|
|
3304
|
+
modified = updateStringsInExportedIdentifier(path16, data) || modified;
|
|
3306
3305
|
}
|
|
3307
3306
|
}
|
|
3308
3307
|
});
|
|
@@ -3313,7 +3312,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
3313
3312
|
objectExpression.properties.forEach((prop) => {
|
|
3314
3313
|
if (!t.isObjectProperty(prop)) return;
|
|
3315
3314
|
const key = getPropertyKey(prop);
|
|
3316
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
3315
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _149 => _149[key]]);
|
|
3317
3316
|
if (incomingVal === void 0) {
|
|
3318
3317
|
return;
|
|
3319
3318
|
}
|
|
@@ -3349,7 +3348,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
3349
3348
|
let modified = false;
|
|
3350
3349
|
arrayExpression.elements.forEach((element, index) => {
|
|
3351
3350
|
if (!element) return;
|
|
3352
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
3351
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _150 => _150[index]]);
|
|
3353
3352
|
if (incomingVal === void 0) return;
|
|
3354
3353
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
3355
3354
|
if (element.value !== incomingVal) {
|
|
@@ -3373,9 +3372,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
3373
3372
|
});
|
|
3374
3373
|
return modified;
|
|
3375
3374
|
}
|
|
3376
|
-
function updateStringsInExportedIdentifier(
|
|
3377
|
-
const exportName =
|
|
3378
|
-
const binding =
|
|
3375
|
+
function updateStringsInExportedIdentifier(path16, data) {
|
|
3376
|
+
const exportName = path16.node.declaration.name;
|
|
3377
|
+
const binding = path16.scope.bindings[exportName];
|
|
3379
3378
|
if (!binding || !binding.path.node) return false;
|
|
3380
3379
|
if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
3381
3380
|
const initRaw = binding.path.node.init;
|
|
@@ -3625,7 +3624,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3625
3624
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
3626
3625
|
const result = {
|
|
3627
3626
|
frontmatter: data.frontmatter,
|
|
3628
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
3627
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _151 => _151.codePlaceholders]) || {},
|
|
3629
3628
|
content
|
|
3630
3629
|
};
|
|
3631
3630
|
return result;
|
|
@@ -4006,8 +4005,24 @@ function createLingoLocalizer(params) {
|
|
|
4006
4005
|
|
|
4007
4006
|
// src/cli/processor/basic.ts
|
|
4008
4007
|
var _ai = require('ai');
|
|
4008
|
+
|
|
4009
4009
|
function createBasicTranslator(model, systemPrompt) {
|
|
4010
4010
|
return async (input2, onProgress) => {
|
|
4011
|
+
const chunks = extractPayloadChunks(input2.processableData);
|
|
4012
|
+
const subResults = [];
|
|
4013
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
4014
|
+
const chunk = chunks[i];
|
|
4015
|
+
const result2 = await doJob({
|
|
4016
|
+
...input2,
|
|
4017
|
+
processableData: chunk
|
|
4018
|
+
});
|
|
4019
|
+
subResults.push(result2);
|
|
4020
|
+
onProgress(i / chunks.length * 100, chunk, result2);
|
|
4021
|
+
}
|
|
4022
|
+
const result = _lodash2.default.merge({}, ...subResults);
|
|
4023
|
+
return result;
|
|
4024
|
+
};
|
|
4025
|
+
async function doJob(input2) {
|
|
4011
4026
|
if (!Object.keys(input2.processableData).length) {
|
|
4012
4027
|
return input2.processableData;
|
|
4013
4028
|
}
|
|
@@ -4052,8 +4067,42 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
4052
4067
|
]
|
|
4053
4068
|
});
|
|
4054
4069
|
const result = JSON.parse(response.text);
|
|
4055
|
-
return _optionalChain([result, 'optionalAccess',
|
|
4056
|
-
}
|
|
4070
|
+
return _optionalChain([result, 'optionalAccess', _152 => _152.data]) || {};
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
function extractPayloadChunks(payload) {
|
|
4074
|
+
const idealBatchItemSize = 250;
|
|
4075
|
+
const batchSize = 25;
|
|
4076
|
+
const result = [];
|
|
4077
|
+
let currentChunk = {};
|
|
4078
|
+
let currentChunkItemCount = 0;
|
|
4079
|
+
const payloadEntries = Object.entries(payload);
|
|
4080
|
+
for (let i = 0; i < payloadEntries.length; i++) {
|
|
4081
|
+
const [key, value] = payloadEntries[i];
|
|
4082
|
+
currentChunk[key] = value;
|
|
4083
|
+
currentChunkItemCount++;
|
|
4084
|
+
const currentChunkSize = countWordsInRecord(currentChunk);
|
|
4085
|
+
if (currentChunkSize > idealBatchItemSize || currentChunkItemCount >= batchSize || i === payloadEntries.length - 1) {
|
|
4086
|
+
result.push(currentChunk);
|
|
4087
|
+
currentChunk = {};
|
|
4088
|
+
currentChunkItemCount = 0;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
return result;
|
|
4092
|
+
}
|
|
4093
|
+
function countWordsInRecord(payload) {
|
|
4094
|
+
if (Array.isArray(payload)) {
|
|
4095
|
+
return payload.reduce((acc, item) => acc + countWordsInRecord(item), 0);
|
|
4096
|
+
} else if (typeof payload === "object" && payload !== null) {
|
|
4097
|
+
return Object.values(payload).reduce(
|
|
4098
|
+
(acc, item) => acc + countWordsInRecord(item),
|
|
4099
|
+
0
|
|
4100
|
+
);
|
|
4101
|
+
} else if (typeof payload === "string") {
|
|
4102
|
+
return payload.trim().split(/\s+/).filter(Boolean).length;
|
|
4103
|
+
} else {
|
|
4104
|
+
return 0;
|
|
4105
|
+
}
|
|
4057
4106
|
}
|
|
4058
4107
|
|
|
4059
4108
|
// src/cli/processor/index.ts
|
|
@@ -4100,7 +4149,7 @@ function getPureModelProvider(provider) {
|
|
|
4100
4149
|
|
|
4101
4150
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4102
4151
|
`;
|
|
4103
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
4152
|
+
switch (_optionalChain([provider, 'optionalAccess', _153 => _153.id])) {
|
|
4104
4153
|
case "openai":
|
|
4105
4154
|
if (!process.env.OPENAI_API_KEY) {
|
|
4106
4155
|
throw new Error(
|
|
@@ -4121,7 +4170,7 @@ function getPureModelProvider(provider) {
|
|
|
4121
4170
|
apiKey: process.env.ANTHROPIC_API_KEY
|
|
4122
4171
|
})(provider.model);
|
|
4123
4172
|
default:
|
|
4124
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
4173
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _154 => _154.id])));
|
|
4125
4174
|
}
|
|
4126
4175
|
}
|
|
4127
4176
|
|
|
@@ -4286,7 +4335,6 @@ function createDeltaProcessor(fileKey) {
|
|
|
4286
4335
|
}
|
|
4287
4336
|
|
|
4288
4337
|
// src/cli/cmd/i18n.ts
|
|
4289
|
-
|
|
4290
4338
|
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
4291
4339
|
"--locale <locale>",
|
|
4292
4340
|
"Locale to process",
|
|
@@ -4346,7 +4394,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4346
4394
|
validateParams(i18nConfig, flags);
|
|
4347
4395
|
ora.succeed("Localization configuration is valid");
|
|
4348
4396
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
4349
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
4397
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _155 => _155.provider]);
|
|
4350
4398
|
if (isByokMode) {
|
|
4351
4399
|
authId = null;
|
|
4352
4400
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -4360,16 +4408,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4360
4408
|
flags
|
|
4361
4409
|
});
|
|
4362
4410
|
let buckets = getBuckets(i18nConfig);
|
|
4363
|
-
if (_optionalChain([flags, 'access',
|
|
4411
|
+
if (_optionalChain([flags, 'access', _156 => _156.bucket, 'optionalAccess', _157 => _157.length])) {
|
|
4364
4412
|
buckets = buckets.filter(
|
|
4365
4413
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
4366
4414
|
);
|
|
4367
4415
|
}
|
|
4368
4416
|
ora.succeed("Buckets retrieved");
|
|
4369
|
-
if (_optionalChain([flags, 'access',
|
|
4417
|
+
if (_optionalChain([flags, 'access', _158 => _158.file, 'optionalAccess', _159 => _159.length])) {
|
|
4370
4418
|
buckets = buckets.map((bucket) => {
|
|
4371
4419
|
const paths = bucket.paths.filter(
|
|
4372
|
-
(
|
|
4420
|
+
(path16) => flags.file.find((file) => _optionalChain([path16, 'access', _160 => _160.pathPattern, 'optionalAccess', _161 => _161.includes, 'call', _162 => _162(file)]))
|
|
4373
4421
|
);
|
|
4374
4422
|
return { ...bucket, paths };
|
|
4375
4423
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4382,13 +4430,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4382
4430
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
4383
4431
|
buckets.map((bucket) => {
|
|
4384
4432
|
ora.info(` ${bucket.type}:`);
|
|
4385
|
-
bucket.paths.forEach((
|
|
4386
|
-
ora.info(` - ${
|
|
4433
|
+
bucket.paths.forEach((path16) => {
|
|
4434
|
+
ora.info(` - ${path16.pathPattern}`);
|
|
4387
4435
|
});
|
|
4388
4436
|
});
|
|
4389
4437
|
}
|
|
4390
4438
|
}
|
|
4391
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
4439
|
+
const targetLocales = _optionalChain([flags, 'access', _163 => _163.locale, 'optionalAccess', _164 => _164.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
4392
4440
|
ora.start("Setting up localization cache...");
|
|
4393
4441
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
4394
4442
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -4426,73 +4474,6 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4426
4474
|
} else {
|
|
4427
4475
|
ora.succeed("Localization cache loaded");
|
|
4428
4476
|
}
|
|
4429
|
-
for (const bucket of buckets) {
|
|
4430
|
-
if (bucket.type !== "json") {
|
|
4431
|
-
continue;
|
|
4432
|
-
}
|
|
4433
|
-
ora.start("Validating localization state...");
|
|
4434
|
-
for (const bucketPath of bucket.paths) {
|
|
4435
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
|
|
4436
|
-
i18nConfig.locale.source,
|
|
4437
|
-
bucketPath.delimiter
|
|
4438
|
-
);
|
|
4439
|
-
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
4440
|
-
const sourcePath = path14.join(
|
|
4441
|
-
process.cwd(),
|
|
4442
|
-
bucketPath.pathPattern.replace("[locale]", sourceLocale)
|
|
4443
|
-
);
|
|
4444
|
-
const sourceContent = tryReadFile(sourcePath, null);
|
|
4445
|
-
const sourceData = JSON.parse(sourceContent || "{}");
|
|
4446
|
-
const sourceFlattenedData = _flat.flatten.call(void 0, sourceData, {
|
|
4447
|
-
delimiter: "/",
|
|
4448
|
-
transformKey(key) {
|
|
4449
|
-
return encodeURIComponent(key);
|
|
4450
|
-
}
|
|
4451
|
-
});
|
|
4452
|
-
for (const _targetLocale of targetLocales) {
|
|
4453
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
|
|
4454
|
-
_targetLocale,
|
|
4455
|
-
bucketPath.delimiter
|
|
4456
|
-
);
|
|
4457
|
-
const targetPath = path14.join(
|
|
4458
|
-
process.cwd(),
|
|
4459
|
-
bucketPath.pathPattern.replace("[locale]", targetLocale)
|
|
4460
|
-
);
|
|
4461
|
-
const targetContent = tryReadFile(targetPath, null);
|
|
4462
|
-
const targetData = JSON.parse(targetContent || "{}");
|
|
4463
|
-
const targetFlattenedData = _flat.flatten.call(void 0, targetData, {
|
|
4464
|
-
delimiter: "/",
|
|
4465
|
-
transformKey(key) {
|
|
4466
|
-
return encodeURIComponent(key);
|
|
4467
|
-
}
|
|
4468
|
-
});
|
|
4469
|
-
const checksums = await deltaProcessor.loadChecksums();
|
|
4470
|
-
const delta = await deltaProcessor.calculateDelta({
|
|
4471
|
-
sourceData: sourceFlattenedData,
|
|
4472
|
-
targetData: targetFlattenedData,
|
|
4473
|
-
checksums
|
|
4474
|
-
});
|
|
4475
|
-
if (!delta.hasChanges) {
|
|
4476
|
-
continue;
|
|
4477
|
-
}
|
|
4478
|
-
for (const [oldKey, newKey] of delta.renamed) {
|
|
4479
|
-
targetFlattenedData[newKey] = targetFlattenedData[oldKey];
|
|
4480
|
-
delete targetFlattenedData[oldKey];
|
|
4481
|
-
}
|
|
4482
|
-
const updatedTargetData = _flat.unflatten.call(void 0, targetFlattenedData, {
|
|
4483
|
-
delimiter: "/",
|
|
4484
|
-
transformKey(key) {
|
|
4485
|
-
return decodeURIComponent(key);
|
|
4486
|
-
}
|
|
4487
|
-
});
|
|
4488
|
-
await writeFile(
|
|
4489
|
-
targetPath,
|
|
4490
|
-
JSON.stringify(updatedTargetData, null, 2)
|
|
4491
|
-
);
|
|
4492
|
-
}
|
|
4493
|
-
}
|
|
4494
|
-
ora.succeed("Localization state check completed");
|
|
4495
|
-
}
|
|
4496
4477
|
if (flags.frozen) {
|
|
4497
4478
|
ora.start("Checking for lockfile updates...");
|
|
4498
4479
|
let requiresUpdate = null;
|
|
@@ -4629,7 +4610,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4629
4610
|
if (flags.key) {
|
|
4630
4611
|
processableData = _lodash2.default.pickBy(
|
|
4631
4612
|
processableData,
|
|
4632
|
-
(
|
|
4613
|
+
(_30, key) => key === flags.key
|
|
4633
4614
|
);
|
|
4634
4615
|
}
|
|
4635
4616
|
if (flags.verbose) {
|
|
@@ -4668,6 +4649,15 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4668
4649
|
targetData,
|
|
4669
4650
|
processedTargetData
|
|
4670
4651
|
);
|
|
4652
|
+
finalTargetData = _lodash2.default.chain(finalTargetData).entries().map(([key, value]) => {
|
|
4653
|
+
const renaming = delta.renamed.find(
|
|
4654
|
+
([oldKey, newKey]) => oldKey === key
|
|
4655
|
+
);
|
|
4656
|
+
if (!renaming) {
|
|
4657
|
+
return [key, value];
|
|
4658
|
+
}
|
|
4659
|
+
return [renaming[1], value];
|
|
4660
|
+
}).fromPairs().value();
|
|
4671
4661
|
if (flags.interactive) {
|
|
4672
4662
|
bucketOra.stop();
|
|
4673
4663
|
const reviewedData = await reviewChanges({
|
|
@@ -4790,12 +4780,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
4790
4780
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
4791
4781
|
docUrl: "bucketNotFound"
|
|
4792
4782
|
});
|
|
4793
|
-
} else if (_optionalChain([flags, 'access',
|
|
4783
|
+
} else if (_optionalChain([flags, 'access', _165 => _165.locale, 'optionalAccess', _166 => _166.some, 'call', _167 => _167((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
4794
4784
|
throw new CLIError({
|
|
4795
4785
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
4796
4786
|
docUrl: "localeTargetNotFound"
|
|
4797
4787
|
});
|
|
4798
|
-
} else if (_optionalChain([flags, 'access',
|
|
4788
|
+
} else if (_optionalChain([flags, 'access', _168 => _168.bucket, 'optionalAccess', _169 => _169.some, 'call', _170 => _170(
|
|
4799
4789
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
4800
4790
|
)])) {
|
|
4801
4791
|
throw new CLIError({
|
|
@@ -4972,7 +4962,7 @@ function createLockfileHelper() {
|
|
|
4972
4962
|
fs10.default.writeFileSync(lockfilePath, content);
|
|
4973
4963
|
}
|
|
4974
4964
|
function _getLockfilePath() {
|
|
4975
|
-
return
|
|
4965
|
+
return path12.default.join(process.cwd(), "i18n.lock");
|
|
4976
4966
|
}
|
|
4977
4967
|
}
|
|
4978
4968
|
var LockfileSchema = _zod2.default.object({
|
|
@@ -5123,7 +5113,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
5123
5113
|
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
5124
5114
|
|
|
5125
5115
|
|
|
5126
|
-
var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (
|
|
5116
|
+
var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_30, program) => {
|
|
5127
5117
|
const apiKey = program.args[0];
|
|
5128
5118
|
const settings = getSettings(apiKey);
|
|
5129
5119
|
if (!settings.auth.apiKey) {
|
|
@@ -5260,7 +5250,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5260
5250
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
5261
5251
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
5262
5252
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
5263
|
-
_optionalChain([this, 'access',
|
|
5253
|
+
_optionalChain([this, 'access', _171 => _171.platformKit, 'optionalAccess', _172 => _172.gitConfig, 'call', _173 => _173()]);
|
|
5264
5254
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
5265
5255
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
5266
5256
|
if (!processOwnCommits) {
|
|
@@ -5275,7 +5265,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5275
5265
|
return false;
|
|
5276
5266
|
}
|
|
5277
5267
|
}
|
|
5278
|
-
const workingDir =
|
|
5268
|
+
const workingDir = path12.default.resolve(
|
|
5279
5269
|
process.cwd(),
|
|
5280
5270
|
this.platformKit.config.workingDir
|
|
5281
5271
|
);
|
|
@@ -5292,7 +5282,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5292
5282
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
5293
5283
|
var PullRequestFlow = class extends InBranchFlow {
|
|
5294
5284
|
async preRun() {
|
|
5295
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
5285
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _174 => _174()]);
|
|
5296
5286
|
if (!canContinue) {
|
|
5297
5287
|
return false;
|
|
5298
5288
|
}
|
|
@@ -5544,10 +5534,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5544
5534
|
repo_slug: this.platformConfig.repositoryName,
|
|
5545
5535
|
state: "OPEN"
|
|
5546
5536
|
}).then(({ data: { values } }) => {
|
|
5547
|
-
return _optionalChain([values, 'optionalAccess',
|
|
5548
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
5537
|
+
return _optionalChain([values, 'optionalAccess', _175 => _175.find, 'call', _176 => _176(
|
|
5538
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _177 => _177.branch, 'optionalAccess', _178 => _178.name]) === branch && _optionalChain([destination, 'optionalAccess', _179 => _179.branch, 'optionalAccess', _180 => _180.name]) === this.platformConfig.baseBranchName
|
|
5549
5539
|
)]);
|
|
5550
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5540
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _181 => _181.id]));
|
|
5551
5541
|
}
|
|
5552
5542
|
async closePullRequest({ pullRequestNumber }) {
|
|
5553
5543
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -5643,7 +5633,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5643
5633
|
repo: this.platformConfig.repositoryName,
|
|
5644
5634
|
base: this.platformConfig.baseBranchName,
|
|
5645
5635
|
state: "open"
|
|
5646
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5636
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _182 => _182.number]));
|
|
5647
5637
|
}
|
|
5648
5638
|
async closePullRequest({ pullRequestNumber }) {
|
|
5649
5639
|
await this.octokit.rest.pulls.update({
|
|
@@ -5770,7 +5760,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5770
5760
|
sourceBranch: branch,
|
|
5771
5761
|
state: "opened"
|
|
5772
5762
|
});
|
|
5773
|
-
return _optionalChain([mergeRequests, 'access',
|
|
5763
|
+
return _optionalChain([mergeRequests, 'access', _183 => _183[0], 'optionalAccess', _184 => _184.iid]);
|
|
5774
5764
|
}
|
|
5775
5765
|
async closePullRequest({
|
|
5776
5766
|
pullRequestNumber
|
|
@@ -5854,7 +5844,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5854
5844
|
}
|
|
5855
5845
|
const env = {
|
|
5856
5846
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
5857
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5847
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _185 => _185.pullRequest, 'optionalAccess', _186 => _186.toString, 'call', _187 => _187()]) || "false",
|
|
5858
5848
|
...options.commitMessage && {
|
|
5859
5849
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
5860
5850
|
},
|
|
@@ -5874,7 +5864,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5874
5864
|
const { isPullRequestMode } = platformKit.config;
|
|
5875
5865
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5876
5866
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5877
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
5867
|
+
const canRun = await _optionalChain([flow, 'access', _188 => _188.preRun, 'optionalCall', _189 => _189()]);
|
|
5878
5868
|
if (canRun === false) {
|
|
5879
5869
|
return;
|
|
5880
5870
|
}
|
|
@@ -5882,7 +5872,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5882
5872
|
if (!hasChanges) {
|
|
5883
5873
|
return;
|
|
5884
5874
|
}
|
|
5885
|
-
await _optionalChain([flow, 'access',
|
|
5875
|
+
await _optionalChain([flow, 'access', _190 => _190.postRun, 'optionalCall', _191 => _191()]);
|
|
5886
5876
|
});
|
|
5887
5877
|
|
|
5888
5878
|
// src/cli/cmd/status.ts
|
|
@@ -5926,13 +5916,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5926
5916
|
flags
|
|
5927
5917
|
});
|
|
5928
5918
|
let buckets = getBuckets(i18nConfig);
|
|
5929
|
-
if (_optionalChain([flags, 'access',
|
|
5919
|
+
if (_optionalChain([flags, 'access', _192 => _192.bucket, 'optionalAccess', _193 => _193.length])) {
|
|
5930
5920
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
5931
5921
|
}
|
|
5932
5922
|
ora.succeed("Buckets retrieved");
|
|
5933
|
-
if (_optionalChain([flags, 'access',
|
|
5923
|
+
if (_optionalChain([flags, 'access', _194 => _194.file, 'optionalAccess', _195 => _195.length])) {
|
|
5934
5924
|
buckets = buckets.map((bucket) => {
|
|
5935
|
-
const paths = bucket.paths.filter((
|
|
5925
|
+
const paths = bucket.paths.filter((path16) => flags.file.find((file) => _optionalChain([path16, 'access', _196 => _196.pathPattern, 'optionalAccess', _197 => _197.match, 'call', _198 => _198(file)])));
|
|
5936
5926
|
return { ...bucket, paths };
|
|
5937
5927
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5938
5928
|
if (buckets.length === 0) {
|
|
@@ -5942,13 +5932,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5942
5932
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
5943
5933
|
buckets.map((bucket) => {
|
|
5944
5934
|
ora.info(` ${bucket.type}:`);
|
|
5945
|
-
bucket.paths.forEach((
|
|
5946
|
-
ora.info(` - ${
|
|
5935
|
+
bucket.paths.forEach((path16) => {
|
|
5936
|
+
ora.info(` - ${path16.pathPattern}`);
|
|
5947
5937
|
});
|
|
5948
5938
|
});
|
|
5949
5939
|
}
|
|
5950
5940
|
}
|
|
5951
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
5941
|
+
const targetLocales = _optionalChain([flags, 'access', _199 => _199.locale, 'optionalAccess', _200 => _200.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
5952
5942
|
let totalSourceKeyCount = 0;
|
|
5953
5943
|
let uniqueKeysToTranslate = 0;
|
|
5954
5944
|
let totalExistingTranslations = 0;
|
|
@@ -6172,10 +6162,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
6172
6162
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
6173
6163
|
console.log(_chalk2.default.bold(`
|
|
6174
6164
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
6175
|
-
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([
|
|
6165
|
+
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path16, stats]) => {
|
|
6176
6166
|
if (stats.sourceKeys === 0) return;
|
|
6177
6167
|
console.log(_chalk2.default.bold(`
|
|
6178
|
-
\u2022 ${
|
|
6168
|
+
\u2022 ${path16}:`));
|
|
6179
6169
|
console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
|
|
6180
6170
|
const fileTable = new (0, _clitable32.default)({
|
|
6181
6171
|
head: ["Language", "Status", "Details"],
|
|
@@ -6289,12 +6279,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6289
6279
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
6290
6280
|
docUrl: "bucketNotFound"
|
|
6291
6281
|
});
|
|
6292
|
-
} else if (_optionalChain([flags, 'access',
|
|
6282
|
+
} else if (_optionalChain([flags, 'access', _201 => _201.locale, 'optionalAccess', _202 => _202.some, 'call', _203 => _203((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
6293
6283
|
throw new CLIError({
|
|
6294
6284
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
6295
6285
|
docUrl: "localeTargetNotFound"
|
|
6296
6286
|
});
|
|
6297
|
-
} else if (_optionalChain([flags, 'access',
|
|
6287
|
+
} else if (_optionalChain([flags, 'access', _204 => _204.bucket, 'optionalAccess', _205 => _205.some, 'call', _206 => _206((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
6298
6288
|
throw new CLIError({
|
|
6299
6289
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
6300
6290
|
docUrl: "bucketNotFound"
|
|
@@ -6377,7 +6367,7 @@ async function renderHero() {
|
|
|
6377
6367
|
// package.json
|
|
6378
6368
|
var package_default = {
|
|
6379
6369
|
name: "lingo.dev",
|
|
6380
|
-
version: "0.92.
|
|
6370
|
+
version: "0.92.14",
|
|
6381
6371
|
description: "Lingo.dev CLI",
|
|
6382
6372
|
private: false,
|
|
6383
6373
|
publishConfig: {
|
|
@@ -6592,7 +6582,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
6592
6582
|
const response = await engine.whoami();
|
|
6593
6583
|
return {
|
|
6594
6584
|
authenticated: !!response,
|
|
6595
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
6585
|
+
username: _optionalChain([response, 'optionalAccess', _207 => _207.email])
|
|
6596
6586
|
};
|
|
6597
6587
|
} catch (e3) {
|
|
6598
6588
|
return { authenticated: false };
|
|
@@ -6771,14 +6761,14 @@ async function setup(input2) {
|
|
|
6771
6761
|
throw new Error(
|
|
6772
6762
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
6773
6763
|
);
|
|
6774
|
-
} else if (_optionalChain([ctx, 'access',
|
|
6775
|
-
(locale) => !_optionalChain([ctx, 'access',
|
|
6764
|
+
} else if (_optionalChain([ctx, 'access', _208 => _208.flags, 'access', _209 => _209.locale, 'optionalAccess', _210 => _210.some, 'call', _211 => _211(
|
|
6765
|
+
(locale) => !_optionalChain([ctx, 'access', _212 => _212.config, 'optionalAccess', _213 => _213.locale, 'access', _214 => _214.targets, 'access', _215 => _215.includes, 'call', _216 => _216(locale)])
|
|
6776
6766
|
)])) {
|
|
6777
6767
|
throw new Error(
|
|
6778
6768
|
`One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list first and try again.`
|
|
6779
6769
|
);
|
|
6780
|
-
} else if (_optionalChain([ctx, 'access',
|
|
6781
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
6770
|
+
} else if (_optionalChain([ctx, 'access', _217 => _217.flags, 'access', _218 => _218.bucket, 'optionalAccess', _219 => _219.some, 'call', _220 => _220(
|
|
6771
|
+
(bucket) => !_optionalChain([ctx, 'access', _221 => _221.config, 'optionalAccess', _222 => _222.buckets, 'access', _223 => _223[bucket]])
|
|
6782
6772
|
)])) {
|
|
6783
6773
|
throw new Error(
|
|
6784
6774
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -6790,7 +6780,7 @@ async function setup(input2) {
|
|
|
6790
6780
|
{
|
|
6791
6781
|
title: "Selecting localization provider",
|
|
6792
6782
|
task: async (ctx, task) => {
|
|
6793
|
-
ctx.localizer = createLocalizer(_optionalChain([ctx, 'access',
|
|
6783
|
+
ctx.localizer = createLocalizer(_optionalChain([ctx, 'access', _224 => _224.config, 'optionalAccess', _225 => _225.provider]));
|
|
6794
6784
|
if (!ctx.localizer) {
|
|
6795
6785
|
throw new Error(
|
|
6796
6786
|
"Could not create localization provider. Please check your i18n.json configuration."
|
|
@@ -6976,7 +6966,7 @@ async function execute(input2) {
|
|
|
6976
6966
|
const workerTasks = [];
|
|
6977
6967
|
for (let i = 0; i < workersCount; i++) {
|
|
6978
6968
|
const assignedTasks = ctx.tasks.filter(
|
|
6979
|
-
(
|
|
6969
|
+
(_30, idx) => idx % workersCount === i
|
|
6980
6970
|
);
|
|
6981
6971
|
workerTasks.push(
|
|
6982
6972
|
createWorkerTask({
|
|
@@ -7096,12 +7086,21 @@ function createWorkerTask(args) {
|
|
|
7096
7086
|
});
|
|
7097
7087
|
}
|
|
7098
7088
|
);
|
|
7099
|
-
|
|
7089
|
+
let finalTargetData = _lodash2.default.merge(
|
|
7100
7090
|
{},
|
|
7101
7091
|
sourceData,
|
|
7102
7092
|
targetData,
|
|
7103
7093
|
processedTargetData
|
|
7104
7094
|
);
|
|
7095
|
+
finalTargetData = _lodash2.default.chain(finalTargetData).entries().map(([key, value]) => {
|
|
7096
|
+
const renaming = delta.renamed.find(
|
|
7097
|
+
([oldKey]) => oldKey === key
|
|
7098
|
+
);
|
|
7099
|
+
if (!renaming) {
|
|
7100
|
+
return [key, value];
|
|
7101
|
+
}
|
|
7102
|
+
return [renaming[1], value];
|
|
7103
|
+
}).fromPairs().value();
|
|
7105
7104
|
await args.ioLimiter(async () => {
|
|
7106
7105
|
await bucketLoader.pull(assignedTask.sourceLocale);
|
|
7107
7106
|
await bucketLoader.push(
|