lingo.dev 0.82.0 → 0.83.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 +138 -74
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +193 -129
- package/build/cli.mjs.map +1 -1
- package/package.json +18 -3
package/build/cli.mjs
CHANGED
|
@@ -994,7 +994,7 @@ var show_default = new Command5().command("show").description("Prints out the cu
|
|
|
994
994
|
import { bucketTypeSchema, localeCodeSchema, resolveOverriddenLocale as resolveOverriddenLocale3 } from "@lingo.dev/_spec";
|
|
995
995
|
import { Command as Command6 } from "interactive-commander";
|
|
996
996
|
import Z3 from "zod";
|
|
997
|
-
import
|
|
997
|
+
import _22 from "lodash";
|
|
998
998
|
import * as path15 from "path";
|
|
999
999
|
import Ora5 from "ora";
|
|
1000
1000
|
|
|
@@ -1202,7 +1202,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1202
1202
|
const trimmedResult = result.trim();
|
|
1203
1203
|
return trimmedResult;
|
|
1204
1204
|
},
|
|
1205
|
-
async push(locale, data,
|
|
1205
|
+
async push(locale, data, _25, originalLocale) {
|
|
1206
1206
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1207
1207
|
const finalPath = path10.resolve(draftPath);
|
|
1208
1208
|
const dirPath = path10.dirname(finalPath);
|
|
@@ -1625,6 +1625,45 @@ ${content}`;
|
|
|
1625
1625
|
});
|
|
1626
1626
|
}
|
|
1627
1627
|
|
|
1628
|
+
// src/cli/loaders/mdx.ts
|
|
1629
|
+
import _9 from "lodash";
|
|
1630
|
+
import { unified } from "unified";
|
|
1631
|
+
import remarkParse from "remark-parse";
|
|
1632
|
+
import remarkMdx from "remark-mdx";
|
|
1633
|
+
import remarkFrontmatter from "remark-frontmatter";
|
|
1634
|
+
import remarkGfm from "remark-gfm";
|
|
1635
|
+
import remarkStringify from "remark-stringify";
|
|
1636
|
+
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
1637
|
+
import { VFile } from "vfile";
|
|
1638
|
+
function createMdxFormatLoader() {
|
|
1639
|
+
const parser = unified().use(remarkParse).use(remarkMdx).use(remarkFrontmatter, ["yaml"]).use(remarkMdxFrontmatter).use(remarkGfm);
|
|
1640
|
+
const serializer = unified().use(remarkStringify).use(remarkMdx).use(remarkFrontmatter, ["yaml"]).use(remarkMdxFrontmatter).use(remarkGfm);
|
|
1641
|
+
return createLoader({
|
|
1642
|
+
async pull(locale, input2) {
|
|
1643
|
+
const file = new VFile(input2);
|
|
1644
|
+
const ast = parser.parse(file);
|
|
1645
|
+
return JSON.parse(JSON.stringify(ast));
|
|
1646
|
+
},
|
|
1647
|
+
async push(locale, data) {
|
|
1648
|
+
const ast = data;
|
|
1649
|
+
const file = serializer.stringify(ast);
|
|
1650
|
+
return String(file);
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
function createMdxStructureLoader() {
|
|
1655
|
+
return createLoader({
|
|
1656
|
+
async pull(locale, input2) {
|
|
1657
|
+
const result = _9.chain(input2).pickBy((value, key) => key.endsWith("/value")).value();
|
|
1658
|
+
return result;
|
|
1659
|
+
},
|
|
1660
|
+
async push(locale, data, originalInput) {
|
|
1661
|
+
const result = _9.merge({}, originalInput, data);
|
|
1662
|
+
return result;
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1628
1667
|
// src/cli/loaders/properties.ts
|
|
1629
1668
|
function createPropertiesLoader() {
|
|
1630
1669
|
return createLoader({
|
|
@@ -1644,7 +1683,7 @@ function createPropertiesLoader() {
|
|
|
1644
1683
|
return result;
|
|
1645
1684
|
},
|
|
1646
1685
|
async push(locale, payload) {
|
|
1647
|
-
const result = Object.entries(payload).filter(([
|
|
1686
|
+
const result = Object.entries(payload).filter(([_25, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1648
1687
|
return result;
|
|
1649
1688
|
}
|
|
1650
1689
|
});
|
|
@@ -1730,7 +1769,7 @@ function createXcodeStringsdictLoader() {
|
|
|
1730
1769
|
}
|
|
1731
1770
|
|
|
1732
1771
|
// src/cli/loaders/xcode-xcstrings.ts
|
|
1733
|
-
import
|
|
1772
|
+
import _10 from "lodash";
|
|
1734
1773
|
function createXcodeXcstringsLoader(defaultLocale) {
|
|
1735
1774
|
return createLoader({
|
|
1736
1775
|
async pull(locale, input2, initCtx) {
|
|
@@ -1766,7 +1805,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1766
1805
|
async push(locale, payload, originalInput) {
|
|
1767
1806
|
const langDataToMerge = {};
|
|
1768
1807
|
langDataToMerge.strings = {};
|
|
1769
|
-
const input2 =
|
|
1808
|
+
const input2 = _10.cloneDeep(originalInput) || { sourceLanguage: locale, strings: {} };
|
|
1770
1809
|
for (const [key, value] of Object.entries(payload)) {
|
|
1771
1810
|
if (value === null || value === void 0) {
|
|
1772
1811
|
continue;
|
|
@@ -1812,7 +1851,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1812
1851
|
}
|
|
1813
1852
|
}
|
|
1814
1853
|
}
|
|
1815
|
-
const result =
|
|
1854
|
+
const result = _10.merge({}, originalInput, langDataToMerge);
|
|
1816
1855
|
return result;
|
|
1817
1856
|
}
|
|
1818
1857
|
});
|
|
@@ -1872,17 +1911,17 @@ async function loadPrettierConfig(filePath) {
|
|
|
1872
1911
|
}
|
|
1873
1912
|
|
|
1874
1913
|
// src/cli/loaders/unlocalizable.ts
|
|
1875
|
-
import
|
|
1914
|
+
import _11 from "lodash";
|
|
1876
1915
|
import _isUrl from "is-url";
|
|
1877
1916
|
import { isValid, parseISO } from "date-fns";
|
|
1878
1917
|
function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys = false) {
|
|
1879
1918
|
const rules = {
|
|
1880
|
-
isEmpty: (v) =>
|
|
1919
|
+
isEmpty: (v) => _11.isEmpty(v),
|
|
1881
1920
|
isNumber: (v) => typeof v === "number" || /^[0-9]+$/.test(v),
|
|
1882
|
-
isBoolean: (v) =>
|
|
1883
|
-
isIsoDate: (v) =>
|
|
1884
|
-
isSystemId: (v) =>
|
|
1885
|
-
isUrl: (v) =>
|
|
1921
|
+
isBoolean: (v) => _11.isBoolean(v),
|
|
1922
|
+
isIsoDate: (v) => _11.isString(v) && _isIsoDate(v),
|
|
1923
|
+
isSystemId: (v) => _11.isString(v) && _isSystemId(v),
|
|
1924
|
+
isUrl: (v) => _11.isString(v) && _isUrl(v)
|
|
1886
1925
|
};
|
|
1887
1926
|
return createLoader({
|
|
1888
1927
|
async pull(locale, input2) {
|
|
@@ -1893,18 +1932,18 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
1893
1932
|
}
|
|
1894
1933
|
}
|
|
1895
1934
|
return false;
|
|
1896
|
-
}).map(([key,
|
|
1897
|
-
const result =
|
|
1935
|
+
}).map(([key, _25]) => key);
|
|
1936
|
+
const result = _11.omitBy(input2, (_25, key) => passthroughKeys.includes(key));
|
|
1898
1937
|
if (returnUnlocalizedKeys) {
|
|
1899
|
-
result.unlocalizable =
|
|
1938
|
+
result.unlocalizable = _11.omitBy(input2, (_25, key) => !passthroughKeys.includes(key));
|
|
1900
1939
|
}
|
|
1901
1940
|
return result;
|
|
1902
1941
|
},
|
|
1903
1942
|
async push(locale, data, originalInput) {
|
|
1904
1943
|
if (isCacheRestore) {
|
|
1905
|
-
return
|
|
1944
|
+
return _11.merge({}, data);
|
|
1906
1945
|
}
|
|
1907
|
-
const result =
|
|
1946
|
+
const result = _11.merge({}, originalInput, data);
|
|
1908
1947
|
return result;
|
|
1909
1948
|
}
|
|
1910
1949
|
});
|
|
@@ -1917,7 +1956,7 @@ function _isIsoDate(v) {
|
|
|
1917
1956
|
}
|
|
1918
1957
|
|
|
1919
1958
|
// src/cli/loaders/po/index.ts
|
|
1920
|
-
import
|
|
1959
|
+
import _12 from "lodash";
|
|
1921
1960
|
import gettextParser from "gettext-parser";
|
|
1922
1961
|
function createPoLoader(params = { multiline: false }) {
|
|
1923
1962
|
return composeLoaders(createPoDataLoader(params), createPoContentLoader());
|
|
@@ -1930,7 +1969,7 @@ function createPoDataLoader(params) {
|
|
|
1930
1969
|
const sections = input2.split("\n\n").filter(Boolean);
|
|
1931
1970
|
for (const section of sections) {
|
|
1932
1971
|
const sectionPo = gettextParser.po.parse(section);
|
|
1933
|
-
const contextKey =
|
|
1972
|
+
const contextKey = _12.keys(sectionPo.translations)[0];
|
|
1934
1973
|
const entries = sectionPo.translations[contextKey];
|
|
1935
1974
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1936
1975
|
if (msgid && entry.msgid) {
|
|
@@ -1948,12 +1987,12 @@ function createPoDataLoader(params) {
|
|
|
1948
1987
|
const sections = originalInput?.split("\n\n").filter(Boolean) || [];
|
|
1949
1988
|
const result = sections.map((section) => {
|
|
1950
1989
|
const sectionPo = gettextParser.po.parse(section);
|
|
1951
|
-
const contextKey =
|
|
1990
|
+
const contextKey = _12.keys(sectionPo.translations)[0];
|
|
1952
1991
|
const entries = sectionPo.translations[contextKey];
|
|
1953
1992
|
const msgid = Object.keys(entries).find((key) => entries[key].msgid);
|
|
1954
1993
|
if (!msgid) return section;
|
|
1955
1994
|
if (data[msgid]) {
|
|
1956
|
-
const updatedPo =
|
|
1995
|
+
const updatedPo = _12.merge({}, sectionPo, {
|
|
1957
1996
|
translations: {
|
|
1958
1997
|
[contextKey]: {
|
|
1959
1998
|
[msgid]: {
|
|
@@ -1973,7 +2012,7 @@ function createPoDataLoader(params) {
|
|
|
1973
2012
|
function createPoContentLoader() {
|
|
1974
2013
|
return createLoader({
|
|
1975
2014
|
async pull(locale, input2) {
|
|
1976
|
-
const result =
|
|
2015
|
+
const result = _12.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => [
|
|
1977
2016
|
entry.msgid,
|
|
1978
2017
|
{
|
|
1979
2018
|
singular: entry.msgstr[0] || entry.msgid,
|
|
@@ -1983,7 +2022,7 @@ function createPoContentLoader() {
|
|
|
1983
2022
|
return result;
|
|
1984
2023
|
},
|
|
1985
2024
|
async push(locale, data, originalInput) {
|
|
1986
|
-
const result =
|
|
2025
|
+
const result = _12.chain(originalInput).entries().map(([, entry]) => [
|
|
1987
2026
|
entry.msgid,
|
|
1988
2027
|
{
|
|
1989
2028
|
...entry,
|
|
@@ -2106,34 +2145,34 @@ var datoSettingsSchema = Z2.object({
|
|
|
2106
2145
|
});
|
|
2107
2146
|
|
|
2108
2147
|
// src/cli/loaders/dato/filter.ts
|
|
2109
|
-
import
|
|
2148
|
+
import _13 from "lodash";
|
|
2110
2149
|
function createDatoFilterLoader() {
|
|
2111
2150
|
return createLoader({
|
|
2112
2151
|
async pull(locale, input2) {
|
|
2113
2152
|
const result = {};
|
|
2114
|
-
for (const [modelId, modelInfo] of
|
|
2153
|
+
for (const [modelId, modelInfo] of _13.entries(input2)) {
|
|
2115
2154
|
result[modelId] = {};
|
|
2116
2155
|
for (const record of modelInfo.records) {
|
|
2117
|
-
result[modelId][record.id] =
|
|
2156
|
+
result[modelId][record.id] = _13.chain(modelInfo.fields).mapKeys((field) => field.api_key).mapValues((field) => _13.get(record, [field.api_key, locale])).value();
|
|
2118
2157
|
}
|
|
2119
2158
|
}
|
|
2120
2159
|
return result;
|
|
2121
2160
|
},
|
|
2122
2161
|
async push(locale, data, originalInput, originalLocale) {
|
|
2123
|
-
const result =
|
|
2124
|
-
for (const [modelId, modelInfo] of
|
|
2162
|
+
const result = _13.cloneDeep(originalInput || {});
|
|
2163
|
+
for (const [modelId, modelInfo] of _13.entries(result)) {
|
|
2125
2164
|
for (const record of modelInfo.records) {
|
|
2126
|
-
for (const [fieldId, fieldValue] of
|
|
2165
|
+
for (const [fieldId, fieldValue] of _13.entries(record)) {
|
|
2127
2166
|
const fieldInfo = modelInfo.fields.find((field) => field.api_key === fieldId);
|
|
2128
2167
|
if (fieldInfo) {
|
|
2129
|
-
const sourceFieldValue =
|
|
2130
|
-
const targetFieldValue =
|
|
2168
|
+
const sourceFieldValue = _13.get(fieldValue, [originalLocale]);
|
|
2169
|
+
const targetFieldValue = _13.get(data, [modelId, record.id, fieldId]);
|
|
2131
2170
|
if (targetFieldValue) {
|
|
2132
|
-
|
|
2171
|
+
_13.set(record, [fieldId, locale], targetFieldValue);
|
|
2133
2172
|
} else {
|
|
2134
|
-
|
|
2173
|
+
_13.set(record, [fieldId, locale], sourceFieldValue);
|
|
2135
2174
|
}
|
|
2136
|
-
|
|
2175
|
+
_13.chain(fieldValue).keys().reject((loc) => loc === locale || loc === originalLocale).filter((loc) => _13.isEmpty(_13.get(fieldValue, [loc]))).forEach((loc) => _13.set(record, [fieldId, loc], sourceFieldValue)).value();
|
|
2137
2176
|
}
|
|
2138
2177
|
}
|
|
2139
2178
|
}
|
|
@@ -2144,10 +2183,10 @@ function createDatoFilterLoader() {
|
|
|
2144
2183
|
}
|
|
2145
2184
|
|
|
2146
2185
|
// src/cli/loaders/dato/api.ts
|
|
2147
|
-
import
|
|
2186
|
+
import _15 from "lodash";
|
|
2148
2187
|
|
|
2149
2188
|
// src/cli/loaders/dato/_utils.ts
|
|
2150
|
-
import
|
|
2189
|
+
import _14 from "lodash";
|
|
2151
2190
|
import { buildClient } from "@datocms/cma-client-node";
|
|
2152
2191
|
function createDatoClient(params) {
|
|
2153
2192
|
if (!params.apiKey) {
|
|
@@ -2322,7 +2361,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2322
2361
|
const result = {
|
|
2323
2362
|
models: {}
|
|
2324
2363
|
};
|
|
2325
|
-
const updatedConfig =
|
|
2364
|
+
const updatedConfig = _15.cloneDeep(config);
|
|
2326
2365
|
console.log(`Initializing DatoCMS loader...`);
|
|
2327
2366
|
const project = await dato.findProject();
|
|
2328
2367
|
const modelChoices = await getModelChoices(dato, config);
|
|
@@ -2340,7 +2379,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2340
2379
|
delete updatedConfig.models[modelId];
|
|
2341
2380
|
}
|
|
2342
2381
|
}
|
|
2343
|
-
for (const modelId of
|
|
2382
|
+
for (const modelId of _15.keys(updatedConfig.models)) {
|
|
2344
2383
|
const { modelName, fields } = await getModelFields(dato, modelId);
|
|
2345
2384
|
if (fields.length > 0) {
|
|
2346
2385
|
result.models[modelId] = { fields: [], records: [] };
|
|
@@ -2351,7 +2390,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2351
2390
|
const isLocalized = await updateFieldLocalization(dato, fieldInfo, selectedFields.includes(fieldInfo.id));
|
|
2352
2391
|
if (isLocalized) {
|
|
2353
2392
|
result.models[modelId].fields.push(fieldInfo);
|
|
2354
|
-
updatedConfig.models[modelId].fields =
|
|
2393
|
+
updatedConfig.models[modelId].fields = _15.uniq([
|
|
2355
2394
|
...updatedConfig.models[modelId].fields || [],
|
|
2356
2395
|
fieldInfo.api_key
|
|
2357
2396
|
]);
|
|
@@ -2370,7 +2409,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2370
2409
|
},
|
|
2371
2410
|
async pull(locale, input2, initCtx) {
|
|
2372
2411
|
const result = {};
|
|
2373
|
-
for (const modelId of
|
|
2412
|
+
for (const modelId of _15.keys(initCtx?.models || {})) {
|
|
2374
2413
|
let records = initCtx?.models[modelId].records || [];
|
|
2375
2414
|
const recordIds = records.map((record) => record.id);
|
|
2376
2415
|
records = await dato.findRecords(recordIds);
|
|
@@ -2385,7 +2424,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2385
2424
|
return result;
|
|
2386
2425
|
},
|
|
2387
2426
|
async push(locale, data, originalInput) {
|
|
2388
|
-
for (const modelId of
|
|
2427
|
+
for (const modelId of _15.keys(data)) {
|
|
2389
2428
|
for (let i = 0; i < data[modelId].records.length; i++) {
|
|
2390
2429
|
const record = data[modelId].records[i];
|
|
2391
2430
|
console.log(`Updating record ${i + 1}/${data[modelId].records.length} for model ${modelId}...`);
|
|
@@ -2399,7 +2438,7 @@ async function getModelFields(dato, modelId) {
|
|
|
2399
2438
|
const modelInfo = await dato.findModel(modelId);
|
|
2400
2439
|
return {
|
|
2401
2440
|
modelName: modelInfo.name,
|
|
2402
|
-
fields:
|
|
2441
|
+
fields: _15.filter(modelInfo.fields, (field) => field.type === "field")
|
|
2403
2442
|
};
|
|
2404
2443
|
}
|
|
2405
2444
|
async function getFieldDetails(dato, fields) {
|
|
@@ -2477,17 +2516,17 @@ async function promptModelSelection(choices) {
|
|
|
2477
2516
|
}
|
|
2478
2517
|
|
|
2479
2518
|
// src/cli/loaders/dato/extract.ts
|
|
2480
|
-
import
|
|
2519
|
+
import _16 from "lodash";
|
|
2481
2520
|
function createDatoExtractLoader() {
|
|
2482
2521
|
return createLoader({
|
|
2483
2522
|
async pull(locale, input2) {
|
|
2484
2523
|
const result = {};
|
|
2485
|
-
for (const [modelId, modelInfo] of
|
|
2486
|
-
for (const [recordId, record] of
|
|
2487
|
-
for (const [fieldName, fieldValue] of
|
|
2524
|
+
for (const [modelId, modelInfo] of _16.entries(input2)) {
|
|
2525
|
+
for (const [recordId, record] of _16.entries(modelInfo)) {
|
|
2526
|
+
for (const [fieldName, fieldValue] of _16.entries(record)) {
|
|
2488
2527
|
const parsedValue = createParsedDatoValue(fieldValue);
|
|
2489
2528
|
if (parsedValue) {
|
|
2490
|
-
|
|
2529
|
+
_16.set(result, [modelId, `_${recordId}`, fieldName], parsedValue);
|
|
2491
2530
|
}
|
|
2492
2531
|
}
|
|
2493
2532
|
}
|
|
@@ -2495,14 +2534,14 @@ function createDatoExtractLoader() {
|
|
|
2495
2534
|
return result;
|
|
2496
2535
|
},
|
|
2497
2536
|
async push(locale, data, originalInput) {
|
|
2498
|
-
const result =
|
|
2499
|
-
for (const [modelId, modelInfo] of
|
|
2500
|
-
for (const [virtualRecordId, record] of
|
|
2501
|
-
for (const [fieldName, fieldValue] of
|
|
2537
|
+
const result = _16.cloneDeep(originalInput || {});
|
|
2538
|
+
for (const [modelId, modelInfo] of _16.entries(data)) {
|
|
2539
|
+
for (const [virtualRecordId, record] of _16.entries(modelInfo)) {
|
|
2540
|
+
for (const [fieldName, fieldValue] of _16.entries(record)) {
|
|
2502
2541
|
const [, recordId] = virtualRecordId.split("_");
|
|
2503
|
-
const originalFieldValue =
|
|
2542
|
+
const originalFieldValue = _16.get(originalInput, [modelId, recordId, fieldName]);
|
|
2504
2543
|
const rawValue = createRawDatoValue(fieldValue, originalFieldValue, true);
|
|
2505
|
-
|
|
2544
|
+
_16.set(result, [modelId, recordId, fieldName], rawValue || originalFieldValue);
|
|
2506
2545
|
}
|
|
2507
2546
|
}
|
|
2508
2547
|
}
|
|
@@ -2511,25 +2550,25 @@ function createDatoExtractLoader() {
|
|
|
2511
2550
|
});
|
|
2512
2551
|
}
|
|
2513
2552
|
function detectDatoFieldType(rawDatoValue) {
|
|
2514
|
-
if (
|
|
2553
|
+
if (_16.has(rawDatoValue, "document") && _16.get(rawDatoValue, "schema") === "dast") {
|
|
2515
2554
|
return "structured_text";
|
|
2516
|
-
} else if (
|
|
2555
|
+
} else if (_16.has(rawDatoValue, "no_index") || _16.has(rawDatoValue, "twitter_card")) {
|
|
2517
2556
|
return "seo";
|
|
2518
|
-
} else if (
|
|
2557
|
+
} else if (_16.get(rawDatoValue, "type") === "item") {
|
|
2519
2558
|
return "single_block";
|
|
2520
|
-
} else if (
|
|
2559
|
+
} else if (_16.isArray(rawDatoValue) && _16.every(rawDatoValue, (item) => _16.get(item, "type") === "item")) {
|
|
2521
2560
|
return "rich_text";
|
|
2522
2561
|
} else if (_isFile(rawDatoValue)) {
|
|
2523
2562
|
return "file";
|
|
2524
|
-
} else if (
|
|
2563
|
+
} else if (_16.isArray(rawDatoValue) && _16.every(rawDatoValue, (item) => _isFile(item))) {
|
|
2525
2564
|
return "gallery";
|
|
2526
2565
|
} else if (_isJson(rawDatoValue)) {
|
|
2527
2566
|
return "json";
|
|
2528
|
-
} else if (
|
|
2567
|
+
} else if (_16.isString(rawDatoValue)) {
|
|
2529
2568
|
return "string";
|
|
2530
2569
|
} else if (_isVideo(rawDatoValue)) {
|
|
2531
2570
|
return "video";
|
|
2532
|
-
} else if (
|
|
2571
|
+
} else if (_16.isArray(rawDatoValue) && _16.every(rawDatoValue, (item) => _16.isString(item))) {
|
|
2533
2572
|
return "ref_list";
|
|
2534
2573
|
} else {
|
|
2535
2574
|
return null;
|
|
@@ -2591,9 +2630,9 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
2591
2630
|
if ("document" in node) {
|
|
2592
2631
|
return serializeStructuredTextNode(node.document, [...path18, "document"], acc);
|
|
2593
2632
|
}
|
|
2594
|
-
if (!
|
|
2633
|
+
if (!_16.isNil(node.value)) {
|
|
2595
2634
|
acc[[...path18, "value"].join(".")] = node.value;
|
|
2596
|
-
} else if (
|
|
2635
|
+
} else if (_16.get(node, "type") === "block") {
|
|
2597
2636
|
acc[[...path18, "item"].join(".")] = serializeBlock(node.item);
|
|
2598
2637
|
}
|
|
2599
2638
|
if (node.children) {
|
|
@@ -2605,44 +2644,44 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
2605
2644
|
}
|
|
2606
2645
|
}
|
|
2607
2646
|
function serializeSeo(rawSeo) {
|
|
2608
|
-
return
|
|
2647
|
+
return _16.chain(rawSeo).pick(["title", "description"]).value();
|
|
2609
2648
|
}
|
|
2610
2649
|
function serializeBlock(rawBlock) {
|
|
2611
|
-
if (
|
|
2650
|
+
if (_16.get(rawBlock, "type") === "item" && _16.has(rawBlock, "id")) {
|
|
2612
2651
|
return serializeBlock(rawBlock.attributes);
|
|
2613
2652
|
}
|
|
2614
2653
|
const result = {};
|
|
2615
|
-
for (const [attributeName, attributeValue] of
|
|
2654
|
+
for (const [attributeName, attributeValue] of _16.entries(rawBlock)) {
|
|
2616
2655
|
result[attributeName] = createParsedDatoValue(attributeValue);
|
|
2617
2656
|
}
|
|
2618
2657
|
return result;
|
|
2619
2658
|
}
|
|
2620
2659
|
function serializeBlockList(rawBlockList) {
|
|
2621
|
-
return
|
|
2660
|
+
return _16.chain(rawBlockList).map((block) => serializeBlock(block)).value();
|
|
2622
2661
|
}
|
|
2623
2662
|
function serializeVideo(rawVideo) {
|
|
2624
|
-
return
|
|
2663
|
+
return _16.chain(rawVideo).pick(["title"]).value();
|
|
2625
2664
|
}
|
|
2626
2665
|
function serializeFile(rawFile) {
|
|
2627
|
-
return
|
|
2666
|
+
return _16.chain(rawFile).pick(["alt", "title"]).value();
|
|
2628
2667
|
}
|
|
2629
2668
|
function serializeGallery(rawGallery) {
|
|
2630
|
-
return
|
|
2669
|
+
return _16.chain(rawGallery).map((item) => serializeFile(item)).value();
|
|
2631
2670
|
}
|
|
2632
2671
|
function deserializeFile(parsedFile, originalRawFile) {
|
|
2633
|
-
return
|
|
2672
|
+
return _16.chain(parsedFile).defaults(originalRawFile).value();
|
|
2634
2673
|
}
|
|
2635
2674
|
function deserializeGallery(parsedGallery, originalRawGallery) {
|
|
2636
|
-
return
|
|
2675
|
+
return _16.chain(parsedGallery).map((item, i) => deserializeFile(item, originalRawGallery[i])).value();
|
|
2637
2676
|
}
|
|
2638
2677
|
function deserializeVideo(parsedVideo, originalRawVideo) {
|
|
2639
|
-
return
|
|
2678
|
+
return _16.chain(parsedVideo).defaults(originalRawVideo).value();
|
|
2640
2679
|
}
|
|
2641
2680
|
function deserializeBlock(payload, rawNode, isClean = false) {
|
|
2642
|
-
const result =
|
|
2643
|
-
for (const [attributeName, attributeValue] of
|
|
2681
|
+
const result = _16.cloneDeep(rawNode);
|
|
2682
|
+
for (const [attributeName, attributeValue] of _16.entries(rawNode.attributes)) {
|
|
2644
2683
|
const rawValue = createRawDatoValue(payload[attributeName], attributeValue, isClean);
|
|
2645
|
-
|
|
2684
|
+
_16.set(result, ["attributes", attributeName], rawValue);
|
|
2646
2685
|
}
|
|
2647
2686
|
if (isClean) {
|
|
2648
2687
|
delete result["id"];
|
|
@@ -2650,33 +2689,33 @@ function deserializeBlock(payload, rawNode, isClean = false) {
|
|
|
2650
2689
|
return result;
|
|
2651
2690
|
}
|
|
2652
2691
|
function deserializeSeo(parsedSeo, originalRawSeo) {
|
|
2653
|
-
return
|
|
2692
|
+
return _16.chain(parsedSeo).pick(["title", "description"]).defaults(originalRawSeo).value();
|
|
2654
2693
|
}
|
|
2655
2694
|
function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = false) {
|
|
2656
|
-
return
|
|
2695
|
+
return _16.chain(parsedBlockList).map((block, i) => deserializeBlock(block, originalRawBlockList[i], isClean)).value();
|
|
2657
2696
|
}
|
|
2658
2697
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2659
|
-
const result =
|
|
2660
|
-
for (const [path18, value] of
|
|
2661
|
-
const realPath =
|
|
2662
|
-
const deserializedValue = createRawDatoValue(value,
|
|
2663
|
-
|
|
2698
|
+
const result = _16.cloneDeep(originalRawStructuredText);
|
|
2699
|
+
for (const [path18, value] of _16.entries(parsedStructuredText)) {
|
|
2700
|
+
const realPath = _16.chain(path18.split(".")).flatMap((s) => !_16.isNaN(_16.toNumber(s)) ? ["children", s] : s).value();
|
|
2701
|
+
const deserializedValue = createRawDatoValue(value, _16.get(originalRawStructuredText, realPath), true);
|
|
2702
|
+
_16.set(result, realPath, deserializedValue);
|
|
2664
2703
|
}
|
|
2665
2704
|
return result;
|
|
2666
2705
|
}
|
|
2667
2706
|
function _isJson(rawDatoValue) {
|
|
2668
2707
|
try {
|
|
2669
|
-
return
|
|
2708
|
+
return _16.isString(rawDatoValue) && rawDatoValue.startsWith("{") && rawDatoValue.endsWith("}") && !!JSON.parse(rawDatoValue);
|
|
2670
2709
|
} catch (e) {
|
|
2671
2710
|
return false;
|
|
2672
2711
|
}
|
|
2673
2712
|
}
|
|
2674
2713
|
function _isFile(rawDatoValue) {
|
|
2675
|
-
return
|
|
2714
|
+
return _16.isObject(rawDatoValue) && ["alt", "title", "custom_data", "focal_point", "upload_id"].every((key) => _16.has(rawDatoValue, key));
|
|
2676
2715
|
}
|
|
2677
2716
|
function _isVideo(rawDatoValue) {
|
|
2678
|
-
return
|
|
2679
|
-
(key) =>
|
|
2717
|
+
return _16.isObject(rawDatoValue) && ["url", "title", "width", "height", "provider", "provider_uid", "thumbnail_url"].every(
|
|
2718
|
+
(key) => _16.has(rawDatoValue, key)
|
|
2680
2719
|
);
|
|
2681
2720
|
}
|
|
2682
2721
|
|
|
@@ -2737,7 +2776,7 @@ function createVttLoader() {
|
|
|
2737
2776
|
}
|
|
2738
2777
|
|
|
2739
2778
|
// src/cli/loaders/variable/index.ts
|
|
2740
|
-
import
|
|
2779
|
+
import _17 from "lodash";
|
|
2741
2780
|
function createVariableLoader(params) {
|
|
2742
2781
|
return composeLoaders(variableExtractLoader(params), variableContentLoader());
|
|
2743
2782
|
}
|
|
@@ -2746,7 +2785,7 @@ function variableExtractLoader(params) {
|
|
|
2746
2785
|
return createLoader({
|
|
2747
2786
|
pull: async (locale, input2) => {
|
|
2748
2787
|
const result = {};
|
|
2749
|
-
const inputValues =
|
|
2788
|
+
const inputValues = _17.omitBy(input2, _17.isEmpty);
|
|
2750
2789
|
for (const [key, value] of Object.entries(inputValues)) {
|
|
2751
2790
|
const matches = value.match(specifierPattern) || [];
|
|
2752
2791
|
result[key] = result[key] || {
|
|
@@ -2781,11 +2820,11 @@ function variableExtractLoader(params) {
|
|
|
2781
2820
|
function variableContentLoader() {
|
|
2782
2821
|
return createLoader({
|
|
2783
2822
|
pull: async (locale, input2) => {
|
|
2784
|
-
const result =
|
|
2823
|
+
const result = _17.mapValues(input2, (payload) => payload.value);
|
|
2785
2824
|
return result;
|
|
2786
2825
|
},
|
|
2787
2826
|
push: async (locale, data, originalInput) => {
|
|
2788
|
-
const result =
|
|
2827
|
+
const result = _17.cloneDeep(originalInput || {});
|
|
2789
2828
|
for (const [key, originalValueObj] of Object.entries(result)) {
|
|
2790
2829
|
result[key] = {
|
|
2791
2830
|
...originalValueObj,
|
|
@@ -2808,20 +2847,20 @@ function getFormatSpecifierPattern(type) {
|
|
|
2808
2847
|
}
|
|
2809
2848
|
|
|
2810
2849
|
// src/cli/loaders/sync.ts
|
|
2811
|
-
import
|
|
2850
|
+
import _18 from "lodash";
|
|
2812
2851
|
function createSyncLoader() {
|
|
2813
2852
|
return createLoader({
|
|
2814
2853
|
async pull(locale, input2, originalInput) {
|
|
2815
2854
|
if (!originalInput) {
|
|
2816
2855
|
return input2;
|
|
2817
2856
|
}
|
|
2818
|
-
return
|
|
2857
|
+
return _18.chain(originalInput).mapValues((value, key) => input2[key]).value();
|
|
2819
2858
|
},
|
|
2820
2859
|
async push(locale, data, originalInput) {
|
|
2821
2860
|
if (!originalInput) {
|
|
2822
2861
|
return data;
|
|
2823
2862
|
}
|
|
2824
|
-
return
|
|
2863
|
+
return _18.chain(originalInput || {}).mapValues((value, key) => data[key]).value();
|
|
2825
2864
|
}
|
|
2826
2865
|
});
|
|
2827
2866
|
}
|
|
@@ -2981,7 +3020,7 @@ function parseVueFile(input2) {
|
|
|
2981
3020
|
}
|
|
2982
3021
|
|
|
2983
3022
|
// src/cli/loaders/inject-locale.ts
|
|
2984
|
-
import
|
|
3023
|
+
import _19 from "lodash";
|
|
2985
3024
|
function createInjectLocaleLoader(injectLocaleKeys) {
|
|
2986
3025
|
return createLoader({
|
|
2987
3026
|
async pull(locale, data) {
|
|
@@ -2989,19 +3028,19 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
2989
3028
|
return data;
|
|
2990
3029
|
}
|
|
2991
3030
|
const omitKeys = injectLocaleKeys.filter((key) => {
|
|
2992
|
-
return
|
|
3031
|
+
return _19.get(data, key) === locale;
|
|
2993
3032
|
});
|
|
2994
|
-
const result =
|
|
3033
|
+
const result = _19.omit(data, omitKeys);
|
|
2995
3034
|
return result;
|
|
2996
3035
|
},
|
|
2997
3036
|
async push(locale, data, originalInput, originalLocale) {
|
|
2998
3037
|
if (!injectLocaleKeys) {
|
|
2999
3038
|
return data;
|
|
3000
3039
|
}
|
|
3001
|
-
const mergedData =
|
|
3040
|
+
const mergedData = _19.merge({}, originalInput, data);
|
|
3002
3041
|
injectLocaleKeys.forEach((key) => {
|
|
3003
|
-
if (
|
|
3004
|
-
|
|
3042
|
+
if (_19.get(mergedData, key) === originalLocale) {
|
|
3043
|
+
_19.set(mergedData, key, locale);
|
|
3005
3044
|
}
|
|
3006
3045
|
});
|
|
3007
3046
|
return mergedData;
|
|
@@ -3010,16 +3049,16 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
3010
3049
|
}
|
|
3011
3050
|
|
|
3012
3051
|
// src/cli/loaders/locked-keys.ts
|
|
3013
|
-
import
|
|
3052
|
+
import _20 from "lodash";
|
|
3014
3053
|
function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
|
|
3015
3054
|
return createLoader({
|
|
3016
|
-
pull: async (locale, data) =>
|
|
3055
|
+
pull: async (locale, data) => _20.chain(data).pickBy((value, key) => !lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value(),
|
|
3017
3056
|
push: async (locale, data, originalInput) => {
|
|
3018
|
-
const lockedSubObject =
|
|
3057
|
+
const lockedSubObject = _20.chain(originalInput).pickBy((value, key) => lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value();
|
|
3019
3058
|
if (isCacheRestore) {
|
|
3020
|
-
return
|
|
3059
|
+
return _20.merge({}, data, lockedSubObject);
|
|
3021
3060
|
} else {
|
|
3022
|
-
return
|
|
3061
|
+
return _20.merge({}, originalInput, data, lockedSubObject);
|
|
3023
3062
|
}
|
|
3024
3063
|
}
|
|
3025
3064
|
});
|
|
@@ -3073,6 +3112,16 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3073
3112
|
createSyncLoader(),
|
|
3074
3113
|
createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
|
|
3075
3114
|
);
|
|
3115
|
+
case "mdx":
|
|
3116
|
+
return composeLoaders(
|
|
3117
|
+
createTextFileLoader(bucketPathPattern),
|
|
3118
|
+
createPrettierLoader({ parser: "mdx", bucketPathPattern }),
|
|
3119
|
+
createMdxFormatLoader(),
|
|
3120
|
+
createFlatLoader(),
|
|
3121
|
+
createMdxStructureLoader(),
|
|
3122
|
+
createSyncLoader(),
|
|
3123
|
+
createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
|
|
3124
|
+
);
|
|
3076
3125
|
case "po":
|
|
3077
3126
|
return composeLoaders(
|
|
3078
3127
|
createTextFileLoader(bucketPathPattern),
|
|
@@ -3439,7 +3488,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
3439
3488
|
}
|
|
3440
3489
|
|
|
3441
3490
|
// src/cli/utils/delta.ts
|
|
3442
|
-
import
|
|
3491
|
+
import _21 from "lodash";
|
|
3443
3492
|
import z from "zod";
|
|
3444
3493
|
import { MD5 } from "object-hash";
|
|
3445
3494
|
|
|
@@ -3489,9 +3538,9 @@ function createDeltaProcessor(fileKey) {
|
|
|
3489
3538
|
return checkIfFileExists(lockfilePath);
|
|
3490
3539
|
},
|
|
3491
3540
|
async calculateDelta(params) {
|
|
3492
|
-
let added =
|
|
3493
|
-
let removed =
|
|
3494
|
-
const updated =
|
|
3541
|
+
let added = _21.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
|
|
3542
|
+
let removed = _21.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
|
|
3543
|
+
const updated = _21.filter(Object.keys(params.sourceData), (key) => {
|
|
3495
3544
|
return MD5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
|
|
3496
3545
|
});
|
|
3497
3546
|
const renamed = [];
|
|
@@ -3540,7 +3589,7 @@ function createDeltaProcessor(fileKey) {
|
|
|
3540
3589
|
await this.saveLock(lockfileData);
|
|
3541
3590
|
},
|
|
3542
3591
|
async createChecksums(sourceData) {
|
|
3543
|
-
const checksums =
|
|
3592
|
+
const checksums = _21.mapValues(sourceData, (value) => MD5(value));
|
|
3544
3593
|
return checksums;
|
|
3545
3594
|
}
|
|
3546
3595
|
};
|
|
@@ -3770,7 +3819,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3770
3819
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
3771
3820
|
const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
|
|
3772
3821
|
const savedChecksums = await deltaProcessor.loadChecksums();
|
|
3773
|
-
const updatedSourceData =
|
|
3822
|
+
const updatedSourceData = _22.pickBy(
|
|
3774
3823
|
sourceData,
|
|
3775
3824
|
(value, key) => sourceChecksums[key] !== savedChecksums[key]
|
|
3776
3825
|
);
|
|
@@ -3781,9 +3830,9 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3781
3830
|
for (const _targetLocale of targetLocales) {
|
|
3782
3831
|
const targetLocale = resolveOverriddenLocale3(_targetLocale, bucketPath.delimiter);
|
|
3783
3832
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
3784
|
-
const missingKeys =
|
|
3785
|
-
const extraKeys =
|
|
3786
|
-
const unlocalizableDataDiff = !
|
|
3833
|
+
const missingKeys = _22.difference(Object.keys(sourceData), Object.keys(targetData));
|
|
3834
|
+
const extraKeys = _22.difference(Object.keys(targetData), Object.keys(sourceData));
|
|
3835
|
+
const unlocalizableDataDiff = !_22.isEqual(sourceUnlocalizable, targetUnlocalizable);
|
|
3787
3836
|
if (missingKeys.length > 0) {
|
|
3788
3837
|
requiresUpdate = "missing";
|
|
3789
3838
|
break bucketLoop;
|
|
@@ -3846,9 +3895,9 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3846
3895
|
targetData,
|
|
3847
3896
|
checksums: checksums2
|
|
3848
3897
|
});
|
|
3849
|
-
let processableData =
|
|
3898
|
+
let processableData = _22.chain(sourceData).entries().filter(([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force).fromPairs().value();
|
|
3850
3899
|
if (flags.key) {
|
|
3851
|
-
processableData =
|
|
3900
|
+
processableData = _22.pickBy(processableData, (_25, key) => key === flags.key);
|
|
3852
3901
|
}
|
|
3853
3902
|
if (flags.verbose) {
|
|
3854
3903
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -3885,7 +3934,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3885
3934
|
if (flags.verbose) {
|
|
3886
3935
|
bucketOra.info(JSON.stringify(processedTargetData, null, 2));
|
|
3887
3936
|
}
|
|
3888
|
-
let finalTargetData =
|
|
3937
|
+
let finalTargetData = _22.merge({}, sourceData, targetData, processedTargetData);
|
|
3889
3938
|
if (flags.interactive) {
|
|
3890
3939
|
bucketOra.stop();
|
|
3891
3940
|
const reviewedData = await reviewChanges({
|
|
@@ -3899,7 +3948,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3899
3948
|
finalTargetData = reviewedData;
|
|
3900
3949
|
bucketOra.start(`Applying changes to ${bucketPath} (${targetLocale})`);
|
|
3901
3950
|
}
|
|
3902
|
-
const finalDiffSize =
|
|
3951
|
+
const finalDiffSize = _22.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
3903
3952
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
3904
3953
|
if (finalDiffSize > 0 || flags.force) {
|
|
3905
3954
|
bucketOra.succeed(`[${sourceLocale} -> ${targetLocale}] Localization completed`);
|
|
@@ -4059,7 +4108,7 @@ Reviewing changes for ${chalk.blue(args.pathPattern)} (${chalk.yellow(args.targe
|
|
|
4059
4108
|
return args.currentData;
|
|
4060
4109
|
}
|
|
4061
4110
|
const customData = { ...args.currentData };
|
|
4062
|
-
const changes =
|
|
4111
|
+
const changes = _22.reduce(
|
|
4063
4112
|
args.proposedData,
|
|
4064
4113
|
(result, value, key) => {
|
|
4065
4114
|
if (args.currentData[key] !== value) {
|
|
@@ -4118,7 +4167,7 @@ import path16 from "path";
|
|
|
4118
4167
|
import Z4 from "zod";
|
|
4119
4168
|
import YAML4 from "yaml";
|
|
4120
4169
|
import { MD5 as MD52 } from "object-hash";
|
|
4121
|
-
import
|
|
4170
|
+
import _23 from "lodash";
|
|
4122
4171
|
function createLockfileHelper() {
|
|
4123
4172
|
return {
|
|
4124
4173
|
isLockfileExists: () => {
|
|
@@ -4128,23 +4177,23 @@ function createLockfileHelper() {
|
|
|
4128
4177
|
registerSourceData: (pathPattern, sourceData) => {
|
|
4129
4178
|
const lockfile = _loadLockfile();
|
|
4130
4179
|
const sectionKey = MD52(pathPattern);
|
|
4131
|
-
const sectionChecksums =
|
|
4180
|
+
const sectionChecksums = _23.mapValues(sourceData, (value) => MD52(value));
|
|
4132
4181
|
lockfile.checksums[sectionKey] = sectionChecksums;
|
|
4133
4182
|
_saveLockfile(lockfile);
|
|
4134
4183
|
},
|
|
4135
4184
|
registerPartialSourceData: (pathPattern, partialSourceData) => {
|
|
4136
4185
|
const lockfile = _loadLockfile();
|
|
4137
4186
|
const sectionKey = MD52(pathPattern);
|
|
4138
|
-
const sectionChecksums =
|
|
4139
|
-
lockfile.checksums[sectionKey] =
|
|
4187
|
+
const sectionChecksums = _23.mapValues(partialSourceData, (value) => MD52(value));
|
|
4188
|
+
lockfile.checksums[sectionKey] = _23.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
|
|
4140
4189
|
_saveLockfile(lockfile);
|
|
4141
4190
|
},
|
|
4142
4191
|
extractUpdatedData: (pathPattern, sourceData) => {
|
|
4143
4192
|
const lockfile = _loadLockfile();
|
|
4144
4193
|
const sectionKey = MD52(pathPattern);
|
|
4145
|
-
const currentChecksums =
|
|
4194
|
+
const currentChecksums = _23.mapValues(sourceData, (value) => MD52(value));
|
|
4146
4195
|
const savedChecksums = lockfile.checksums[sectionKey] || {};
|
|
4147
|
-
const updatedData =
|
|
4196
|
+
const updatedData = _23.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
|
|
4148
4197
|
return updatedData;
|
|
4149
4198
|
}
|
|
4150
4199
|
};
|
|
@@ -4214,7 +4263,7 @@ var flagsSchema = Z5.object({
|
|
|
4214
4263
|
// src/cli/cmd/cleanup.ts
|
|
4215
4264
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
4216
4265
|
import { Command as Command8 } from "interactive-commander";
|
|
4217
|
-
import
|
|
4266
|
+
import _24 from "lodash";
|
|
4218
4267
|
import Ora7 from "ora";
|
|
4219
4268
|
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(
|
|
4220
4269
|
"--verbose",
|
|
@@ -4250,7 +4299,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
4250
4299
|
try {
|
|
4251
4300
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
4252
4301
|
const targetKeys = Object.keys(targetData);
|
|
4253
|
-
const keysToRemove =
|
|
4302
|
+
const keysToRemove = _24.difference(targetKeys, sourceKeys);
|
|
4254
4303
|
if (keysToRemove.length === 0) {
|
|
4255
4304
|
bucketOra.succeed(`[${targetLocale}] No keys to remove`);
|
|
4256
4305
|
continue;
|
|
@@ -4259,7 +4308,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
4259
4308
|
bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
|
|
4260
4309
|
}
|
|
4261
4310
|
if (!options.dryRun) {
|
|
4262
|
-
const cleanedData =
|
|
4311
|
+
const cleanedData = _24.pick(targetData, sourceKeys);
|
|
4263
4312
|
await bucketLoader.push(targetLocale, cleanedData);
|
|
4264
4313
|
bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
|
|
4265
4314
|
} else {
|
|
@@ -4314,7 +4363,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4314
4363
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4315
4364
|
import Z6 from "zod";
|
|
4316
4365
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
4317
|
-
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 (
|
|
4366
|
+
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 (_25, program) => {
|
|
4318
4367
|
const apiKey = program.args[0];
|
|
4319
4368
|
const settings = getSettings(apiKey);
|
|
4320
4369
|
if (!settings.auth.apiKey) {
|
|
@@ -4978,7 +5027,7 @@ var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD
|
|
|
4978
5027
|
// package.json
|
|
4979
5028
|
var package_default = {
|
|
4980
5029
|
name: "lingo.dev",
|
|
4981
|
-
version: "0.
|
|
5030
|
+
version: "0.83.0",
|
|
4982
5031
|
description: "Lingo.dev CLI",
|
|
4983
5032
|
private: false,
|
|
4984
5033
|
publishConfig: {
|
|
@@ -5044,6 +5093,7 @@ var package_default = {
|
|
|
5044
5093
|
"@lingo.dev/_spec": "workspace:*",
|
|
5045
5094
|
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
5046
5095
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
5096
|
+
"@types/mdast": "^4.0.4",
|
|
5047
5097
|
ai: "^4.3.2",
|
|
5048
5098
|
bitbucket: "^2.12.0",
|
|
5049
5099
|
chalk: "^5.4.1",
|
|
@@ -5073,6 +5123,11 @@ var package_default = {
|
|
|
5073
5123
|
"markdown-it": "^14.1.0",
|
|
5074
5124
|
"markdown-it-front-matter": "^0.2.4",
|
|
5075
5125
|
marked: "^15.0.6",
|
|
5126
|
+
"mdast-util-from-markdown": "^2.0.2",
|
|
5127
|
+
"mdast-util-frontmatter": "^2.0.1",
|
|
5128
|
+
"mdast-util-gfm": "^3.1.0",
|
|
5129
|
+
"mdast-util-mdx": "^3.0.0",
|
|
5130
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
5076
5131
|
"node-webvtt": "^1.9.4",
|
|
5077
5132
|
"object-hash": "^3.0.0",
|
|
5078
5133
|
octokit: "^4.0.2",
|
|
@@ -5084,9 +5139,18 @@ var package_default = {
|
|
|
5084
5139
|
"posthog-node": "^4.11.2",
|
|
5085
5140
|
prettier: "^3.4.2",
|
|
5086
5141
|
"properties-parser": "^0.6.0",
|
|
5142
|
+
"remark-frontmatter": "^5.0.0",
|
|
5143
|
+
"remark-gfm": "^4.0.1",
|
|
5144
|
+
"remark-mdx": "^3.1.0",
|
|
5145
|
+
"remark-mdx-frontmatter": "^5.1.0",
|
|
5146
|
+
"remark-parse": "^11.0.0",
|
|
5147
|
+
"remark-stringify": "^11.0.0",
|
|
5087
5148
|
slugify: "^1.6.6",
|
|
5088
5149
|
"srt-parser-2": "^1.2.3",
|
|
5089
5150
|
typescript: "^5.7.2",
|
|
5151
|
+
unified: "^11.0.5",
|
|
5152
|
+
"unist-util-visit": "^5.0.0",
|
|
5153
|
+
vfile: "^6.0.3",
|
|
5090
5154
|
vitest: "^2.1.8",
|
|
5091
5155
|
xliff: "^6.2.1",
|
|
5092
5156
|
xml2js: "^0.6.2",
|