lingo.dev 0.91.0 → 0.92.0
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 +203 -122
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +177 -96
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -180,7 +180,7 @@ var require_lib = __commonJS({
|
|
|
180
180
|
let regex = null;
|
|
181
181
|
try {
|
|
182
182
|
regex = new RegExp(pattern, flags);
|
|
183
|
-
} catch (
|
|
183
|
+
} catch (_27) {
|
|
184
184
|
}
|
|
185
185
|
const node = this.estreeParseLiteral(regex);
|
|
186
186
|
node.regex = { pattern, flags };
|
|
@@ -13119,7 +13119,7 @@ var require_node = __commonJS({
|
|
|
13119
13119
|
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
13120
13120
|
return /^debug_/i.test(key);
|
|
13121
13121
|
}).reduce((obj, key) => {
|
|
13122
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (
|
|
13122
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_27, k) => {
|
|
13123
13123
|
return k.toUpperCase();
|
|
13124
13124
|
});
|
|
13125
13125
|
let val = process.env[key];
|
|
@@ -13279,7 +13279,7 @@ var require_generated = __commonJS({
|
|
|
13279
13279
|
exports.isAccessor = isAccessor;
|
|
13280
13280
|
exports.isAnyTypeAnnotation = isAnyTypeAnnotation;
|
|
13281
13281
|
exports.isArgumentPlaceholder = isArgumentPlaceholder;
|
|
13282
|
-
exports.isArrayExpression =
|
|
13282
|
+
exports.isArrayExpression = isArrayExpression2;
|
|
13283
13283
|
exports.isArrayPattern = isArrayPattern;
|
|
13284
13284
|
exports.isArrayTypeAnnotation = isArrayTypeAnnotation;
|
|
13285
13285
|
exports.isArrowFunctionExpression = isArrowFunctionExpression;
|
|
@@ -13584,7 +13584,7 @@ var require_generated = __commonJS({
|
|
|
13584
13584
|
exports.isYieldExpression = isYieldExpression;
|
|
13585
13585
|
var _shallowEqual = require_shallowEqual();
|
|
13586
13586
|
var _deprecationWarning = require_deprecationWarning();
|
|
13587
|
-
function
|
|
13587
|
+
function isArrayExpression2(node, opts) {
|
|
13588
13588
|
if (!node) return false;
|
|
13589
13589
|
if (node.type !== "ArrayExpression") return false;
|
|
13590
13590
|
return opts == null || (0, _shallowEqual.default)(node, opts);
|
|
@@ -29430,7 +29430,7 @@ var require_scope = __commonJS({
|
|
|
29430
29430
|
cloneNode,
|
|
29431
29431
|
getBindingIdentifiers,
|
|
29432
29432
|
identifier,
|
|
29433
|
-
isArrayExpression,
|
|
29433
|
+
isArrayExpression: isArrayExpression2,
|
|
29434
29434
|
isBinary,
|
|
29435
29435
|
isCallExpression,
|
|
29436
29436
|
isClass,
|
|
@@ -29981,7 +29981,7 @@ var require_scope = __commonJS({
|
|
|
29981
29981
|
return true;
|
|
29982
29982
|
} else if (isBinary(node)) {
|
|
29983
29983
|
return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
|
|
29984
|
-
} else if (
|
|
29984
|
+
} else if (isArrayExpression2(node) || isTupleExpression(node)) {
|
|
29985
29985
|
for (const elem of node.elements) {
|
|
29986
29986
|
if (elem !== null && !this.isPure(elem, constantsOnly)) return false;
|
|
29987
29987
|
}
|
|
@@ -30360,7 +30360,7 @@ var require_scope = __commonJS({
|
|
|
30360
30360
|
return node;
|
|
30361
30361
|
}
|
|
30362
30362
|
}
|
|
30363
|
-
if (
|
|
30363
|
+
if (isArrayExpression2(node)) {
|
|
30364
30364
|
return node;
|
|
30365
30365
|
}
|
|
30366
30366
|
if (isIdentifier2(node, {
|
|
@@ -32173,7 +32173,7 @@ var require_whitespace = __commonJS({
|
|
|
32173
32173
|
var _t = require_lib4();
|
|
32174
32174
|
var {
|
|
32175
32175
|
FLIPPED_ALIAS_KEYS,
|
|
32176
|
-
isArrayExpression,
|
|
32176
|
+
isArrayExpression: isArrayExpression2,
|
|
32177
32177
|
isAssignmentExpression,
|
|
32178
32178
|
isBinary,
|
|
32179
32179
|
isBlockStatement,
|
|
@@ -32227,7 +32227,7 @@ var require_whitespace = __commonJS({
|
|
|
32227
32227
|
}
|
|
32228
32228
|
}
|
|
32229
32229
|
function isType(node) {
|
|
32230
|
-
return isLiteral(node) || isObjectExpression2(node) ||
|
|
32230
|
+
return isLiteral(node) || isObjectExpression2(node) || isArrayExpression2(node) || isIdentifier2(node) || isMemberExpression(node);
|
|
32231
32231
|
}
|
|
32232
32232
|
var nodes = exports.nodes = {
|
|
32233
32233
|
AssignmentExpression(node) {
|
|
@@ -41487,7 +41487,7 @@ var require_family = __commonJS({
|
|
|
41487
41487
|
const node = this.node;
|
|
41488
41488
|
const container = node[key];
|
|
41489
41489
|
if (Array.isArray(container)) {
|
|
41490
|
-
return container.map((
|
|
41490
|
+
return container.map((_27, i) => {
|
|
41491
41491
|
return _index.default.get({
|
|
41492
41492
|
listKey: key,
|
|
41493
41493
|
parentPath: this,
|
|
@@ -43456,7 +43456,7 @@ import {
|
|
|
43456
43456
|
} from "@lingo.dev/_spec";
|
|
43457
43457
|
import { Command as Command6 } from "interactive-commander";
|
|
43458
43458
|
import Z3 from "zod";
|
|
43459
|
-
import
|
|
43459
|
+
import _24 from "lodash";
|
|
43460
43460
|
import * as path14 from "path";
|
|
43461
43461
|
import Ora5 from "ora";
|
|
43462
43462
|
|
|
@@ -43681,7 +43681,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
43681
43681
|
const trimmedResult = result.trim();
|
|
43682
43682
|
return trimmedResult;
|
|
43683
43683
|
},
|
|
43684
|
-
async push(locale, data,
|
|
43684
|
+
async push(locale, data, _27, originalLocale) {
|
|
43685
43685
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
43686
43686
|
const finalPath = path10.resolve(draftPath);
|
|
43687
43687
|
const dirPath = path10.dirname(finalPath);
|
|
@@ -44207,7 +44207,7 @@ function createPropertiesLoader() {
|
|
|
44207
44207
|
return result;
|
|
44208
44208
|
},
|
|
44209
44209
|
async push(locale, payload) {
|
|
44210
|
-
const result = Object.entries(payload).filter(([
|
|
44210
|
+
const result = Object.entries(payload).filter(([_27, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
44211
44211
|
return result;
|
|
44212
44212
|
}
|
|
44213
44213
|
});
|
|
@@ -44474,10 +44474,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
44474
44474
|
}
|
|
44475
44475
|
}
|
|
44476
44476
|
return false;
|
|
44477
|
-
}).map(([key,
|
|
44478
|
-
const result = _10.omitBy(input2, (
|
|
44477
|
+
}).map(([key, _27]) => key);
|
|
44478
|
+
const result = _10.omitBy(input2, (_27, key) => passthroughKeys.includes(key));
|
|
44479
44479
|
if (returnUnlocalizedKeys) {
|
|
44480
|
-
result.unlocalizable = _10.omitBy(input2, (
|
|
44480
|
+
result.unlocalizable = _10.omitBy(input2, (_27, key) => !passthroughKeys.includes(key));
|
|
44481
44481
|
}
|
|
44482
44482
|
return result;
|
|
44483
44483
|
},
|
|
@@ -45592,6 +45592,8 @@ var import_parser = __toESM(require_lib(), 1);
|
|
|
45592
45592
|
var import_traverse = __toESM(require_lib8(), 1);
|
|
45593
45593
|
var t = __toESM(require_lib4(), 1);
|
|
45594
45594
|
var import_generator = __toESM(require_lib5(), 1);
|
|
45595
|
+
import { flatten as flatten2, unflatten as unflatten2 } from "flat";
|
|
45596
|
+
import _18 from "lodash";
|
|
45595
45597
|
function createTypescriptLoader() {
|
|
45596
45598
|
return createLoader({
|
|
45597
45599
|
pull: async (locale, input2) => {
|
|
@@ -45600,7 +45602,8 @@ function createTypescriptLoader() {
|
|
|
45600
45602
|
}
|
|
45601
45603
|
try {
|
|
45602
45604
|
const ast = parseTypeScript(input2);
|
|
45603
|
-
|
|
45605
|
+
const extractedStrings = extractStringsFromDefaultExport(ast);
|
|
45606
|
+
return flattenExtractedStrings(extractedStrings);
|
|
45604
45607
|
} catch (error) {
|
|
45605
45608
|
console.error("Error parsing TypeScript file:", error);
|
|
45606
45609
|
return {};
|
|
@@ -45613,7 +45616,8 @@ function createTypescriptLoader() {
|
|
|
45613
45616
|
const input2 = originalInput;
|
|
45614
45617
|
try {
|
|
45615
45618
|
const ast = parseTypeScript(input2);
|
|
45616
|
-
const
|
|
45619
|
+
const nestedData = unflattenStringData(data);
|
|
45620
|
+
const modified = updateStringsInDefaultExport(ast, nestedData);
|
|
45617
45621
|
if (!modified) {
|
|
45618
45622
|
return input2;
|
|
45619
45623
|
}
|
|
@@ -45632,36 +45636,69 @@ function parseTypeScript(input2) {
|
|
|
45632
45636
|
plugins: ["typescript"]
|
|
45633
45637
|
});
|
|
45634
45638
|
}
|
|
45639
|
+
function flattenExtractedStrings(obj) {
|
|
45640
|
+
const flattened = flatten2(obj, { delimiter: "/" });
|
|
45641
|
+
return Object.entries(flattened).reduce((acc, [key, value]) => {
|
|
45642
|
+
if (typeof value === "string") {
|
|
45643
|
+
acc[key] = value;
|
|
45644
|
+
}
|
|
45645
|
+
return acc;
|
|
45646
|
+
}, {});
|
|
45647
|
+
}
|
|
45648
|
+
function unflattenStringData(data) {
|
|
45649
|
+
return unflatten2(data, { delimiter: "/" });
|
|
45650
|
+
}
|
|
45635
45651
|
function extractStringsFromDefaultExport(ast) {
|
|
45636
45652
|
const result = {};
|
|
45637
45653
|
(0, import_traverse.default)(ast, {
|
|
45638
45654
|
ExportDefaultDeclaration(path17) {
|
|
45639
45655
|
if (t.isObjectExpression(path17.node.declaration)) {
|
|
45640
|
-
extractStringsFromObjectExpression(path17.node.declaration, result);
|
|
45656
|
+
extractStringsFromObjectExpression(path17.node.declaration, result, "");
|
|
45641
45657
|
} else if (t.isIdentifier(path17.node.declaration)) {
|
|
45642
|
-
extractStringsFromExportedIdentifier(path17, result);
|
|
45658
|
+
extractStringsFromExportedIdentifier(path17, result, "");
|
|
45643
45659
|
}
|
|
45644
45660
|
}
|
|
45645
45661
|
});
|
|
45646
45662
|
return result;
|
|
45647
45663
|
}
|
|
45648
|
-
function extractStringsFromObjectExpression(objectExpression, result) {
|
|
45664
|
+
function extractStringsFromObjectExpression(objectExpression, result, path17) {
|
|
45649
45665
|
objectExpression.properties.forEach((prop) => {
|
|
45650
45666
|
if (t.isObjectProperty(prop)) {
|
|
45651
45667
|
const key = getPropertyKey(prop);
|
|
45668
|
+
const currentPath = path17 ? `${path17}/${key}` : key;
|
|
45652
45669
|
if (t.isStringLiteral(prop.value)) {
|
|
45653
|
-
result
|
|
45670
|
+
_18.set(result, currentPath, prop.value.value);
|
|
45671
|
+
} else if (t.isObjectExpression(prop.value)) {
|
|
45672
|
+
extractStringsFromObjectExpression(prop.value, result, currentPath);
|
|
45673
|
+
} else if (t.isArrayExpression(prop.value)) {
|
|
45674
|
+
extractStringsFromArrayExpression(prop.value, result, currentPath);
|
|
45654
45675
|
}
|
|
45655
45676
|
}
|
|
45656
45677
|
});
|
|
45657
45678
|
}
|
|
45658
|
-
function
|
|
45679
|
+
function extractStringsFromArrayExpression(arrayExpression, result, path17) {
|
|
45680
|
+
arrayExpression.elements.forEach((element, index) => {
|
|
45681
|
+
const currentPath = `${path17}/${index}`;
|
|
45682
|
+
if (t.isStringLiteral(element)) {
|
|
45683
|
+
_18.set(result, currentPath, element.value);
|
|
45684
|
+
} else if (t.isObjectExpression(element)) {
|
|
45685
|
+
extractStringsFromObjectExpression(element, result, currentPath);
|
|
45686
|
+
} else if (t.isArrayExpression(element)) {
|
|
45687
|
+
extractStringsFromArrayExpression(element, result, currentPath);
|
|
45688
|
+
}
|
|
45689
|
+
});
|
|
45690
|
+
}
|
|
45691
|
+
function extractStringsFromExportedIdentifier(path17, result, basePath) {
|
|
45659
45692
|
const exportName = path17.node.declaration.name;
|
|
45660
45693
|
const binding = path17.scope.bindings[exportName];
|
|
45661
45694
|
if (binding && binding.path.node) {
|
|
45662
45695
|
const bindingPath = binding.path;
|
|
45663
|
-
if (t.isVariableDeclarator(bindingPath.node) && bindingPath.node.init
|
|
45664
|
-
|
|
45696
|
+
if (t.isVariableDeclarator(bindingPath.node) && bindingPath.node.init) {
|
|
45697
|
+
if (t.isObjectExpression(bindingPath.node.init)) {
|
|
45698
|
+
extractStringsFromObjectExpression(bindingPath.node.init, result, basePath);
|
|
45699
|
+
} else if (t.isArrayExpression(bindingPath.node.init)) {
|
|
45700
|
+
extractStringsFromArrayExpression(bindingPath.node.init, result, basePath);
|
|
45701
|
+
}
|
|
45665
45702
|
}
|
|
45666
45703
|
}
|
|
45667
45704
|
}
|
|
@@ -45670,35 +45707,93 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
45670
45707
|
(0, import_traverse.default)(ast, {
|
|
45671
45708
|
ExportDefaultDeclaration(path17) {
|
|
45672
45709
|
if (t.isObjectExpression(path17.node.declaration)) {
|
|
45673
|
-
modified = updateStringsInObjectExpression(path17.node.declaration, data) || modified;
|
|
45710
|
+
modified = updateStringsInObjectExpression(path17.node.declaration, data, "") || modified;
|
|
45674
45711
|
} else if (t.isIdentifier(path17.node.declaration)) {
|
|
45675
|
-
modified = updateStringsInExportedIdentifier(path17, data) || modified;
|
|
45712
|
+
modified = updateStringsInExportedIdentifier(path17, data, "") || modified;
|
|
45676
45713
|
}
|
|
45677
45714
|
}
|
|
45678
45715
|
});
|
|
45679
45716
|
return modified;
|
|
45680
45717
|
}
|
|
45681
|
-
function updateStringsInObjectExpression(objectExpression, data) {
|
|
45718
|
+
function updateStringsInObjectExpression(objectExpression, data, path17) {
|
|
45682
45719
|
let modified = false;
|
|
45683
45720
|
objectExpression.properties.forEach((prop) => {
|
|
45684
45721
|
if (t.isObjectProperty(prop)) {
|
|
45685
45722
|
const key = getPropertyKey(prop);
|
|
45686
|
-
|
|
45687
|
-
|
|
45723
|
+
const currentPath = path17 ? `${path17}/${key}` : key;
|
|
45724
|
+
if (t.isStringLiteral(prop.value)) {
|
|
45725
|
+
if (data[currentPath] !== void 0) {
|
|
45726
|
+
prop.value.value = data[currentPath];
|
|
45727
|
+
modified = true;
|
|
45728
|
+
} else if (path17 === "" && data[key] !== void 0) {
|
|
45729
|
+
prop.value.value = data[key];
|
|
45730
|
+
modified = true;
|
|
45731
|
+
}
|
|
45732
|
+
} else if (t.isObjectExpression(prop.value)) {
|
|
45733
|
+
if (data[key] && typeof data[key] === "object") {
|
|
45734
|
+
const subModified = updateStringsInObjectExpression(prop.value, data[key], "");
|
|
45735
|
+
modified = subModified || modified;
|
|
45736
|
+
} else {
|
|
45737
|
+
const subModified = updateStringsInObjectExpression(prop.value, data, currentPath);
|
|
45738
|
+
modified = subModified || modified;
|
|
45739
|
+
}
|
|
45740
|
+
} else if (t.isArrayExpression(prop.value)) {
|
|
45741
|
+
if (data[key] && Array.isArray(data[key])) {
|
|
45742
|
+
const subModified = updateStringsInArrayExpression(prop.value, data[key], "");
|
|
45743
|
+
modified = subModified || modified;
|
|
45744
|
+
} else {
|
|
45745
|
+
const subModified = updateStringsInArrayExpression(prop.value, data, currentPath);
|
|
45746
|
+
modified = subModified || modified;
|
|
45747
|
+
}
|
|
45748
|
+
}
|
|
45749
|
+
}
|
|
45750
|
+
});
|
|
45751
|
+
return modified;
|
|
45752
|
+
}
|
|
45753
|
+
function updateStringsInArrayExpression(arrayExpression, data, path17) {
|
|
45754
|
+
let modified = false;
|
|
45755
|
+
arrayExpression.elements.forEach((element, index) => {
|
|
45756
|
+
const currentPath = `${path17}/${index}`;
|
|
45757
|
+
if (t.isStringLiteral(element)) {
|
|
45758
|
+
if (Array.isArray(data) && data[index] !== void 0) {
|
|
45759
|
+
element.value = data[index];
|
|
45688
45760
|
modified = true;
|
|
45761
|
+
} else if (!Array.isArray(data) && data[currentPath] !== void 0) {
|
|
45762
|
+
element.value = data[currentPath];
|
|
45763
|
+
modified = true;
|
|
45764
|
+
}
|
|
45765
|
+
} else if (t.isObjectExpression(element)) {
|
|
45766
|
+
if (Array.isArray(data) && data[index] && typeof data[index] === "object") {
|
|
45767
|
+
const subModified = updateStringsInObjectExpression(element, data[index], "");
|
|
45768
|
+
modified = subModified || modified;
|
|
45769
|
+
} else {
|
|
45770
|
+
const subModified = updateStringsInObjectExpression(element, data, currentPath);
|
|
45771
|
+
modified = subModified || modified;
|
|
45772
|
+
}
|
|
45773
|
+
} else if (t.isArrayExpression(element)) {
|
|
45774
|
+
if (Array.isArray(data) && data[index] && Array.isArray(data[index])) {
|
|
45775
|
+
const subModified = updateStringsInArrayExpression(element, data[index], "");
|
|
45776
|
+
modified = subModified || modified;
|
|
45777
|
+
} else {
|
|
45778
|
+
const subModified = updateStringsInArrayExpression(element, data, currentPath);
|
|
45779
|
+
modified = subModified || modified;
|
|
45689
45780
|
}
|
|
45690
45781
|
}
|
|
45691
45782
|
});
|
|
45692
45783
|
return modified;
|
|
45693
45784
|
}
|
|
45694
|
-
function updateStringsInExportedIdentifier(path17, data) {
|
|
45785
|
+
function updateStringsInExportedIdentifier(path17, data, basePath) {
|
|
45695
45786
|
let modified = false;
|
|
45696
45787
|
const exportName = path17.node.declaration.name;
|
|
45697
45788
|
const binding = path17.scope.bindings[exportName];
|
|
45698
45789
|
if (binding && binding.path.node) {
|
|
45699
45790
|
const bindingPath = binding.path;
|
|
45700
|
-
if (t.isVariableDeclarator(bindingPath.node) && bindingPath.node.init
|
|
45701
|
-
|
|
45791
|
+
if (t.isVariableDeclarator(bindingPath.node) && bindingPath.node.init) {
|
|
45792
|
+
if (t.isObjectExpression(bindingPath.node.init)) {
|
|
45793
|
+
modified = updateStringsInObjectExpression(bindingPath.node.init, data, basePath) || modified;
|
|
45794
|
+
} else if (t.isArrayExpression(bindingPath.node.init)) {
|
|
45795
|
+
modified = updateStringsInArrayExpression(bindingPath.node.init, data, basePath) || modified;
|
|
45796
|
+
}
|
|
45702
45797
|
}
|
|
45703
45798
|
}
|
|
45704
45799
|
return modified;
|
|
@@ -45713,7 +45808,7 @@ function getPropertyKey(prop) {
|
|
|
45713
45808
|
}
|
|
45714
45809
|
|
|
45715
45810
|
// src/cli/loaders/inject-locale.ts
|
|
45716
|
-
import
|
|
45811
|
+
import _19 from "lodash";
|
|
45717
45812
|
function createInjectLocaleLoader(injectLocaleKeys) {
|
|
45718
45813
|
return createLoader({
|
|
45719
45814
|
async pull(locale, data) {
|
|
@@ -45721,19 +45816,19 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
45721
45816
|
return data;
|
|
45722
45817
|
}
|
|
45723
45818
|
const omitKeys = injectLocaleKeys.filter((key) => {
|
|
45724
|
-
return
|
|
45819
|
+
return _19.get(data, key) === locale;
|
|
45725
45820
|
});
|
|
45726
|
-
const result =
|
|
45821
|
+
const result = _19.omit(data, omitKeys);
|
|
45727
45822
|
return result;
|
|
45728
45823
|
},
|
|
45729
45824
|
async push(locale, data, originalInput, originalLocale) {
|
|
45730
45825
|
if (!injectLocaleKeys) {
|
|
45731
45826
|
return data;
|
|
45732
45827
|
}
|
|
45733
|
-
const mergedData =
|
|
45828
|
+
const mergedData = _19.merge({}, originalInput, data);
|
|
45734
45829
|
injectLocaleKeys.forEach((key) => {
|
|
45735
|
-
if (
|
|
45736
|
-
|
|
45830
|
+
if (_19.get(mergedData, key) === originalLocale) {
|
|
45831
|
+
_19.set(mergedData, key, locale);
|
|
45737
45832
|
}
|
|
45738
45833
|
});
|
|
45739
45834
|
return mergedData;
|
|
@@ -45742,16 +45837,16 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
45742
45837
|
}
|
|
45743
45838
|
|
|
45744
45839
|
// src/cli/loaders/locked-keys.ts
|
|
45745
|
-
import
|
|
45840
|
+
import _20 from "lodash";
|
|
45746
45841
|
function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
|
|
45747
45842
|
return createLoader({
|
|
45748
|
-
pull: async (locale, data) =>
|
|
45843
|
+
pull: async (locale, data) => _20.chain(data).pickBy((value, key) => !lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value(),
|
|
45749
45844
|
push: async (locale, data, originalInput) => {
|
|
45750
|
-
const lockedSubObject =
|
|
45845
|
+
const lockedSubObject = _20.chain(originalInput).pickBy((value, key) => lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value();
|
|
45751
45846
|
if (isCacheRestore) {
|
|
45752
|
-
return
|
|
45847
|
+
return _20.merge({}, data, lockedSubObject);
|
|
45753
45848
|
} else {
|
|
45754
|
-
return
|
|
45849
|
+
return _20.merge({}, originalInput, data, lockedSubObject);
|
|
45755
45850
|
}
|
|
45756
45851
|
}
|
|
45757
45852
|
});
|
|
@@ -45804,7 +45899,7 @@ function md5(input2) {
|
|
|
45804
45899
|
}
|
|
45805
45900
|
|
|
45806
45901
|
// src/cli/loaders/mdx2/code-placeholder.ts
|
|
45807
|
-
import
|
|
45902
|
+
import _21 from "lodash";
|
|
45808
45903
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
45809
45904
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
45810
45905
|
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
@@ -45827,7 +45922,7 @@ ${match}
|
|
|
45827
45922
|
found = true;
|
|
45828
45923
|
}
|
|
45829
45924
|
} while (found);
|
|
45830
|
-
content =
|
|
45925
|
+
content = _21.chain(content).split("\n\n").map((section) => _21.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
45831
45926
|
return content;
|
|
45832
45927
|
}
|
|
45833
45928
|
function ensureTrailingFenceNewline(_content) {
|
|
@@ -45849,7 +45944,7 @@ ${match}
|
|
|
45849
45944
|
found = true;
|
|
45850
45945
|
}
|
|
45851
45946
|
} while (found);
|
|
45852
|
-
content =
|
|
45947
|
+
content = _21.chain(content).split("\n\n").map((section) => _21.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
45853
45948
|
return content;
|
|
45854
45949
|
}
|
|
45855
45950
|
function extractCodePlaceholders(content) {
|
|
@@ -45889,13 +45984,13 @@ function createMdxCodePlaceholderLoader() {
|
|
|
45889
45984
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
45890
45985
|
const sourceInfo = extractCodePlaceholders(originalInput ?? "");
|
|
45891
45986
|
const currentInfo = extractCodePlaceholders(pullInput ?? "");
|
|
45892
|
-
const codePlaceholders =
|
|
45987
|
+
const codePlaceholders = _21.merge(
|
|
45893
45988
|
sourceInfo.codePlaceholders,
|
|
45894
45989
|
currentInfo.codePlaceholders
|
|
45895
45990
|
);
|
|
45896
45991
|
let result = data;
|
|
45897
45992
|
for (const [placeholder, original] of Object.entries(codePlaceholders)) {
|
|
45898
|
-
const replacement = original.startsWith(">") ?
|
|
45993
|
+
const replacement = original.startsWith(">") ? _21.trimStart(original, "> ") : original;
|
|
45899
45994
|
result = result.replaceAll(placeholder, replacement);
|
|
45900
45995
|
}
|
|
45901
45996
|
return result;
|
|
@@ -45923,11 +46018,11 @@ function createLocalizableMdxDocumentLoader() {
|
|
|
45923
46018
|
}
|
|
45924
46019
|
|
|
45925
46020
|
// src/cli/loaders/mdx2/sections-split-2.ts
|
|
45926
|
-
import
|
|
46021
|
+
import _22 from "lodash";
|
|
45927
46022
|
function createMdxSectionsSplit2Loader() {
|
|
45928
46023
|
return createLoader({
|
|
45929
46024
|
async pull(locale, input2) {
|
|
45930
|
-
const sections =
|
|
46025
|
+
const sections = _22.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
|
|
45931
46026
|
const result = {
|
|
45932
46027
|
frontmatter: input2.frontmatter,
|
|
45933
46028
|
sections
|
|
@@ -45935,7 +46030,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
45935
46030
|
return result;
|
|
45936
46031
|
},
|
|
45937
46032
|
async push(locale, data, originalInput, _originalLocale, pullInput) {
|
|
45938
|
-
const content =
|
|
46033
|
+
const content = _22.chain(data.sections).values().join("\n\n").value();
|
|
45939
46034
|
const result = {
|
|
45940
46035
|
frontmatter: data.frontmatter,
|
|
45941
46036
|
codePlaceholders: pullInput?.codePlaceholders || {},
|
|
@@ -46449,7 +46544,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
46449
46544
|
}
|
|
46450
46545
|
|
|
46451
46546
|
// src/cli/utils/delta.ts
|
|
46452
|
-
import
|
|
46547
|
+
import _23 from "lodash";
|
|
46453
46548
|
import z from "zod";
|
|
46454
46549
|
|
|
46455
46550
|
// src/cli/utils/fs.ts
|
|
@@ -46498,9 +46593,9 @@ function createDeltaProcessor(fileKey) {
|
|
|
46498
46593
|
return checkIfFileExists(lockfilePath);
|
|
46499
46594
|
},
|
|
46500
46595
|
async calculateDelta(params) {
|
|
46501
|
-
let added =
|
|
46502
|
-
let removed =
|
|
46503
|
-
const updated =
|
|
46596
|
+
let added = _23.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
|
|
46597
|
+
let removed = _23.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
|
|
46598
|
+
const updated = _23.filter(Object.keys(params.sourceData), (key) => {
|
|
46504
46599
|
return md5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
|
|
46505
46600
|
});
|
|
46506
46601
|
const renamed = [];
|
|
@@ -46549,14 +46644,14 @@ function createDeltaProcessor(fileKey) {
|
|
|
46549
46644
|
await this.saveLock(lockfileData);
|
|
46550
46645
|
},
|
|
46551
46646
|
async createChecksums(sourceData) {
|
|
46552
|
-
const checksums =
|
|
46647
|
+
const checksums = _23.mapValues(sourceData, (value) => md5(value));
|
|
46553
46648
|
return checksums;
|
|
46554
46649
|
}
|
|
46555
46650
|
};
|
|
46556
46651
|
}
|
|
46557
46652
|
|
|
46558
46653
|
// src/cli/cmd/i18n.ts
|
|
46559
|
-
import { flatten as
|
|
46654
|
+
import { flatten as flatten3, unflatten as unflatten3 } from "flat";
|
|
46560
46655
|
var i18n_default = new Command6().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
46561
46656
|
"--locale <locale>",
|
|
46562
46657
|
"Locale to process",
|
|
@@ -46706,7 +46801,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46706
46801
|
);
|
|
46707
46802
|
const sourceContent = tryReadFile(sourcePath, null);
|
|
46708
46803
|
const sourceData = JSON.parse(sourceContent || "{}");
|
|
46709
|
-
const sourceFlattenedData =
|
|
46804
|
+
const sourceFlattenedData = flatten3(sourceData, {
|
|
46710
46805
|
delimiter: "/",
|
|
46711
46806
|
transformKey(key) {
|
|
46712
46807
|
return encodeURIComponent(key);
|
|
@@ -46723,7 +46818,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46723
46818
|
);
|
|
46724
46819
|
const targetContent = tryReadFile(targetPath, null);
|
|
46725
46820
|
const targetData = JSON.parse(targetContent || "{}");
|
|
46726
|
-
const targetFlattenedData =
|
|
46821
|
+
const targetFlattenedData = flatten3(targetData, {
|
|
46727
46822
|
delimiter: "/",
|
|
46728
46823
|
transformKey(key) {
|
|
46729
46824
|
return encodeURIComponent(key);
|
|
@@ -46742,7 +46837,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46742
46837
|
targetFlattenedData[newKey] = targetFlattenedData[oldKey];
|
|
46743
46838
|
delete targetFlattenedData[oldKey];
|
|
46744
46839
|
}
|
|
46745
|
-
const updatedTargetData =
|
|
46840
|
+
const updatedTargetData = unflatten3(targetFlattenedData, {
|
|
46746
46841
|
delimiter: "/",
|
|
46747
46842
|
transformKey(key) {
|
|
46748
46843
|
return decodeURIComponent(key);
|
|
@@ -46782,7 +46877,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46782
46877
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
46783
46878
|
const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
|
|
46784
46879
|
const savedChecksums = await deltaProcessor.loadChecksums();
|
|
46785
|
-
const updatedSourceData =
|
|
46880
|
+
const updatedSourceData = _24.pickBy(
|
|
46786
46881
|
sourceData,
|
|
46787
46882
|
(value, key) => sourceChecksums[key] !== savedChecksums[key]
|
|
46788
46883
|
);
|
|
@@ -46796,15 +46891,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46796
46891
|
bucketPath.delimiter
|
|
46797
46892
|
);
|
|
46798
46893
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
46799
|
-
const missingKeys =
|
|
46894
|
+
const missingKeys = _24.difference(
|
|
46800
46895
|
Object.keys(sourceData),
|
|
46801
46896
|
Object.keys(targetData)
|
|
46802
46897
|
);
|
|
46803
|
-
const extraKeys =
|
|
46898
|
+
const extraKeys = _24.difference(
|
|
46804
46899
|
Object.keys(targetData),
|
|
46805
46900
|
Object.keys(sourceData)
|
|
46806
46901
|
);
|
|
46807
|
-
const unlocalizableDataDiff = !
|
|
46902
|
+
const unlocalizableDataDiff = !_24.isEqual(
|
|
46808
46903
|
sourceUnlocalizable,
|
|
46809
46904
|
targetUnlocalizable
|
|
46810
46905
|
);
|
|
@@ -46885,13 +46980,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46885
46980
|
targetData,
|
|
46886
46981
|
checksums: checksums2
|
|
46887
46982
|
});
|
|
46888
|
-
let processableData =
|
|
46983
|
+
let processableData = _24.chain(sourceData).entries().filter(
|
|
46889
46984
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
|
|
46890
46985
|
).fromPairs().value();
|
|
46891
46986
|
if (flags.key) {
|
|
46892
|
-
processableData =
|
|
46987
|
+
processableData = _24.pickBy(
|
|
46893
46988
|
processableData,
|
|
46894
|
-
(
|
|
46989
|
+
(_27, key) => key === flags.key
|
|
46895
46990
|
);
|
|
46896
46991
|
}
|
|
46897
46992
|
if (flags.verbose) {
|
|
@@ -46932,7 +47027,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46932
47027
|
if (flags.verbose) {
|
|
46933
47028
|
bucketOra.info(JSON.stringify(processedTargetData, null, 2));
|
|
46934
47029
|
}
|
|
46935
|
-
let finalTargetData =
|
|
47030
|
+
let finalTargetData = _24.merge(
|
|
46936
47031
|
{},
|
|
46937
47032
|
sourceData,
|
|
46938
47033
|
targetData,
|
|
@@ -46953,7 +47048,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
46953
47048
|
`Applying changes to ${bucketPath} (${targetLocale})`
|
|
46954
47049
|
);
|
|
46955
47050
|
}
|
|
46956
|
-
const finalDiffSize =
|
|
47051
|
+
const finalDiffSize = _24.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
46957
47052
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
46958
47053
|
if (finalDiffSize > 0 || flags.force) {
|
|
46959
47054
|
bucketOra.succeed(
|
|
@@ -47121,7 +47216,7 @@ Reviewing changes for ${chalk.blue(args.pathPattern)} (${chalk.yellow(args.targe
|
|
|
47121
47216
|
return args.currentData;
|
|
47122
47217
|
}
|
|
47123
47218
|
const customData = { ...args.currentData };
|
|
47124
|
-
const changes =
|
|
47219
|
+
const changes = _24.reduce(
|
|
47125
47220
|
args.proposedData,
|
|
47126
47221
|
(result, value, key) => {
|
|
47127
47222
|
if (args.currentData[key] !== value) {
|
|
@@ -47194,7 +47289,7 @@ import path15 from "path";
|
|
|
47194
47289
|
import Z4 from "zod";
|
|
47195
47290
|
import YAML5 from "yaml";
|
|
47196
47291
|
import { MD5 as MD52 } from "object-hash";
|
|
47197
|
-
import
|
|
47292
|
+
import _25 from "lodash";
|
|
47198
47293
|
function createLockfileHelper() {
|
|
47199
47294
|
return {
|
|
47200
47295
|
isLockfileExists: () => {
|
|
@@ -47204,23 +47299,23 @@ function createLockfileHelper() {
|
|
|
47204
47299
|
registerSourceData: (pathPattern, sourceData) => {
|
|
47205
47300
|
const lockfile = _loadLockfile();
|
|
47206
47301
|
const sectionKey = MD52(pathPattern);
|
|
47207
|
-
const sectionChecksums =
|
|
47302
|
+
const sectionChecksums = _25.mapValues(sourceData, (value) => MD52(value));
|
|
47208
47303
|
lockfile.checksums[sectionKey] = sectionChecksums;
|
|
47209
47304
|
_saveLockfile(lockfile);
|
|
47210
47305
|
},
|
|
47211
47306
|
registerPartialSourceData: (pathPattern, partialSourceData) => {
|
|
47212
47307
|
const lockfile = _loadLockfile();
|
|
47213
47308
|
const sectionKey = MD52(pathPattern);
|
|
47214
|
-
const sectionChecksums =
|
|
47215
|
-
lockfile.checksums[sectionKey] =
|
|
47309
|
+
const sectionChecksums = _25.mapValues(partialSourceData, (value) => MD52(value));
|
|
47310
|
+
lockfile.checksums[sectionKey] = _25.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
|
|
47216
47311
|
_saveLockfile(lockfile);
|
|
47217
47312
|
},
|
|
47218
47313
|
extractUpdatedData: (pathPattern, sourceData) => {
|
|
47219
47314
|
const lockfile = _loadLockfile();
|
|
47220
47315
|
const sectionKey = MD52(pathPattern);
|
|
47221
|
-
const currentChecksums =
|
|
47316
|
+
const currentChecksums = _25.mapValues(sourceData, (value) => MD52(value));
|
|
47222
47317
|
const savedChecksums = lockfile.checksums[sectionKey] || {};
|
|
47223
|
-
const updatedData =
|
|
47318
|
+
const updatedData = _25.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
|
|
47224
47319
|
return updatedData;
|
|
47225
47320
|
}
|
|
47226
47321
|
};
|
|
@@ -47290,7 +47385,7 @@ var flagsSchema = Z5.object({
|
|
|
47290
47385
|
// src/cli/cmd/cleanup.ts
|
|
47291
47386
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
47292
47387
|
import { Command as Command8 } from "interactive-commander";
|
|
47293
|
-
import
|
|
47388
|
+
import _26 from "lodash";
|
|
47294
47389
|
import Ora7 from "ora";
|
|
47295
47390
|
var cleanup_default = new Command8().command("cleanup").description("Remove keys from target files that do not exist in the source file").helpOption("-h, --help", "Show help").option("--locale <locale>", "Specific locale to cleanup").option("--bucket <bucket>", "Specific bucket to cleanup").option("--dry-run", "Show what would be removed without making changes").option(
|
|
47296
47391
|
"--verbose",
|
|
@@ -47326,7 +47421,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
47326
47421
|
try {
|
|
47327
47422
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
47328
47423
|
const targetKeys = Object.keys(targetData);
|
|
47329
|
-
const keysToRemove =
|
|
47424
|
+
const keysToRemove = _26.difference(targetKeys, sourceKeys);
|
|
47330
47425
|
if (keysToRemove.length === 0) {
|
|
47331
47426
|
bucketOra.succeed(`[${targetLocale}] No keys to remove`);
|
|
47332
47427
|
continue;
|
|
@@ -47335,7 +47430,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
47335
47430
|
bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
|
|
47336
47431
|
}
|
|
47337
47432
|
if (!options.dryRun) {
|
|
47338
|
-
const cleanedData =
|
|
47433
|
+
const cleanedData = _26.pick(targetData, sourceKeys);
|
|
47339
47434
|
await bucketLoader.push(targetLocale, cleanedData);
|
|
47340
47435
|
bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
|
|
47341
47436
|
} else {
|
|
@@ -47390,7 +47485,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
47390
47485
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
47391
47486
|
import Z6 from "zod";
|
|
47392
47487
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
47393
|
-
var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (
|
|
47488
|
+
var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_27, program) => {
|
|
47394
47489
|
const apiKey = program.args[0];
|
|
47395
47490
|
const settings = getSettings(apiKey);
|
|
47396
47491
|
if (!settings.auth.apiKey) {
|
|
@@ -48101,24 +48196,10 @@ var getPlatformKit = () => {
|
|
|
48101
48196
|
};
|
|
48102
48197
|
|
|
48103
48198
|
// src/cli/cmd/ci/index.ts
|
|
48104
|
-
import inquirer3 from "inquirer";
|
|
48105
48199
|
var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD action").helpOption("-h, --help", "Show help").option("--api-key <key>", "API key").option("--pull-request [boolean]", "Create a pull request with the changes").option("--commit-message <message>", "Commit message").option("--pull-request-title <title>", "Pull request title").option("--working-directory <dir>", "Working directory").option(
|
|
48106
48200
|
"--process-own-commits [boolean]",
|
|
48107
48201
|
"Process commits made by this action"
|
|
48108
|
-
).option(
|
|
48109
|
-
"--debug",
|
|
48110
|
-
"Debug mode. Wait for user input before continuing.",
|
|
48111
|
-
false
|
|
48112
48202
|
).action(async (options) => {
|
|
48113
|
-
if (options.debug) {
|
|
48114
|
-
const { debug } = await inquirer3.prompt([
|
|
48115
|
-
{
|
|
48116
|
-
type: "confirm",
|
|
48117
|
-
name: "debug",
|
|
48118
|
-
message: "Debug mode. Wait for user input before continuing."
|
|
48119
|
-
}
|
|
48120
|
-
]);
|
|
48121
|
-
}
|
|
48122
48203
|
const settings = getSettings(options.apiKey);
|
|
48123
48204
|
if (!settings.auth.apiKey) {
|
|
48124
48205
|
console.error("No API key provided");
|
|
@@ -48658,7 +48739,7 @@ async function renderHero() {
|
|
|
48658
48739
|
// package.json
|
|
48659
48740
|
var package_default = {
|
|
48660
48741
|
name: "lingo.dev",
|
|
48661
|
-
version: "0.
|
|
48742
|
+
version: "0.92.0",
|
|
48662
48743
|
description: "Lingo.dev CLI",
|
|
48663
48744
|
private: false,
|
|
48664
48745
|
publishConfig: {
|