lingo.dev 0.109.2 → 0.110.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 +159 -146
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +92 -79
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -1495,7 +1495,7 @@ import {
|
|
|
1495
1495
|
} from "@lingo.dev/_spec";
|
|
1496
1496
|
import { Command as Command12 } from "interactive-commander";
|
|
1497
1497
|
import Z3 from "zod";
|
|
1498
|
-
import
|
|
1498
|
+
import _30 from "lodash";
|
|
1499
1499
|
import Ora7 from "ora";
|
|
1500
1500
|
|
|
1501
1501
|
// src/cli/loaders/_utils.ts
|
|
@@ -1968,7 +1968,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1968
1968
|
const trimmedResult = result.trim();
|
|
1969
1969
|
return trimmedResult;
|
|
1970
1970
|
},
|
|
1971
|
-
async push(locale, data,
|
|
1971
|
+
async push(locale, data, _34, originalLocale) {
|
|
1972
1972
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1973
1973
|
const finalPath = path10.resolve(draftPath);
|
|
1974
1974
|
const dirPath = path10.dirname(finalPath);
|
|
@@ -2547,7 +2547,7 @@ function createPropertiesLoader() {
|
|
|
2547
2547
|
return result;
|
|
2548
2548
|
},
|
|
2549
2549
|
async push(locale, payload) {
|
|
2550
|
-
const result = Object.entries(payload).filter(([
|
|
2550
|
+
const result = Object.entries(payload).filter(([_34, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
2551
2551
|
return result;
|
|
2552
2552
|
}
|
|
2553
2553
|
});
|
|
@@ -2848,12 +2848,12 @@ function createUnlocalizableLoader(returnUnlocalizedKeys = false) {
|
|
|
2848
2848
|
const unlocalizableKeys = _getUnlocalizableKeys(input2);
|
|
2849
2849
|
const result = _13.omitBy(
|
|
2850
2850
|
input2,
|
|
2851
|
-
(
|
|
2851
|
+
(_34, key) => unlocalizableKeys.includes(key)
|
|
2852
2852
|
);
|
|
2853
2853
|
if (returnUnlocalizedKeys) {
|
|
2854
2854
|
result.unlocalizable = _13.omitBy(
|
|
2855
2855
|
input2,
|
|
2856
|
-
(
|
|
2856
|
+
(_34, key) => !unlocalizableKeys.includes(key)
|
|
2857
2857
|
);
|
|
2858
2858
|
}
|
|
2859
2859
|
return result;
|
|
@@ -2863,7 +2863,7 @@ function createUnlocalizableLoader(returnUnlocalizedKeys = false) {
|
|
|
2863
2863
|
const result = _13.merge(
|
|
2864
2864
|
{},
|
|
2865
2865
|
data,
|
|
2866
|
-
_13.omitBy(originalInput, (
|
|
2866
|
+
_13.omitBy(originalInput, (_34, key) => !unlocalizableKeys.includes(key))
|
|
2867
2867
|
);
|
|
2868
2868
|
return result;
|
|
2869
2869
|
}
|
|
@@ -2894,7 +2894,7 @@ function _getUnlocalizableKeys(input2) {
|
|
|
2894
2894
|
}
|
|
2895
2895
|
}
|
|
2896
2896
|
return false;
|
|
2897
|
-
}).map(([key,
|
|
2897
|
+
}).map(([key, _34]) => key);
|
|
2898
2898
|
}
|
|
2899
2899
|
|
|
2900
2900
|
// src/cli/loaders/po/index.ts
|
|
@@ -4535,7 +4535,6 @@ function parseVueFile(input2) {
|
|
|
4535
4535
|
|
|
4536
4536
|
// src/cli/loaders/typescript/index.ts
|
|
4537
4537
|
import { parse as parse3 } from "@babel/parser";
|
|
4538
|
-
import _21 from "lodash";
|
|
4539
4538
|
import babelTraverseModule from "@babel/traverse";
|
|
4540
4539
|
import * as t from "@babel/types";
|
|
4541
4540
|
import babelGenerateModule from "@babel/generator";
|
|
@@ -4571,8 +4570,7 @@ function createTypescriptLoader() {
|
|
|
4571
4570
|
},
|
|
4572
4571
|
push: async (locale, data, originalInput, defaultLocale, pullInput, pullOutput) => {
|
|
4573
4572
|
const ast = parseTypeScript(originalInput || "");
|
|
4574
|
-
|
|
4575
|
-
updateStringsInDefaultExport(ast, finalData);
|
|
4573
|
+
updateStringsInDefaultExport(ast, data);
|
|
4576
4574
|
const { code } = generate(ast, {
|
|
4577
4575
|
jsescOption: {
|
|
4578
4576
|
minimal: true
|
|
@@ -4682,12 +4680,22 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
4682
4680
|
}
|
|
4683
4681
|
function updateStringsInObjectExpression(objectExpression, data) {
|
|
4684
4682
|
let modified = false;
|
|
4683
|
+
const propertiesToKeep = [];
|
|
4685
4684
|
objectExpression.properties.forEach((prop) => {
|
|
4686
|
-
if (!t.isObjectProperty(prop))
|
|
4685
|
+
if (!t.isObjectProperty(prop)) {
|
|
4686
|
+
propertiesToKeep.push(prop);
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4687
4689
|
const key = getPropertyKey(prop);
|
|
4688
4690
|
const incomingVal = data?.[key];
|
|
4689
4691
|
if (incomingVal === void 0) {
|
|
4690
|
-
|
|
4692
|
+
if (t.isStringLiteral(prop.value) || t.isTemplateLiteral(prop.value) && prop.value.expressions.length === 0 || t.isObjectExpression(prop.value) || t.isArrayExpression(prop.value)) {
|
|
4693
|
+
modified = true;
|
|
4694
|
+
return;
|
|
4695
|
+
} else {
|
|
4696
|
+
propertiesToKeep.push(prop);
|
|
4697
|
+
return;
|
|
4698
|
+
}
|
|
4691
4699
|
}
|
|
4692
4700
|
if (t.isStringLiteral(prop.value) && typeof incomingVal === "string") {
|
|
4693
4701
|
if (prop.value.value !== incomingVal) {
|
|
@@ -4714,7 +4722,11 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
4714
4722
|
);
|
|
4715
4723
|
modified = subModified || modified;
|
|
4716
4724
|
}
|
|
4725
|
+
propertiesToKeep.push(prop);
|
|
4717
4726
|
});
|
|
4727
|
+
if (modified) {
|
|
4728
|
+
objectExpression.properties = propertiesToKeep;
|
|
4729
|
+
}
|
|
4718
4730
|
return modified;
|
|
4719
4731
|
}
|
|
4720
4732
|
function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
@@ -4772,7 +4784,7 @@ function getPropertyKey(prop) {
|
|
|
4772
4784
|
}
|
|
4773
4785
|
|
|
4774
4786
|
// src/cli/loaders/inject-locale.ts
|
|
4775
|
-
import
|
|
4787
|
+
import _21 from "lodash";
|
|
4776
4788
|
|
|
4777
4789
|
// ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
4778
4790
|
var balanced = (a, b, str) => {
|
|
@@ -5463,7 +5475,7 @@ var AST = class _AST {
|
|
|
5463
5475
|
if (!this.type) {
|
|
5464
5476
|
const noEmpty = this.isStart() && this.isEnd();
|
|
5465
5477
|
const src = this.#parts.map((p) => {
|
|
5466
|
-
const [re,
|
|
5478
|
+
const [re, _34, hasMagic, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
5467
5479
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
5468
5480
|
this.#uflag = this.#uflag || uflag;
|
|
5469
5481
|
return re;
|
|
@@ -5536,7 +5548,7 @@ var AST = class _AST {
|
|
|
5536
5548
|
if (typeof p === "string") {
|
|
5537
5549
|
throw new Error("string type in extglob ast??");
|
|
5538
5550
|
}
|
|
5539
|
-
const [re,
|
|
5551
|
+
const [re, _34, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
5540
5552
|
this.#uflag = this.#uflag || uflag;
|
|
5541
5553
|
return re;
|
|
5542
5554
|
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
@@ -5781,7 +5793,7 @@ var Minimatch = class {
|
|
|
5781
5793
|
}
|
|
5782
5794
|
return false;
|
|
5783
5795
|
}
|
|
5784
|
-
debug(...
|
|
5796
|
+
debug(..._34) {
|
|
5785
5797
|
}
|
|
5786
5798
|
make() {
|
|
5787
5799
|
const pattern = this.pattern;
|
|
@@ -5803,7 +5815,7 @@ var Minimatch = class {
|
|
|
5803
5815
|
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
5804
5816
|
this.globParts = this.preprocess(rawGlobParts);
|
|
5805
5817
|
this.debug(this.pattern, this.globParts);
|
|
5806
|
-
let set = this.globParts.map((s,
|
|
5818
|
+
let set = this.globParts.map((s, _34, __) => {
|
|
5807
5819
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
5808
5820
|
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
5809
5821
|
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
@@ -6320,7 +6332,7 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
6320
6332
|
return data;
|
|
6321
6333
|
}
|
|
6322
6334
|
const omitKeys = _getKeysWithLocales(data, injectLocaleKeys, locale);
|
|
6323
|
-
const result =
|
|
6335
|
+
const result = _21.omit(data, omitKeys);
|
|
6324
6336
|
return result;
|
|
6325
6337
|
},
|
|
6326
6338
|
async push(locale, data, originalInput, originalLocale) {
|
|
@@ -6333,7 +6345,7 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
6333
6345
|
originalLocale
|
|
6334
6346
|
);
|
|
6335
6347
|
localeKeys.forEach((key) => {
|
|
6336
|
-
|
|
6348
|
+
_21.set(data, key, locale);
|
|
6337
6349
|
});
|
|
6338
6350
|
return data;
|
|
6339
6351
|
}
|
|
@@ -6342,7 +6354,7 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
6342
6354
|
function _getKeysWithLocales(data, injectLocaleKeys, locale) {
|
|
6343
6355
|
const allKeys = _getAllKeys(data);
|
|
6344
6356
|
return allKeys.filter((key) => {
|
|
6345
|
-
return injectLocaleKeys.some((pattern) => minimatch(key, pattern)) &&
|
|
6357
|
+
return injectLocaleKeys.some((pattern) => minimatch(key, pattern)) && _21.get(data, key) === locale;
|
|
6346
6358
|
});
|
|
6347
6359
|
}
|
|
6348
6360
|
function _getAllKeys(obj, prefix = "") {
|
|
@@ -6360,15 +6372,15 @@ function _getAllKeys(obj, prefix = "") {
|
|
|
6360
6372
|
}
|
|
6361
6373
|
|
|
6362
6374
|
// src/cli/loaders/locked-keys.ts
|
|
6363
|
-
import
|
|
6375
|
+
import _22 from "lodash";
|
|
6364
6376
|
function createLockedKeysLoader(lockedKeys) {
|
|
6365
6377
|
return createLoader({
|
|
6366
6378
|
pull: async (locale, data) => {
|
|
6367
|
-
return
|
|
6379
|
+
return _22.pickBy(data, (value, key) => !_isLockedKey(key, lockedKeys));
|
|
6368
6380
|
},
|
|
6369
6381
|
push: async (locale, data, originalInput) => {
|
|
6370
|
-
const lockedSubObject =
|
|
6371
|
-
return
|
|
6382
|
+
const lockedSubObject = _22.chain(originalInput).pickBy((value, key) => _isLockedKey(key, lockedKeys)).value();
|
|
6383
|
+
return _22.merge({}, data, lockedSubObject);
|
|
6372
6384
|
}
|
|
6373
6385
|
});
|
|
6374
6386
|
}
|
|
@@ -6425,7 +6437,7 @@ function md5(input2) {
|
|
|
6425
6437
|
}
|
|
6426
6438
|
|
|
6427
6439
|
// src/cli/loaders/mdx2/code-placeholder.ts
|
|
6428
|
-
import
|
|
6440
|
+
import _23 from "lodash";
|
|
6429
6441
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
6430
6442
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
6431
6443
|
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
@@ -6448,7 +6460,7 @@ ${match2}
|
|
|
6448
6460
|
found = true;
|
|
6449
6461
|
}
|
|
6450
6462
|
} while (found);
|
|
6451
|
-
content =
|
|
6463
|
+
content = _23.chain(content).split("\n\n").map((section) => _23.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
6452
6464
|
return content;
|
|
6453
6465
|
}
|
|
6454
6466
|
function ensureTrailingFenceNewline(_content) {
|
|
@@ -6470,7 +6482,7 @@ ${match2}
|
|
|
6470
6482
|
found = true;
|
|
6471
6483
|
}
|
|
6472
6484
|
} while (found);
|
|
6473
|
-
content =
|
|
6485
|
+
content = _23.chain(content).split("\n\n").map((section) => _23.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
6474
6486
|
return content;
|
|
6475
6487
|
}
|
|
6476
6488
|
function extractCodePlaceholders(content) {
|
|
@@ -6512,7 +6524,7 @@ function createMdxCodePlaceholderLoader() {
|
|
|
6512
6524
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
6513
6525
|
const sourceInfo = extractCodePlaceholders(originalInput ?? "");
|
|
6514
6526
|
const currentInfo = extractCodePlaceholders(pullInput ?? "");
|
|
6515
|
-
const codePlaceholders =
|
|
6527
|
+
const codePlaceholders = _23.merge(
|
|
6516
6528
|
sourceInfo.codePlaceholders,
|
|
6517
6529
|
currentInfo.codePlaceholders,
|
|
6518
6530
|
globalPlaceholderRegistry
|
|
@@ -6520,7 +6532,7 @@ function createMdxCodePlaceholderLoader() {
|
|
|
6520
6532
|
);
|
|
6521
6533
|
let result = data;
|
|
6522
6534
|
for (const [placeholder, original] of Object.entries(codePlaceholders)) {
|
|
6523
|
-
const replacement = original.startsWith(">") ?
|
|
6535
|
+
const replacement = original.startsWith(">") ? _23.trimStart(original, "> ") : original;
|
|
6524
6536
|
result = result.replaceAll(placeholder, replacement);
|
|
6525
6537
|
}
|
|
6526
6538
|
return result;
|
|
@@ -6548,11 +6560,11 @@ function createLocalizableMdxDocumentLoader() {
|
|
|
6548
6560
|
}
|
|
6549
6561
|
|
|
6550
6562
|
// src/cli/loaders/mdx2/sections-split-2.ts
|
|
6551
|
-
import
|
|
6563
|
+
import _24 from "lodash";
|
|
6552
6564
|
function createMdxSectionsSplit2Loader() {
|
|
6553
6565
|
return createLoader({
|
|
6554
6566
|
async pull(locale, input2) {
|
|
6555
|
-
const sections =
|
|
6567
|
+
const sections = _24.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
|
|
6556
6568
|
const result = {
|
|
6557
6569
|
frontmatter: input2.frontmatter,
|
|
6558
6570
|
sections
|
|
@@ -6560,7 +6572,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
6560
6572
|
return result;
|
|
6561
6573
|
},
|
|
6562
6574
|
async push(locale, data, originalInput, _originalLocale, pullInput) {
|
|
6563
|
-
const content =
|
|
6575
|
+
const content = _24.chain(data.sections).values().join("\n\n").value();
|
|
6564
6576
|
const result = {
|
|
6565
6577
|
frontmatter: data.frontmatter,
|
|
6566
6578
|
codePlaceholders: pullInput?.codePlaceholders || {},
|
|
@@ -6626,22 +6638,21 @@ function createMdxLockedPatternsLoader(defaultPatterns) {
|
|
|
6626
6638
|
}
|
|
6627
6639
|
|
|
6628
6640
|
// src/cli/loaders/ignored-keys.ts
|
|
6629
|
-
import
|
|
6641
|
+
import _25 from "lodash";
|
|
6630
6642
|
function createIgnoredKeysLoader(ignoredKeys) {
|
|
6631
6643
|
return createLoader({
|
|
6632
6644
|
pull: async (locale, data) => {
|
|
6633
|
-
const result =
|
|
6645
|
+
const result = _25.omitBy(
|
|
6634
6646
|
data,
|
|
6635
6647
|
(value, key) => _isIgnoredKey(key, ignoredKeys)
|
|
6636
6648
|
);
|
|
6637
6649
|
return result;
|
|
6638
6650
|
},
|
|
6639
6651
|
push: async (locale, data, originalInput, originalLocale, pullInput) => {
|
|
6640
|
-
const
|
|
6641
|
-
|
|
6652
|
+
const result = _25.omitBy(
|
|
6653
|
+
data,
|
|
6642
6654
|
(value, key) => _isIgnoredKey(key, ignoredKeys)
|
|
6643
6655
|
);
|
|
6644
|
-
const result = _26.merge({}, data, ignoredSubObject);
|
|
6645
6656
|
return result;
|
|
6646
6657
|
}
|
|
6647
6658
|
});
|
|
@@ -6784,7 +6795,7 @@ function createEjsLoader() {
|
|
|
6784
6795
|
}
|
|
6785
6796
|
|
|
6786
6797
|
// src/cli/loaders/ensure-key-order.ts
|
|
6787
|
-
import
|
|
6798
|
+
import _26 from "lodash";
|
|
6788
6799
|
function createEnsureKeyOrderLoader() {
|
|
6789
6800
|
return createLoader({
|
|
6790
6801
|
pull: async (_locale, input2) => {
|
|
@@ -6799,10 +6810,10 @@ function createEnsureKeyOrderLoader() {
|
|
|
6799
6810
|
});
|
|
6800
6811
|
}
|
|
6801
6812
|
function reorderKeys(data, originalInput) {
|
|
6802
|
-
if (
|
|
6813
|
+
if (_26.isArray(originalInput) && _26.isArray(data)) {
|
|
6803
6814
|
return data.map((item, idx) => reorderKeys(item, originalInput[idx] ?? {}));
|
|
6804
6815
|
}
|
|
6805
|
-
if (!
|
|
6816
|
+
if (!_26.isObject(data) || _26.isArray(data) || _26.isDate(data)) {
|
|
6806
6817
|
return data;
|
|
6807
6818
|
}
|
|
6808
6819
|
const orderedData = {};
|
|
@@ -6834,13 +6845,13 @@ function createTxtLoader() {
|
|
|
6834
6845
|
const sortedEntries = Object.entries(payload).sort(
|
|
6835
6846
|
([a], [b]) => parseInt(a) - parseInt(b)
|
|
6836
6847
|
);
|
|
6837
|
-
return sortedEntries.map(([
|
|
6848
|
+
return sortedEntries.map(([_34, value]) => value).join("\n");
|
|
6838
6849
|
}
|
|
6839
6850
|
});
|
|
6840
6851
|
}
|
|
6841
6852
|
|
|
6842
6853
|
// src/cli/loaders/json-dictionary.ts
|
|
6843
|
-
import
|
|
6854
|
+
import _27 from "lodash";
|
|
6844
6855
|
var TOP_LEVEL_KEY = "--content--";
|
|
6845
6856
|
function createJsonDictionaryLoader() {
|
|
6846
6857
|
return createLoader({
|
|
@@ -6855,7 +6866,7 @@ function createJsonDictionaryLoader() {
|
|
|
6855
6866
|
if (!originalInput) {
|
|
6856
6867
|
throw new Error("Error while parsing json-dictionary bucket");
|
|
6857
6868
|
}
|
|
6858
|
-
const input2 =
|
|
6869
|
+
const input2 = _27.cloneDeep(originalInput);
|
|
6859
6870
|
if (Object.keys(data).length === 1 && Object.keys(data)[0] === TOP_LEVEL_KEY) {
|
|
6860
6871
|
setNestedLocale(
|
|
6861
6872
|
{ [TOP_LEVEL_KEY]: input2 },
|
|
@@ -7238,7 +7249,7 @@ function createLingoLocalizer(params) {
|
|
|
7238
7249
|
|
|
7239
7250
|
// src/cli/processor/basic.ts
|
|
7240
7251
|
import { generateText } from "ai";
|
|
7241
|
-
import
|
|
7252
|
+
import _28 from "lodash";
|
|
7242
7253
|
function createBasicTranslator(model, systemPrompt) {
|
|
7243
7254
|
return async (input2, onProgress) => {
|
|
7244
7255
|
const chunks = extractPayloadChunks(input2.processableData);
|
|
@@ -7252,7 +7263,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
7252
7263
|
subResults.push(result2);
|
|
7253
7264
|
onProgress(i / chunks.length * 100, chunk, result2);
|
|
7254
7265
|
}
|
|
7255
|
-
const result =
|
|
7266
|
+
const result = _28.merge({}, ...subResults);
|
|
7256
7267
|
return result;
|
|
7257
7268
|
};
|
|
7258
7269
|
async function doJob(input2) {
|
|
@@ -7499,7 +7510,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
7499
7510
|
}
|
|
7500
7511
|
|
|
7501
7512
|
// src/cli/utils/delta.ts
|
|
7502
|
-
import
|
|
7513
|
+
import _29 from "lodash";
|
|
7503
7514
|
import z from "zod";
|
|
7504
7515
|
|
|
7505
7516
|
// src/cli/utils/fs.ts
|
|
@@ -7548,11 +7559,11 @@ function createDeltaProcessor(fileKey) {
|
|
|
7548
7559
|
return checkIfFileExists(lockfilePath);
|
|
7549
7560
|
},
|
|
7550
7561
|
async calculateDelta(params) {
|
|
7551
|
-
let added =
|
|
7562
|
+
let added = _29.difference(
|
|
7552
7563
|
Object.keys(params.sourceData),
|
|
7553
7564
|
Object.keys(params.targetData)
|
|
7554
7565
|
);
|
|
7555
|
-
let removed =
|
|
7566
|
+
let removed = _29.difference(
|
|
7556
7567
|
Object.keys(params.targetData),
|
|
7557
7568
|
Object.keys(params.sourceData)
|
|
7558
7569
|
);
|
|
@@ -7614,7 +7625,7 @@ function createDeltaProcessor(fileKey) {
|
|
|
7614
7625
|
await this.saveLock(lockfileData);
|
|
7615
7626
|
},
|
|
7616
7627
|
async createChecksums(sourceData) {
|
|
7617
|
-
const checksums =
|
|
7628
|
+
const checksums = _29.mapValues(sourceData, (value) => md5(value));
|
|
7618
7629
|
return checksums;
|
|
7619
7630
|
}
|
|
7620
7631
|
};
|
|
@@ -7784,7 +7795,7 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7784
7795
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
7785
7796
|
const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
|
|
7786
7797
|
const savedChecksums = await deltaProcessor.loadChecksums();
|
|
7787
|
-
const updatedSourceData =
|
|
7798
|
+
const updatedSourceData = _30.pickBy(
|
|
7788
7799
|
sourceData,
|
|
7789
7800
|
(value, key) => sourceChecksums[key] !== savedChecksums[key]
|
|
7790
7801
|
);
|
|
@@ -7798,15 +7809,15 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7798
7809
|
bucketPath.delimiter
|
|
7799
7810
|
);
|
|
7800
7811
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
7801
|
-
const missingKeys =
|
|
7812
|
+
const missingKeys = _30.difference(
|
|
7802
7813
|
Object.keys(sourceData),
|
|
7803
7814
|
Object.keys(targetData)
|
|
7804
7815
|
);
|
|
7805
|
-
const extraKeys =
|
|
7816
|
+
const extraKeys = _30.difference(
|
|
7806
7817
|
Object.keys(targetData),
|
|
7807
7818
|
Object.keys(sourceData)
|
|
7808
7819
|
);
|
|
7809
|
-
const unlocalizableDataDiff = !
|
|
7820
|
+
const unlocalizableDataDiff = !_30.isEqual(
|
|
7810
7821
|
sourceUnlocalizable,
|
|
7811
7822
|
targetUnlocalizable
|
|
7812
7823
|
);
|
|
@@ -7887,13 +7898,13 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7887
7898
|
targetData,
|
|
7888
7899
|
checksums: checksums2
|
|
7889
7900
|
});
|
|
7890
|
-
let processableData =
|
|
7901
|
+
let processableData = _30.chain(sourceData).entries().filter(
|
|
7891
7902
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
|
|
7892
7903
|
).fromPairs().value();
|
|
7893
7904
|
if (flags.key) {
|
|
7894
|
-
processableData =
|
|
7905
|
+
processableData = _30.pickBy(
|
|
7895
7906
|
processableData,
|
|
7896
|
-
(
|
|
7907
|
+
(_34, key) => key === flags.key
|
|
7897
7908
|
);
|
|
7898
7909
|
}
|
|
7899
7910
|
if (flags.verbose) {
|
|
@@ -7926,13 +7937,13 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7926
7937
|
if (flags.verbose) {
|
|
7927
7938
|
bucketOra.info(JSON.stringify(processedTargetData, null, 2));
|
|
7928
7939
|
}
|
|
7929
|
-
let finalTargetData =
|
|
7940
|
+
let finalTargetData = _30.merge(
|
|
7930
7941
|
{},
|
|
7931
7942
|
sourceData,
|
|
7932
7943
|
targetData,
|
|
7933
7944
|
processedTargetData
|
|
7934
7945
|
);
|
|
7935
|
-
finalTargetData =
|
|
7946
|
+
finalTargetData = _30.chain(finalTargetData).entries().map(([key, value]) => {
|
|
7936
7947
|
const renaming = delta.renamed.find(
|
|
7937
7948
|
([oldKey, newKey]) => oldKey === key
|
|
7938
7949
|
);
|
|
@@ -7956,7 +7967,7 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7956
7967
|
`Applying changes to ${bucketPath} (${targetLocale})`
|
|
7957
7968
|
);
|
|
7958
7969
|
}
|
|
7959
|
-
const finalDiffSize =
|
|
7970
|
+
const finalDiffSize = _30.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
7960
7971
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
7961
7972
|
if (finalDiffSize > 0 || flags.force) {
|
|
7962
7973
|
bucketOra.succeed(
|
|
@@ -8133,7 +8144,7 @@ Reviewing changes for ${chalk6.blue(args.pathPattern)} (${chalk6.yellow(
|
|
|
8133
8144
|
return args.currentData;
|
|
8134
8145
|
}
|
|
8135
8146
|
const customData = { ...args.currentData };
|
|
8136
|
-
const changes =
|
|
8147
|
+
const changes = _30.reduce(
|
|
8137
8148
|
args.proposedData,
|
|
8138
8149
|
(result, value, key) => {
|
|
8139
8150
|
if (args.currentData[key] !== value) {
|
|
@@ -8206,7 +8217,7 @@ import path15 from "path";
|
|
|
8206
8217
|
import Z4 from "zod";
|
|
8207
8218
|
import YAML5 from "yaml";
|
|
8208
8219
|
import { MD5 as MD52 } from "object-hash";
|
|
8209
|
-
import
|
|
8220
|
+
import _31 from "lodash";
|
|
8210
8221
|
function createLockfileHelper() {
|
|
8211
8222
|
return {
|
|
8212
8223
|
isLockfileExists: () => {
|
|
@@ -8216,18 +8227,18 @@ function createLockfileHelper() {
|
|
|
8216
8227
|
registerSourceData: (pathPattern, sourceData) => {
|
|
8217
8228
|
const lockfile = _loadLockfile();
|
|
8218
8229
|
const sectionKey = MD52(pathPattern);
|
|
8219
|
-
const sectionChecksums =
|
|
8230
|
+
const sectionChecksums = _31.mapValues(sourceData, (value) => MD52(value));
|
|
8220
8231
|
lockfile.checksums[sectionKey] = sectionChecksums;
|
|
8221
8232
|
_saveLockfile(lockfile);
|
|
8222
8233
|
},
|
|
8223
8234
|
registerPartialSourceData: (pathPattern, partialSourceData) => {
|
|
8224
8235
|
const lockfile = _loadLockfile();
|
|
8225
8236
|
const sectionKey = MD52(pathPattern);
|
|
8226
|
-
const sectionChecksums =
|
|
8237
|
+
const sectionChecksums = _31.mapValues(
|
|
8227
8238
|
partialSourceData,
|
|
8228
8239
|
(value) => MD52(value)
|
|
8229
8240
|
);
|
|
8230
|
-
lockfile.checksums[sectionKey] =
|
|
8241
|
+
lockfile.checksums[sectionKey] = _31.merge(
|
|
8231
8242
|
{},
|
|
8232
8243
|
lockfile.checksums[sectionKey] ?? {},
|
|
8233
8244
|
sectionChecksums
|
|
@@ -8237,9 +8248,9 @@ function createLockfileHelper() {
|
|
|
8237
8248
|
extractUpdatedData: (pathPattern, sourceData) => {
|
|
8238
8249
|
const lockfile = _loadLockfile();
|
|
8239
8250
|
const sectionKey = MD52(pathPattern);
|
|
8240
|
-
const currentChecksums =
|
|
8251
|
+
const currentChecksums = _31.mapValues(sourceData, (value) => MD52(value));
|
|
8241
8252
|
const savedChecksums = lockfile.checksums[sectionKey] || {};
|
|
8242
|
-
const updatedData =
|
|
8253
|
+
const updatedData = _31.pickBy(
|
|
8243
8254
|
sourceData,
|
|
8244
8255
|
(value, key) => savedChecksums[key] !== currentChecksums[key]
|
|
8245
8256
|
);
|
|
@@ -8323,7 +8334,7 @@ var flagsSchema = Z5.object({
|
|
|
8323
8334
|
// src/cli/cmd/cleanup.ts
|
|
8324
8335
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
8325
8336
|
import { Command as Command14 } from "interactive-commander";
|
|
8326
|
-
import
|
|
8337
|
+
import _32 from "lodash";
|
|
8327
8338
|
import Ora9 from "ora";
|
|
8328
8339
|
var cleanup_default = new Command14().command("cleanup").description(
|
|
8329
8340
|
"Remove keys from target files that do not exist in the source file"
|
|
@@ -8374,7 +8385,7 @@ var cleanup_default = new Command14().command("cleanup").description(
|
|
|
8374
8385
|
try {
|
|
8375
8386
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
8376
8387
|
const targetKeys = Object.keys(targetData);
|
|
8377
|
-
const keysToRemove =
|
|
8388
|
+
const keysToRemove = _32.difference(targetKeys, sourceKeys);
|
|
8378
8389
|
if (keysToRemove.length === 0) {
|
|
8379
8390
|
bucketOra.succeed(`[${targetLocale}] No keys to remove`);
|
|
8380
8391
|
continue;
|
|
@@ -8389,7 +8400,7 @@ var cleanup_default = new Command14().command("cleanup").description(
|
|
|
8389
8400
|
);
|
|
8390
8401
|
}
|
|
8391
8402
|
if (!options.dryRun) {
|
|
8392
|
-
const cleanedData =
|
|
8403
|
+
const cleanedData = _32.pick(targetData, sourceKeys);
|
|
8393
8404
|
await bucketLoader.push(targetLocale, cleanedData);
|
|
8394
8405
|
bucketOra.succeed(
|
|
8395
8406
|
`[${targetLocale}] Removed ${keysToRemove.length} keys`
|
|
@@ -8450,7 +8461,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
8450
8461
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8451
8462
|
import Z6 from "zod";
|
|
8452
8463
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
8453
|
-
var mcp_default = new Command15().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (
|
|
8464
|
+
var mcp_default = new Command15().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_34, program) => {
|
|
8454
8465
|
const apiKey = program.args[0];
|
|
8455
8466
|
const settings = getSettings(apiKey);
|
|
8456
8467
|
if (!settings.auth.apiKey) {
|
|
@@ -8980,6 +8991,7 @@ async function plan(input2) {
|
|
|
8980
8991
|
injectLocale: bucket.injectLocale || [],
|
|
8981
8992
|
lockedKeys: bucket.lockedKeys || [],
|
|
8982
8993
|
lockedPatterns: bucket.lockedPatterns || [],
|
|
8994
|
+
ignoredKeys: bucket.ignoredKeys || [],
|
|
8983
8995
|
onlyKeys: input2.flags.key || []
|
|
8984
8996
|
});
|
|
8985
8997
|
}
|
|
@@ -9001,7 +9013,7 @@ async function plan(input2) {
|
|
|
9001
9013
|
import chalk12 from "chalk";
|
|
9002
9014
|
import { Listr as Listr3 } from "listr2";
|
|
9003
9015
|
import pLimit from "p-limit";
|
|
9004
|
-
import
|
|
9016
|
+
import _33 from "lodash";
|
|
9005
9017
|
var MAX_WORKER_COUNT = 10;
|
|
9006
9018
|
async function execute(input2) {
|
|
9007
9019
|
const effectiveConcurrency = Math.min(
|
|
@@ -9036,7 +9048,7 @@ async function execute(input2) {
|
|
|
9036
9048
|
const workerTasks = [];
|
|
9037
9049
|
for (let i = 0; i < workersCount; i++) {
|
|
9038
9050
|
const assignedTasks = ctx.tasks.filter(
|
|
9039
|
-
(
|
|
9051
|
+
(_34, idx) => idx % workersCount === i
|
|
9040
9052
|
);
|
|
9041
9053
|
workerTasks.push(
|
|
9042
9054
|
createWorkerTask({
|
|
@@ -9104,7 +9116,8 @@ function createLoaderForTask(assignedTask) {
|
|
|
9104
9116
|
injectLocale: assignedTask.injectLocale
|
|
9105
9117
|
},
|
|
9106
9118
|
assignedTask.lockedKeys,
|
|
9107
|
-
assignedTask.lockedPatterns
|
|
9119
|
+
assignedTask.lockedPatterns,
|
|
9120
|
+
assignedTask.ignoredKeys
|
|
9108
9121
|
);
|
|
9109
9122
|
bucketLoader.setDefaultLocale(assignedTask.sourceLocale);
|
|
9110
9123
|
return bucketLoader;
|
|
@@ -9137,7 +9150,7 @@ function createWorkerTask(args) {
|
|
|
9137
9150
|
targetData,
|
|
9138
9151
|
checksums
|
|
9139
9152
|
});
|
|
9140
|
-
const processableData =
|
|
9153
|
+
const processableData = _33.chain(sourceData).entries().filter(
|
|
9141
9154
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
9142
9155
|
).filter(
|
|
9143
9156
|
([key]) => !assignedTask.onlyKeys.length || assignedTask.onlyKeys?.some(
|
|
@@ -9150,7 +9163,7 @@ function createWorkerTask(args) {
|
|
|
9150
9163
|
});
|
|
9151
9164
|
return { status: "skipped" };
|
|
9152
9165
|
}
|
|
9153
|
-
const relevantHints =
|
|
9166
|
+
const relevantHints = _33.pick(hints, Object.keys(processableData));
|
|
9154
9167
|
const processedTargetData = await args.ctx.localizer.localize(
|
|
9155
9168
|
{
|
|
9156
9169
|
sourceLocale: assignedTask.sourceLocale,
|
|
@@ -9166,7 +9179,7 @@ function createWorkerTask(args) {
|
|
|
9166
9179
|
const latestTargetData = await bucketLoader.pull(
|
|
9167
9180
|
assignedTask.targetLocale
|
|
9168
9181
|
);
|
|
9169
|
-
const _partialData =
|
|
9182
|
+
const _partialData = _33.merge(
|
|
9170
9183
|
{},
|
|
9171
9184
|
latestTargetData,
|
|
9172
9185
|
processedChunk
|
|
@@ -9186,7 +9199,7 @@ function createWorkerTask(args) {
|
|
|
9186
9199
|
});
|
|
9187
9200
|
}
|
|
9188
9201
|
);
|
|
9189
|
-
const finalTargetData =
|
|
9202
|
+
const finalTargetData = _33.merge(
|
|
9190
9203
|
{},
|
|
9191
9204
|
sourceData,
|
|
9192
9205
|
targetData,
|
|
@@ -9227,7 +9240,7 @@ function countTasks(ctx, predicate) {
|
|
|
9227
9240
|
).length;
|
|
9228
9241
|
}
|
|
9229
9242
|
function processRenamedKeys(delta, targetData) {
|
|
9230
|
-
return
|
|
9243
|
+
return _33.chain(targetData).entries().map(([key, value]) => {
|
|
9231
9244
|
const renaming = delta.renamed.find(([oldKey]) => oldKey === key);
|
|
9232
9245
|
if (!renaming) {
|
|
9233
9246
|
return [key, value];
|
|
@@ -10800,7 +10813,7 @@ async function renderHero2() {
|
|
|
10800
10813
|
// package.json
|
|
10801
10814
|
var package_default = {
|
|
10802
10815
|
name: "lingo.dev",
|
|
10803
|
-
version: "0.
|
|
10816
|
+
version: "0.110.0",
|
|
10804
10817
|
description: "Lingo.dev CLI",
|
|
10805
10818
|
private: false,
|
|
10806
10819
|
publishConfig: {
|