lingo.dev 0.92.11 → 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 +84 -133
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +59 -108
- 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
|
}
|
|
@@ -2963,8 +2962,10 @@ function variableContentLoader() {
|
|
|
2963
2962
|
const result = _lodash2.default.mapValues(input2, (payload) => payload.value);
|
|
2964
2963
|
return result;
|
|
2965
2964
|
},
|
|
2966
|
-
push: async (locale, data, originalInput) => {
|
|
2967
|
-
const result = _lodash2.default.cloneDeep(
|
|
2965
|
+
push: async (locale, data, originalInput, defaultLocale, pullInput) => {
|
|
2966
|
+
const result = _lodash2.default.cloneDeep(
|
|
2967
|
+
pullInput || {}
|
|
2968
|
+
);
|
|
2968
2969
|
for (const [key, originalValueObj] of Object.entries(result)) {
|
|
2969
2970
|
result[key] = {
|
|
2970
2971
|
...originalValueObj,
|
|
@@ -3217,15 +3218,15 @@ function parseTypeScript(input2) {
|
|
|
3217
3218
|
function extractStringsFromDefaultExport(ast) {
|
|
3218
3219
|
let extracted = {};
|
|
3219
3220
|
traverse(ast, {
|
|
3220
|
-
ExportDefaultDeclaration(
|
|
3221
|
-
const { declaration } =
|
|
3221
|
+
ExportDefaultDeclaration(path16) {
|
|
3222
|
+
const { declaration } = path16.node;
|
|
3222
3223
|
const decl = unwrapTSAsExpression(declaration);
|
|
3223
3224
|
if (t.isObjectExpression(decl)) {
|
|
3224
3225
|
extracted = objectExpressionToObject(decl);
|
|
3225
3226
|
} else if (t.isArrayExpression(decl)) {
|
|
3226
3227
|
extracted = arrayExpressionToArray(decl);
|
|
3227
3228
|
} else if (t.isIdentifier(decl)) {
|
|
3228
|
-
const binding =
|
|
3229
|
+
const binding = path16.scope.bindings[decl.name];
|
|
3229
3230
|
if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
3230
3231
|
const initRaw = binding.path.node.init;
|
|
3231
3232
|
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
@@ -3290,8 +3291,8 @@ function arrayExpressionToArray(arrayExpression) {
|
|
|
3290
3291
|
function updateStringsInDefaultExport(ast, data) {
|
|
3291
3292
|
let modified = false;
|
|
3292
3293
|
traverse(ast, {
|
|
3293
|
-
ExportDefaultDeclaration(
|
|
3294
|
-
const { declaration } =
|
|
3294
|
+
ExportDefaultDeclaration(path16) {
|
|
3295
|
+
const { declaration } = path16.node;
|
|
3295
3296
|
const decl = unwrapTSAsExpression(declaration);
|
|
3296
3297
|
if (t.isObjectExpression(decl)) {
|
|
3297
3298
|
modified = updateStringsInObjectExpression(decl, data) || modified;
|
|
@@ -3300,7 +3301,7 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
3300
3301
|
modified = updateStringsInArrayExpression(decl, data) || modified;
|
|
3301
3302
|
}
|
|
3302
3303
|
} else if (t.isIdentifier(decl)) {
|
|
3303
|
-
modified = updateStringsInExportedIdentifier(
|
|
3304
|
+
modified = updateStringsInExportedIdentifier(path16, data) || modified;
|
|
3304
3305
|
}
|
|
3305
3306
|
}
|
|
3306
3307
|
});
|
|
@@ -3371,9 +3372,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
3371
3372
|
});
|
|
3372
3373
|
return modified;
|
|
3373
3374
|
}
|
|
3374
|
-
function updateStringsInExportedIdentifier(
|
|
3375
|
-
const exportName =
|
|
3376
|
-
const binding =
|
|
3375
|
+
function updateStringsInExportedIdentifier(path16, data) {
|
|
3376
|
+
const exportName = path16.node.declaration.name;
|
|
3377
|
+
const binding = path16.scope.bindings[exportName];
|
|
3377
3378
|
if (!binding || !binding.path.node) return false;
|
|
3378
3379
|
if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
3379
3380
|
const initRaw = binding.path.node.init;
|
|
@@ -4284,7 +4285,6 @@ function createDeltaProcessor(fileKey) {
|
|
|
4284
4285
|
}
|
|
4285
4286
|
|
|
4286
4287
|
// src/cli/cmd/i18n.ts
|
|
4287
|
-
|
|
4288
4288
|
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
4289
4289
|
"--locale <locale>",
|
|
4290
4290
|
"Locale to process",
|
|
@@ -4367,7 +4367,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4367
4367
|
if (_optionalChain([flags, 'access', _157 => _157.file, 'optionalAccess', _158 => _158.length])) {
|
|
4368
4368
|
buckets = buckets.map((bucket) => {
|
|
4369
4369
|
const paths = bucket.paths.filter(
|
|
4370
|
-
(
|
|
4370
|
+
(path16) => flags.file.find((file) => _optionalChain([path16, 'access', _159 => _159.pathPattern, 'optionalAccess', _160 => _160.includes, 'call', _161 => _161(file)]))
|
|
4371
4371
|
);
|
|
4372
4372
|
return { ...bucket, paths };
|
|
4373
4373
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4380,8 +4380,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4380
4380
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
4381
4381
|
buckets.map((bucket) => {
|
|
4382
4382
|
ora.info(` ${bucket.type}:`);
|
|
4383
|
-
bucket.paths.forEach((
|
|
4384
|
-
ora.info(` - ${
|
|
4383
|
+
bucket.paths.forEach((path16) => {
|
|
4384
|
+
ora.info(` - ${path16.pathPattern}`);
|
|
4385
4385
|
});
|
|
4386
4386
|
});
|
|
4387
4387
|
}
|
|
@@ -4424,73 +4424,6 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4424
4424
|
} else {
|
|
4425
4425
|
ora.succeed("Localization cache loaded");
|
|
4426
4426
|
}
|
|
4427
|
-
for (const bucket of buckets) {
|
|
4428
|
-
if (bucket.type !== "json") {
|
|
4429
|
-
continue;
|
|
4430
|
-
}
|
|
4431
|
-
ora.start("Validating localization state...");
|
|
4432
|
-
for (const bucketPath of bucket.paths) {
|
|
4433
|
-
const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
|
|
4434
|
-
i18nConfig.locale.source,
|
|
4435
|
-
bucketPath.delimiter
|
|
4436
|
-
);
|
|
4437
|
-
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
4438
|
-
const sourcePath = path14.join(
|
|
4439
|
-
process.cwd(),
|
|
4440
|
-
bucketPath.pathPattern.replace("[locale]", sourceLocale)
|
|
4441
|
-
);
|
|
4442
|
-
const sourceContent = tryReadFile(sourcePath, null);
|
|
4443
|
-
const sourceData = JSON.parse(sourceContent || "{}");
|
|
4444
|
-
const sourceFlattenedData = _flat.flatten.call(void 0, sourceData, {
|
|
4445
|
-
delimiter: "/",
|
|
4446
|
-
transformKey(key) {
|
|
4447
|
-
return encodeURIComponent(key);
|
|
4448
|
-
}
|
|
4449
|
-
});
|
|
4450
|
-
for (const _targetLocale of targetLocales) {
|
|
4451
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
|
|
4452
|
-
_targetLocale,
|
|
4453
|
-
bucketPath.delimiter
|
|
4454
|
-
);
|
|
4455
|
-
const targetPath = path14.join(
|
|
4456
|
-
process.cwd(),
|
|
4457
|
-
bucketPath.pathPattern.replace("[locale]", targetLocale)
|
|
4458
|
-
);
|
|
4459
|
-
const targetContent = tryReadFile(targetPath, null);
|
|
4460
|
-
const targetData = JSON.parse(targetContent || "{}");
|
|
4461
|
-
const targetFlattenedData = _flat.flatten.call(void 0, targetData, {
|
|
4462
|
-
delimiter: "/",
|
|
4463
|
-
transformKey(key) {
|
|
4464
|
-
return encodeURIComponent(key);
|
|
4465
|
-
}
|
|
4466
|
-
});
|
|
4467
|
-
const checksums = await deltaProcessor.loadChecksums();
|
|
4468
|
-
const delta = await deltaProcessor.calculateDelta({
|
|
4469
|
-
sourceData: sourceFlattenedData,
|
|
4470
|
-
targetData: targetFlattenedData,
|
|
4471
|
-
checksums
|
|
4472
|
-
});
|
|
4473
|
-
if (!delta.hasChanges) {
|
|
4474
|
-
continue;
|
|
4475
|
-
}
|
|
4476
|
-
for (const [oldKey, newKey] of delta.renamed) {
|
|
4477
|
-
targetFlattenedData[newKey] = targetFlattenedData[oldKey];
|
|
4478
|
-
delete targetFlattenedData[oldKey];
|
|
4479
|
-
}
|
|
4480
|
-
const updatedTargetData = _flat.unflatten.call(void 0, targetFlattenedData, {
|
|
4481
|
-
delimiter: "/",
|
|
4482
|
-
transformKey(key) {
|
|
4483
|
-
return decodeURIComponent(key);
|
|
4484
|
-
}
|
|
4485
|
-
});
|
|
4486
|
-
await writeFile(
|
|
4487
|
-
targetPath,
|
|
4488
|
-
JSON.stringify(updatedTargetData, null, 2)
|
|
4489
|
-
);
|
|
4490
|
-
}
|
|
4491
|
-
}
|
|
4492
|
-
ora.succeed("Localization state check completed");
|
|
4493
|
-
}
|
|
4494
4427
|
if (flags.frozen) {
|
|
4495
4428
|
ora.start("Checking for lockfile updates...");
|
|
4496
4429
|
let requiresUpdate = null;
|
|
@@ -4666,6 +4599,15 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4666
4599
|
targetData,
|
|
4667
4600
|
processedTargetData
|
|
4668
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();
|
|
4669
4611
|
if (flags.interactive) {
|
|
4670
4612
|
bucketOra.stop();
|
|
4671
4613
|
const reviewedData = await reviewChanges({
|
|
@@ -4970,7 +4912,7 @@ function createLockfileHelper() {
|
|
|
4970
4912
|
fs10.default.writeFileSync(lockfilePath, content);
|
|
4971
4913
|
}
|
|
4972
4914
|
function _getLockfilePath() {
|
|
4973
|
-
return
|
|
4915
|
+
return path12.default.join(process.cwd(), "i18n.lock");
|
|
4974
4916
|
}
|
|
4975
4917
|
}
|
|
4976
4918
|
var LockfileSchema = _zod2.default.object({
|
|
@@ -5273,7 +5215,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5273
5215
|
return false;
|
|
5274
5216
|
}
|
|
5275
5217
|
}
|
|
5276
|
-
const workingDir =
|
|
5218
|
+
const workingDir = path12.default.resolve(
|
|
5277
5219
|
process.cwd(),
|
|
5278
5220
|
this.platformKit.config.workingDir
|
|
5279
5221
|
);
|
|
@@ -5930,7 +5872,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5930
5872
|
ora.succeed("Buckets retrieved");
|
|
5931
5873
|
if (_optionalChain([flags, 'access', _193 => _193.file, 'optionalAccess', _194 => _194.length])) {
|
|
5932
5874
|
buckets = buckets.map((bucket) => {
|
|
5933
|
-
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)])));
|
|
5934
5876
|
return { ...bucket, paths };
|
|
5935
5877
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5936
5878
|
if (buckets.length === 0) {
|
|
@@ -5940,8 +5882,8 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5940
5882
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
5941
5883
|
buckets.map((bucket) => {
|
|
5942
5884
|
ora.info(` ${bucket.type}:`);
|
|
5943
|
-
bucket.paths.forEach((
|
|
5944
|
-
ora.info(` - ${
|
|
5885
|
+
bucket.paths.forEach((path16) => {
|
|
5886
|
+
ora.info(` - ${path16.pathPattern}`);
|
|
5945
5887
|
});
|
|
5946
5888
|
});
|
|
5947
5889
|
}
|
|
@@ -6170,10 +6112,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
6170
6112
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
6171
6113
|
console.log(_chalk2.default.bold(`
|
|
6172
6114
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
6173
|
-
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]) => {
|
|
6174
6116
|
if (stats.sourceKeys === 0) return;
|
|
6175
6117
|
console.log(_chalk2.default.bold(`
|
|
6176
|
-
\u2022 ${
|
|
6118
|
+
\u2022 ${path16}:`));
|
|
6177
6119
|
console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
|
|
6178
6120
|
const fileTable = new (0, _clitable32.default)({
|
|
6179
6121
|
head: ["Language", "Status", "Details"],
|
|
@@ -6375,7 +6317,7 @@ async function renderHero() {
|
|
|
6375
6317
|
// package.json
|
|
6376
6318
|
var package_default = {
|
|
6377
6319
|
name: "lingo.dev",
|
|
6378
|
-
version: "0.92.
|
|
6320
|
+
version: "0.92.13",
|
|
6379
6321
|
description: "Lingo.dev CLI",
|
|
6380
6322
|
private: false,
|
|
6381
6323
|
publishConfig: {
|
|
@@ -7094,12 +7036,21 @@ function createWorkerTask(args) {
|
|
|
7094
7036
|
});
|
|
7095
7037
|
}
|
|
7096
7038
|
);
|
|
7097
|
-
|
|
7039
|
+
let finalTargetData = _lodash2.default.merge(
|
|
7098
7040
|
{},
|
|
7099
7041
|
sourceData,
|
|
7100
7042
|
targetData,
|
|
7101
7043
|
processedTargetData
|
|
7102
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();
|
|
7103
7054
|
await args.ioLimiter(async () => {
|
|
7104
7055
|
await bucketLoader.pull(assignedTask.sourceLocale);
|
|
7105
7056
|
await bucketLoader.push(
|