lingo.dev 0.92.12 → 0.92.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.cjs +80 -131
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +55 -106
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
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);
|
|
@@ -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() {
|
|
@@ -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`);
|
|
@@ -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;
|
|
@@ -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,7 +1028,6 @@ 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 {
|
|
@@ -1252,8 +1251,8 @@ function createTextFileLoader(pathPattern) {
|
|
|
1252
1251
|
},
|
|
1253
1252
|
async push(locale, data, _29, 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 "";
|
|
@@ -1674,9 +1673,9 @@ 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;
|
|
@@ -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
|
});
|
|
@@ -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
|
}
|
|
@@ -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
|
});
|
|
@@ -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;
|
|
@@ -4286,7 +4285,6 @@ function createDeltaProcessor(fileKey) {
|
|
|
4286
4285
|
}
|
|
4287
4286
|
|
|
4288
4287
|
// src/cli/cmd/i18n.ts
|
|
4289
|
-
|
|
4290
4288
|
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
4291
4289
|
"--locale <locale>",
|
|
4292
4290
|
"Locale to process",
|
|
@@ -4369,7 +4367,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4369
4367
|
if (_optionalChain([flags, 'access', _157 => _157.file, 'optionalAccess', _158 => _158.length])) {
|
|
4370
4368
|
buckets = buckets.map((bucket) => {
|
|
4371
4369
|
const paths = bucket.paths.filter(
|
|
4372
|
-
(
|
|
4370
|
+
(path16) => flags.file.find((file) => _optionalChain([path16, 'access', _159 => _159.pathPattern, 'optionalAccess', _160 => _160.includes, 'call', _161 => _161(file)]))
|
|
4373
4371
|
);
|
|
4374
4372
|
return { ...bucket, paths };
|
|
4375
4373
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4382,8 +4380,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4382
4380
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
4383
4381
|
buckets.map((bucket) => {
|
|
4384
4382
|
ora.info(` ${bucket.type}:`);
|
|
4385
|
-
bucket.paths.forEach((
|
|
4386
|
-
ora.info(` - ${
|
|
4383
|
+
bucket.paths.forEach((path16) => {
|
|
4384
|
+
ora.info(` - ${path16.pathPattern}`);
|
|
4387
4385
|
});
|
|
4388
4386
|
});
|
|
4389
4387
|
}
|
|
@@ -4426,73 +4424,6 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4426
4424
|
} else {
|
|
4427
4425
|
ora.succeed("Localization cache loaded");
|
|
4428
4426
|
}
|
|
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
4427
|
if (flags.frozen) {
|
|
4497
4428
|
ora.start("Checking for lockfile updates...");
|
|
4498
4429
|
let requiresUpdate = null;
|
|
@@ -4668,6 +4599,15 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4668
4599
|
targetData,
|
|
4669
4600
|
processedTargetData
|
|
4670
4601
|
);
|
|
4602
|
+
finalTargetData = _lodash2.default.chain(finalTargetData).entries().map(([key, value]) => {
|
|
4603
|
+
const renaming = delta.renamed.find(
|
|
4604
|
+
([oldKey, newKey]) => oldKey === key
|
|
4605
|
+
);
|
|
4606
|
+
if (!renaming) {
|
|
4607
|
+
return [key, value];
|
|
4608
|
+
}
|
|
4609
|
+
return [renaming[1], value];
|
|
4610
|
+
}).fromPairs().value();
|
|
4671
4611
|
if (flags.interactive) {
|
|
4672
4612
|
bucketOra.stop();
|
|
4673
4613
|
const reviewedData = await reviewChanges({
|
|
@@ -4972,7 +4912,7 @@ function createLockfileHelper() {
|
|
|
4972
4912
|
fs10.default.writeFileSync(lockfilePath, content);
|
|
4973
4913
|
}
|
|
4974
4914
|
function _getLockfilePath() {
|
|
4975
|
-
return
|
|
4915
|
+
return path12.default.join(process.cwd(), "i18n.lock");
|
|
4976
4916
|
}
|
|
4977
4917
|
}
|
|
4978
4918
|
var LockfileSchema = _zod2.default.object({
|
|
@@ -5275,7 +5215,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5275
5215
|
return false;
|
|
5276
5216
|
}
|
|
5277
5217
|
}
|
|
5278
|
-
const workingDir =
|
|
5218
|
+
const workingDir = path12.default.resolve(
|
|
5279
5219
|
process.cwd(),
|
|
5280
5220
|
this.platformKit.config.workingDir
|
|
5281
5221
|
);
|
|
@@ -5932,7 +5872,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5932
5872
|
ora.succeed("Buckets retrieved");
|
|
5933
5873
|
if (_optionalChain([flags, 'access', _193 => _193.file, 'optionalAccess', _194 => _194.length])) {
|
|
5934
5874
|
buckets = buckets.map((bucket) => {
|
|
5935
|
-
const paths = bucket.paths.filter((
|
|
5875
|
+
const paths = bucket.paths.filter((path16) => flags.file.find((file) => _optionalChain([path16, 'access', _195 => _195.pathPattern, 'optionalAccess', _196 => _196.match, 'call', _197 => _197(file)])));
|
|
5936
5876
|
return { ...bucket, paths };
|
|
5937
5877
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5938
5878
|
if (buckets.length === 0) {
|
|
@@ -5942,8 +5882,8 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5942
5882
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
5943
5883
|
buckets.map((bucket) => {
|
|
5944
5884
|
ora.info(` ${bucket.type}:`);
|
|
5945
|
-
bucket.paths.forEach((
|
|
5946
|
-
ora.info(` - ${
|
|
5885
|
+
bucket.paths.forEach((path16) => {
|
|
5886
|
+
ora.info(` - ${path16.pathPattern}`);
|
|
5947
5887
|
});
|
|
5948
5888
|
});
|
|
5949
5889
|
}
|
|
@@ -6172,10 +6112,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
6172
6112
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
6173
6113
|
console.log(_chalk2.default.bold(`
|
|
6174
6114
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
6175
|
-
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([
|
|
6115
|
+
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path16, stats]) => {
|
|
6176
6116
|
if (stats.sourceKeys === 0) return;
|
|
6177
6117
|
console.log(_chalk2.default.bold(`
|
|
6178
|
-
\u2022 ${
|
|
6118
|
+
\u2022 ${path16}:`));
|
|
6179
6119
|
console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
|
|
6180
6120
|
const fileTable = new (0, _clitable32.default)({
|
|
6181
6121
|
head: ["Language", "Status", "Details"],
|
|
@@ -6377,7 +6317,7 @@ async function renderHero() {
|
|
|
6377
6317
|
// package.json
|
|
6378
6318
|
var package_default = {
|
|
6379
6319
|
name: "lingo.dev",
|
|
6380
|
-
version: "0.92.
|
|
6320
|
+
version: "0.92.13",
|
|
6381
6321
|
description: "Lingo.dev CLI",
|
|
6382
6322
|
private: false,
|
|
6383
6323
|
publishConfig: {
|
|
@@ -7096,12 +7036,21 @@ function createWorkerTask(args) {
|
|
|
7096
7036
|
});
|
|
7097
7037
|
}
|
|
7098
7038
|
);
|
|
7099
|
-
|
|
7039
|
+
let finalTargetData = _lodash2.default.merge(
|
|
7100
7040
|
{},
|
|
7101
7041
|
sourceData,
|
|
7102
7042
|
targetData,
|
|
7103
7043
|
processedTargetData
|
|
7104
7044
|
);
|
|
7045
|
+
finalTargetData = _lodash2.default.chain(finalTargetData).entries().map(([key, value]) => {
|
|
7046
|
+
const renaming = delta.renamed.find(
|
|
7047
|
+
([oldKey]) => oldKey === key
|
|
7048
|
+
);
|
|
7049
|
+
if (!renaming) {
|
|
7050
|
+
return [key, value];
|
|
7051
|
+
}
|
|
7052
|
+
return [renaming[1], value];
|
|
7053
|
+
}).fromPairs().value();
|
|
7105
7054
|
await args.ioLimiter(async () => {
|
|
7106
7055
|
await bucketLoader.pull(assignedTask.sourceLocale);
|
|
7107
7056
|
await bucketLoader.push(
|