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