lingo.dev 0.112.0 → 0.112.1
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 +294 -154
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +479 -339
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -1277,7 +1277,7 @@ var init_default = new InteractiveCommand().command("init").description("Create
|
|
|
1277
1277
|
});
|
|
1278
1278
|
|
|
1279
1279
|
// src/cli/cmd/show/index.ts
|
|
1280
|
-
import { Command as
|
|
1280
|
+
import { Command as Command9 } from "interactive-commander";
|
|
1281
1281
|
|
|
1282
1282
|
// src/cli/cmd/show/config.ts
|
|
1283
1283
|
import { Command as Command4 } from "interactive-commander";
|
|
@@ -1539,150 +1539,13 @@ var files_default = new Command6().command("files").description(
|
|
|
1539
1539
|
}
|
|
1540
1540
|
});
|
|
1541
1541
|
|
|
1542
|
-
// src/cli/cmd/show/
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
// src/cli/cmd/config/index.ts
|
|
1546
|
-
import { Command as Command11 } from "interactive-commander";
|
|
1547
|
-
|
|
1548
|
-
// src/cli/cmd/config/set.ts
|
|
1549
|
-
import { Command as Command8 } from "interactive-commander";
|
|
1550
|
-
import chalk2 from "chalk";
|
|
1551
|
-
import dedent from "dedent";
|
|
1552
|
-
import _6 from "lodash";
|
|
1553
|
-
var set_default = new Command8().name("set").description("Set or update a CLI setting in ~/.lingodotdevrc").addHelpText("afterAll", `
|
|
1554
|
-
Available keys:
|
|
1555
|
-
${SETTINGS_KEYS.join("\n ")}`).argument(
|
|
1556
|
-
"<key>",
|
|
1557
|
-
"Configuration key to set (dot notation, e.g., auth.apiKey)"
|
|
1558
|
-
).argument("<value>", "The configuration value to set").helpOption("-h, --help", "Show help").action(async (key, value) => {
|
|
1559
|
-
if (!SETTINGS_KEYS.includes(key)) {
|
|
1560
|
-
console.error(
|
|
1561
|
-
dedent`
|
|
1562
|
-
${chalk2.red("\u2716")} Unknown configuration key: ${chalk2.bold(key)}
|
|
1563
|
-
Run ${chalk2.dim("lingo.dev config set --help")} to see available keys.
|
|
1564
|
-
`
|
|
1565
|
-
);
|
|
1566
|
-
process.exitCode = 1;
|
|
1567
|
-
return;
|
|
1568
|
-
}
|
|
1569
|
-
const current = loadSystemSettings();
|
|
1570
|
-
const updated = _6.cloneDeep(current);
|
|
1571
|
-
_6.set(updated, key, value);
|
|
1572
|
-
try {
|
|
1573
|
-
saveSettings(updated);
|
|
1574
|
-
console.log(`${chalk2.green("\u2714")} Set ${chalk2.bold(key)}`);
|
|
1575
|
-
} catch (err) {
|
|
1576
|
-
console.error(
|
|
1577
|
-
chalk2.red(
|
|
1578
|
-
`\u2716 Failed to save configuration: ${chalk2.dim(
|
|
1579
|
-
err instanceof Error ? err.message : String(err)
|
|
1580
|
-
)}`
|
|
1581
|
-
)
|
|
1582
|
-
);
|
|
1583
|
-
process.exitCode = 1;
|
|
1584
|
-
}
|
|
1585
|
-
});
|
|
1586
|
-
|
|
1587
|
-
// src/cli/cmd/config/unset.ts
|
|
1588
|
-
import { Command as Command9 } from "interactive-commander";
|
|
1589
|
-
import chalk3 from "chalk";
|
|
1590
|
-
import dedent2 from "dedent";
|
|
1591
|
-
import _7 from "lodash";
|
|
1592
|
-
var unset_default = new Command9().name("unset").description("Remove a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
|
|
1593
|
-
Available keys:
|
|
1594
|
-
${SETTINGS_KEYS.join("\n ")}`).argument(
|
|
1595
|
-
"<key>",
|
|
1596
|
-
"Configuration key to remove (must match one of the available keys listed below)"
|
|
1597
|
-
).helpOption("-h, --help", "Show help").action(async (key) => {
|
|
1598
|
-
if (!SETTINGS_KEYS.includes(key)) {
|
|
1599
|
-
console.error(
|
|
1600
|
-
dedent2`
|
|
1601
|
-
${chalk3.red("\u2716")} Unknown configuration key: ${chalk3.bold(key)}
|
|
1602
|
-
Run ${chalk3.dim(
|
|
1603
|
-
"lingo.dev config unset --help"
|
|
1604
|
-
)} to see available keys.
|
|
1605
|
-
`
|
|
1606
|
-
);
|
|
1607
|
-
process.exitCode = 1;
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
|
-
const settings = loadSystemSettings();
|
|
1611
|
-
const currentValue = _7.get(settings, key);
|
|
1612
|
-
if (!_7.trim(String(currentValue || ""))) {
|
|
1613
|
-
console.log(`${chalk3.cyan("\u2139")} ${chalk3.bold(key)} is not set.`);
|
|
1614
|
-
return;
|
|
1615
|
-
} else {
|
|
1616
|
-
const updated = _7.cloneDeep(settings);
|
|
1617
|
-
_7.unset(updated, key);
|
|
1618
|
-
try {
|
|
1619
|
-
saveSettings(updated);
|
|
1620
|
-
console.log(
|
|
1621
|
-
`${chalk3.green("\u2714")} Removed configuration key ${chalk3.bold(key)}`
|
|
1622
|
-
);
|
|
1623
|
-
} catch (err) {
|
|
1624
|
-
console.error(
|
|
1625
|
-
chalk3.red(
|
|
1626
|
-
`\u2716 Failed to save configuration: ${chalk3.dim(
|
|
1627
|
-
err instanceof Error ? err.message : String(err)
|
|
1628
|
-
)}`
|
|
1629
|
-
)
|
|
1630
|
-
);
|
|
1631
|
-
process.exitCode = 1;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
});
|
|
1635
|
-
|
|
1636
|
-
// src/cli/cmd/config/get.ts
|
|
1637
|
-
import { Command as Command10 } from "interactive-commander";
|
|
1638
|
-
import chalk4 from "chalk";
|
|
1639
|
-
import _8 from "lodash";
|
|
1640
|
-
import dedent3 from "dedent";
|
|
1641
|
-
var get_default = new Command10().name("get").description("Display the value of a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
|
|
1642
|
-
Available keys:
|
|
1643
|
-
${SETTINGS_KEYS.join("\n ")}`).argument(
|
|
1644
|
-
"<key>",
|
|
1645
|
-
"Configuration key to read (choose from the available keys listed below)"
|
|
1646
|
-
).helpOption("-h, --help", "Show help").action(async (key) => {
|
|
1647
|
-
if (!SETTINGS_KEYS.includes(key)) {
|
|
1648
|
-
console.error(
|
|
1649
|
-
dedent3`
|
|
1650
|
-
${chalk4.red("\u2716")} Unknown configuration key: ${chalk4.bold(key)}
|
|
1651
|
-
Run ${chalk4.dim("lingo.dev config get --help")} to see available keys.
|
|
1652
|
-
`
|
|
1653
|
-
);
|
|
1654
|
-
process.exitCode = 1;
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
const settings = loadSystemSettings();
|
|
1658
|
-
const value = _8.get(settings, key);
|
|
1659
|
-
if (!value) {
|
|
1660
|
-
console.log(`${chalk4.cyan("\u2139")} ${chalk4.bold(key)} is not set.`);
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
|
-
if (typeof value === "object") {
|
|
1664
|
-
console.log(JSON.stringify(value, null, 2));
|
|
1665
|
-
} else {
|
|
1666
|
-
console.log(value);
|
|
1667
|
-
}
|
|
1668
|
-
});
|
|
1669
|
-
|
|
1670
|
-
// src/cli/cmd/config/index.ts
|
|
1671
|
-
var config_default2 = new Command11().command("config").description(
|
|
1672
|
-
"Manage CLI settings (authentication, API keys) stored in ~/.lingodotdevrc"
|
|
1673
|
-
).helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
|
|
1674
|
-
|
|
1675
|
-
// src/cli/cmd/i18n.ts
|
|
1676
|
-
import {
|
|
1677
|
-
bucketTypeSchema,
|
|
1678
|
-
localeCodeSchema,
|
|
1679
|
-
resolveOverriddenLocale as resolveOverriddenLocale3
|
|
1680
|
-
} from "@lingo.dev/_spec";
|
|
1681
|
-
import { Command as Command12 } from "interactive-commander";
|
|
1682
|
-
import Z3 from "zod";
|
|
1683
|
-
import _31 from "lodash";
|
|
1542
|
+
// src/cli/cmd/show/locked-keys.ts
|
|
1543
|
+
import { Command as Command7 } from "interactive-commander";
|
|
1684
1544
|
import Ora7 from "ora";
|
|
1685
1545
|
|
|
1546
|
+
// src/cli/cmd/show/_shared-key-command.ts
|
|
1547
|
+
import { resolveOverriddenLocale as resolveOverriddenLocale3 } from "@lingo.dev/_spec";
|
|
1548
|
+
|
|
1686
1549
|
// src/cli/loaders/_utils.ts
|
|
1687
1550
|
function composeLoaders(...loaders) {
|
|
1688
1551
|
return {
|
|
@@ -2009,7 +1872,7 @@ function createJsoncLoader() {
|
|
|
2009
1872
|
|
|
2010
1873
|
// src/cli/loaders/flat.ts
|
|
2011
1874
|
import { flatten, unflatten } from "flat";
|
|
2012
|
-
import
|
|
1875
|
+
import _6 from "lodash";
|
|
2013
1876
|
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
2014
1877
|
function createFlatLoader() {
|
|
2015
1878
|
const composedLoader = composeLoaders(
|
|
@@ -2088,12 +1951,12 @@ function mapDenormalizedKeys(obj, denormalizedKeysMap) {
|
|
|
2088
1951
|
);
|
|
2089
1952
|
}
|
|
2090
1953
|
function denormalizeObjectKeys(obj) {
|
|
2091
|
-
if (
|
|
2092
|
-
return
|
|
1954
|
+
if (_6.isObject(obj) && !_6.isArray(obj)) {
|
|
1955
|
+
return _6.transform(
|
|
2093
1956
|
obj,
|
|
2094
1957
|
(result, value, key) => {
|
|
2095
1958
|
const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
|
|
2096
|
-
result[newKey] =
|
|
1959
|
+
result[newKey] = _6.isObject(value) && !_6.isDate(value) ? denormalizeObjectKeys(value) : value;
|
|
2097
1960
|
},
|
|
2098
1961
|
{}
|
|
2099
1962
|
);
|
|
@@ -2102,12 +1965,12 @@ function denormalizeObjectKeys(obj) {
|
|
|
2102
1965
|
}
|
|
2103
1966
|
}
|
|
2104
1967
|
function normalizeObjectKeys(obj) {
|
|
2105
|
-
if (
|
|
2106
|
-
return
|
|
1968
|
+
if (_6.isObject(obj) && !_6.isArray(obj)) {
|
|
1969
|
+
return _6.transform(
|
|
2107
1970
|
obj,
|
|
2108
1971
|
(result, value, key) => {
|
|
2109
1972
|
const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
2110
|
-
result[newKey] =
|
|
1973
|
+
result[newKey] = _6.isObject(value) && !_6.isDate(value) ? normalizeObjectKeys(value) : value;
|
|
2111
1974
|
},
|
|
2112
1975
|
{}
|
|
2113
1976
|
);
|
|
@@ -2118,14 +1981,14 @@ function normalizeObjectKeys(obj) {
|
|
|
2118
1981
|
function flattenHints(obj, parentHints = [], parentPath = "") {
|
|
2119
1982
|
const result = {};
|
|
2120
1983
|
for (const [key, _value] of Object.entries(obj)) {
|
|
2121
|
-
if (
|
|
1984
|
+
if (_6.isObject(_value) && !_6.isArray(_value)) {
|
|
2122
1985
|
const value = _value;
|
|
2123
1986
|
const currentHints = [...parentHints];
|
|
2124
1987
|
const currentPath = parentPath ? `${parentPath}/${key}` : key;
|
|
2125
1988
|
if (value.hint && typeof value.hint === "string") {
|
|
2126
1989
|
currentHints.push(value.hint);
|
|
2127
1990
|
}
|
|
2128
|
-
const nestedObj =
|
|
1991
|
+
const nestedObj = _6.omit(value, "hint");
|
|
2129
1992
|
if (Object.keys(nestedObj).length === 0) {
|
|
2130
1993
|
if (currentHints.length > 0) {
|
|
2131
1994
|
result[currentPath] = currentHints;
|
|
@@ -2253,19 +2116,19 @@ function createRootKeyLoader(replaceAll = false) {
|
|
|
2253
2116
|
}
|
|
2254
2117
|
|
|
2255
2118
|
// src/cli/loaders/flutter.ts
|
|
2256
|
-
import
|
|
2119
|
+
import _7 from "lodash";
|
|
2257
2120
|
function createFlutterLoader() {
|
|
2258
2121
|
return createLoader({
|
|
2259
2122
|
async pull(locale, input2) {
|
|
2260
|
-
const result =
|
|
2123
|
+
const result = _7.pickBy(input2, (value, key) => !_isMetadataKey(key));
|
|
2261
2124
|
return result;
|
|
2262
2125
|
},
|
|
2263
2126
|
async push(locale, data, originalInput) {
|
|
2264
|
-
const metadata =
|
|
2127
|
+
const metadata = _7.pickBy(
|
|
2265
2128
|
originalInput,
|
|
2266
2129
|
(value, key) => _isMetadataKey(key)
|
|
2267
2130
|
);
|
|
2268
|
-
const result =
|
|
2131
|
+
const result = _7.merge({}, metadata, { "@@locale": locale }, data);
|
|
2269
2132
|
return result;
|
|
2270
2133
|
}
|
|
2271
2134
|
});
|
|
@@ -2455,7 +2318,7 @@ function createAndroidLoader() {
|
|
|
2455
2318
|
// src/cli/loaders/csv.ts
|
|
2456
2319
|
import { parse as parse2 } from "csv-parse/sync";
|
|
2457
2320
|
import { stringify } from "csv-stringify/sync";
|
|
2458
|
-
import
|
|
2321
|
+
import _8 from "lodash";
|
|
2459
2322
|
function detectKeyColumnName(csvString) {
|
|
2460
2323
|
const row = parse2(csvString)[0];
|
|
2461
2324
|
const firstColumn = row?.[0]?.trim();
|
|
@@ -2476,7 +2339,7 @@ function _createCsvLoader() {
|
|
|
2476
2339
|
relax_column_count_less: true
|
|
2477
2340
|
});
|
|
2478
2341
|
const items = {};
|
|
2479
|
-
|
|
2342
|
+
_8.forEach(inputParsed, (row) => {
|
|
2480
2343
|
const key = row[keyColumnName];
|
|
2481
2344
|
if (key && row[locale] && row[locale].trim() !== "") {
|
|
2482
2345
|
items[key] = row[locale];
|
|
@@ -2945,7 +2808,7 @@ function createXcodeStringsdictLoader() {
|
|
|
2945
2808
|
}
|
|
2946
2809
|
|
|
2947
2810
|
// src/cli/loaders/xcode-xcstrings.ts
|
|
2948
|
-
import
|
|
2811
|
+
import _9 from "lodash";
|
|
2949
2812
|
function createXcodeXcstringsLoader(defaultLocale) {
|
|
2950
2813
|
return createLoader({
|
|
2951
2814
|
async pull(locale, input2, initCtx) {
|
|
@@ -2982,7 +2845,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2982
2845
|
async push(locale, payload, originalInput) {
|
|
2983
2846
|
const langDataToMerge = {};
|
|
2984
2847
|
langDataToMerge.strings = {};
|
|
2985
|
-
const input2 =
|
|
2848
|
+
const input2 = _9.cloneDeep(originalInput) || {
|
|
2986
2849
|
sourceLanguage: locale,
|
|
2987
2850
|
strings: {}
|
|
2988
2851
|
};
|
|
@@ -3032,7 +2895,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
3032
2895
|
}
|
|
3033
2896
|
}
|
|
3034
2897
|
const originalInputWithoutLocale = originalInput ? _removeLocale(originalInput, locale) : {};
|
|
3035
|
-
const result =
|
|
2898
|
+
const result = _9.merge({}, originalInputWithoutLocale, langDataToMerge);
|
|
3036
2899
|
return result;
|
|
3037
2900
|
},
|
|
3038
2901
|
async pullHints(originalInput) {
|
|
@@ -3069,7 +2932,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
3069
2932
|
}
|
|
3070
2933
|
function _removeLocale(input2, locale) {
|
|
3071
2934
|
const { strings } = input2;
|
|
3072
|
-
const newStrings =
|
|
2935
|
+
const newStrings = _9.cloneDeep(strings);
|
|
3073
2936
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
3074
2937
|
if (value.localizations?.[locale]) {
|
|
3075
2938
|
delete value.localizations[locale];
|
|
@@ -3079,19 +2942,19 @@ function _removeLocale(input2, locale) {
|
|
|
3079
2942
|
}
|
|
3080
2943
|
|
|
3081
2944
|
// src/cli/loaders/unlocalizable.ts
|
|
3082
|
-
import
|
|
2945
|
+
import _10 from "lodash";
|
|
3083
2946
|
import _isUrl from "is-url";
|
|
3084
2947
|
import { isValid, parseISO } from "date-fns";
|
|
3085
2948
|
function createUnlocalizableLoader(returnUnlocalizedKeys = false) {
|
|
3086
2949
|
return createLoader({
|
|
3087
2950
|
async pull(locale, input2) {
|
|
3088
2951
|
const unlocalizableKeys = _getUnlocalizableKeys(input2);
|
|
3089
|
-
const result =
|
|
2952
|
+
const result = _10.omitBy(
|
|
3090
2953
|
input2,
|
|
3091
2954
|
(_35, key) => unlocalizableKeys.includes(key)
|
|
3092
2955
|
);
|
|
3093
2956
|
if (returnUnlocalizedKeys) {
|
|
3094
|
-
result.unlocalizable =
|
|
2957
|
+
result.unlocalizable = _10.omitBy(
|
|
3095
2958
|
input2,
|
|
3096
2959
|
(_35, key) => !unlocalizableKeys.includes(key)
|
|
3097
2960
|
);
|
|
@@ -3100,10 +2963,10 @@ function createUnlocalizableLoader(returnUnlocalizedKeys = false) {
|
|
|
3100
2963
|
},
|
|
3101
2964
|
async push(locale, data, originalInput) {
|
|
3102
2965
|
const unlocalizableKeys = _getUnlocalizableKeys(originalInput);
|
|
3103
|
-
const result =
|
|
2966
|
+
const result = _10.merge(
|
|
3104
2967
|
{},
|
|
3105
2968
|
data,
|
|
3106
|
-
|
|
2969
|
+
_10.omitBy(originalInput, (_35, key) => !unlocalizableKeys.includes(key))
|
|
3107
2970
|
);
|
|
3108
2971
|
return result;
|
|
3109
2972
|
}
|
|
@@ -3117,12 +2980,12 @@ function _isIsoDate(v) {
|
|
|
3117
2980
|
}
|
|
3118
2981
|
function _getUnlocalizableKeys(input2) {
|
|
3119
2982
|
const rules = {
|
|
3120
|
-
isEmpty: (v) =>
|
|
2983
|
+
isEmpty: (v) => _10.isEmpty(v),
|
|
3121
2984
|
isNumber: (v) => typeof v === "number" || /^[0-9]+$/.test(v),
|
|
3122
|
-
isBoolean: (v) =>
|
|
3123
|
-
isIsoDate: (v) =>
|
|
3124
|
-
isSystemId: (v) =>
|
|
3125
|
-
isUrl: (v) =>
|
|
2985
|
+
isBoolean: (v) => _10.isBoolean(v),
|
|
2986
|
+
isIsoDate: (v) => _10.isString(v) && _isIsoDate(v),
|
|
2987
|
+
isSystemId: (v) => _10.isString(v) && _isSystemId(v),
|
|
2988
|
+
isUrl: (v) => _10.isString(v) && _isUrl(v)
|
|
3126
2989
|
};
|
|
3127
2990
|
if (!input2) {
|
|
3128
2991
|
return [];
|
|
@@ -3301,7 +3164,7 @@ function createFormatterLoader(formatterType, parser, bucketPathPattern) {
|
|
|
3301
3164
|
}
|
|
3302
3165
|
|
|
3303
3166
|
// src/cli/loaders/po/index.ts
|
|
3304
|
-
import
|
|
3167
|
+
import _11 from "lodash";
|
|
3305
3168
|
import gettextParser from "gettext-parser";
|
|
3306
3169
|
function createPoLoader(params = { multiline: false }) {
|
|
3307
3170
|
return composeLoaders(createPoDataLoader(params), createPoContentLoader());
|
|
@@ -3317,7 +3180,7 @@ function createPoDataLoader(params) {
|
|
|
3317
3180
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
3318
3181
|
continue;
|
|
3319
3182
|
}
|
|
3320
|
-
const contextKey =
|
|
3183
|
+
const contextKey = _11.keys(sectionPo.translations)[0];
|
|
3321
3184
|
const entries = sectionPo.translations[contextKey];
|
|
3322
3185
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
3323
3186
|
if (msgid && entry.msgid) {
|
|
@@ -3339,13 +3202,13 @@ function createPoDataLoader(params) {
|
|
|
3339
3202
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
3340
3203
|
return null;
|
|
3341
3204
|
}
|
|
3342
|
-
const contextKey =
|
|
3205
|
+
const contextKey = _11.keys(sectionPo.translations)[0];
|
|
3343
3206
|
const entries = sectionPo.translations[contextKey];
|
|
3344
3207
|
const msgid = Object.keys(entries).find((key) => entries[key].msgid);
|
|
3345
3208
|
if (!msgid) {
|
|
3346
3209
|
const currentSection = currentSections.find((cs) => {
|
|
3347
3210
|
const csPo = gettextParser.po.parse(cs);
|
|
3348
|
-
const csContextKey =
|
|
3211
|
+
const csContextKey = _11.keys(csPo.translations)[0];
|
|
3349
3212
|
const csEntries = csPo.translations[csContextKey];
|
|
3350
3213
|
const csMsgid = Object.keys(csEntries).find(
|
|
3351
3214
|
(key) => csEntries[key].msgid
|
|
@@ -3358,7 +3221,7 @@ function createPoDataLoader(params) {
|
|
|
3358
3221
|
return section;
|
|
3359
3222
|
}
|
|
3360
3223
|
if (data[msgid]) {
|
|
3361
|
-
const updatedPo =
|
|
3224
|
+
const updatedPo = _11.merge({}, sectionPo, {
|
|
3362
3225
|
translations: {
|
|
3363
3226
|
[contextKey]: {
|
|
3364
3227
|
[msgid]: {
|
|
@@ -3382,7 +3245,7 @@ function createPoDataLoader(params) {
|
|
|
3382
3245
|
function createPoContentLoader() {
|
|
3383
3246
|
return createLoader({
|
|
3384
3247
|
async pull(locale, input2, initCtx, originalLocale) {
|
|
3385
|
-
const result =
|
|
3248
|
+
const result = _11.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => {
|
|
3386
3249
|
const singularFallback = locale === originalLocale ? entry.msgid : null;
|
|
3387
3250
|
const pluralFallback = locale === originalLocale ? entry.msgid_plural || entry.msgid : null;
|
|
3388
3251
|
const hasPlural = entry.msgstr.length > 1;
|
|
@@ -3397,7 +3260,7 @@ function createPoContentLoader() {
|
|
|
3397
3260
|
return result;
|
|
3398
3261
|
},
|
|
3399
3262
|
async push(locale, data, originalInput) {
|
|
3400
|
-
const result =
|
|
3263
|
+
const result = _11.chain(originalInput).entries().map(([, entry]) => [
|
|
3401
3264
|
entry.msgid,
|
|
3402
3265
|
{
|
|
3403
3266
|
...entry,
|
|
@@ -3940,41 +3803,41 @@ var datoSettingsSchema = Z2.object({
|
|
|
3940
3803
|
});
|
|
3941
3804
|
|
|
3942
3805
|
// src/cli/loaders/dato/filter.ts
|
|
3943
|
-
import
|
|
3806
|
+
import _12 from "lodash";
|
|
3944
3807
|
function createDatoFilterLoader() {
|
|
3945
3808
|
return createLoader({
|
|
3946
3809
|
async pull(locale, input2) {
|
|
3947
3810
|
const result = {};
|
|
3948
|
-
for (const [modelId, modelInfo] of
|
|
3811
|
+
for (const [modelId, modelInfo] of _12.entries(input2)) {
|
|
3949
3812
|
result[modelId] = {};
|
|
3950
3813
|
for (const record of modelInfo.records) {
|
|
3951
|
-
result[modelId][record.id] =
|
|
3814
|
+
result[modelId][record.id] = _12.chain(modelInfo.fields).mapKeys((field) => field.api_key).mapValues((field) => _12.get(record, [field.api_key, locale])).value();
|
|
3952
3815
|
}
|
|
3953
3816
|
}
|
|
3954
3817
|
return result;
|
|
3955
3818
|
},
|
|
3956
3819
|
async push(locale, data, originalInput, originalLocale) {
|
|
3957
|
-
const result =
|
|
3958
|
-
for (const [modelId, modelInfo] of
|
|
3820
|
+
const result = _12.cloneDeep(originalInput || {});
|
|
3821
|
+
for (const [modelId, modelInfo] of _12.entries(result)) {
|
|
3959
3822
|
for (const record of modelInfo.records) {
|
|
3960
|
-
for (const [fieldId, fieldValue] of
|
|
3823
|
+
for (const [fieldId, fieldValue] of _12.entries(record)) {
|
|
3961
3824
|
const fieldInfo = modelInfo.fields.find(
|
|
3962
3825
|
(field) => field.api_key === fieldId
|
|
3963
3826
|
);
|
|
3964
3827
|
if (fieldInfo) {
|
|
3965
|
-
const sourceFieldValue =
|
|
3966
|
-
const targetFieldValue =
|
|
3828
|
+
const sourceFieldValue = _12.get(fieldValue, [originalLocale]);
|
|
3829
|
+
const targetFieldValue = _12.get(data, [
|
|
3967
3830
|
modelId,
|
|
3968
3831
|
record.id,
|
|
3969
3832
|
fieldId
|
|
3970
3833
|
]);
|
|
3971
3834
|
if (targetFieldValue) {
|
|
3972
|
-
|
|
3835
|
+
_12.set(record, [fieldId, locale], targetFieldValue);
|
|
3973
3836
|
} else {
|
|
3974
|
-
|
|
3837
|
+
_12.set(record, [fieldId, locale], sourceFieldValue);
|
|
3975
3838
|
}
|
|
3976
|
-
|
|
3977
|
-
(loc) =>
|
|
3839
|
+
_12.chain(fieldValue).keys().reject((loc) => loc === locale || loc === originalLocale).filter((loc) => _12.isEmpty(_12.get(fieldValue, [loc]))).forEach(
|
|
3840
|
+
(loc) => _12.set(record, [fieldId, loc], sourceFieldValue)
|
|
3978
3841
|
).value();
|
|
3979
3842
|
}
|
|
3980
3843
|
}
|
|
@@ -3986,10 +3849,10 @@ function createDatoFilterLoader() {
|
|
|
3986
3849
|
}
|
|
3987
3850
|
|
|
3988
3851
|
// src/cli/loaders/dato/api.ts
|
|
3989
|
-
import
|
|
3852
|
+
import _14 from "lodash";
|
|
3990
3853
|
|
|
3991
3854
|
// src/cli/loaders/dato/_utils.ts
|
|
3992
|
-
import
|
|
3855
|
+
import _13 from "lodash";
|
|
3993
3856
|
import { buildClient } from "@datocms/cma-client-node";
|
|
3994
3857
|
function createDatoClient(params) {
|
|
3995
3858
|
if (!params.apiKey) {
|
|
@@ -4182,7 +4045,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
4182
4045
|
const result = {
|
|
4183
4046
|
models: {}
|
|
4184
4047
|
};
|
|
4185
|
-
const updatedConfig =
|
|
4048
|
+
const updatedConfig = _14.cloneDeep(config);
|
|
4186
4049
|
console.log(`Initializing DatoCMS loader...`);
|
|
4187
4050
|
const project = await dato.findProject();
|
|
4188
4051
|
const modelChoices = await getModelChoices(dato, config);
|
|
@@ -4200,7 +4063,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
4200
4063
|
delete updatedConfig.models[modelId];
|
|
4201
4064
|
}
|
|
4202
4065
|
}
|
|
4203
|
-
for (const modelId of
|
|
4066
|
+
for (const modelId of _14.keys(updatedConfig.models)) {
|
|
4204
4067
|
const { modelName, fields } = await getModelFields(dato, modelId);
|
|
4205
4068
|
if (fields.length > 0) {
|
|
4206
4069
|
result.models[modelId] = { fields: [], records: [] };
|
|
@@ -4218,7 +4081,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
4218
4081
|
);
|
|
4219
4082
|
if (isLocalized) {
|
|
4220
4083
|
result.models[modelId].fields.push(fieldInfo);
|
|
4221
|
-
updatedConfig.models[modelId].fields =
|
|
4084
|
+
updatedConfig.models[modelId].fields = _14.uniq([
|
|
4222
4085
|
...updatedConfig.models[modelId].fields || [],
|
|
4223
4086
|
fieldInfo.api_key
|
|
4224
4087
|
]);
|
|
@@ -4246,7 +4109,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
4246
4109
|
},
|
|
4247
4110
|
async pull(locale, input2, initCtx) {
|
|
4248
4111
|
const result = {};
|
|
4249
|
-
for (const modelId of
|
|
4112
|
+
for (const modelId of _14.keys(initCtx?.models || {})) {
|
|
4250
4113
|
let records = initCtx?.models[modelId].records || [];
|
|
4251
4114
|
const recordIds = records.map((record) => record.id);
|
|
4252
4115
|
records = await dato.findRecords(recordIds);
|
|
@@ -4261,7 +4124,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
4261
4124
|
return result;
|
|
4262
4125
|
},
|
|
4263
4126
|
async push(locale, data, originalInput) {
|
|
4264
|
-
for (const modelId of
|
|
4127
|
+
for (const modelId of _14.keys(data)) {
|
|
4265
4128
|
for (let i = 0; i < data[modelId].records.length; i++) {
|
|
4266
4129
|
const record = data[modelId].records[i];
|
|
4267
4130
|
console.log(
|
|
@@ -4277,7 +4140,7 @@ async function getModelFields(dato, modelId) {
|
|
|
4277
4140
|
const modelInfo = await dato.findModel(modelId);
|
|
4278
4141
|
return {
|
|
4279
4142
|
modelName: modelInfo.name,
|
|
4280
|
-
fields:
|
|
4143
|
+
fields: _14.filter(modelInfo.fields, (field) => field.type === "field")
|
|
4281
4144
|
};
|
|
4282
4145
|
}
|
|
4283
4146
|
async function getFieldDetails(dato, fields) {
|
|
@@ -4357,17 +4220,17 @@ async function promptModelSelection(choices) {
|
|
|
4357
4220
|
}
|
|
4358
4221
|
|
|
4359
4222
|
// src/cli/loaders/dato/extract.ts
|
|
4360
|
-
import
|
|
4223
|
+
import _15 from "lodash";
|
|
4361
4224
|
function createDatoExtractLoader() {
|
|
4362
4225
|
return createLoader({
|
|
4363
4226
|
async pull(locale, input2) {
|
|
4364
4227
|
const result = {};
|
|
4365
|
-
for (const [modelId, modelInfo] of
|
|
4366
|
-
for (const [recordId, record] of
|
|
4367
|
-
for (const [fieldName, fieldValue] of
|
|
4228
|
+
for (const [modelId, modelInfo] of _15.entries(input2)) {
|
|
4229
|
+
for (const [recordId, record] of _15.entries(modelInfo)) {
|
|
4230
|
+
for (const [fieldName, fieldValue] of _15.entries(record)) {
|
|
4368
4231
|
const parsedValue = createParsedDatoValue(fieldValue);
|
|
4369
4232
|
if (parsedValue) {
|
|
4370
|
-
|
|
4233
|
+
_15.set(result, [modelId, `_${recordId}`, fieldName], parsedValue);
|
|
4371
4234
|
}
|
|
4372
4235
|
}
|
|
4373
4236
|
}
|
|
@@ -4375,12 +4238,12 @@ function createDatoExtractLoader() {
|
|
|
4375
4238
|
return result;
|
|
4376
4239
|
},
|
|
4377
4240
|
async push(locale, data, originalInput) {
|
|
4378
|
-
const result =
|
|
4379
|
-
for (const [modelId, modelInfo] of
|
|
4380
|
-
for (const [virtualRecordId, record] of
|
|
4381
|
-
for (const [fieldName, fieldValue] of
|
|
4241
|
+
const result = _15.cloneDeep(originalInput || {});
|
|
4242
|
+
for (const [modelId, modelInfo] of _15.entries(data)) {
|
|
4243
|
+
for (const [virtualRecordId, record] of _15.entries(modelInfo)) {
|
|
4244
|
+
for (const [fieldName, fieldValue] of _15.entries(record)) {
|
|
4382
4245
|
const [, recordId] = virtualRecordId.split("_");
|
|
4383
|
-
const originalFieldValue =
|
|
4246
|
+
const originalFieldValue = _15.get(originalInput, [
|
|
4384
4247
|
modelId,
|
|
4385
4248
|
recordId,
|
|
4386
4249
|
fieldName
|
|
@@ -4390,7 +4253,7 @@ function createDatoExtractLoader() {
|
|
|
4390
4253
|
originalFieldValue,
|
|
4391
4254
|
true
|
|
4392
4255
|
);
|
|
4393
|
-
|
|
4256
|
+
_15.set(
|
|
4394
4257
|
result,
|
|
4395
4258
|
[modelId, recordId, fieldName],
|
|
4396
4259
|
rawValue || originalFieldValue
|
|
@@ -4403,25 +4266,25 @@ function createDatoExtractLoader() {
|
|
|
4403
4266
|
});
|
|
4404
4267
|
}
|
|
4405
4268
|
function detectDatoFieldType(rawDatoValue) {
|
|
4406
|
-
if (
|
|
4269
|
+
if (_15.has(rawDatoValue, "document") && _15.get(rawDatoValue, "schema") === "dast") {
|
|
4407
4270
|
return "structured_text";
|
|
4408
|
-
} else if (
|
|
4271
|
+
} else if (_15.has(rawDatoValue, "no_index") || _15.has(rawDatoValue, "twitter_card")) {
|
|
4409
4272
|
return "seo";
|
|
4410
|
-
} else if (
|
|
4273
|
+
} else if (_15.get(rawDatoValue, "type") === "item") {
|
|
4411
4274
|
return "single_block";
|
|
4412
|
-
} else if (
|
|
4275
|
+
} else if (_15.isArray(rawDatoValue) && _15.every(rawDatoValue, (item) => _15.get(item, "type") === "item")) {
|
|
4413
4276
|
return "rich_text";
|
|
4414
4277
|
} else if (_isFile(rawDatoValue)) {
|
|
4415
4278
|
return "file";
|
|
4416
|
-
} else if (
|
|
4279
|
+
} else if (_15.isArray(rawDatoValue) && _15.every(rawDatoValue, (item) => _isFile(item))) {
|
|
4417
4280
|
return "gallery";
|
|
4418
4281
|
} else if (_isJson(rawDatoValue)) {
|
|
4419
4282
|
return "json";
|
|
4420
|
-
} else if (
|
|
4283
|
+
} else if (_15.isString(rawDatoValue)) {
|
|
4421
4284
|
return "string";
|
|
4422
4285
|
} else if (_isVideo(rawDatoValue)) {
|
|
4423
4286
|
return "video";
|
|
4424
|
-
} else if (
|
|
4287
|
+
} else if (_15.isArray(rawDatoValue) && _15.every(rawDatoValue, (item) => _15.isString(item))) {
|
|
4425
4288
|
return "ref_list";
|
|
4426
4289
|
} else {
|
|
4427
4290
|
return null;
|
|
@@ -4491,9 +4354,9 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
4491
4354
|
acc
|
|
4492
4355
|
);
|
|
4493
4356
|
}
|
|
4494
|
-
if (!
|
|
4357
|
+
if (!_15.isNil(node.value)) {
|
|
4495
4358
|
acc[[...path19, "value"].join(".")] = node.value;
|
|
4496
|
-
} else if (
|
|
4359
|
+
} else if (_15.get(node, "type") === "block") {
|
|
4497
4360
|
acc[[...path19, "item"].join(".")] = serializeBlock(node.item);
|
|
4498
4361
|
}
|
|
4499
4362
|
if (node.children) {
|
|
@@ -4509,48 +4372,48 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
4509
4372
|
}
|
|
4510
4373
|
}
|
|
4511
4374
|
function serializeSeo(rawSeo) {
|
|
4512
|
-
return
|
|
4375
|
+
return _15.chain(rawSeo).pick(["title", "description"]).value();
|
|
4513
4376
|
}
|
|
4514
4377
|
function serializeBlock(rawBlock) {
|
|
4515
|
-
if (
|
|
4378
|
+
if (_15.get(rawBlock, "type") === "item" && _15.has(rawBlock, "id")) {
|
|
4516
4379
|
return serializeBlock(rawBlock.attributes);
|
|
4517
4380
|
}
|
|
4518
4381
|
const result = {};
|
|
4519
|
-
for (const [attributeName, attributeValue] of
|
|
4382
|
+
for (const [attributeName, attributeValue] of _15.entries(rawBlock)) {
|
|
4520
4383
|
result[attributeName] = createParsedDatoValue(attributeValue);
|
|
4521
4384
|
}
|
|
4522
4385
|
return result;
|
|
4523
4386
|
}
|
|
4524
4387
|
function serializeBlockList(rawBlockList) {
|
|
4525
|
-
return
|
|
4388
|
+
return _15.chain(rawBlockList).map((block) => serializeBlock(block)).value();
|
|
4526
4389
|
}
|
|
4527
4390
|
function serializeVideo(rawVideo) {
|
|
4528
|
-
return
|
|
4391
|
+
return _15.chain(rawVideo).pick(["title"]).value();
|
|
4529
4392
|
}
|
|
4530
4393
|
function serializeFile(rawFile) {
|
|
4531
|
-
return
|
|
4394
|
+
return _15.chain(rawFile).pick(["alt", "title"]).value();
|
|
4532
4395
|
}
|
|
4533
4396
|
function serializeGallery(rawGallery) {
|
|
4534
|
-
return
|
|
4397
|
+
return _15.chain(rawGallery).map((item) => serializeFile(item)).value();
|
|
4535
4398
|
}
|
|
4536
4399
|
function deserializeFile(parsedFile, originalRawFile) {
|
|
4537
|
-
return
|
|
4400
|
+
return _15.chain(parsedFile).defaults(originalRawFile).value();
|
|
4538
4401
|
}
|
|
4539
4402
|
function deserializeGallery(parsedGallery, originalRawGallery) {
|
|
4540
|
-
return
|
|
4403
|
+
return _15.chain(parsedGallery).map((item, i) => deserializeFile(item, originalRawGallery[i])).value();
|
|
4541
4404
|
}
|
|
4542
4405
|
function deserializeVideo(parsedVideo, originalRawVideo) {
|
|
4543
|
-
return
|
|
4406
|
+
return _15.chain(parsedVideo).defaults(originalRawVideo).value();
|
|
4544
4407
|
}
|
|
4545
4408
|
function deserializeBlock(payload, rawNode, isClean = false) {
|
|
4546
|
-
const result =
|
|
4547
|
-
for (const [attributeName, attributeValue] of
|
|
4409
|
+
const result = _15.cloneDeep(rawNode);
|
|
4410
|
+
for (const [attributeName, attributeValue] of _15.entries(rawNode.attributes)) {
|
|
4548
4411
|
const rawValue = createRawDatoValue(
|
|
4549
4412
|
payload[attributeName],
|
|
4550
4413
|
attributeValue,
|
|
4551
4414
|
isClean
|
|
4552
4415
|
);
|
|
4553
|
-
|
|
4416
|
+
_15.set(result, ["attributes", attributeName], rawValue);
|
|
4554
4417
|
}
|
|
4555
4418
|
if (isClean) {
|
|
4556
4419
|
delete result["id"];
|
|
@@ -4558,40 +4421,40 @@ function deserializeBlock(payload, rawNode, isClean = false) {
|
|
|
4558
4421
|
return result;
|
|
4559
4422
|
}
|
|
4560
4423
|
function deserializeSeo(parsedSeo, originalRawSeo) {
|
|
4561
|
-
return
|
|
4424
|
+
return _15.chain(parsedSeo).pick(["title", "description"]).defaults(originalRawSeo).value();
|
|
4562
4425
|
}
|
|
4563
4426
|
function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = false) {
|
|
4564
|
-
return
|
|
4427
|
+
return _15.chain(parsedBlockList).map(
|
|
4565
4428
|
(block, i) => deserializeBlock(block, originalRawBlockList[i], isClean)
|
|
4566
4429
|
).value();
|
|
4567
4430
|
}
|
|
4568
4431
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
4569
|
-
const result =
|
|
4570
|
-
for (const [path19, value] of
|
|
4571
|
-
const realPath =
|
|
4432
|
+
const result = _15.cloneDeep(originalRawStructuredText);
|
|
4433
|
+
for (const [path19, value] of _15.entries(parsedStructuredText)) {
|
|
4434
|
+
const realPath = _15.chain(path19.split(".")).flatMap((s) => !_15.isNaN(_15.toNumber(s)) ? ["children", s] : s).value();
|
|
4572
4435
|
const deserializedValue = createRawDatoValue(
|
|
4573
4436
|
value,
|
|
4574
|
-
|
|
4437
|
+
_15.get(originalRawStructuredText, realPath),
|
|
4575
4438
|
true
|
|
4576
4439
|
);
|
|
4577
|
-
|
|
4440
|
+
_15.set(result, realPath, deserializedValue);
|
|
4578
4441
|
}
|
|
4579
4442
|
return result;
|
|
4580
4443
|
}
|
|
4581
4444
|
function _isJson(rawDatoValue) {
|
|
4582
4445
|
try {
|
|
4583
|
-
return
|
|
4446
|
+
return _15.isString(rawDatoValue) && rawDatoValue.startsWith("{") && rawDatoValue.endsWith("}") && !!JSON.parse(rawDatoValue);
|
|
4584
4447
|
} catch (e) {
|
|
4585
4448
|
return false;
|
|
4586
4449
|
}
|
|
4587
4450
|
}
|
|
4588
4451
|
function _isFile(rawDatoValue) {
|
|
4589
|
-
return
|
|
4590
|
-
(key) =>
|
|
4452
|
+
return _15.isObject(rawDatoValue) && ["alt", "title", "custom_data", "focal_point", "upload_id"].every(
|
|
4453
|
+
(key) => _15.has(rawDatoValue, key)
|
|
4591
4454
|
);
|
|
4592
4455
|
}
|
|
4593
4456
|
function _isVideo(rawDatoValue) {
|
|
4594
|
-
return
|
|
4457
|
+
return _15.isObject(rawDatoValue) && [
|
|
4595
4458
|
"url",
|
|
4596
4459
|
"title",
|
|
4597
4460
|
"width",
|
|
@@ -4599,7 +4462,7 @@ function _isVideo(rawDatoValue) {
|
|
|
4599
4462
|
"provider",
|
|
4600
4463
|
"provider_uid",
|
|
4601
4464
|
"thumbnail_url"
|
|
4602
|
-
].every((key) =>
|
|
4465
|
+
].every((key) => _15.has(rawDatoValue, key));
|
|
4603
4466
|
}
|
|
4604
4467
|
|
|
4605
4468
|
// src/cli/loaders/dato/index.ts
|
|
@@ -4669,7 +4532,7 @@ function createVttLoader() {
|
|
|
4669
4532
|
}
|
|
4670
4533
|
|
|
4671
4534
|
// src/cli/loaders/variable/index.ts
|
|
4672
|
-
import
|
|
4535
|
+
import _16 from "lodash";
|
|
4673
4536
|
function createVariableLoader(params) {
|
|
4674
4537
|
return composeLoaders(variableExtractLoader(params), variableContentLoader());
|
|
4675
4538
|
}
|
|
@@ -4678,7 +4541,7 @@ function variableExtractLoader(params) {
|
|
|
4678
4541
|
return createLoader({
|
|
4679
4542
|
pull: async (locale, input2, initXtx, originalLocale, originalInput) => {
|
|
4680
4543
|
const result = {};
|
|
4681
|
-
const inputValues =
|
|
4544
|
+
const inputValues = _16.omitBy(input2, _16.isEmpty);
|
|
4682
4545
|
for (const [key, value] of Object.entries(inputValues)) {
|
|
4683
4546
|
const originalValue = originalInput[key];
|
|
4684
4547
|
const matches = originalValue.match(specifierPattern) || [];
|
|
@@ -4714,11 +4577,11 @@ function variableExtractLoader(params) {
|
|
|
4714
4577
|
function variableContentLoader() {
|
|
4715
4578
|
return createLoader({
|
|
4716
4579
|
pull: async (locale, input2) => {
|
|
4717
|
-
const result =
|
|
4580
|
+
const result = _16.mapValues(input2, (payload) => payload.value);
|
|
4718
4581
|
return result;
|
|
4719
4582
|
},
|
|
4720
4583
|
push: async (locale, data, originalInput, defaultLocale, pullInput) => {
|
|
4721
|
-
const result =
|
|
4584
|
+
const result = _16.cloneDeep(
|
|
4722
4585
|
originalInput || {}
|
|
4723
4586
|
);
|
|
4724
4587
|
for (const [key, originalValueObj] of Object.entries(result)) {
|
|
@@ -4743,20 +4606,20 @@ function getFormatSpecifierPattern(type) {
|
|
|
4743
4606
|
}
|
|
4744
4607
|
|
|
4745
4608
|
// src/cli/loaders/sync.ts
|
|
4746
|
-
import
|
|
4609
|
+
import _17 from "lodash";
|
|
4747
4610
|
function createSyncLoader() {
|
|
4748
4611
|
return createLoader({
|
|
4749
4612
|
async pull(locale, input2, initCtx, originalLocale, originalInput) {
|
|
4750
4613
|
if (!originalInput) {
|
|
4751
4614
|
return input2;
|
|
4752
4615
|
}
|
|
4753
|
-
return
|
|
4616
|
+
return _17.chain(originalInput).mapValues((value, key) => input2[key]).value();
|
|
4754
4617
|
},
|
|
4755
4618
|
async push(locale, data, originalInput) {
|
|
4756
4619
|
if (!originalInput) {
|
|
4757
4620
|
return data;
|
|
4758
4621
|
}
|
|
4759
|
-
return
|
|
4622
|
+
return _17.chain(originalInput || {}).mapValues((value, key) => data[key]).value();
|
|
4760
4623
|
}
|
|
4761
4624
|
});
|
|
4762
4625
|
}
|
|
@@ -4938,7 +4801,7 @@ function parseVueFile(input2) {
|
|
|
4938
4801
|
|
|
4939
4802
|
// src/cli/loaders/typescript/index.ts
|
|
4940
4803
|
import { parse as parse3 } from "@babel/parser";
|
|
4941
|
-
import
|
|
4804
|
+
import _18 from "lodash";
|
|
4942
4805
|
import babelTraverseModule from "@babel/traverse";
|
|
4943
4806
|
import * as t from "@babel/types";
|
|
4944
4807
|
import babelGenerateModule from "@babel/generator";
|
|
@@ -4974,7 +4837,7 @@ function createTypescriptLoader() {
|
|
|
4974
4837
|
},
|
|
4975
4838
|
push: async (locale, data, originalInput, defaultLocale, pullInput, pullOutput) => {
|
|
4976
4839
|
const ast = parseTypeScript(originalInput || "");
|
|
4977
|
-
const finalData =
|
|
4840
|
+
const finalData = _18.merge({}, pullOutput, data);
|
|
4978
4841
|
updateStringsInDefaultExport(ast, finalData);
|
|
4979
4842
|
const { code } = generate(ast, {
|
|
4980
4843
|
jsescOption: {
|
|
@@ -5175,7 +5038,7 @@ function getPropertyKey(prop) {
|
|
|
5175
5038
|
}
|
|
5176
5039
|
|
|
5177
5040
|
// src/cli/loaders/inject-locale.ts
|
|
5178
|
-
import
|
|
5041
|
+
import _19 from "lodash";
|
|
5179
5042
|
|
|
5180
5043
|
// ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
5181
5044
|
var balanced = (a, b, str) => {
|
|
@@ -6723,7 +6586,7 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
6723
6586
|
return data;
|
|
6724
6587
|
}
|
|
6725
6588
|
const omitKeys = _getKeysWithLocales(data, injectLocaleKeys, locale);
|
|
6726
|
-
const result =
|
|
6589
|
+
const result = _19.omit(data, omitKeys);
|
|
6727
6590
|
return result;
|
|
6728
6591
|
},
|
|
6729
6592
|
async push(locale, data, originalInput, originalLocale) {
|
|
@@ -6736,7 +6599,7 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
6736
6599
|
originalLocale
|
|
6737
6600
|
);
|
|
6738
6601
|
localeKeys.forEach((key) => {
|
|
6739
|
-
|
|
6602
|
+
_19.set(data, key, locale);
|
|
6740
6603
|
});
|
|
6741
6604
|
return data;
|
|
6742
6605
|
}
|
|
@@ -6745,7 +6608,7 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
6745
6608
|
function _getKeysWithLocales(data, injectLocaleKeys, locale) {
|
|
6746
6609
|
const allKeys = _getAllKeys(data);
|
|
6747
6610
|
return allKeys.filter((key) => {
|
|
6748
|
-
return injectLocaleKeys.some((pattern) => minimatch(key, pattern)) &&
|
|
6611
|
+
return injectLocaleKeys.some((pattern) => minimatch(key, pattern)) && _19.get(data, key) === locale;
|
|
6749
6612
|
});
|
|
6750
6613
|
}
|
|
6751
6614
|
function _getAllKeys(obj, prefix = "") {
|
|
@@ -6763,23 +6626,36 @@ function _getAllKeys(obj, prefix = "") {
|
|
|
6763
6626
|
}
|
|
6764
6627
|
|
|
6765
6628
|
// src/cli/loaders/locked-keys.ts
|
|
6766
|
-
import
|
|
6629
|
+
import _20 from "lodash";
|
|
6630
|
+
|
|
6631
|
+
// src/cli/utils/key-matching.ts
|
|
6632
|
+
function matchesKeyPattern(key, patterns) {
|
|
6633
|
+
return patterns.some(
|
|
6634
|
+
(pattern) => key.startsWith(pattern) || minimatch(key, pattern)
|
|
6635
|
+
);
|
|
6636
|
+
}
|
|
6637
|
+
function formatDisplayValue(value, maxLength = 50) {
|
|
6638
|
+
if (typeof value === "string") {
|
|
6639
|
+
return value.length > maxLength ? `${value.substring(0, maxLength)}...` : value;
|
|
6640
|
+
}
|
|
6641
|
+
return JSON.stringify(value);
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6644
|
+
// src/cli/loaders/locked-keys.ts
|
|
6767
6645
|
function createLockedKeysLoader(lockedKeys) {
|
|
6768
6646
|
return createLoader({
|
|
6769
6647
|
pull: async (locale, data) => {
|
|
6770
|
-
return
|
|
6648
|
+
return _20.pickBy(
|
|
6649
|
+
data,
|
|
6650
|
+
(value, key) => !matchesKeyPattern(key, lockedKeys)
|
|
6651
|
+
);
|
|
6771
6652
|
},
|
|
6772
6653
|
push: async (locale, data, originalInput) => {
|
|
6773
|
-
const lockedSubObject =
|
|
6774
|
-
return
|
|
6654
|
+
const lockedSubObject = _20.chain(originalInput).pickBy((value, key) => matchesKeyPattern(key, lockedKeys)).value();
|
|
6655
|
+
return _20.merge({}, data, lockedSubObject);
|
|
6775
6656
|
}
|
|
6776
6657
|
});
|
|
6777
6658
|
}
|
|
6778
|
-
function _isLockedKey(key, lockedKeys) {
|
|
6779
|
-
return lockedKeys.some(
|
|
6780
|
-
(lockedKey) => key.startsWith(lockedKey) || minimatch(key, lockedKey)
|
|
6781
|
-
);
|
|
6782
|
-
}
|
|
6783
6659
|
|
|
6784
6660
|
// src/cli/loaders/mdx2/frontmatter-split.ts
|
|
6785
6661
|
import matter2 from "gray-matter";
|
|
@@ -6828,7 +6704,7 @@ function md5(input2) {
|
|
|
6828
6704
|
}
|
|
6829
6705
|
|
|
6830
6706
|
// src/cli/loaders/mdx2/code-placeholder.ts
|
|
6831
|
-
import
|
|
6707
|
+
import _21 from "lodash";
|
|
6832
6708
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
6833
6709
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
6834
6710
|
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
@@ -6851,7 +6727,7 @@ ${match2}
|
|
|
6851
6727
|
found = true;
|
|
6852
6728
|
}
|
|
6853
6729
|
} while (found);
|
|
6854
|
-
content =
|
|
6730
|
+
content = _21.chain(content).split("\n\n").map((section) => _21.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
6855
6731
|
return content;
|
|
6856
6732
|
}
|
|
6857
6733
|
function ensureTrailingFenceNewline(_content) {
|
|
@@ -6873,7 +6749,7 @@ ${match2}
|
|
|
6873
6749
|
found = true;
|
|
6874
6750
|
}
|
|
6875
6751
|
} while (found);
|
|
6876
|
-
content =
|
|
6752
|
+
content = _21.chain(content).split("\n\n").map((section) => _21.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
6877
6753
|
return content;
|
|
6878
6754
|
}
|
|
6879
6755
|
function extractCodePlaceholders(content) {
|
|
@@ -6915,7 +6791,7 @@ function createMdxCodePlaceholderLoader() {
|
|
|
6915
6791
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
6916
6792
|
const sourceInfo = extractCodePlaceholders(originalInput ?? "");
|
|
6917
6793
|
const currentInfo = extractCodePlaceholders(pullInput ?? "");
|
|
6918
|
-
const codePlaceholders =
|
|
6794
|
+
const codePlaceholders = _21.merge(
|
|
6919
6795
|
sourceInfo.codePlaceholders,
|
|
6920
6796
|
currentInfo.codePlaceholders,
|
|
6921
6797
|
globalPlaceholderRegistry
|
|
@@ -6923,7 +6799,7 @@ function createMdxCodePlaceholderLoader() {
|
|
|
6923
6799
|
);
|
|
6924
6800
|
let result = data;
|
|
6925
6801
|
for (const [placeholder, original] of Object.entries(codePlaceholders)) {
|
|
6926
|
-
const replacement = original.startsWith(">") ?
|
|
6802
|
+
const replacement = original.startsWith(">") ? _21.trimStart(original, "> ") : original;
|
|
6927
6803
|
result = result.replaceAll(placeholder, replacement);
|
|
6928
6804
|
}
|
|
6929
6805
|
return result;
|
|
@@ -6951,11 +6827,11 @@ function createLocalizableMdxDocumentLoader() {
|
|
|
6951
6827
|
}
|
|
6952
6828
|
|
|
6953
6829
|
// src/cli/loaders/mdx2/sections-split-2.ts
|
|
6954
|
-
import
|
|
6830
|
+
import _22 from "lodash";
|
|
6955
6831
|
function createMdxSectionsSplit2Loader() {
|
|
6956
6832
|
return createLoader({
|
|
6957
6833
|
async pull(locale, input2) {
|
|
6958
|
-
const sections =
|
|
6834
|
+
const sections = _22.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
|
|
6959
6835
|
const result = {
|
|
6960
6836
|
frontmatter: input2.frontmatter,
|
|
6961
6837
|
sections
|
|
@@ -6963,7 +6839,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
6963
6839
|
return result;
|
|
6964
6840
|
},
|
|
6965
6841
|
async push(locale, data, originalInput, _originalLocale, pullInput) {
|
|
6966
|
-
const content =
|
|
6842
|
+
const content = _22.chain(data.sections).values().join("\n\n").value();
|
|
6967
6843
|
const result = {
|
|
6968
6844
|
frontmatter: data.frontmatter,
|
|
6969
6845
|
codePlaceholders: pullInput?.codePlaceholders || {},
|
|
@@ -7029,31 +6905,26 @@ function createMdxLockedPatternsLoader(defaultPatterns) {
|
|
|
7029
6905
|
}
|
|
7030
6906
|
|
|
7031
6907
|
// src/cli/loaders/ignored-keys.ts
|
|
7032
|
-
import
|
|
6908
|
+
import _23 from "lodash";
|
|
7033
6909
|
function createIgnoredKeysLoader(ignoredKeys) {
|
|
7034
6910
|
return createLoader({
|
|
7035
6911
|
pull: async (locale, data) => {
|
|
7036
|
-
const result =
|
|
6912
|
+
const result = _23.omitBy(
|
|
7037
6913
|
data,
|
|
7038
|
-
(value, key) =>
|
|
6914
|
+
(value, key) => matchesKeyPattern(key, ignoredKeys)
|
|
7039
6915
|
);
|
|
7040
6916
|
return result;
|
|
7041
6917
|
},
|
|
7042
6918
|
push: async (locale, data, originalInput, originalLocale, pullInput) => {
|
|
7043
|
-
const ignoredSubObject =
|
|
6919
|
+
const ignoredSubObject = _23.pickBy(
|
|
7044
6920
|
pullInput,
|
|
7045
|
-
(value, key) =>
|
|
6921
|
+
(value, key) => matchesKeyPattern(key, ignoredKeys)
|
|
7046
6922
|
);
|
|
7047
|
-
const result =
|
|
6923
|
+
const result = _23.merge({}, data, ignoredSubObject);
|
|
7048
6924
|
return result;
|
|
7049
6925
|
}
|
|
7050
6926
|
});
|
|
7051
6927
|
}
|
|
7052
|
-
function _isIgnoredKey(key, ignoredKeys) {
|
|
7053
|
-
return ignoredKeys.some(
|
|
7054
|
-
(ignoredKey) => key.startsWith(ignoredKey) || minimatch(key, ignoredKey)
|
|
7055
|
-
);
|
|
7056
|
-
}
|
|
7057
6928
|
|
|
7058
6929
|
// src/cli/loaders/ejs.ts
|
|
7059
6930
|
function parseEjsForTranslation(input2) {
|
|
@@ -7187,7 +7058,7 @@ function createEjsLoader() {
|
|
|
7187
7058
|
}
|
|
7188
7059
|
|
|
7189
7060
|
// src/cli/loaders/ensure-key-order.ts
|
|
7190
|
-
import
|
|
7061
|
+
import _24 from "lodash";
|
|
7191
7062
|
function createEnsureKeyOrderLoader() {
|
|
7192
7063
|
return createLoader({
|
|
7193
7064
|
pull: async (_locale, input2) => {
|
|
@@ -7202,10 +7073,10 @@ function createEnsureKeyOrderLoader() {
|
|
|
7202
7073
|
});
|
|
7203
7074
|
}
|
|
7204
7075
|
function reorderKeys(data, originalInput) {
|
|
7205
|
-
if (
|
|
7076
|
+
if (_24.isArray(originalInput) && _24.isArray(data)) {
|
|
7206
7077
|
return data.map((item, idx) => reorderKeys(item, originalInput[idx] ?? {}));
|
|
7207
7078
|
}
|
|
7208
|
-
if (!
|
|
7079
|
+
if (!_24.isObject(data) || _24.isArray(data) || _24.isDate(data)) {
|
|
7209
7080
|
return data;
|
|
7210
7081
|
}
|
|
7211
7082
|
const orderedData = {};
|
|
@@ -7243,7 +7114,7 @@ function createTxtLoader() {
|
|
|
7243
7114
|
}
|
|
7244
7115
|
|
|
7245
7116
|
// src/cli/loaders/json-dictionary.ts
|
|
7246
|
-
import
|
|
7117
|
+
import _25 from "lodash";
|
|
7247
7118
|
var TOP_LEVEL_KEY = "--content--";
|
|
7248
7119
|
function createJsonDictionaryLoader() {
|
|
7249
7120
|
return createLoader({
|
|
@@ -7258,7 +7129,7 @@ function createJsonDictionaryLoader() {
|
|
|
7258
7129
|
if (!originalInput) {
|
|
7259
7130
|
throw new Error("Error while parsing json-dictionary bucket");
|
|
7260
7131
|
}
|
|
7261
|
-
const input2 =
|
|
7132
|
+
const input2 = _25.cloneDeep(originalInput);
|
|
7262
7133
|
if (Object.keys(data).length === 1 && Object.keys(data)[0] === TOP_LEVEL_KEY) {
|
|
7263
7134
|
setNestedLocale(
|
|
7264
7135
|
{ [TOP_LEVEL_KEY]: input2 },
|
|
@@ -7613,7 +7484,276 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
7613
7484
|
}
|
|
7614
7485
|
}
|
|
7615
7486
|
|
|
7487
|
+
// src/cli/cmd/show/_shared-key-command.ts
|
|
7488
|
+
async function executeKeyCommand(i18nConfig, buckets, options, config) {
|
|
7489
|
+
let hasAnyKeys = false;
|
|
7490
|
+
for (const bucket of buckets) {
|
|
7491
|
+
if (options.bucket && bucket.type !== options.bucket) {
|
|
7492
|
+
continue;
|
|
7493
|
+
}
|
|
7494
|
+
const keyPatterns = bucket[config.filterType];
|
|
7495
|
+
if (!keyPatterns || keyPatterns.length === 0) {
|
|
7496
|
+
continue;
|
|
7497
|
+
}
|
|
7498
|
+
hasAnyKeys = true;
|
|
7499
|
+
console.log(`
|
|
7500
|
+
Bucket: ${bucket.type}`);
|
|
7501
|
+
console.log(
|
|
7502
|
+
`${capitalize(config.displayName)} key patterns: ${keyPatterns.join(", ")}`
|
|
7503
|
+
);
|
|
7504
|
+
for (const bucketConfig of bucket.paths) {
|
|
7505
|
+
const sourceLocale = resolveOverriddenLocale3(
|
|
7506
|
+
i18nConfig.locale.source,
|
|
7507
|
+
bucketConfig.delimiter
|
|
7508
|
+
);
|
|
7509
|
+
const sourcePath = bucketConfig.pathPattern.replace(
|
|
7510
|
+
/\[locale\]/g,
|
|
7511
|
+
sourceLocale
|
|
7512
|
+
);
|
|
7513
|
+
try {
|
|
7514
|
+
const loader = createBucketLoader(
|
|
7515
|
+
bucket.type,
|
|
7516
|
+
bucketConfig.pathPattern,
|
|
7517
|
+
{
|
|
7518
|
+
defaultLocale: sourceLocale,
|
|
7519
|
+
injectLocale: bucket.injectLocale
|
|
7520
|
+
},
|
|
7521
|
+
[],
|
|
7522
|
+
// Don't apply any filtering when reading
|
|
7523
|
+
[],
|
|
7524
|
+
[]
|
|
7525
|
+
);
|
|
7526
|
+
loader.setDefaultLocale(sourceLocale);
|
|
7527
|
+
const data = await loader.pull(sourceLocale);
|
|
7528
|
+
if (!data || Object.keys(data).length === 0) {
|
|
7529
|
+
continue;
|
|
7530
|
+
}
|
|
7531
|
+
const matchedEntries = Object.entries(data).filter(
|
|
7532
|
+
([key]) => matchesKeyPattern(key, keyPatterns)
|
|
7533
|
+
);
|
|
7534
|
+
if (matchedEntries.length > 0) {
|
|
7535
|
+
console.log(`
|
|
7536
|
+
Matches in ${sourcePath}:`);
|
|
7537
|
+
for (const [key, value] of matchedEntries) {
|
|
7538
|
+
const displayValue = formatDisplayValue(value);
|
|
7539
|
+
console.log(` - ${key}: ${displayValue}`);
|
|
7540
|
+
}
|
|
7541
|
+
console.log(
|
|
7542
|
+
`Total: ${matchedEntries.length} ${config.displayName} key(s)`
|
|
7543
|
+
);
|
|
7544
|
+
}
|
|
7545
|
+
} catch (error) {
|
|
7546
|
+
console.error(` Error reading ${sourcePath}: ${error.message}`);
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
}
|
|
7550
|
+
if (!hasAnyKeys) {
|
|
7551
|
+
if (options.bucket) {
|
|
7552
|
+
console.log(
|
|
7553
|
+
`No ${config.displayName} keys configured for bucket: ${options.bucket}`
|
|
7554
|
+
);
|
|
7555
|
+
} else {
|
|
7556
|
+
console.log(`No ${config.displayName} keys configured in any bucket.`);
|
|
7557
|
+
}
|
|
7558
|
+
}
|
|
7559
|
+
}
|
|
7560
|
+
function capitalize(str) {
|
|
7561
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
7562
|
+
}
|
|
7563
|
+
|
|
7564
|
+
// src/cli/cmd/show/locked-keys.ts
|
|
7565
|
+
var locked_keys_default = new Command7().command("locked-keys").description(
|
|
7566
|
+
"Show which key-value pairs in source files match lockedKeys patterns"
|
|
7567
|
+
).option("--bucket <name>", "Only show locked keys for a specific bucket").helpOption("-h, --help", "Show help").action(async (options) => {
|
|
7568
|
+
const ora = Ora7();
|
|
7569
|
+
try {
|
|
7570
|
+
const i18nConfig = await getConfig();
|
|
7571
|
+
if (!i18nConfig) {
|
|
7572
|
+
throw new CLIError({
|
|
7573
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
7574
|
+
docUrl: "i18nNotFound"
|
|
7575
|
+
});
|
|
7576
|
+
}
|
|
7577
|
+
const buckets = getBuckets(i18nConfig);
|
|
7578
|
+
await executeKeyCommand(i18nConfig, buckets, options, {
|
|
7579
|
+
filterType: "lockedKeys",
|
|
7580
|
+
displayName: "locked"
|
|
7581
|
+
});
|
|
7582
|
+
} catch (error) {
|
|
7583
|
+
ora.fail(error.message);
|
|
7584
|
+
process.exit(1);
|
|
7585
|
+
}
|
|
7586
|
+
});
|
|
7587
|
+
|
|
7588
|
+
// src/cli/cmd/show/ignored-keys.ts
|
|
7589
|
+
import { Command as Command8 } from "interactive-commander";
|
|
7590
|
+
import Ora8 from "ora";
|
|
7591
|
+
var ignored_keys_default = new Command8().command("ignored-keys").description(
|
|
7592
|
+
"Show which key-value pairs in source files match ignoredKeys patterns"
|
|
7593
|
+
).option("--bucket <name>", "Only show ignored keys for a specific bucket").helpOption("-h, --help", "Show help").action(async (options) => {
|
|
7594
|
+
const ora = Ora8();
|
|
7595
|
+
try {
|
|
7596
|
+
const i18nConfig = await getConfig();
|
|
7597
|
+
if (!i18nConfig) {
|
|
7598
|
+
throw new CLIError({
|
|
7599
|
+
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
7600
|
+
docUrl: "i18nNotFound"
|
|
7601
|
+
});
|
|
7602
|
+
}
|
|
7603
|
+
const buckets = getBuckets(i18nConfig);
|
|
7604
|
+
await executeKeyCommand(i18nConfig, buckets, options, {
|
|
7605
|
+
filterType: "ignoredKeys",
|
|
7606
|
+
displayName: "ignored"
|
|
7607
|
+
});
|
|
7608
|
+
} catch (error) {
|
|
7609
|
+
ora.fail(error.message);
|
|
7610
|
+
process.exit(1);
|
|
7611
|
+
}
|
|
7612
|
+
});
|
|
7613
|
+
|
|
7614
|
+
// src/cli/cmd/show/index.ts
|
|
7615
|
+
var show_default = new Command9().command("show").description("Display configuration, locales, and file paths").helpOption("-h, --help", "Show help").addCommand(config_default).addCommand(locale_default).addCommand(files_default).addCommand(locked_keys_default).addCommand(ignored_keys_default);
|
|
7616
|
+
|
|
7617
|
+
// src/cli/cmd/config/index.ts
|
|
7618
|
+
import { Command as Command13 } from "interactive-commander";
|
|
7619
|
+
|
|
7620
|
+
// src/cli/cmd/config/set.ts
|
|
7621
|
+
import { Command as Command10 } from "interactive-commander";
|
|
7622
|
+
import chalk2 from "chalk";
|
|
7623
|
+
import dedent from "dedent";
|
|
7624
|
+
import _26 from "lodash";
|
|
7625
|
+
var set_default = new Command10().name("set").description("Set or update a CLI setting in ~/.lingodotdevrc").addHelpText("afterAll", `
|
|
7626
|
+
Available keys:
|
|
7627
|
+
${SETTINGS_KEYS.join("\n ")}`).argument(
|
|
7628
|
+
"<key>",
|
|
7629
|
+
"Configuration key to set (dot notation, e.g., auth.apiKey)"
|
|
7630
|
+
).argument("<value>", "The configuration value to set").helpOption("-h, --help", "Show help").action(async (key, value) => {
|
|
7631
|
+
if (!SETTINGS_KEYS.includes(key)) {
|
|
7632
|
+
console.error(
|
|
7633
|
+
dedent`
|
|
7634
|
+
${chalk2.red("\u2716")} Unknown configuration key: ${chalk2.bold(key)}
|
|
7635
|
+
Run ${chalk2.dim("lingo.dev config set --help")} to see available keys.
|
|
7636
|
+
`
|
|
7637
|
+
);
|
|
7638
|
+
process.exitCode = 1;
|
|
7639
|
+
return;
|
|
7640
|
+
}
|
|
7641
|
+
const current = loadSystemSettings();
|
|
7642
|
+
const updated = _26.cloneDeep(current);
|
|
7643
|
+
_26.set(updated, key, value);
|
|
7644
|
+
try {
|
|
7645
|
+
saveSettings(updated);
|
|
7646
|
+
console.log(`${chalk2.green("\u2714")} Set ${chalk2.bold(key)}`);
|
|
7647
|
+
} catch (err) {
|
|
7648
|
+
console.error(
|
|
7649
|
+
chalk2.red(
|
|
7650
|
+
`\u2716 Failed to save configuration: ${chalk2.dim(
|
|
7651
|
+
err instanceof Error ? err.message : String(err)
|
|
7652
|
+
)}`
|
|
7653
|
+
)
|
|
7654
|
+
);
|
|
7655
|
+
process.exitCode = 1;
|
|
7656
|
+
}
|
|
7657
|
+
});
|
|
7658
|
+
|
|
7659
|
+
// src/cli/cmd/config/unset.ts
|
|
7660
|
+
import { Command as Command11 } from "interactive-commander";
|
|
7661
|
+
import chalk3 from "chalk";
|
|
7662
|
+
import dedent2 from "dedent";
|
|
7663
|
+
import _27 from "lodash";
|
|
7664
|
+
var unset_default = new Command11().name("unset").description("Remove a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
|
|
7665
|
+
Available keys:
|
|
7666
|
+
${SETTINGS_KEYS.join("\n ")}`).argument(
|
|
7667
|
+
"<key>",
|
|
7668
|
+
"Configuration key to remove (must match one of the available keys listed below)"
|
|
7669
|
+
).helpOption("-h, --help", "Show help").action(async (key) => {
|
|
7670
|
+
if (!SETTINGS_KEYS.includes(key)) {
|
|
7671
|
+
console.error(
|
|
7672
|
+
dedent2`
|
|
7673
|
+
${chalk3.red("\u2716")} Unknown configuration key: ${chalk3.bold(key)}
|
|
7674
|
+
Run ${chalk3.dim(
|
|
7675
|
+
"lingo.dev config unset --help"
|
|
7676
|
+
)} to see available keys.
|
|
7677
|
+
`
|
|
7678
|
+
);
|
|
7679
|
+
process.exitCode = 1;
|
|
7680
|
+
return;
|
|
7681
|
+
}
|
|
7682
|
+
const settings = loadSystemSettings();
|
|
7683
|
+
const currentValue = _27.get(settings, key);
|
|
7684
|
+
if (!_27.trim(String(currentValue || ""))) {
|
|
7685
|
+
console.log(`${chalk3.cyan("\u2139")} ${chalk3.bold(key)} is not set.`);
|
|
7686
|
+
return;
|
|
7687
|
+
} else {
|
|
7688
|
+
const updated = _27.cloneDeep(settings);
|
|
7689
|
+
_27.unset(updated, key);
|
|
7690
|
+
try {
|
|
7691
|
+
saveSettings(updated);
|
|
7692
|
+
console.log(
|
|
7693
|
+
`${chalk3.green("\u2714")} Removed configuration key ${chalk3.bold(key)}`
|
|
7694
|
+
);
|
|
7695
|
+
} catch (err) {
|
|
7696
|
+
console.error(
|
|
7697
|
+
chalk3.red(
|
|
7698
|
+
`\u2716 Failed to save configuration: ${chalk3.dim(
|
|
7699
|
+
err instanceof Error ? err.message : String(err)
|
|
7700
|
+
)}`
|
|
7701
|
+
)
|
|
7702
|
+
);
|
|
7703
|
+
process.exitCode = 1;
|
|
7704
|
+
}
|
|
7705
|
+
}
|
|
7706
|
+
});
|
|
7707
|
+
|
|
7708
|
+
// src/cli/cmd/config/get.ts
|
|
7709
|
+
import { Command as Command12 } from "interactive-commander";
|
|
7710
|
+
import chalk4 from "chalk";
|
|
7711
|
+
import _28 from "lodash";
|
|
7712
|
+
import dedent3 from "dedent";
|
|
7713
|
+
var get_default = new Command12().name("get").description("Display the value of a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
|
|
7714
|
+
Available keys:
|
|
7715
|
+
${SETTINGS_KEYS.join("\n ")}`).argument(
|
|
7716
|
+
"<key>",
|
|
7717
|
+
"Configuration key to read (choose from the available keys listed below)"
|
|
7718
|
+
).helpOption("-h, --help", "Show help").action(async (key) => {
|
|
7719
|
+
if (!SETTINGS_KEYS.includes(key)) {
|
|
7720
|
+
console.error(
|
|
7721
|
+
dedent3`
|
|
7722
|
+
${chalk4.red("\u2716")} Unknown configuration key: ${chalk4.bold(key)}
|
|
7723
|
+
Run ${chalk4.dim("lingo.dev config get --help")} to see available keys.
|
|
7724
|
+
`
|
|
7725
|
+
);
|
|
7726
|
+
process.exitCode = 1;
|
|
7727
|
+
return;
|
|
7728
|
+
}
|
|
7729
|
+
const settings = loadSystemSettings();
|
|
7730
|
+
const value = _28.get(settings, key);
|
|
7731
|
+
if (!value) {
|
|
7732
|
+
console.log(`${chalk4.cyan("\u2139")} ${chalk4.bold(key)} is not set.`);
|
|
7733
|
+
return;
|
|
7734
|
+
}
|
|
7735
|
+
if (typeof value === "object") {
|
|
7736
|
+
console.log(JSON.stringify(value, null, 2));
|
|
7737
|
+
} else {
|
|
7738
|
+
console.log(value);
|
|
7739
|
+
}
|
|
7740
|
+
});
|
|
7741
|
+
|
|
7742
|
+
// src/cli/cmd/config/index.ts
|
|
7743
|
+
var config_default2 = new Command13().command("config").description(
|
|
7744
|
+
"Manage CLI settings (authentication, API keys) stored in ~/.lingodotdevrc"
|
|
7745
|
+
).helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
|
|
7746
|
+
|
|
7616
7747
|
// src/cli/cmd/i18n.ts
|
|
7748
|
+
import {
|
|
7749
|
+
bucketTypeSchema,
|
|
7750
|
+
localeCodeSchema,
|
|
7751
|
+
resolveOverriddenLocale as resolveOverriddenLocale4
|
|
7752
|
+
} from "@lingo.dev/_spec";
|
|
7753
|
+
import { Command as Command14 } from "interactive-commander";
|
|
7754
|
+
import Z3 from "zod";
|
|
7755
|
+
import _31 from "lodash";
|
|
7756
|
+
import Ora9 from "ora";
|
|
7617
7757
|
import chalk6 from "chalk";
|
|
7618
7758
|
import { createTwoFilesPatch } from "diff";
|
|
7619
7759
|
import inquirer2 from "inquirer";
|
|
@@ -8065,7 +8205,7 @@ function createDeltaProcessor(fileKey) {
|
|
|
8065
8205
|
}
|
|
8066
8206
|
|
|
8067
8207
|
// src/cli/cmd/i18n.ts
|
|
8068
|
-
var i18n_default = new
|
|
8208
|
+
var i18n_default = new Command14().command("i18n").description(
|
|
8069
8209
|
"DEPRECATED: Run localization pipeline (prefer `run` command instead)"
|
|
8070
8210
|
).helpOption("-h, --help", "Show help").option(
|
|
8071
8211
|
"--locale <locale>",
|
|
@@ -8104,7 +8244,7 @@ var i18n_default = new Command12().command("i18n").description(
|
|
|
8104
8244
|
"Stop immediately on first error instead of continuing to process remaining buckets and locales (fail-fast mode)"
|
|
8105
8245
|
).action(async function(options) {
|
|
8106
8246
|
updateGitignore();
|
|
8107
|
-
const ora =
|
|
8247
|
+
const ora = Ora9();
|
|
8108
8248
|
let flags;
|
|
8109
8249
|
try {
|
|
8110
8250
|
flags = parseFlags(options);
|
|
@@ -8193,7 +8333,7 @@ var i18n_default = new Command12().command("i18n").description(
|
|
|
8193
8333
|
ora.start("Creating i18n.lock...");
|
|
8194
8334
|
for (const bucket of buckets) {
|
|
8195
8335
|
for (const bucketPath of bucket.paths) {
|
|
8196
|
-
const sourceLocale =
|
|
8336
|
+
const sourceLocale = resolveOverriddenLocale4(
|
|
8197
8337
|
i18nConfig.locale.source,
|
|
8198
8338
|
bucketPath.delimiter
|
|
8199
8339
|
);
|
|
@@ -8228,7 +8368,7 @@ var i18n_default = new Command12().command("i18n").description(
|
|
|
8228
8368
|
let requiresUpdate = null;
|
|
8229
8369
|
bucketLoop: for (const bucket of buckets) {
|
|
8230
8370
|
for (const bucketPath of bucket.paths) {
|
|
8231
|
-
const sourceLocale =
|
|
8371
|
+
const sourceLocale = resolveOverriddenLocale4(
|
|
8232
8372
|
i18nConfig.locale.source,
|
|
8233
8373
|
bucketPath.delimiter
|
|
8234
8374
|
);
|
|
@@ -8257,7 +8397,7 @@ var i18n_default = new Command12().command("i18n").description(
|
|
|
8257
8397
|
break bucketLoop;
|
|
8258
8398
|
}
|
|
8259
8399
|
for (const _targetLocale of targetLocales) {
|
|
8260
|
-
const targetLocale =
|
|
8400
|
+
const targetLocale = resolveOverriddenLocale4(
|
|
8261
8401
|
_targetLocale,
|
|
8262
8402
|
bucketPath.delimiter
|
|
8263
8403
|
);
|
|
@@ -8312,10 +8452,10 @@ var i18n_default = new Command12().command("i18n").description(
|
|
|
8312
8452
|
console.log();
|
|
8313
8453
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
8314
8454
|
for (const bucketPath of bucket.paths) {
|
|
8315
|
-
const bucketOra =
|
|
8455
|
+
const bucketOra = Ora9({ indent: 2 }).info(
|
|
8316
8456
|
`Processing path: ${bucketPath.pathPattern}`
|
|
8317
8457
|
);
|
|
8318
|
-
const sourceLocale =
|
|
8458
|
+
const sourceLocale = resolveOverriddenLocale4(
|
|
8319
8459
|
i18nConfig.locale.source,
|
|
8320
8460
|
bucketPath.delimiter
|
|
8321
8461
|
);
|
|
@@ -8335,7 +8475,7 @@ var i18n_default = new Command12().command("i18n").description(
|
|
|
8335
8475
|
await bucketLoader.init();
|
|
8336
8476
|
let sourceData = await bucketLoader.pull(sourceLocale);
|
|
8337
8477
|
for (const _targetLocale of targetLocales) {
|
|
8338
|
-
const targetLocale =
|
|
8478
|
+
const targetLocale = resolveOverriddenLocale4(
|
|
8339
8479
|
_targetLocale,
|
|
8340
8480
|
bucketPath.delimiter
|
|
8341
8481
|
);
|
|
@@ -8717,9 +8857,9 @@ Editing value for: ${chalk6.cyan(key)}`);
|
|
|
8717
8857
|
}
|
|
8718
8858
|
|
|
8719
8859
|
// src/cli/cmd/lockfile.ts
|
|
8720
|
-
import { Command as
|
|
8860
|
+
import { Command as Command15 } from "interactive-commander";
|
|
8721
8861
|
import Z5 from "zod";
|
|
8722
|
-
import
|
|
8862
|
+
import Ora10 from "ora";
|
|
8723
8863
|
|
|
8724
8864
|
// src/cli/utils/lockfile.ts
|
|
8725
8865
|
import fs12 from "fs";
|
|
@@ -8801,15 +8941,15 @@ var LockfileSchema = Z4.object({
|
|
|
8801
8941
|
});
|
|
8802
8942
|
|
|
8803
8943
|
// src/cli/cmd/lockfile.ts
|
|
8804
|
-
import { resolveOverriddenLocale as
|
|
8805
|
-
var lockfile_default = new
|
|
8944
|
+
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
8945
|
+
var lockfile_default = new Command15().command("lockfile").description(
|
|
8806
8946
|
"Generate or refresh i18n.lock based on the current source locale content"
|
|
8807
8947
|
).helpOption("-h, --help", "Show help").option(
|
|
8808
8948
|
"-f, --force",
|
|
8809
8949
|
"Overwrite existing lockfile to reset translation tracking"
|
|
8810
8950
|
).action(async (options) => {
|
|
8811
8951
|
const flags = flagsSchema.parse(options);
|
|
8812
|
-
const ora =
|
|
8952
|
+
const ora = Ora10();
|
|
8813
8953
|
const lockfileHelper = createLockfileHelper();
|
|
8814
8954
|
if (lockfileHelper.isLockfileExists() && !flags.force) {
|
|
8815
8955
|
ora.warn(
|
|
@@ -8820,7 +8960,7 @@ var lockfile_default = new Command13().command("lockfile").description(
|
|
|
8820
8960
|
const buckets = getBuckets(i18nConfig);
|
|
8821
8961
|
for (const bucket of buckets) {
|
|
8822
8962
|
for (const bucketConfig of bucket.paths) {
|
|
8823
|
-
const sourceLocale =
|
|
8963
|
+
const sourceLocale = resolveOverriddenLocale5(
|
|
8824
8964
|
i18nConfig.locale.source,
|
|
8825
8965
|
bucketConfig.delimiter
|
|
8826
8966
|
);
|
|
@@ -8848,11 +8988,11 @@ var flagsSchema = Z5.object({
|
|
|
8848
8988
|
});
|
|
8849
8989
|
|
|
8850
8990
|
// src/cli/cmd/cleanup.ts
|
|
8851
|
-
import { resolveOverriddenLocale as
|
|
8852
|
-
import { Command as
|
|
8991
|
+
import { resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
|
|
8992
|
+
import { Command as Command16 } from "interactive-commander";
|
|
8853
8993
|
import _33 from "lodash";
|
|
8854
|
-
import
|
|
8855
|
-
var cleanup_default = new
|
|
8994
|
+
import Ora11 from "ora";
|
|
8995
|
+
var cleanup_default = new Command16().command("cleanup").description(
|
|
8856
8996
|
"Remove translation keys from target locales that no longer exist in the source locale"
|
|
8857
8997
|
).helpOption("-h, --help", "Show help").option(
|
|
8858
8998
|
"--locale <locale>",
|
|
@@ -8867,7 +9007,7 @@ var cleanup_default = new Command14().command("cleanup").description(
|
|
|
8867
9007
|
"--verbose",
|
|
8868
9008
|
"Print detailed output showing the specific keys to be removed for each locale"
|
|
8869
9009
|
).action(async function(options) {
|
|
8870
|
-
const ora =
|
|
9010
|
+
const ora = Ora11();
|
|
8871
9011
|
const results = [];
|
|
8872
9012
|
try {
|
|
8873
9013
|
ora.start("Loading configuration...");
|
|
@@ -8885,11 +9025,11 @@ var cleanup_default = new Command14().command("cleanup").description(
|
|
|
8885
9025
|
console.log();
|
|
8886
9026
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
8887
9027
|
for (const bucketConfig of bucket.paths) {
|
|
8888
|
-
const sourceLocale =
|
|
9028
|
+
const sourceLocale = resolveOverriddenLocale6(
|
|
8889
9029
|
i18nConfig.locale.source,
|
|
8890
9030
|
bucketConfig.delimiter
|
|
8891
9031
|
);
|
|
8892
|
-
const bucketOra =
|
|
9032
|
+
const bucketOra = Ora11({ indent: 2 }).info(
|
|
8893
9033
|
`Processing path: ${bucketConfig.pathPattern}`
|
|
8894
9034
|
);
|
|
8895
9035
|
const bucketLoader = createBucketLoader(
|
|
@@ -8904,7 +9044,7 @@ var cleanup_default = new Command14().command("cleanup").description(
|
|
|
8904
9044
|
const sourceData = await bucketLoader.pull(sourceLocale);
|
|
8905
9045
|
const sourceKeys = Object.keys(sourceData);
|
|
8906
9046
|
for (const _targetLocale of targetLocales) {
|
|
8907
|
-
const targetLocale =
|
|
9047
|
+
const targetLocale = resolveOverriddenLocale6(
|
|
8908
9048
|
_targetLocale,
|
|
8909
9049
|
bucketConfig.delimiter
|
|
8910
9050
|
);
|
|
@@ -8982,12 +9122,12 @@ function displaySummary(results) {
|
|
|
8982
9122
|
}
|
|
8983
9123
|
|
|
8984
9124
|
// src/cli/cmd/mcp.ts
|
|
8985
|
-
import { Command as
|
|
9125
|
+
import { Command as Command17 } from "interactive-commander";
|
|
8986
9126
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8987
9127
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8988
9128
|
import Z6 from "zod";
|
|
8989
9129
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
8990
|
-
var mcp_default = new
|
|
9130
|
+
var mcp_default = new Command17().command("mcp").description(
|
|
8991
9131
|
"Start a Model Context Protocol (MCP) server for AI assistant integration"
|
|
8992
9132
|
).helpOption("-h, --help", "Show help").action(async (_35, program) => {
|
|
8993
9133
|
const apiKey = program.args[0];
|
|
@@ -9037,7 +9177,7 @@ var mcp_default = new Command15().command("mcp").description(
|
|
|
9037
9177
|
});
|
|
9038
9178
|
|
|
9039
9179
|
// src/cli/cmd/ci/index.ts
|
|
9040
|
-
import { Command as
|
|
9180
|
+
import { Command as Command19 } from "interactive-commander";
|
|
9041
9181
|
import createOra from "ora";
|
|
9042
9182
|
|
|
9043
9183
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
@@ -9064,7 +9204,7 @@ function escapeShellArg(arg) {
|
|
|
9064
9204
|
}
|
|
9065
9205
|
|
|
9066
9206
|
// src/cli/cmd/run/index.ts
|
|
9067
|
-
import { Command as
|
|
9207
|
+
import { Command as Command18 } from "interactive-commander";
|
|
9068
9208
|
import { exec } from "child_process";
|
|
9069
9209
|
import path17 from "path";
|
|
9070
9210
|
import { fileURLToPath } from "url";
|
|
@@ -9451,7 +9591,7 @@ async function setup(input2) {
|
|
|
9451
9591
|
// src/cli/cmd/run/plan.ts
|
|
9452
9592
|
import chalk11 from "chalk";
|
|
9453
9593
|
import { Listr as Listr2 } from "listr2";
|
|
9454
|
-
import { resolveOverriddenLocale as
|
|
9594
|
+
import { resolveOverriddenLocale as resolveOverriddenLocale7 } from "@lingo.dev/_spec";
|
|
9455
9595
|
async function plan(input2) {
|
|
9456
9596
|
console.log(chalk11.hex(colors.orange)("[Planning]"));
|
|
9457
9597
|
let buckets = getBuckets(input2.config);
|
|
@@ -9532,12 +9672,12 @@ async function plan(input2) {
|
|
|
9532
9672
|
continue;
|
|
9533
9673
|
}
|
|
9534
9674
|
}
|
|
9535
|
-
const sourceLocale =
|
|
9675
|
+
const sourceLocale = resolveOverriddenLocale7(
|
|
9536
9676
|
_sourceLocale,
|
|
9537
9677
|
bucketPath.delimiter
|
|
9538
9678
|
);
|
|
9539
9679
|
for (const _targetLocale of _targetLocales) {
|
|
9540
|
-
const targetLocale =
|
|
9680
|
+
const targetLocale = resolveOverriddenLocale7(
|
|
9541
9681
|
_targetLocale,
|
|
9542
9682
|
bucketPath.delimiter
|
|
9543
9683
|
);
|
|
@@ -10029,7 +10169,7 @@ function playSound(type) {
|
|
|
10029
10169
|
setTimeout(resolve, 3e3);
|
|
10030
10170
|
});
|
|
10031
10171
|
}
|
|
10032
|
-
var run_default = new
|
|
10172
|
+
var run_default = new Command18().command("run").description("Run localization pipeline").helpOption("-h, --help", "Show help").option(
|
|
10033
10173
|
"--source-locale <source-locale>",
|
|
10034
10174
|
"Override the source locale from i18n.json for this run"
|
|
10035
10175
|
).option(
|
|
@@ -10772,7 +10912,7 @@ var getPlatformKit = () => {
|
|
|
10772
10912
|
};
|
|
10773
10913
|
|
|
10774
10914
|
// src/cli/cmd/ci/index.ts
|
|
10775
|
-
var ci_default = new
|
|
10915
|
+
var ci_default = new Command19().command("ci").description("Run localization pipeline in CI/CD environment").helpOption("-h, --help", "Show help").option(
|
|
10776
10916
|
"--parallel [boolean]",
|
|
10777
10917
|
"Process translations concurrently for faster execution. Defaults to false",
|
|
10778
10918
|
parseBooleanArg
|
|
@@ -10858,11 +10998,11 @@ function parseBooleanArg(val) {
|
|
|
10858
10998
|
import {
|
|
10859
10999
|
bucketTypeSchema as bucketTypeSchema4,
|
|
10860
11000
|
localeCodeSchema as localeCodeSchema3,
|
|
10861
|
-
resolveOverriddenLocale as
|
|
11001
|
+
resolveOverriddenLocale as resolveOverriddenLocale8
|
|
10862
11002
|
} from "@lingo.dev/_spec";
|
|
10863
|
-
import { Command as
|
|
11003
|
+
import { Command as Command20 } from "interactive-commander";
|
|
10864
11004
|
import Z11 from "zod";
|
|
10865
|
-
import
|
|
11005
|
+
import Ora12 from "ora";
|
|
10866
11006
|
import chalk14 from "chalk";
|
|
10867
11007
|
import Table from "cli-table3";
|
|
10868
11008
|
|
|
@@ -10900,7 +11040,7 @@ function checkForPendingOperations() {
|
|
|
10900
11040
|
}
|
|
10901
11041
|
|
|
10902
11042
|
// src/cli/cmd/status.ts
|
|
10903
|
-
var status_default = new
|
|
11043
|
+
var status_default = new Command20().command("status").description("Show the status of the localization process").helpOption("-h, --help", "Show help").option(
|
|
10904
11044
|
"--locale <locale>",
|
|
10905
11045
|
"Limit the report to specific target locales from i18n.json. Repeat the flag to include multiple locales. Defaults to all configured target locales",
|
|
10906
11046
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
@@ -10921,7 +11061,7 @@ var status_default = new Command18().command("status").description("Show the sta
|
|
|
10921
11061
|
"--api-key <api-key>",
|
|
10922
11062
|
"Override the API key from settings or environment variables for this run"
|
|
10923
11063
|
).action(async function(options) {
|
|
10924
|
-
const ora =
|
|
11064
|
+
const ora = Ora12();
|
|
10925
11065
|
const flags = parseFlags2(options);
|
|
10926
11066
|
let authId = null;
|
|
10927
11067
|
try {
|
|
@@ -11002,10 +11142,10 @@ var status_default = new Command18().command("status").description("Show the sta
|
|
|
11002
11142
|
console.log();
|
|
11003
11143
|
ora.info(`Analyzing bucket: ${bucket.type}`);
|
|
11004
11144
|
for (const bucketPath of bucket.paths) {
|
|
11005
|
-
const bucketOra =
|
|
11145
|
+
const bucketOra = Ora12({ indent: 2 }).info(
|
|
11006
11146
|
`Analyzing path: ${bucketPath.pathPattern}`
|
|
11007
11147
|
);
|
|
11008
|
-
const sourceLocale =
|
|
11148
|
+
const sourceLocale = resolveOverriddenLocale8(
|
|
11009
11149
|
i18nConfig.locale.source,
|
|
11010
11150
|
bucketPath.delimiter
|
|
11011
11151
|
);
|
|
@@ -11052,7 +11192,7 @@ var status_default = new Command18().command("status").description("Show the sta
|
|
|
11052
11192
|
}
|
|
11053
11193
|
fileStats[filePath].wordCount = sourceWordCount;
|
|
11054
11194
|
for (const _targetLocale of targetLocales) {
|
|
11055
|
-
const targetLocale =
|
|
11195
|
+
const targetLocale = resolveOverriddenLocale8(
|
|
11056
11196
|
_targetLocale,
|
|
11057
11197
|
bucketPath.delimiter
|
|
11058
11198
|
);
|
|
@@ -11403,7 +11543,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
11403
11543
|
}
|
|
11404
11544
|
|
|
11405
11545
|
// src/cli/cmd/may-the-fourth.ts
|
|
11406
|
-
import { Command as
|
|
11546
|
+
import { Command as Command21 } from "interactive-commander";
|
|
11407
11547
|
import * as cp from "node:child_process";
|
|
11408
11548
|
import figlet2 from "figlet";
|
|
11409
11549
|
import chalk15 from "chalk";
|
|
@@ -11416,7 +11556,7 @@ var colors2 = {
|
|
|
11416
11556
|
grey: "#808080",
|
|
11417
11557
|
red: "#ff0000"
|
|
11418
11558
|
};
|
|
11419
|
-
var may_the_fourth_default = new
|
|
11559
|
+
var may_the_fourth_default = new Command21().command("may-the-fourth").description("May the Fourth be with you").helpOption("-h, --help", "Show help").action(async () => {
|
|
11420
11560
|
await renderClear2();
|
|
11421
11561
|
await renderBanner2();
|
|
11422
11562
|
await renderSpacer2();
|
|
@@ -11484,7 +11624,7 @@ async function renderHero2() {
|
|
|
11484
11624
|
// package.json
|
|
11485
11625
|
var package_default = {
|
|
11486
11626
|
name: "lingo.dev",
|
|
11487
|
-
version: "0.112.
|
|
11627
|
+
version: "0.112.1",
|
|
11488
11628
|
description: "Lingo.dev CLI",
|
|
11489
11629
|
private: false,
|
|
11490
11630
|
publishConfig: {
|
|
@@ -11733,11 +11873,11 @@ var package_default = {
|
|
|
11733
11873
|
};
|
|
11734
11874
|
|
|
11735
11875
|
// src/cli/cmd/purge.ts
|
|
11736
|
-
import { Command as
|
|
11737
|
-
import
|
|
11738
|
-
import { resolveOverriddenLocale as
|
|
11876
|
+
import { Command as Command22 } from "interactive-commander";
|
|
11877
|
+
import Ora13 from "ora";
|
|
11878
|
+
import { resolveOverriddenLocale as resolveOverriddenLocale9 } from "@lingo.dev/_spec";
|
|
11739
11879
|
import { confirm as confirm3 } from "@inquirer/prompts";
|
|
11740
|
-
var purge_default = new
|
|
11880
|
+
var purge_default = new Command22().command("purge").description(
|
|
11741
11881
|
"WARNING: Permanently delete translation entries from bucket path patterns defined in i18n.json. This is a destructive operation that cannot be undone. Without any filters, ALL managed keys will be removed from EVERY target locale."
|
|
11742
11882
|
).helpOption("-h, --help", "Show help").option(
|
|
11743
11883
|
"--bucket <bucket>",
|
|
@@ -11757,7 +11897,7 @@ var purge_default = new Command20().command("purge").description(
|
|
|
11757
11897
|
"--yes-really",
|
|
11758
11898
|
"Bypass safety confirmations for destructive operations. Use with extreme caution - this will delete translation keys without asking for confirmation. Intended for automated scripts and CI environments only."
|
|
11759
11899
|
).action(async function(options) {
|
|
11760
|
-
const ora =
|
|
11900
|
+
const ora = Ora13();
|
|
11761
11901
|
try {
|
|
11762
11902
|
ora.start("Loading configuration...");
|
|
11763
11903
|
const i18nConfig = getConfig();
|
|
@@ -11791,11 +11931,11 @@ var purge_default = new Command20().command("purge").description(
|
|
|
11791
11931
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
11792
11932
|
for (const bucketPath of bucket.paths) {
|
|
11793
11933
|
for (const _targetLocale of targetLocales) {
|
|
11794
|
-
const targetLocale =
|
|
11934
|
+
const targetLocale = resolveOverriddenLocale9(
|
|
11795
11935
|
_targetLocale,
|
|
11796
11936
|
bucketPath.delimiter
|
|
11797
11937
|
);
|
|
11798
|
-
const bucketOra =
|
|
11938
|
+
const bucketOra = Ora13({ indent: 2 }).start(
|
|
11799
11939
|
`Processing path: ${bucketPath.pathPattern} [${targetLocale}]`
|
|
11800
11940
|
);
|
|
11801
11941
|
try {
|