lingo.dev 0.92.16 → 0.92.18
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/README.md +1 -1
- package/build/cli.cjs +281 -100
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +488 -307
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.mjs
CHANGED
|
@@ -29,33 +29,62 @@ function getSettings(explicitApiKey) {
|
|
|
29
29
|
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || systemFile.auth?.apiKey || defaults.auth.apiKey,
|
|
30
30
|
apiUrl: env.LINGODOTDEV_API_URL || systemFile.auth?.apiUrl || defaults.auth.apiUrl,
|
|
31
31
|
webUrl: env.LINGODOTDEV_WEB_URL || systemFile.auth?.webUrl || defaults.auth.webUrl
|
|
32
|
+
},
|
|
33
|
+
llm: {
|
|
34
|
+
openaiApiKey: env.OPENAI_API_KEY || systemFile.llm?.openaiApiKey,
|
|
35
|
+
anthropicApiKey: env.ANTHROPIC_API_KEY || systemFile.llm?.anthropicApiKey,
|
|
36
|
+
groqApiKey: env.GROQ_API_KEY || systemFile.llm?.groqApiKey
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
function saveSettings(settings) {
|
|
36
41
|
_saveSystemFile(settings);
|
|
37
42
|
}
|
|
43
|
+
function loadSystemSettings() {
|
|
44
|
+
return _loadSystemFile();
|
|
45
|
+
}
|
|
46
|
+
var flattenZodObject = (schema, prefix = "") => {
|
|
47
|
+
return Object.entries(schema.shape).flatMap(([key, value]) => {
|
|
48
|
+
const newPrefix = prefix ? `${prefix}.${key}` : key;
|
|
49
|
+
if (value instanceof Z.ZodObject) {
|
|
50
|
+
return flattenZodObject(value, newPrefix);
|
|
51
|
+
}
|
|
52
|
+
return [newPrefix];
|
|
53
|
+
});
|
|
54
|
+
};
|
|
38
55
|
var SettingsSchema = Z.object({
|
|
39
56
|
auth: Z.object({
|
|
40
57
|
apiKey: Z.string(),
|
|
41
58
|
apiUrl: Z.string(),
|
|
42
59
|
webUrl: Z.string()
|
|
60
|
+
}),
|
|
61
|
+
llm: Z.object({
|
|
62
|
+
openaiApiKey: Z.string().optional(),
|
|
63
|
+
anthropicApiKey: Z.string().optional(),
|
|
64
|
+
groqApiKey: Z.string().optional()
|
|
43
65
|
})
|
|
44
66
|
});
|
|
67
|
+
var SETTINGS_KEYS = flattenZodObject(
|
|
68
|
+
SettingsSchema
|
|
69
|
+
);
|
|
45
70
|
function _loadDefaults() {
|
|
46
71
|
return {
|
|
47
72
|
auth: {
|
|
48
73
|
apiKey: "",
|
|
49
74
|
apiUrl: "https://engine.lingo.dev",
|
|
50
75
|
webUrl: "https://lingo.dev"
|
|
51
|
-
}
|
|
76
|
+
},
|
|
77
|
+
llm: {}
|
|
52
78
|
};
|
|
53
79
|
}
|
|
54
80
|
function _loadEnv() {
|
|
55
81
|
return Z.object({
|
|
56
82
|
LINGODOTDEV_API_KEY: Z.string().optional(),
|
|
57
83
|
LINGODOTDEV_API_URL: Z.string().optional(),
|
|
58
|
-
LINGODOTDEV_WEB_URL: Z.string().optional()
|
|
84
|
+
LINGODOTDEV_WEB_URL: Z.string().optional(),
|
|
85
|
+
OPENAI_API_KEY: Z.string().optional(),
|
|
86
|
+
ANTHROPIC_API_KEY: Z.string().optional(),
|
|
87
|
+
GROQ_API_KEY: Z.string().optional()
|
|
59
88
|
}).passthrough().parse(process.env);
|
|
60
89
|
}
|
|
61
90
|
function _loadSystemFile() {
|
|
@@ -67,6 +96,11 @@ function _loadSystemFile() {
|
|
|
67
96
|
apiKey: Z.string().optional(),
|
|
68
97
|
apiUrl: Z.string().optional(),
|
|
69
98
|
webUrl: Z.string().optional()
|
|
99
|
+
}).optional(),
|
|
100
|
+
llm: Z.object({
|
|
101
|
+
openaiApiKey: Z.string().optional(),
|
|
102
|
+
anthropicApiKey: Z.string().optional(),
|
|
103
|
+
groqApiKey: Z.string().optional()
|
|
70
104
|
}).optional()
|
|
71
105
|
}).passthrough().parse(data);
|
|
72
106
|
}
|
|
@@ -102,14 +136,38 @@ function _envVarsInfo() {
|
|
|
102
136
|
if (env.LINGODOTDEV_API_KEY && systemFile.auth?.apiKey) {
|
|
103
137
|
console.info(
|
|
104
138
|
"\x1B[36m%s\x1B[0m",
|
|
105
|
-
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from
|
|
139
|
+
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from user config`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (env.OPENAI_API_KEY && systemFile.llm?.openaiApiKey) {
|
|
143
|
+
console.info(
|
|
144
|
+
"\x1B[36m%s\x1B[0m",
|
|
145
|
+
`\u2139\uFE0F Using OPENAI_API_KEY env var instead of key from user config.`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (env.ANTHROPIC_API_KEY && systemFile.llm?.anthropicApiKey) {
|
|
149
|
+
console.info(
|
|
150
|
+
"\x1B[36m%s\x1B[0m",
|
|
151
|
+
`\u2139\uFE0F Using ANTHROPIC_API_KEY env var instead of key from user config`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (env.GROQ_API_KEY && systemFile.llm?.groqApiKey) {
|
|
155
|
+
console.info(
|
|
156
|
+
"\x1B[36m%s\x1B[0m",
|
|
157
|
+
`\u2139\uFE0F Using GROQ_API_KEY env var instead of key from user config`
|
|
106
158
|
);
|
|
107
159
|
}
|
|
108
160
|
if (env.LINGODOTDEV_API_URL) {
|
|
109
|
-
console.info(
|
|
161
|
+
console.info(
|
|
162
|
+
"\x1B[36m%s\x1B[0m",
|
|
163
|
+
`\u2139\uFE0F Using LINGODOTDEV_API_URL: ${env.LINGODOTDEV_API_URL}`
|
|
164
|
+
);
|
|
110
165
|
}
|
|
111
166
|
if (env.LINGODOTDEV_WEB_URL) {
|
|
112
|
-
console.info(
|
|
167
|
+
console.info(
|
|
168
|
+
"\x1B[36m%s\x1B[0m",
|
|
169
|
+
`\u2139\uFE0F Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`
|
|
170
|
+
);
|
|
113
171
|
}
|
|
114
172
|
}
|
|
115
173
|
|
|
@@ -1017,15 +1075,132 @@ var files_default = new Command4().command("files").description("Print out the l
|
|
|
1017
1075
|
// src/cli/cmd/show/index.ts
|
|
1018
1076
|
var show_default = new Command5().command("show").description("Prints out the current configuration").helpOption("-h, --help", "Show help").addCommand(config_default).addCommand(locale_default).addCommand(files_default);
|
|
1019
1077
|
|
|
1078
|
+
// src/cli/cmd/config/index.ts
|
|
1079
|
+
import { Command as Command9 } from "interactive-commander";
|
|
1080
|
+
|
|
1081
|
+
// src/cli/cmd/config/set.ts
|
|
1082
|
+
import { Command as Command6 } from "interactive-commander";
|
|
1083
|
+
import chalk from "chalk";
|
|
1084
|
+
import dedent from "dedent";
|
|
1085
|
+
import _6 from "lodash";
|
|
1086
|
+
var set_default = new Command6().name("set").description("Set a configuration key to a value").addHelpText("afterAll", `
|
|
1087
|
+
Available keys:
|
|
1088
|
+
${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key to set").argument("<value>", "New value").helpOption("-h, --help", "Show help").action(async (key, value) => {
|
|
1089
|
+
if (!SETTINGS_KEYS.includes(key)) {
|
|
1090
|
+
console.error(
|
|
1091
|
+
dedent`
|
|
1092
|
+
${chalk.red("\u2716")} Unknown configuration key: ${chalk.bold(key)}
|
|
1093
|
+
Run ${chalk.dim("lingo.dev config set --help")} to see available keys.
|
|
1094
|
+
`
|
|
1095
|
+
);
|
|
1096
|
+
process.exitCode = 1;
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
const current = loadSystemSettings();
|
|
1100
|
+
const updated = _6.cloneDeep(current);
|
|
1101
|
+
_6.set(updated, key, value);
|
|
1102
|
+
try {
|
|
1103
|
+
saveSettings(updated);
|
|
1104
|
+
console.log(`${chalk.green("\u2714")} Set ${chalk.bold(key)}`);
|
|
1105
|
+
} catch (err) {
|
|
1106
|
+
console.error(
|
|
1107
|
+
chalk.red(
|
|
1108
|
+
`\u2716 Failed to save configuration: ${chalk.dim(
|
|
1109
|
+
err instanceof Error ? err.message : String(err)
|
|
1110
|
+
)}`
|
|
1111
|
+
)
|
|
1112
|
+
);
|
|
1113
|
+
process.exitCode = 1;
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// src/cli/cmd/config/unset.ts
|
|
1118
|
+
import { Command as Command7 } from "interactive-commander";
|
|
1119
|
+
import chalk2 from "chalk";
|
|
1120
|
+
import dedent2 from "dedent";
|
|
1121
|
+
import _7 from "lodash";
|
|
1122
|
+
var unset_default = new Command7().name("unset").description("Remove a configuration key").addHelpText("afterAll", `
|
|
1123
|
+
Available keys:
|
|
1124
|
+
${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key to remove").helpOption("-h, --help", "Show help").action(async (key) => {
|
|
1125
|
+
if (!SETTINGS_KEYS.includes(key)) {
|
|
1126
|
+
console.error(
|
|
1127
|
+
dedent2`
|
|
1128
|
+
${chalk2.red("\u2716")} Unknown configuration key: ${chalk2.bold(key)}
|
|
1129
|
+
Run ${chalk2.dim("lingo.dev config unset --help")} to see available keys.
|
|
1130
|
+
`
|
|
1131
|
+
);
|
|
1132
|
+
process.exitCode = 1;
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
const settings = loadSystemSettings();
|
|
1136
|
+
const currentValue = _7.get(settings, key);
|
|
1137
|
+
if (!_7.trim(String(currentValue || ""))) {
|
|
1138
|
+
console.log(`${chalk2.cyan("\u2139")} ${chalk2.bold(key)} is not set.`);
|
|
1139
|
+
return;
|
|
1140
|
+
} else {
|
|
1141
|
+
const updated = _7.cloneDeep(settings);
|
|
1142
|
+
_7.unset(updated, key);
|
|
1143
|
+
try {
|
|
1144
|
+
saveSettings(updated);
|
|
1145
|
+
console.log(
|
|
1146
|
+
`${chalk2.green("\u2714")} Removed configuration key ${chalk2.bold(key)}`
|
|
1147
|
+
);
|
|
1148
|
+
} catch (err) {
|
|
1149
|
+
console.error(
|
|
1150
|
+
chalk2.red(
|
|
1151
|
+
`\u2716 Failed to save configuration: ${chalk2.dim(
|
|
1152
|
+
err instanceof Error ? err.message : String(err)
|
|
1153
|
+
)}`
|
|
1154
|
+
)
|
|
1155
|
+
);
|
|
1156
|
+
process.exitCode = 1;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
// src/cli/cmd/config/get.ts
|
|
1162
|
+
import { Command as Command8 } from "interactive-commander";
|
|
1163
|
+
import chalk3 from "chalk";
|
|
1164
|
+
import _8 from "lodash";
|
|
1165
|
+
import dedent3 from "dedent";
|
|
1166
|
+
var get_default = new Command8().name("get").description("Get the value of a configuration key").addHelpText("afterAll", `
|
|
1167
|
+
Available keys:
|
|
1168
|
+
${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key").helpOption("-h, --help", "Show help").action(async (key) => {
|
|
1169
|
+
if (!SETTINGS_KEYS.includes(key)) {
|
|
1170
|
+
console.error(
|
|
1171
|
+
dedent3`
|
|
1172
|
+
${chalk3.red("\u2716")} Unknown configuration key: ${chalk3.bold(key)}
|
|
1173
|
+
Run ${chalk3.dim("lingo.dev config get --help")} to see available keys.
|
|
1174
|
+
`
|
|
1175
|
+
);
|
|
1176
|
+
process.exitCode = 1;
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
const settings = loadSystemSettings();
|
|
1180
|
+
const value = _8.get(settings, key);
|
|
1181
|
+
if (!value) {
|
|
1182
|
+
console.log(`${chalk3.cyan("\u2139")} ${chalk3.bold(key)} is not set.`);
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
if (typeof value === "object") {
|
|
1186
|
+
console.log(JSON.stringify(value, null, 2));
|
|
1187
|
+
} else {
|
|
1188
|
+
console.log(value);
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
|
|
1192
|
+
// src/cli/cmd/config/index.ts
|
|
1193
|
+
var config_default2 = new Command9().command("config").description("Manage Lingo.dev CLI configuration").helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
|
|
1194
|
+
|
|
1020
1195
|
// src/cli/cmd/i18n.ts
|
|
1021
1196
|
import {
|
|
1022
1197
|
bucketTypeSchema,
|
|
1023
1198
|
localeCodeSchema,
|
|
1024
1199
|
resolveOverriddenLocale as resolveOverriddenLocale3
|
|
1025
1200
|
} from "@lingo.dev/_spec";
|
|
1026
|
-
import { Command as
|
|
1201
|
+
import { Command as Command10 } from "interactive-commander";
|
|
1027
1202
|
import Z3 from "zod";
|
|
1028
|
-
import
|
|
1203
|
+
import _29 from "lodash";
|
|
1029
1204
|
import Ora5 from "ora";
|
|
1030
1205
|
|
|
1031
1206
|
// src/cli/loaders/_utils.ts
|
|
@@ -1145,7 +1320,7 @@ function createJsonLoader() {
|
|
|
1145
1320
|
|
|
1146
1321
|
// src/cli/loaders/flat.ts
|
|
1147
1322
|
import { flatten, unflatten } from "flat";
|
|
1148
|
-
import
|
|
1323
|
+
import _9 from "lodash";
|
|
1149
1324
|
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
1150
1325
|
function createFlatLoader() {
|
|
1151
1326
|
return composeLoaders(createDenormalizeLoader(), createNormalizeLoader());
|
|
@@ -1212,12 +1387,12 @@ function mapDenormalizedKeys(obj, denormalizedKeysMap) {
|
|
|
1212
1387
|
);
|
|
1213
1388
|
}
|
|
1214
1389
|
function denormalizeObjectKeys(obj) {
|
|
1215
|
-
if (
|
|
1216
|
-
return
|
|
1390
|
+
if (_9.isObject(obj) && !_9.isArray(obj)) {
|
|
1391
|
+
return _9.transform(
|
|
1217
1392
|
obj,
|
|
1218
1393
|
(result, value, key) => {
|
|
1219
1394
|
const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
|
|
1220
|
-
result[newKey] =
|
|
1395
|
+
result[newKey] = _9.isObject(value) && !_9.isDate(value) ? denormalizeObjectKeys(value) : value;
|
|
1221
1396
|
},
|
|
1222
1397
|
{}
|
|
1223
1398
|
);
|
|
@@ -1226,12 +1401,12 @@ function denormalizeObjectKeys(obj) {
|
|
|
1226
1401
|
}
|
|
1227
1402
|
}
|
|
1228
1403
|
function normalizeObjectKeys(obj) {
|
|
1229
|
-
if (
|
|
1230
|
-
return
|
|
1404
|
+
if (_9.isObject(obj) && !_9.isArray(obj)) {
|
|
1405
|
+
return _9.transform(
|
|
1231
1406
|
obj,
|
|
1232
1407
|
(result, value, key) => {
|
|
1233
1408
|
const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
1234
|
-
result[newKey] =
|
|
1409
|
+
result[newKey] = _9.isObject(value) && !_9.isDate(value) ? normalizeObjectKeys(value) : value;
|
|
1235
1410
|
},
|
|
1236
1411
|
{}
|
|
1237
1412
|
);
|
|
@@ -1250,7 +1425,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1250
1425
|
const trimmedResult = result.trim();
|
|
1251
1426
|
return trimmedResult;
|
|
1252
1427
|
},
|
|
1253
|
-
async push(locale, data,
|
|
1428
|
+
async push(locale, data, _33, originalLocale) {
|
|
1254
1429
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1255
1430
|
const finalPath = path10.resolve(draftPath);
|
|
1256
1431
|
const dirPath = path10.dirname(finalPath);
|
|
@@ -1346,15 +1521,15 @@ function createRootKeyLoader(replaceAll = false) {
|
|
|
1346
1521
|
}
|
|
1347
1522
|
|
|
1348
1523
|
// src/cli/loaders/flutter.ts
|
|
1349
|
-
import
|
|
1524
|
+
import _10 from "lodash";
|
|
1350
1525
|
function createFlutterLoader() {
|
|
1351
1526
|
return createLoader({
|
|
1352
1527
|
async pull(locale, input2) {
|
|
1353
|
-
const result =
|
|
1528
|
+
const result = _10.pickBy(input2, (value, key) => !key.startsWith("@"));
|
|
1354
1529
|
return result;
|
|
1355
1530
|
},
|
|
1356
1531
|
async push(locale, data, originalInput) {
|
|
1357
|
-
const result =
|
|
1532
|
+
const result = _10.merge({}, originalInput, { "@@locale": locale }, data);
|
|
1358
1533
|
return result;
|
|
1359
1534
|
}
|
|
1360
1535
|
});
|
|
@@ -1541,7 +1716,7 @@ function createAndroidLoader() {
|
|
|
1541
1716
|
// src/cli/loaders/csv.ts
|
|
1542
1717
|
import { parse } from "csv-parse/sync";
|
|
1543
1718
|
import { stringify } from "csv-stringify/sync";
|
|
1544
|
-
import
|
|
1719
|
+
import _11 from "lodash";
|
|
1545
1720
|
function createCsvLoader() {
|
|
1546
1721
|
return createLoader({
|
|
1547
1722
|
async pull(locale, _input) {
|
|
@@ -1550,7 +1725,7 @@ function createCsvLoader() {
|
|
|
1550
1725
|
skip_empty_lines: true
|
|
1551
1726
|
});
|
|
1552
1727
|
const result = {};
|
|
1553
|
-
|
|
1728
|
+
_11.forEach(input2, (row) => {
|
|
1554
1729
|
const key = row.id;
|
|
1555
1730
|
if (key && row[locale] && row[locale].trim() !== "") {
|
|
1556
1731
|
result[key] = row[locale];
|
|
@@ -1779,7 +1954,7 @@ function createPropertiesLoader() {
|
|
|
1779
1954
|
return result;
|
|
1780
1955
|
},
|
|
1781
1956
|
async push(locale, payload) {
|
|
1782
|
-
const result = Object.entries(payload).filter(([
|
|
1957
|
+
const result = Object.entries(payload).filter(([_33, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1783
1958
|
return result;
|
|
1784
1959
|
}
|
|
1785
1960
|
});
|
|
@@ -1865,7 +2040,7 @@ function createXcodeStringsdictLoader() {
|
|
|
1865
2040
|
}
|
|
1866
2041
|
|
|
1867
2042
|
// src/cli/loaders/xcode-xcstrings.ts
|
|
1868
|
-
import
|
|
2043
|
+
import _12 from "lodash";
|
|
1869
2044
|
function createXcodeXcstringsLoader(defaultLocale) {
|
|
1870
2045
|
return createLoader({
|
|
1871
2046
|
async pull(locale, input2, initCtx) {
|
|
@@ -1900,7 +2075,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1900
2075
|
async push(locale, payload, originalInput) {
|
|
1901
2076
|
const langDataToMerge = {};
|
|
1902
2077
|
langDataToMerge.strings = {};
|
|
1903
|
-
const input2 =
|
|
2078
|
+
const input2 = _12.cloneDeep(originalInput) || { sourceLanguage: locale, strings: {} };
|
|
1904
2079
|
for (const [key, value] of Object.entries(payload)) {
|
|
1905
2080
|
if (value === null || value === void 0) {
|
|
1906
2081
|
continue;
|
|
@@ -1946,7 +2121,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1946
2121
|
}
|
|
1947
2122
|
}
|
|
1948
2123
|
}
|
|
1949
|
-
const result =
|
|
2124
|
+
const result = _12.merge({}, originalInput, langDataToMerge);
|
|
1950
2125
|
return result;
|
|
1951
2126
|
}
|
|
1952
2127
|
});
|
|
@@ -2025,17 +2200,17 @@ async function formatDataWithPrettier(data, filePath, options) {
|
|
|
2025
2200
|
}
|
|
2026
2201
|
|
|
2027
2202
|
// src/cli/loaders/unlocalizable.ts
|
|
2028
|
-
import
|
|
2203
|
+
import _13 from "lodash";
|
|
2029
2204
|
import _isUrl from "is-url";
|
|
2030
2205
|
import { isValid, parseISO } from "date-fns";
|
|
2031
2206
|
function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys = false) {
|
|
2032
2207
|
const rules = {
|
|
2033
|
-
isEmpty: (v) =>
|
|
2208
|
+
isEmpty: (v) => _13.isEmpty(v),
|
|
2034
2209
|
isNumber: (v) => typeof v === "number" || /^[0-9]+$/.test(v),
|
|
2035
|
-
isBoolean: (v) =>
|
|
2036
|
-
isIsoDate: (v) =>
|
|
2037
|
-
isSystemId: (v) =>
|
|
2038
|
-
isUrl: (v) =>
|
|
2210
|
+
isBoolean: (v) => _13.isBoolean(v),
|
|
2211
|
+
isIsoDate: (v) => _13.isString(v) && _isIsoDate(v),
|
|
2212
|
+
isSystemId: (v) => _13.isString(v) && _isSystemId(v),
|
|
2213
|
+
isUrl: (v) => _13.isString(v) && _isUrl(v)
|
|
2039
2214
|
};
|
|
2040
2215
|
return createLoader({
|
|
2041
2216
|
async pull(locale, input2) {
|
|
@@ -2046,18 +2221,18 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
2046
2221
|
}
|
|
2047
2222
|
}
|
|
2048
2223
|
return false;
|
|
2049
|
-
}).map(([key,
|
|
2050
|
-
const result =
|
|
2224
|
+
}).map(([key, _33]) => key);
|
|
2225
|
+
const result = _13.omitBy(input2, (_33, key) => passthroughKeys.includes(key));
|
|
2051
2226
|
if (returnUnlocalizedKeys) {
|
|
2052
|
-
result.unlocalizable =
|
|
2227
|
+
result.unlocalizable = _13.omitBy(input2, (_33, key) => !passthroughKeys.includes(key));
|
|
2053
2228
|
}
|
|
2054
2229
|
return result;
|
|
2055
2230
|
},
|
|
2056
2231
|
async push(locale, data, originalInput) {
|
|
2057
2232
|
if (isCacheRestore) {
|
|
2058
|
-
return
|
|
2233
|
+
return _13.merge({}, data);
|
|
2059
2234
|
}
|
|
2060
|
-
const result =
|
|
2235
|
+
const result = _13.merge({}, originalInput, data);
|
|
2061
2236
|
return result;
|
|
2062
2237
|
}
|
|
2063
2238
|
});
|
|
@@ -2070,7 +2245,7 @@ function _isIsoDate(v) {
|
|
|
2070
2245
|
}
|
|
2071
2246
|
|
|
2072
2247
|
// src/cli/loaders/po/index.ts
|
|
2073
|
-
import
|
|
2248
|
+
import _14 from "lodash";
|
|
2074
2249
|
import gettextParser from "gettext-parser";
|
|
2075
2250
|
function createPoLoader(params = { multiline: false }) {
|
|
2076
2251
|
return composeLoaders(createPoDataLoader(params), createPoContentLoader());
|
|
@@ -2083,7 +2258,10 @@ function createPoDataLoader(params) {
|
|
|
2083
2258
|
const sections = input2.split("\n\n").filter(Boolean);
|
|
2084
2259
|
for (const section of sections) {
|
|
2085
2260
|
const sectionPo = gettextParser.po.parse(section);
|
|
2086
|
-
|
|
2261
|
+
if (Object.keys(sectionPo.translations).length === 0) {
|
|
2262
|
+
continue;
|
|
2263
|
+
}
|
|
2264
|
+
const contextKey = _14.keys(sectionPo.translations)[0];
|
|
2087
2265
|
const entries = sectionPo.translations[contextKey];
|
|
2088
2266
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
2089
2267
|
if (msgid && entry.msgid) {
|
|
@@ -2102,13 +2280,16 @@ function createPoDataLoader(params) {
|
|
|
2102
2280
|
const originalSections = originalInput?.split("\n\n").filter(Boolean) || [];
|
|
2103
2281
|
const result = originalSections.map((section) => {
|
|
2104
2282
|
const sectionPo = gettextParser.po.parse(section);
|
|
2105
|
-
|
|
2283
|
+
if (Object.keys(sectionPo.translations).length === 0) {
|
|
2284
|
+
return null;
|
|
2285
|
+
}
|
|
2286
|
+
const contextKey = _14.keys(sectionPo.translations)[0];
|
|
2106
2287
|
const entries = sectionPo.translations[contextKey];
|
|
2107
2288
|
const msgid = Object.keys(entries).find((key) => entries[key].msgid);
|
|
2108
2289
|
if (!msgid) {
|
|
2109
2290
|
const currentSection = currentSections.find((cs) => {
|
|
2110
2291
|
const csPo = gettextParser.po.parse(cs);
|
|
2111
|
-
const csContextKey =
|
|
2292
|
+
const csContextKey = _14.keys(csPo.translations)[0];
|
|
2112
2293
|
const csEntries = csPo.translations[csContextKey];
|
|
2113
2294
|
const csMsgid = Object.keys(csEntries).find(
|
|
2114
2295
|
(key) => csEntries[key].msgid
|
|
@@ -2121,7 +2302,7 @@ function createPoDataLoader(params) {
|
|
|
2121
2302
|
return section;
|
|
2122
2303
|
}
|
|
2123
2304
|
if (data[msgid]) {
|
|
2124
|
-
const updatedPo =
|
|
2305
|
+
const updatedPo = _14.merge({}, sectionPo, {
|
|
2125
2306
|
translations: {
|
|
2126
2307
|
[contextKey]: {
|
|
2127
2308
|
[msgid]: {
|
|
@@ -2136,7 +2317,7 @@ function createPoDataLoader(params) {
|
|
|
2136
2317
|
).trim();
|
|
2137
2318
|
}
|
|
2138
2319
|
return section.trim();
|
|
2139
|
-
}).join("\n\n");
|
|
2320
|
+
}).filter(Boolean).join("\n\n");
|
|
2140
2321
|
return result;
|
|
2141
2322
|
}
|
|
2142
2323
|
});
|
|
@@ -2144,7 +2325,7 @@ function createPoDataLoader(params) {
|
|
|
2144
2325
|
function createPoContentLoader() {
|
|
2145
2326
|
return createLoader({
|
|
2146
2327
|
async pull(locale, input2, initCtx, originalLocale) {
|
|
2147
|
-
const result =
|
|
2328
|
+
const result = _14.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => {
|
|
2148
2329
|
const singularFallback = locale === originalLocale ? entry.msgid : null;
|
|
2149
2330
|
const pluralFallback = locale === originalLocale ? entry.msgid_plural || entry.msgid : null;
|
|
2150
2331
|
const hasPlural = entry.msgstr.length > 1;
|
|
@@ -2159,7 +2340,7 @@ function createPoContentLoader() {
|
|
|
2159
2340
|
return result;
|
|
2160
2341
|
},
|
|
2161
2342
|
async push(locale, data, originalInput) {
|
|
2162
|
-
const result =
|
|
2343
|
+
const result = _14.chain(originalInput).entries().map(([, entry]) => [
|
|
2163
2344
|
entry.msgid,
|
|
2164
2345
|
{
|
|
2165
2346
|
...entry,
|
|
@@ -2285,34 +2466,34 @@ var datoSettingsSchema = Z2.object({
|
|
|
2285
2466
|
});
|
|
2286
2467
|
|
|
2287
2468
|
// src/cli/loaders/dato/filter.ts
|
|
2288
|
-
import
|
|
2469
|
+
import _15 from "lodash";
|
|
2289
2470
|
function createDatoFilterLoader() {
|
|
2290
2471
|
return createLoader({
|
|
2291
2472
|
async pull(locale, input2) {
|
|
2292
2473
|
const result = {};
|
|
2293
|
-
for (const [modelId, modelInfo] of
|
|
2474
|
+
for (const [modelId, modelInfo] of _15.entries(input2)) {
|
|
2294
2475
|
result[modelId] = {};
|
|
2295
2476
|
for (const record of modelInfo.records) {
|
|
2296
|
-
result[modelId][record.id] =
|
|
2477
|
+
result[modelId][record.id] = _15.chain(modelInfo.fields).mapKeys((field) => field.api_key).mapValues((field) => _15.get(record, [field.api_key, locale])).value();
|
|
2297
2478
|
}
|
|
2298
2479
|
}
|
|
2299
2480
|
return result;
|
|
2300
2481
|
},
|
|
2301
2482
|
async push(locale, data, originalInput, originalLocale) {
|
|
2302
|
-
const result =
|
|
2303
|
-
for (const [modelId, modelInfo] of
|
|
2483
|
+
const result = _15.cloneDeep(originalInput || {});
|
|
2484
|
+
for (const [modelId, modelInfo] of _15.entries(result)) {
|
|
2304
2485
|
for (const record of modelInfo.records) {
|
|
2305
|
-
for (const [fieldId, fieldValue] of
|
|
2486
|
+
for (const [fieldId, fieldValue] of _15.entries(record)) {
|
|
2306
2487
|
const fieldInfo = modelInfo.fields.find((field) => field.api_key === fieldId);
|
|
2307
2488
|
if (fieldInfo) {
|
|
2308
|
-
const sourceFieldValue =
|
|
2309
|
-
const targetFieldValue =
|
|
2489
|
+
const sourceFieldValue = _15.get(fieldValue, [originalLocale]);
|
|
2490
|
+
const targetFieldValue = _15.get(data, [modelId, record.id, fieldId]);
|
|
2310
2491
|
if (targetFieldValue) {
|
|
2311
|
-
|
|
2492
|
+
_15.set(record, [fieldId, locale], targetFieldValue);
|
|
2312
2493
|
} else {
|
|
2313
|
-
|
|
2494
|
+
_15.set(record, [fieldId, locale], sourceFieldValue);
|
|
2314
2495
|
}
|
|
2315
|
-
|
|
2496
|
+
_15.chain(fieldValue).keys().reject((loc) => loc === locale || loc === originalLocale).filter((loc) => _15.isEmpty(_15.get(fieldValue, [loc]))).forEach((loc) => _15.set(record, [fieldId, loc], sourceFieldValue)).value();
|
|
2316
2497
|
}
|
|
2317
2498
|
}
|
|
2318
2499
|
}
|
|
@@ -2323,10 +2504,10 @@ function createDatoFilterLoader() {
|
|
|
2323
2504
|
}
|
|
2324
2505
|
|
|
2325
2506
|
// src/cli/loaders/dato/api.ts
|
|
2326
|
-
import
|
|
2507
|
+
import _17 from "lodash";
|
|
2327
2508
|
|
|
2328
2509
|
// src/cli/loaders/dato/_utils.ts
|
|
2329
|
-
import
|
|
2510
|
+
import _16 from "lodash";
|
|
2330
2511
|
import { buildClient } from "@datocms/cma-client-node";
|
|
2331
2512
|
function createDatoClient(params) {
|
|
2332
2513
|
if (!params.apiKey) {
|
|
@@ -2501,7 +2682,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2501
2682
|
const result = {
|
|
2502
2683
|
models: {}
|
|
2503
2684
|
};
|
|
2504
|
-
const updatedConfig =
|
|
2685
|
+
const updatedConfig = _17.cloneDeep(config);
|
|
2505
2686
|
console.log(`Initializing DatoCMS loader...`);
|
|
2506
2687
|
const project = await dato.findProject();
|
|
2507
2688
|
const modelChoices = await getModelChoices(dato, config);
|
|
@@ -2519,7 +2700,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2519
2700
|
delete updatedConfig.models[modelId];
|
|
2520
2701
|
}
|
|
2521
2702
|
}
|
|
2522
|
-
for (const modelId of
|
|
2703
|
+
for (const modelId of _17.keys(updatedConfig.models)) {
|
|
2523
2704
|
const { modelName, fields } = await getModelFields(dato, modelId);
|
|
2524
2705
|
if (fields.length > 0) {
|
|
2525
2706
|
result.models[modelId] = { fields: [], records: [] };
|
|
@@ -2530,7 +2711,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2530
2711
|
const isLocalized = await updateFieldLocalization(dato, fieldInfo, selectedFields.includes(fieldInfo.id));
|
|
2531
2712
|
if (isLocalized) {
|
|
2532
2713
|
result.models[modelId].fields.push(fieldInfo);
|
|
2533
|
-
updatedConfig.models[modelId].fields =
|
|
2714
|
+
updatedConfig.models[modelId].fields = _17.uniq([
|
|
2534
2715
|
...updatedConfig.models[modelId].fields || [],
|
|
2535
2716
|
fieldInfo.api_key
|
|
2536
2717
|
]);
|
|
@@ -2549,7 +2730,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2549
2730
|
},
|
|
2550
2731
|
async pull(locale, input2, initCtx) {
|
|
2551
2732
|
const result = {};
|
|
2552
|
-
for (const modelId of
|
|
2733
|
+
for (const modelId of _17.keys(initCtx?.models || {})) {
|
|
2553
2734
|
let records = initCtx?.models[modelId].records || [];
|
|
2554
2735
|
const recordIds = records.map((record) => record.id);
|
|
2555
2736
|
records = await dato.findRecords(recordIds);
|
|
@@ -2564,7 +2745,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2564
2745
|
return result;
|
|
2565
2746
|
},
|
|
2566
2747
|
async push(locale, data, originalInput) {
|
|
2567
|
-
for (const modelId of
|
|
2748
|
+
for (const modelId of _17.keys(data)) {
|
|
2568
2749
|
for (let i = 0; i < data[modelId].records.length; i++) {
|
|
2569
2750
|
const record = data[modelId].records[i];
|
|
2570
2751
|
console.log(`Updating record ${i + 1}/${data[modelId].records.length} for model ${modelId}...`);
|
|
@@ -2578,7 +2759,7 @@ async function getModelFields(dato, modelId) {
|
|
|
2578
2759
|
const modelInfo = await dato.findModel(modelId);
|
|
2579
2760
|
return {
|
|
2580
2761
|
modelName: modelInfo.name,
|
|
2581
|
-
fields:
|
|
2762
|
+
fields: _17.filter(modelInfo.fields, (field) => field.type === "field")
|
|
2582
2763
|
};
|
|
2583
2764
|
}
|
|
2584
2765
|
async function getFieldDetails(dato, fields) {
|
|
@@ -2656,17 +2837,17 @@ async function promptModelSelection(choices) {
|
|
|
2656
2837
|
}
|
|
2657
2838
|
|
|
2658
2839
|
// src/cli/loaders/dato/extract.ts
|
|
2659
|
-
import
|
|
2840
|
+
import _18 from "lodash";
|
|
2660
2841
|
function createDatoExtractLoader() {
|
|
2661
2842
|
return createLoader({
|
|
2662
2843
|
async pull(locale, input2) {
|
|
2663
2844
|
const result = {};
|
|
2664
|
-
for (const [modelId, modelInfo] of
|
|
2665
|
-
for (const [recordId, record] of
|
|
2666
|
-
for (const [fieldName, fieldValue] of
|
|
2845
|
+
for (const [modelId, modelInfo] of _18.entries(input2)) {
|
|
2846
|
+
for (const [recordId, record] of _18.entries(modelInfo)) {
|
|
2847
|
+
for (const [fieldName, fieldValue] of _18.entries(record)) {
|
|
2667
2848
|
const parsedValue = createParsedDatoValue(fieldValue);
|
|
2668
2849
|
if (parsedValue) {
|
|
2669
|
-
|
|
2850
|
+
_18.set(result, [modelId, `_${recordId}`, fieldName], parsedValue);
|
|
2670
2851
|
}
|
|
2671
2852
|
}
|
|
2672
2853
|
}
|
|
@@ -2674,14 +2855,14 @@ function createDatoExtractLoader() {
|
|
|
2674
2855
|
return result;
|
|
2675
2856
|
},
|
|
2676
2857
|
async push(locale, data, originalInput) {
|
|
2677
|
-
const result =
|
|
2678
|
-
for (const [modelId, modelInfo] of
|
|
2679
|
-
for (const [virtualRecordId, record] of
|
|
2680
|
-
for (const [fieldName, fieldValue] of
|
|
2858
|
+
const result = _18.cloneDeep(originalInput || {});
|
|
2859
|
+
for (const [modelId, modelInfo] of _18.entries(data)) {
|
|
2860
|
+
for (const [virtualRecordId, record] of _18.entries(modelInfo)) {
|
|
2861
|
+
for (const [fieldName, fieldValue] of _18.entries(record)) {
|
|
2681
2862
|
const [, recordId] = virtualRecordId.split("_");
|
|
2682
|
-
const originalFieldValue =
|
|
2863
|
+
const originalFieldValue = _18.get(originalInput, [modelId, recordId, fieldName]);
|
|
2683
2864
|
const rawValue = createRawDatoValue(fieldValue, originalFieldValue, true);
|
|
2684
|
-
|
|
2865
|
+
_18.set(result, [modelId, recordId, fieldName], rawValue || originalFieldValue);
|
|
2685
2866
|
}
|
|
2686
2867
|
}
|
|
2687
2868
|
}
|
|
@@ -2690,25 +2871,25 @@ function createDatoExtractLoader() {
|
|
|
2690
2871
|
});
|
|
2691
2872
|
}
|
|
2692
2873
|
function detectDatoFieldType(rawDatoValue) {
|
|
2693
|
-
if (
|
|
2874
|
+
if (_18.has(rawDatoValue, "document") && _18.get(rawDatoValue, "schema") === "dast") {
|
|
2694
2875
|
return "structured_text";
|
|
2695
|
-
} else if (
|
|
2876
|
+
} else if (_18.has(rawDatoValue, "no_index") || _18.has(rawDatoValue, "twitter_card")) {
|
|
2696
2877
|
return "seo";
|
|
2697
|
-
} else if (
|
|
2878
|
+
} else if (_18.get(rawDatoValue, "type") === "item") {
|
|
2698
2879
|
return "single_block";
|
|
2699
|
-
} else if (
|
|
2880
|
+
} else if (_18.isArray(rawDatoValue) && _18.every(rawDatoValue, (item) => _18.get(item, "type") === "item")) {
|
|
2700
2881
|
return "rich_text";
|
|
2701
2882
|
} else if (_isFile(rawDatoValue)) {
|
|
2702
2883
|
return "file";
|
|
2703
|
-
} else if (
|
|
2884
|
+
} else if (_18.isArray(rawDatoValue) && _18.every(rawDatoValue, (item) => _isFile(item))) {
|
|
2704
2885
|
return "gallery";
|
|
2705
2886
|
} else if (_isJson(rawDatoValue)) {
|
|
2706
2887
|
return "json";
|
|
2707
|
-
} else if (
|
|
2888
|
+
} else if (_18.isString(rawDatoValue)) {
|
|
2708
2889
|
return "string";
|
|
2709
2890
|
} else if (_isVideo(rawDatoValue)) {
|
|
2710
2891
|
return "video";
|
|
2711
|
-
} else if (
|
|
2892
|
+
} else if (_18.isArray(rawDatoValue) && _18.every(rawDatoValue, (item) => _18.isString(item))) {
|
|
2712
2893
|
return "ref_list";
|
|
2713
2894
|
} else {
|
|
2714
2895
|
return null;
|
|
@@ -2770,9 +2951,9 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
2770
2951
|
if ("document" in node) {
|
|
2771
2952
|
return serializeStructuredTextNode(node.document, [...path16, "document"], acc);
|
|
2772
2953
|
}
|
|
2773
|
-
if (!
|
|
2954
|
+
if (!_18.isNil(node.value)) {
|
|
2774
2955
|
acc[[...path16, "value"].join(".")] = node.value;
|
|
2775
|
-
} else if (
|
|
2956
|
+
} else if (_18.get(node, "type") === "block") {
|
|
2776
2957
|
acc[[...path16, "item"].join(".")] = serializeBlock(node.item);
|
|
2777
2958
|
}
|
|
2778
2959
|
if (node.children) {
|
|
@@ -2784,44 +2965,44 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
2784
2965
|
}
|
|
2785
2966
|
}
|
|
2786
2967
|
function serializeSeo(rawSeo) {
|
|
2787
|
-
return
|
|
2968
|
+
return _18.chain(rawSeo).pick(["title", "description"]).value();
|
|
2788
2969
|
}
|
|
2789
2970
|
function serializeBlock(rawBlock) {
|
|
2790
|
-
if (
|
|
2971
|
+
if (_18.get(rawBlock, "type") === "item" && _18.has(rawBlock, "id")) {
|
|
2791
2972
|
return serializeBlock(rawBlock.attributes);
|
|
2792
2973
|
}
|
|
2793
2974
|
const result = {};
|
|
2794
|
-
for (const [attributeName, attributeValue] of
|
|
2975
|
+
for (const [attributeName, attributeValue] of _18.entries(rawBlock)) {
|
|
2795
2976
|
result[attributeName] = createParsedDatoValue(attributeValue);
|
|
2796
2977
|
}
|
|
2797
2978
|
return result;
|
|
2798
2979
|
}
|
|
2799
2980
|
function serializeBlockList(rawBlockList) {
|
|
2800
|
-
return
|
|
2981
|
+
return _18.chain(rawBlockList).map((block) => serializeBlock(block)).value();
|
|
2801
2982
|
}
|
|
2802
2983
|
function serializeVideo(rawVideo) {
|
|
2803
|
-
return
|
|
2984
|
+
return _18.chain(rawVideo).pick(["title"]).value();
|
|
2804
2985
|
}
|
|
2805
2986
|
function serializeFile(rawFile) {
|
|
2806
|
-
return
|
|
2987
|
+
return _18.chain(rawFile).pick(["alt", "title"]).value();
|
|
2807
2988
|
}
|
|
2808
2989
|
function serializeGallery(rawGallery) {
|
|
2809
|
-
return
|
|
2990
|
+
return _18.chain(rawGallery).map((item) => serializeFile(item)).value();
|
|
2810
2991
|
}
|
|
2811
2992
|
function deserializeFile(parsedFile, originalRawFile) {
|
|
2812
|
-
return
|
|
2993
|
+
return _18.chain(parsedFile).defaults(originalRawFile).value();
|
|
2813
2994
|
}
|
|
2814
2995
|
function deserializeGallery(parsedGallery, originalRawGallery) {
|
|
2815
|
-
return
|
|
2996
|
+
return _18.chain(parsedGallery).map((item, i) => deserializeFile(item, originalRawGallery[i])).value();
|
|
2816
2997
|
}
|
|
2817
2998
|
function deserializeVideo(parsedVideo, originalRawVideo) {
|
|
2818
|
-
return
|
|
2999
|
+
return _18.chain(parsedVideo).defaults(originalRawVideo).value();
|
|
2819
3000
|
}
|
|
2820
3001
|
function deserializeBlock(payload, rawNode, isClean = false) {
|
|
2821
|
-
const result =
|
|
2822
|
-
for (const [attributeName, attributeValue] of
|
|
3002
|
+
const result = _18.cloneDeep(rawNode);
|
|
3003
|
+
for (const [attributeName, attributeValue] of _18.entries(rawNode.attributes)) {
|
|
2823
3004
|
const rawValue = createRawDatoValue(payload[attributeName], attributeValue, isClean);
|
|
2824
|
-
|
|
3005
|
+
_18.set(result, ["attributes", attributeName], rawValue);
|
|
2825
3006
|
}
|
|
2826
3007
|
if (isClean) {
|
|
2827
3008
|
delete result["id"];
|
|
@@ -2829,33 +3010,33 @@ function deserializeBlock(payload, rawNode, isClean = false) {
|
|
|
2829
3010
|
return result;
|
|
2830
3011
|
}
|
|
2831
3012
|
function deserializeSeo(parsedSeo, originalRawSeo) {
|
|
2832
|
-
return
|
|
3013
|
+
return _18.chain(parsedSeo).pick(["title", "description"]).defaults(originalRawSeo).value();
|
|
2833
3014
|
}
|
|
2834
3015
|
function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = false) {
|
|
2835
|
-
return
|
|
3016
|
+
return _18.chain(parsedBlockList).map((block, i) => deserializeBlock(block, originalRawBlockList[i], isClean)).value();
|
|
2836
3017
|
}
|
|
2837
3018
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2838
|
-
const result =
|
|
2839
|
-
for (const [path16, value] of
|
|
2840
|
-
const realPath =
|
|
2841
|
-
const deserializedValue = createRawDatoValue(value,
|
|
2842
|
-
|
|
3019
|
+
const result = _18.cloneDeep(originalRawStructuredText);
|
|
3020
|
+
for (const [path16, value] of _18.entries(parsedStructuredText)) {
|
|
3021
|
+
const realPath = _18.chain(path16.split(".")).flatMap((s) => !_18.isNaN(_18.toNumber(s)) ? ["children", s] : s).value();
|
|
3022
|
+
const deserializedValue = createRawDatoValue(value, _18.get(originalRawStructuredText, realPath), true);
|
|
3023
|
+
_18.set(result, realPath, deserializedValue);
|
|
2843
3024
|
}
|
|
2844
3025
|
return result;
|
|
2845
3026
|
}
|
|
2846
3027
|
function _isJson(rawDatoValue) {
|
|
2847
3028
|
try {
|
|
2848
|
-
return
|
|
3029
|
+
return _18.isString(rawDatoValue) && rawDatoValue.startsWith("{") && rawDatoValue.endsWith("}") && !!JSON.parse(rawDatoValue);
|
|
2849
3030
|
} catch (e) {
|
|
2850
3031
|
return false;
|
|
2851
3032
|
}
|
|
2852
3033
|
}
|
|
2853
3034
|
function _isFile(rawDatoValue) {
|
|
2854
|
-
return
|
|
3035
|
+
return _18.isObject(rawDatoValue) && ["alt", "title", "custom_data", "focal_point", "upload_id"].every((key) => _18.has(rawDatoValue, key));
|
|
2855
3036
|
}
|
|
2856
3037
|
function _isVideo(rawDatoValue) {
|
|
2857
|
-
return
|
|
2858
|
-
(key) =>
|
|
3038
|
+
return _18.isObject(rawDatoValue) && ["url", "title", "width", "height", "provider", "provider_uid", "thumbnail_url"].every(
|
|
3039
|
+
(key) => _18.has(rawDatoValue, key)
|
|
2859
3040
|
);
|
|
2860
3041
|
}
|
|
2861
3042
|
|
|
@@ -2916,7 +3097,7 @@ function createVttLoader() {
|
|
|
2916
3097
|
}
|
|
2917
3098
|
|
|
2918
3099
|
// src/cli/loaders/variable/index.ts
|
|
2919
|
-
import
|
|
3100
|
+
import _19 from "lodash";
|
|
2920
3101
|
function createVariableLoader(params) {
|
|
2921
3102
|
return composeLoaders(variableExtractLoader(params), variableContentLoader());
|
|
2922
3103
|
}
|
|
@@ -2925,7 +3106,7 @@ function variableExtractLoader(params) {
|
|
|
2925
3106
|
return createLoader({
|
|
2926
3107
|
pull: async (locale, input2, initXtx, originalLocale, originalInput) => {
|
|
2927
3108
|
const result = {};
|
|
2928
|
-
const inputValues =
|
|
3109
|
+
const inputValues = _19.omitBy(input2, _19.isEmpty);
|
|
2929
3110
|
for (const [key, value] of Object.entries(inputValues)) {
|
|
2930
3111
|
const originalValue = originalInput[key];
|
|
2931
3112
|
const matches = originalValue.match(specifierPattern) || [];
|
|
@@ -2961,11 +3142,11 @@ function variableExtractLoader(params) {
|
|
|
2961
3142
|
function variableContentLoader() {
|
|
2962
3143
|
return createLoader({
|
|
2963
3144
|
pull: async (locale, input2) => {
|
|
2964
|
-
const result =
|
|
3145
|
+
const result = _19.mapValues(input2, (payload) => payload.value);
|
|
2965
3146
|
return result;
|
|
2966
3147
|
},
|
|
2967
3148
|
push: async (locale, data, originalInput, defaultLocale, pullInput) => {
|
|
2968
|
-
const result =
|
|
3149
|
+
const result = _19.cloneDeep(
|
|
2969
3150
|
originalInput || {}
|
|
2970
3151
|
);
|
|
2971
3152
|
for (const [key, originalValueObj] of Object.entries(result)) {
|
|
@@ -2990,20 +3171,20 @@ function getFormatSpecifierPattern(type) {
|
|
|
2990
3171
|
}
|
|
2991
3172
|
|
|
2992
3173
|
// src/cli/loaders/sync.ts
|
|
2993
|
-
import
|
|
3174
|
+
import _20 from "lodash";
|
|
2994
3175
|
function createSyncLoader() {
|
|
2995
3176
|
return createLoader({
|
|
2996
3177
|
async pull(locale, input2, initCtx, originalLocale, originalInput) {
|
|
2997
3178
|
if (!originalInput) {
|
|
2998
3179
|
return input2;
|
|
2999
3180
|
}
|
|
3000
|
-
return
|
|
3181
|
+
return _20.chain(originalInput).mapValues((value, key) => input2[key]).value();
|
|
3001
3182
|
},
|
|
3002
3183
|
async push(locale, data, originalInput) {
|
|
3003
3184
|
if (!originalInput) {
|
|
3004
3185
|
return data;
|
|
3005
3186
|
}
|
|
3006
|
-
return
|
|
3187
|
+
return _20.chain(originalInput || {}).mapValues((value, key) => data[key]).value();
|
|
3007
3188
|
}
|
|
3008
3189
|
});
|
|
3009
3190
|
}
|
|
@@ -3164,7 +3345,7 @@ function parseVueFile(input2) {
|
|
|
3164
3345
|
|
|
3165
3346
|
// src/cli/loaders/typescript/index.ts
|
|
3166
3347
|
import { parse as parse2 } from "@babel/parser";
|
|
3167
|
-
import
|
|
3348
|
+
import _21 from "lodash";
|
|
3168
3349
|
import babelTraverseModule from "@babel/traverse";
|
|
3169
3350
|
import * as t from "@babel/types";
|
|
3170
3351
|
import babelGenerateModule from "@babel/generator";
|
|
@@ -3200,7 +3381,7 @@ function createTypescriptLoader() {
|
|
|
3200
3381
|
},
|
|
3201
3382
|
push: async (locale, data, originalInput, defaultLocale, pullInput, pullOutput) => {
|
|
3202
3383
|
const ast = parseTypeScript(originalInput || "");
|
|
3203
|
-
const finalData =
|
|
3384
|
+
const finalData = _21.merge({}, pullOutput, data);
|
|
3204
3385
|
updateStringsInDefaultExport(ast, finalData);
|
|
3205
3386
|
const { code } = generate(ast, {
|
|
3206
3387
|
jsescOption: {
|
|
@@ -3401,7 +3582,7 @@ function getPropertyKey(prop) {
|
|
|
3401
3582
|
}
|
|
3402
3583
|
|
|
3403
3584
|
// src/cli/loaders/inject-locale.ts
|
|
3404
|
-
import
|
|
3585
|
+
import _22 from "lodash";
|
|
3405
3586
|
function createInjectLocaleLoader(injectLocaleKeys) {
|
|
3406
3587
|
return createLoader({
|
|
3407
3588
|
async pull(locale, data) {
|
|
@@ -3409,19 +3590,19 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
3409
3590
|
return data;
|
|
3410
3591
|
}
|
|
3411
3592
|
const omitKeys = injectLocaleKeys.filter((key) => {
|
|
3412
|
-
return
|
|
3593
|
+
return _22.get(data, key) === locale;
|
|
3413
3594
|
});
|
|
3414
|
-
const result =
|
|
3595
|
+
const result = _22.omit(data, omitKeys);
|
|
3415
3596
|
return result;
|
|
3416
3597
|
},
|
|
3417
3598
|
async push(locale, data, originalInput, originalLocale) {
|
|
3418
3599
|
if (!injectLocaleKeys) {
|
|
3419
3600
|
return data;
|
|
3420
3601
|
}
|
|
3421
|
-
const mergedData =
|
|
3602
|
+
const mergedData = _22.merge({}, originalInput, data);
|
|
3422
3603
|
injectLocaleKeys.forEach((key) => {
|
|
3423
|
-
if (
|
|
3424
|
-
|
|
3604
|
+
if (_22.get(mergedData, key) === originalLocale) {
|
|
3605
|
+
_22.set(mergedData, key, locale);
|
|
3425
3606
|
}
|
|
3426
3607
|
});
|
|
3427
3608
|
return mergedData;
|
|
@@ -3430,16 +3611,16 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
3430
3611
|
}
|
|
3431
3612
|
|
|
3432
3613
|
// src/cli/loaders/locked-keys.ts
|
|
3433
|
-
import
|
|
3614
|
+
import _23 from "lodash";
|
|
3434
3615
|
function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
|
|
3435
3616
|
return createLoader({
|
|
3436
|
-
pull: async (locale, data) =>
|
|
3617
|
+
pull: async (locale, data) => _23.chain(data).pickBy((value, key) => !lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value(),
|
|
3437
3618
|
push: async (locale, data, originalInput) => {
|
|
3438
|
-
const lockedSubObject =
|
|
3619
|
+
const lockedSubObject = _23.chain(originalInput).pickBy((value, key) => lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value();
|
|
3439
3620
|
if (isCacheRestore) {
|
|
3440
|
-
return
|
|
3621
|
+
return _23.merge({}, data, lockedSubObject);
|
|
3441
3622
|
} else {
|
|
3442
|
-
return
|
|
3623
|
+
return _23.merge({}, originalInput, data, lockedSubObject);
|
|
3443
3624
|
}
|
|
3444
3625
|
}
|
|
3445
3626
|
});
|
|
@@ -3492,7 +3673,7 @@ function md5(input2) {
|
|
|
3492
3673
|
}
|
|
3493
3674
|
|
|
3494
3675
|
// src/cli/loaders/mdx2/code-placeholder.ts
|
|
3495
|
-
import
|
|
3676
|
+
import _24 from "lodash";
|
|
3496
3677
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
3497
3678
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
3498
3679
|
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
@@ -3515,7 +3696,7 @@ ${match}
|
|
|
3515
3696
|
found = true;
|
|
3516
3697
|
}
|
|
3517
3698
|
} while (found);
|
|
3518
|
-
content =
|
|
3699
|
+
content = _24.chain(content).split("\n\n").map((section) => _24.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
3519
3700
|
return content;
|
|
3520
3701
|
}
|
|
3521
3702
|
function ensureTrailingFenceNewline(_content) {
|
|
@@ -3537,7 +3718,7 @@ ${match}
|
|
|
3537
3718
|
found = true;
|
|
3538
3719
|
}
|
|
3539
3720
|
} while (found);
|
|
3540
|
-
content =
|
|
3721
|
+
content = _24.chain(content).split("\n\n").map((section) => _24.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
3541
3722
|
return content;
|
|
3542
3723
|
}
|
|
3543
3724
|
function extractCodePlaceholders(content) {
|
|
@@ -3577,13 +3758,13 @@ function createMdxCodePlaceholderLoader() {
|
|
|
3577
3758
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
3578
3759
|
const sourceInfo = extractCodePlaceholders(originalInput ?? "");
|
|
3579
3760
|
const currentInfo = extractCodePlaceholders(pullInput ?? "");
|
|
3580
|
-
const codePlaceholders =
|
|
3761
|
+
const codePlaceholders = _24.merge(
|
|
3581
3762
|
sourceInfo.codePlaceholders,
|
|
3582
3763
|
currentInfo.codePlaceholders
|
|
3583
3764
|
);
|
|
3584
3765
|
let result = data;
|
|
3585
3766
|
for (const [placeholder, original] of Object.entries(codePlaceholders)) {
|
|
3586
|
-
const replacement = original.startsWith(">") ?
|
|
3767
|
+
const replacement = original.startsWith(">") ? _24.trimStart(original, "> ") : original;
|
|
3587
3768
|
result = result.replaceAll(placeholder, replacement);
|
|
3588
3769
|
}
|
|
3589
3770
|
return result;
|
|
@@ -3611,11 +3792,11 @@ function createLocalizableMdxDocumentLoader() {
|
|
|
3611
3792
|
}
|
|
3612
3793
|
|
|
3613
3794
|
// src/cli/loaders/mdx2/sections-split-2.ts
|
|
3614
|
-
import
|
|
3795
|
+
import _25 from "lodash";
|
|
3615
3796
|
function createMdxSectionsSplit2Loader() {
|
|
3616
3797
|
return createLoader({
|
|
3617
3798
|
async pull(locale, input2) {
|
|
3618
|
-
const sections =
|
|
3799
|
+
const sections = _25.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
|
|
3619
3800
|
const result = {
|
|
3620
3801
|
frontmatter: input2.frontmatter,
|
|
3621
3802
|
sections
|
|
@@ -3623,7 +3804,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3623
3804
|
return result;
|
|
3624
3805
|
},
|
|
3625
3806
|
async push(locale, data, originalInput, _originalLocale, pullInput) {
|
|
3626
|
-
const content =
|
|
3807
|
+
const content = _25.chain(data.sections).values().join("\n\n").value();
|
|
3627
3808
|
const result = {
|
|
3628
3809
|
frontmatter: data.frontmatter,
|
|
3629
3810
|
codePlaceholders: pullInput?.codePlaceholders || {},
|
|
@@ -3684,15 +3865,15 @@ function createMdxLockedPatternsLoader(defaultPatterns) {
|
|
|
3684
3865
|
}
|
|
3685
3866
|
|
|
3686
3867
|
// src/cli/loaders/ignored-keys.ts
|
|
3687
|
-
import
|
|
3868
|
+
import _26 from "lodash";
|
|
3688
3869
|
function createIgnoredKeysLoader(ignoredKeys) {
|
|
3689
3870
|
return createLoader({
|
|
3690
3871
|
pull: async (locale, data) => {
|
|
3691
|
-
const result =
|
|
3872
|
+
const result = _26.chain(data).omit(ignoredKeys).value();
|
|
3692
3873
|
return result;
|
|
3693
3874
|
},
|
|
3694
3875
|
push: async (locale, data, originalInput, originalLocale, pullInput) => {
|
|
3695
|
-
const result =
|
|
3876
|
+
const result = _26.merge({}, data, _26.pick(pullInput, ignoredKeys));
|
|
3696
3877
|
return result;
|
|
3697
3878
|
}
|
|
3698
3879
|
});
|
|
@@ -3969,14 +4150,14 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
3969
4150
|
}
|
|
3970
4151
|
|
|
3971
4152
|
// src/cli/cmd/i18n.ts
|
|
3972
|
-
import
|
|
4153
|
+
import chalk5 from "chalk";
|
|
3973
4154
|
import { createTwoFilesPatch } from "diff";
|
|
3974
4155
|
import inquirer2 from "inquirer";
|
|
3975
4156
|
import externalEditor from "external-editor";
|
|
3976
4157
|
|
|
3977
4158
|
// src/cli/processor/index.ts
|
|
3978
|
-
import
|
|
3979
|
-
import
|
|
4159
|
+
import chalk4 from "chalk";
|
|
4160
|
+
import dedent4 from "dedent";
|
|
3980
4161
|
|
|
3981
4162
|
// src/cli/processor/lingo.ts
|
|
3982
4163
|
import { LingoDotDevEngine } from "@lingo.dev/_sdk";
|
|
@@ -4007,7 +4188,7 @@ function createLingoLocalizer(params) {
|
|
|
4007
4188
|
|
|
4008
4189
|
// src/cli/processor/basic.ts
|
|
4009
4190
|
import { generateText } from "ai";
|
|
4010
|
-
import
|
|
4191
|
+
import _27 from "lodash";
|
|
4011
4192
|
function createBasicTranslator(model, systemPrompt) {
|
|
4012
4193
|
return async (input2, onProgress) => {
|
|
4013
4194
|
const chunks = extractPayloadChunks(input2.processableData);
|
|
@@ -4021,7 +4202,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
4021
4202
|
subResults.push(result2);
|
|
4022
4203
|
onProgress(i / chunks.length * 100, chunk, result2);
|
|
4023
4204
|
}
|
|
4024
|
-
const result =
|
|
4205
|
+
const result = _27.merge({}, ...subResults);
|
|
4025
4206
|
return result;
|
|
4026
4207
|
};
|
|
4027
4208
|
async function doJob(input2) {
|
|
@@ -4133,23 +4314,23 @@ function createProcessor(provider, params) {
|
|
|
4133
4314
|
}
|
|
4134
4315
|
}
|
|
4135
4316
|
function getPureModelProvider(provider) {
|
|
4136
|
-
const createMissingKeyErrorMessage = (providerId, envVar) =>
|
|
4137
|
-
You're trying to use raw ${
|
|
4317
|
+
const createMissingKeyErrorMessage = (providerId, envVar) => dedent4`
|
|
4318
|
+
You're trying to use raw ${chalk4.dim(providerId)} API for translation, however, ${chalk4.dim(envVar)} environment variable is not set.
|
|
4138
4319
|
|
|
4139
4320
|
To fix this issue:
|
|
4140
|
-
1. Set ${
|
|
4141
|
-
2. Remove the ${
|
|
4321
|
+
1. Set ${chalk4.dim(envVar)} in your environment variables, or
|
|
4322
|
+
2. Remove the ${chalk4.italic("provider")} node from your i18n.json configuration to switch to ${chalk4.hex(colors.green)("Lingo.dev")}
|
|
4142
4323
|
|
|
4143
|
-
${
|
|
4324
|
+
${chalk4.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4144
4325
|
`;
|
|
4145
|
-
const createUnsupportedProviderErrorMessage = (providerId) =>
|
|
4146
|
-
You're trying to use unsupported provider: ${
|
|
4326
|
+
const createUnsupportedProviderErrorMessage = (providerId) => dedent4`
|
|
4327
|
+
You're trying to use unsupported provider: ${chalk4.dim(providerId)}.
|
|
4147
4328
|
|
|
4148
4329
|
To fix this issue:
|
|
4149
4330
|
1. Switch to one of the supported providers, or
|
|
4150
|
-
2. Remove the ${
|
|
4331
|
+
2. Remove the ${chalk4.italic("provider")} node from your i18n.json configuration to switch to ${chalk4.hex(colors.green)("Lingo.dev")}
|
|
4151
4332
|
|
|
4152
|
-
${
|
|
4333
|
+
${chalk4.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4153
4334
|
`;
|
|
4154
4335
|
switch (provider?.id) {
|
|
4155
4336
|
case "openai":
|
|
@@ -4230,7 +4411,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
4230
4411
|
}
|
|
4231
4412
|
|
|
4232
4413
|
// src/cli/utils/delta.ts
|
|
4233
|
-
import
|
|
4414
|
+
import _28 from "lodash";
|
|
4234
4415
|
import z from "zod";
|
|
4235
4416
|
|
|
4236
4417
|
// src/cli/utils/fs.ts
|
|
@@ -4279,9 +4460,9 @@ function createDeltaProcessor(fileKey) {
|
|
|
4279
4460
|
return checkIfFileExists(lockfilePath);
|
|
4280
4461
|
},
|
|
4281
4462
|
async calculateDelta(params) {
|
|
4282
|
-
let added =
|
|
4283
|
-
let removed =
|
|
4284
|
-
const updated =
|
|
4463
|
+
let added = _28.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
|
|
4464
|
+
let removed = _28.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
|
|
4465
|
+
const updated = _28.filter(Object.keys(params.sourceData), (key) => {
|
|
4285
4466
|
return md5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
|
|
4286
4467
|
});
|
|
4287
4468
|
const renamed = [];
|
|
@@ -4330,14 +4511,14 @@ function createDeltaProcessor(fileKey) {
|
|
|
4330
4511
|
await this.saveLock(lockfileData);
|
|
4331
4512
|
},
|
|
4332
4513
|
async createChecksums(sourceData) {
|
|
4333
|
-
const checksums =
|
|
4514
|
+
const checksums = _28.mapValues(sourceData, (value) => md5(value));
|
|
4334
4515
|
return checksums;
|
|
4335
4516
|
}
|
|
4336
4517
|
};
|
|
4337
4518
|
}
|
|
4338
4519
|
|
|
4339
4520
|
// src/cli/cmd/i18n.ts
|
|
4340
|
-
var i18n_default = new
|
|
4521
|
+
var i18n_default = new Command10().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
4341
4522
|
"--locale <locale>",
|
|
4342
4523
|
"Locale to process",
|
|
4343
4524
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
@@ -4502,7 +4683,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4502
4683
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
4503
4684
|
const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
|
|
4504
4685
|
const savedChecksums = await deltaProcessor.loadChecksums();
|
|
4505
|
-
const updatedSourceData =
|
|
4686
|
+
const updatedSourceData = _29.pickBy(
|
|
4506
4687
|
sourceData,
|
|
4507
4688
|
(value, key) => sourceChecksums[key] !== savedChecksums[key]
|
|
4508
4689
|
);
|
|
@@ -4516,15 +4697,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4516
4697
|
bucketPath.delimiter
|
|
4517
4698
|
);
|
|
4518
4699
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
4519
|
-
const missingKeys =
|
|
4700
|
+
const missingKeys = _29.difference(
|
|
4520
4701
|
Object.keys(sourceData),
|
|
4521
4702
|
Object.keys(targetData)
|
|
4522
4703
|
);
|
|
4523
|
-
const extraKeys =
|
|
4704
|
+
const extraKeys = _29.difference(
|
|
4524
4705
|
Object.keys(targetData),
|
|
4525
4706
|
Object.keys(sourceData)
|
|
4526
4707
|
);
|
|
4527
|
-
const unlocalizableDataDiff = !
|
|
4708
|
+
const unlocalizableDataDiff = !_29.isEqual(
|
|
4528
4709
|
sourceUnlocalizable,
|
|
4529
4710
|
targetUnlocalizable
|
|
4530
4711
|
);
|
|
@@ -4606,13 +4787,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4606
4787
|
targetData,
|
|
4607
4788
|
checksums: checksums2
|
|
4608
4789
|
});
|
|
4609
|
-
let processableData =
|
|
4790
|
+
let processableData = _29.chain(sourceData).entries().filter(
|
|
4610
4791
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
|
|
4611
4792
|
).fromPairs().value();
|
|
4612
4793
|
if (flags.key) {
|
|
4613
|
-
processableData =
|
|
4794
|
+
processableData = _29.pickBy(
|
|
4614
4795
|
processableData,
|
|
4615
|
-
(
|
|
4796
|
+
(_33, key) => key === flags.key
|
|
4616
4797
|
);
|
|
4617
4798
|
}
|
|
4618
4799
|
if (flags.verbose) {
|
|
@@ -4645,13 +4826,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4645
4826
|
if (flags.verbose) {
|
|
4646
4827
|
bucketOra.info(JSON.stringify(processedTargetData, null, 2));
|
|
4647
4828
|
}
|
|
4648
|
-
let finalTargetData =
|
|
4829
|
+
let finalTargetData = _29.merge(
|
|
4649
4830
|
{},
|
|
4650
4831
|
sourceData,
|
|
4651
4832
|
targetData,
|
|
4652
4833
|
processedTargetData
|
|
4653
4834
|
);
|
|
4654
|
-
finalTargetData =
|
|
4835
|
+
finalTargetData = _29.chain(finalTargetData).entries().map(([key, value]) => {
|
|
4655
4836
|
const renaming = delta.renamed.find(
|
|
4656
4837
|
([oldKey, newKey]) => oldKey === key
|
|
4657
4838
|
);
|
|
@@ -4675,7 +4856,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4675
4856
|
`Applying changes to ${bucketPath} (${targetLocale})`
|
|
4676
4857
|
);
|
|
4677
4858
|
}
|
|
4678
|
-
const finalDiffSize =
|
|
4859
|
+
const finalDiffSize = _29.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
4679
4860
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
4680
4861
|
if (finalDiffSize > 0 || flags.force) {
|
|
4681
4862
|
bucketOra.succeed(
|
|
@@ -4802,7 +4983,7 @@ async function reviewChanges(args) {
|
|
|
4802
4983
|
if (currentStr === proposedStr && !args.force) {
|
|
4803
4984
|
console.log(
|
|
4804
4985
|
`
|
|
4805
|
-
${
|
|
4986
|
+
${chalk5.blue(args.pathPattern)} (${chalk5.yellow(args.targetLocale)}): ${chalk5.gray("No changes to review")}`
|
|
4806
4987
|
);
|
|
4807
4988
|
return args.proposedData;
|
|
4808
4989
|
}
|
|
@@ -4816,14 +4997,14 @@ ${chalk2.blue(args.pathPattern)} (${chalk2.yellow(args.targetLocale)}): ${chalk2
|
|
|
4816
4997
|
{ context: 3 }
|
|
4817
4998
|
);
|
|
4818
4999
|
const coloredDiff = patch.split("\n").map((line) => {
|
|
4819
|
-
if (line.startsWith("+")) return
|
|
4820
|
-
if (line.startsWith("-")) return
|
|
4821
|
-
if (line.startsWith("@")) return
|
|
5000
|
+
if (line.startsWith("+")) return chalk5.green(line);
|
|
5001
|
+
if (line.startsWith("-")) return chalk5.red(line);
|
|
5002
|
+
if (line.startsWith("@")) return chalk5.cyan(line);
|
|
4822
5003
|
return line;
|
|
4823
5004
|
}).join("\n");
|
|
4824
5005
|
console.log(
|
|
4825
5006
|
`
|
|
4826
|
-
Reviewing changes for ${
|
|
5007
|
+
Reviewing changes for ${chalk5.blue(args.pathPattern)} (${chalk5.yellow(args.targetLocale)}):`
|
|
4827
5008
|
);
|
|
4828
5009
|
console.log(coloredDiff);
|
|
4829
5010
|
const { action } = await inquirer2.prompt([
|
|
@@ -4846,7 +5027,7 @@ Reviewing changes for ${chalk2.blue(args.pathPattern)} (${chalk2.yellow(args.tar
|
|
|
4846
5027
|
return args.currentData;
|
|
4847
5028
|
}
|
|
4848
5029
|
const customData = { ...args.currentData };
|
|
4849
|
-
const changes =
|
|
5030
|
+
const changes = _29.reduce(
|
|
4850
5031
|
args.proposedData,
|
|
4851
5032
|
(result, value, key) => {
|
|
4852
5033
|
if (args.currentData[key] !== value) {
|
|
@@ -4858,32 +5039,32 @@ Reviewing changes for ${chalk2.blue(args.pathPattern)} (${chalk2.yellow(args.tar
|
|
|
4858
5039
|
);
|
|
4859
5040
|
for (const key of changes) {
|
|
4860
5041
|
console.log(`
|
|
4861
|
-
Editing value for: ${
|
|
4862
|
-
console.log(
|
|
5042
|
+
Editing value for: ${chalk5.cyan(key)}`);
|
|
5043
|
+
console.log(chalk5.gray("Source text:"), chalk5.blue(args.sourceData[key]));
|
|
4863
5044
|
console.log(
|
|
4864
|
-
|
|
4865
|
-
|
|
5045
|
+
chalk5.gray("Current value:"),
|
|
5046
|
+
chalk5.red(args.currentData[key] || "(empty)")
|
|
4866
5047
|
);
|
|
4867
5048
|
console.log(
|
|
4868
|
-
|
|
4869
|
-
|
|
5049
|
+
chalk5.gray("Suggested value:"),
|
|
5050
|
+
chalk5.green(args.proposedData[key])
|
|
4870
5051
|
);
|
|
4871
5052
|
console.log(
|
|
4872
|
-
|
|
5053
|
+
chalk5.gray(
|
|
4873
5054
|
"\nYour editor will open. Edit the text and save to continue."
|
|
4874
5055
|
)
|
|
4875
5056
|
);
|
|
4876
|
-
console.log(
|
|
5057
|
+
console.log(chalk5.gray("------------"));
|
|
4877
5058
|
try {
|
|
4878
5059
|
const editorContent = [
|
|
4879
5060
|
"# Edit the translation below.",
|
|
4880
5061
|
"# Lines starting with # will be ignored.",
|
|
4881
5062
|
"# Save and exit the editor to continue.",
|
|
4882
5063
|
"#",
|
|
4883
|
-
`# Source text (${
|
|
5064
|
+
`# Source text (${chalk5.blue("English")}):`,
|
|
4884
5065
|
`# ${args.sourceData[key]}`,
|
|
4885
5066
|
"#",
|
|
4886
|
-
`# Current value (${
|
|
5067
|
+
`# Current value (${chalk5.red(args.targetLocale)}):`,
|
|
4887
5068
|
`# ${args.currentData[key] || "(empty)"}`,
|
|
4888
5069
|
"#",
|
|
4889
5070
|
args.proposedData[key]
|
|
@@ -4894,13 +5075,13 @@ Editing value for: ${chalk2.cyan(key)}`);
|
|
|
4894
5075
|
customData[key] = customValue;
|
|
4895
5076
|
} else {
|
|
4896
5077
|
console.log(
|
|
4897
|
-
|
|
5078
|
+
chalk5.yellow("Empty value provided, keeping the current value.")
|
|
4898
5079
|
);
|
|
4899
5080
|
customData[key] = args.currentData[key] || args.proposedData[key];
|
|
4900
5081
|
}
|
|
4901
5082
|
} catch (error) {
|
|
4902
5083
|
console.log(
|
|
4903
|
-
|
|
5084
|
+
chalk5.red("Error while editing, keeping the suggested value.")
|
|
4904
5085
|
);
|
|
4905
5086
|
customData[key] = args.proposedData[key];
|
|
4906
5087
|
}
|
|
@@ -4909,7 +5090,7 @@ Editing value for: ${chalk2.cyan(key)}`);
|
|
|
4909
5090
|
}
|
|
4910
5091
|
|
|
4911
5092
|
// src/cli/cmd/lockfile.ts
|
|
4912
|
-
import { Command as
|
|
5093
|
+
import { Command as Command11 } from "interactive-commander";
|
|
4913
5094
|
import Z5 from "zod";
|
|
4914
5095
|
import Ora6 from "ora";
|
|
4915
5096
|
|
|
@@ -4919,7 +5100,7 @@ import path14 from "path";
|
|
|
4919
5100
|
import Z4 from "zod";
|
|
4920
5101
|
import YAML5 from "yaml";
|
|
4921
5102
|
import { MD5 as MD52 } from "object-hash";
|
|
4922
|
-
import
|
|
5103
|
+
import _30 from "lodash";
|
|
4923
5104
|
function createLockfileHelper() {
|
|
4924
5105
|
return {
|
|
4925
5106
|
isLockfileExists: () => {
|
|
@@ -4929,23 +5110,23 @@ function createLockfileHelper() {
|
|
|
4929
5110
|
registerSourceData: (pathPattern, sourceData) => {
|
|
4930
5111
|
const lockfile = _loadLockfile();
|
|
4931
5112
|
const sectionKey = MD52(pathPattern);
|
|
4932
|
-
const sectionChecksums =
|
|
5113
|
+
const sectionChecksums = _30.mapValues(sourceData, (value) => MD52(value));
|
|
4933
5114
|
lockfile.checksums[sectionKey] = sectionChecksums;
|
|
4934
5115
|
_saveLockfile(lockfile);
|
|
4935
5116
|
},
|
|
4936
5117
|
registerPartialSourceData: (pathPattern, partialSourceData) => {
|
|
4937
5118
|
const lockfile = _loadLockfile();
|
|
4938
5119
|
const sectionKey = MD52(pathPattern);
|
|
4939
|
-
const sectionChecksums =
|
|
4940
|
-
lockfile.checksums[sectionKey] =
|
|
5120
|
+
const sectionChecksums = _30.mapValues(partialSourceData, (value) => MD52(value));
|
|
5121
|
+
lockfile.checksums[sectionKey] = _30.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
|
|
4941
5122
|
_saveLockfile(lockfile);
|
|
4942
5123
|
},
|
|
4943
5124
|
extractUpdatedData: (pathPattern, sourceData) => {
|
|
4944
5125
|
const lockfile = _loadLockfile();
|
|
4945
5126
|
const sectionKey = MD52(pathPattern);
|
|
4946
|
-
const currentChecksums =
|
|
5127
|
+
const currentChecksums = _30.mapValues(sourceData, (value) => MD52(value));
|
|
4947
5128
|
const savedChecksums = lockfile.checksums[sectionKey] || {};
|
|
4948
|
-
const updatedData =
|
|
5129
|
+
const updatedData = _30.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
|
|
4949
5130
|
return updatedData;
|
|
4950
5131
|
}
|
|
4951
5132
|
};
|
|
@@ -4984,7 +5165,7 @@ var LockfileSchema = Z4.object({
|
|
|
4984
5165
|
|
|
4985
5166
|
// src/cli/cmd/lockfile.ts
|
|
4986
5167
|
import { resolveOverriddenLocale as resolveOverriddenLocale4 } from "@lingo.dev/_spec";
|
|
4987
|
-
var lockfile_default = new
|
|
5168
|
+
var lockfile_default = new Command11().command("lockfile").description("Create a lockfile if it does not exist").helpOption("-h, --help", "Show help").option("-f, --force", "Force create a lockfile").action(async (options) => {
|
|
4988
5169
|
const flags = flagsSchema.parse(options);
|
|
4989
5170
|
const ora = Ora6();
|
|
4990
5171
|
const lockfileHelper = createLockfileHelper();
|
|
@@ -5014,10 +5195,10 @@ var flagsSchema = Z5.object({
|
|
|
5014
5195
|
|
|
5015
5196
|
// src/cli/cmd/cleanup.ts
|
|
5016
5197
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
5017
|
-
import { Command as
|
|
5018
|
-
import
|
|
5198
|
+
import { Command as Command12 } from "interactive-commander";
|
|
5199
|
+
import _31 from "lodash";
|
|
5019
5200
|
import Ora7 from "ora";
|
|
5020
|
-
var cleanup_default = new
|
|
5201
|
+
var cleanup_default = new Command12().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(
|
|
5021
5202
|
"--verbose",
|
|
5022
5203
|
"Show detailed output including:\n - List of keys that would be removed.\n - Processing steps."
|
|
5023
5204
|
).action(async function(options) {
|
|
@@ -5051,7 +5232,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
5051
5232
|
try {
|
|
5052
5233
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
5053
5234
|
const targetKeys = Object.keys(targetData);
|
|
5054
|
-
const keysToRemove =
|
|
5235
|
+
const keysToRemove = _31.difference(targetKeys, sourceKeys);
|
|
5055
5236
|
if (keysToRemove.length === 0) {
|
|
5056
5237
|
bucketOra.succeed(`[${targetLocale}] No keys to remove`);
|
|
5057
5238
|
continue;
|
|
@@ -5060,7 +5241,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
5060
5241
|
bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
|
|
5061
5242
|
}
|
|
5062
5243
|
if (!options.dryRun) {
|
|
5063
|
-
const cleanedData =
|
|
5244
|
+
const cleanedData = _31.pick(targetData, sourceKeys);
|
|
5064
5245
|
await bucketLoader.push(targetLocale, cleanedData);
|
|
5065
5246
|
bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
|
|
5066
5247
|
} else {
|
|
@@ -5110,12 +5291,12 @@ function displaySummary(results) {
|
|
|
5110
5291
|
}
|
|
5111
5292
|
|
|
5112
5293
|
// src/cli/cmd/mcp.ts
|
|
5113
|
-
import { Command as
|
|
5294
|
+
import { Command as Command13 } from "interactive-commander";
|
|
5114
5295
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5115
5296
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5116
5297
|
import Z6 from "zod";
|
|
5117
5298
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
5118
|
-
var mcp_default = new
|
|
5299
|
+
var mcp_default = new Command13().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_33, program) => {
|
|
5119
5300
|
const apiKey = program.args[0];
|
|
5120
5301
|
const settings = getSettings(apiKey);
|
|
5121
5302
|
if (!settings.auth.apiKey) {
|
|
@@ -5163,7 +5344,7 @@ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model
|
|
|
5163
5344
|
});
|
|
5164
5345
|
|
|
5165
5346
|
// src/cli/cmd/ci/index.ts
|
|
5166
|
-
import { Command as
|
|
5347
|
+
import { Command as Command14 } from "interactive-commander";
|
|
5167
5348
|
import createOra from "ora";
|
|
5168
5349
|
|
|
5169
5350
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
@@ -5826,7 +6007,7 @@ var getPlatformKit = () => {
|
|
|
5826
6007
|
};
|
|
5827
6008
|
|
|
5828
6009
|
// src/cli/cmd/ci/index.ts
|
|
5829
|
-
var ci_default = new
|
|
6010
|
+
var ci_default = new Command14().command("ci").description("Run Lingo.dev CI/CD action").helpOption("-h, --help", "Show help").option("--api-key <key>", "API key").option("--pull-request [boolean]", "Create a pull request with the changes").option("--commit-message <message>", "Commit message").option("--pull-request-title <title>", "Pull request title").option("--working-directory <dir>", "Working directory").option(
|
|
5830
6011
|
"--process-own-commits [boolean]",
|
|
5831
6012
|
"Process commits made by this action"
|
|
5832
6013
|
).action(async (options) => {
|
|
@@ -5879,12 +6060,12 @@ var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD
|
|
|
5879
6060
|
|
|
5880
6061
|
// src/cli/cmd/status.ts
|
|
5881
6062
|
import { bucketTypeSchema as bucketTypeSchema3, localeCodeSchema as localeCodeSchema2, resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
|
|
5882
|
-
import { Command as
|
|
6063
|
+
import { Command as Command15 } from "interactive-commander";
|
|
5883
6064
|
import Z11 from "zod";
|
|
5884
6065
|
import Ora8 from "ora";
|
|
5885
|
-
import
|
|
6066
|
+
import chalk6 from "chalk";
|
|
5886
6067
|
import Table from "cli-table3";
|
|
5887
|
-
var status_default = new
|
|
6068
|
+
var status_default = new Command15().command("status").description("Show the status of the localization process").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option(
|
|
5888
6069
|
"--file [files...]",
|
|
5889
6070
|
"File to process. Process only a specific path, may contain asterisk * to match multiple files."
|
|
5890
6071
|
).option("--force", "Ignore lockfile and process all keys, useful for estimating full re-translation").option("--verbose", "Show detailed output including key-level word counts").option("--api-key <api-key>", "Explicitly set the API key to use, override the default API key from settings").action(async function(options) {
|
|
@@ -6025,7 +6206,7 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6025
6206
|
languageStats[targetLocale].words += sourceWordCount;
|
|
6026
6207
|
totalWordCount.set(targetLocale, (totalWordCount.get(targetLocale) || 0) + sourceWordCount);
|
|
6027
6208
|
bucketOra.succeed(
|
|
6028
|
-
`[${sourceLocale} -> ${targetLocale}] ${
|
|
6209
|
+
`[${sourceLocale} -> ${targetLocale}] ${chalk6.red(`0% complete`)} (0/${sourceKeys.length} keys) - file not found`
|
|
6029
6210
|
);
|
|
6030
6211
|
continue;
|
|
6031
6212
|
}
|
|
@@ -6061,20 +6242,20 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6061
6242
|
const completionPercent = (completeKeys.length / totalKeysInFile * 100).toFixed(1);
|
|
6062
6243
|
if (missingKeys.length === 0 && updatedKeys.length === 0) {
|
|
6063
6244
|
bucketOra.succeed(
|
|
6064
|
-
`[${sourceLocale} -> ${targetLocale}] ${
|
|
6245
|
+
`[${sourceLocale} -> ${targetLocale}] ${chalk6.green(`100% complete`)} (${completeKeys.length}/${totalKeysInFile} keys)`
|
|
6065
6246
|
);
|
|
6066
6247
|
} else {
|
|
6067
|
-
const message = `[${sourceLocale} -> ${targetLocale}] ${parseFloat(completionPercent) > 50 ?
|
|
6248
|
+
const message = `[${sourceLocale} -> ${targetLocale}] ${parseFloat(completionPercent) > 50 ? chalk6.yellow(`${completionPercent}% complete`) : chalk6.red(`${completionPercent}% complete`)} (${completeKeys.length}/${totalKeysInFile} keys)`;
|
|
6068
6249
|
bucketOra.succeed(message);
|
|
6069
6250
|
if (flags.verbose) {
|
|
6070
6251
|
if (missingKeys.length > 0) {
|
|
6071
|
-
console.log(` ${
|
|
6252
|
+
console.log(` ${chalk6.red(`Missing:`)} ${missingKeys.length} keys, ~${wordsToTranslate} words`);
|
|
6072
6253
|
console.log(
|
|
6073
|
-
` ${
|
|
6254
|
+
` ${chalk6.dim(`Example missing: ${missingKeys.slice(0, 2).join(", ")}${missingKeys.length > 2 ? "..." : ""}`)}`
|
|
6074
6255
|
);
|
|
6075
6256
|
}
|
|
6076
6257
|
if (updatedKeys.length > 0) {
|
|
6077
|
-
console.log(` ${
|
|
6258
|
+
console.log(` ${chalk6.yellow(`Updated:`)} ${updatedKeys.length} keys that changed in source`);
|
|
6078
6259
|
}
|
|
6079
6260
|
}
|
|
6080
6261
|
}
|
|
@@ -6089,16 +6270,16 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6089
6270
|
}, 0);
|
|
6090
6271
|
const totalCompletedKeys = totalSourceKeyCount - totalKeysNeedingTranslation / targetLocales.length;
|
|
6091
6272
|
console.log();
|
|
6092
|
-
ora.succeed(
|
|
6093
|
-
console.log(
|
|
6273
|
+
ora.succeed(chalk6.green(`Localization status completed.`));
|
|
6274
|
+
console.log(chalk6.bold.cyan(`
|
|
6094
6275
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557`));
|
|
6095
|
-
console.log(
|
|
6096
|
-
console.log(
|
|
6097
|
-
console.log(
|
|
6276
|
+
console.log(chalk6.bold.cyan(`\u2551 LOCALIZATION STATUS REPORT \u2551`));
|
|
6277
|
+
console.log(chalk6.bold.cyan(`\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D`));
|
|
6278
|
+
console.log(chalk6.bold(`
|
|
6098
6279
|
\u{1F4DD} SOURCE CONTENT:`));
|
|
6099
|
-
console.log(`\u2022 Source language: ${
|
|
6100
|
-
console.log(`\u2022 Source keys: ${
|
|
6101
|
-
console.log(
|
|
6280
|
+
console.log(`\u2022 Source language: ${chalk6.green(i18nConfig.locale.source)}`);
|
|
6281
|
+
console.log(`\u2022 Source keys: ${chalk6.yellow(totalSourceKeyCount.toString())} keys across all files`);
|
|
6282
|
+
console.log(chalk6.bold(`
|
|
6102
6283
|
\u{1F310} LANGUAGE BY LANGUAGE BREAKDOWN:`));
|
|
6103
6284
|
const table = new Table({
|
|
6104
6285
|
head: ["Language", "Status", "Complete", "Missing", "Updated", "Total Keys", "Words to Translate"],
|
|
@@ -6120,19 +6301,19 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6120
6301
|
let statusColor;
|
|
6121
6302
|
if (stats.missing === totalSourceKeyCount) {
|
|
6122
6303
|
statusText = "\u{1F534} Not started";
|
|
6123
|
-
statusColor =
|
|
6304
|
+
statusColor = chalk6.red;
|
|
6124
6305
|
} else if (stats.missing === 0 && stats.updated === 0) {
|
|
6125
6306
|
statusText = "\u2705 Complete";
|
|
6126
|
-
statusColor =
|
|
6307
|
+
statusColor = chalk6.green;
|
|
6127
6308
|
} else if (parseFloat(percentComplete) > 80) {
|
|
6128
6309
|
statusText = "\u{1F7E1} Almost done";
|
|
6129
|
-
statusColor =
|
|
6310
|
+
statusColor = chalk6.yellow;
|
|
6130
6311
|
} else if (parseFloat(percentComplete) > 0) {
|
|
6131
6312
|
statusText = "\u{1F7E0} In progress";
|
|
6132
|
-
statusColor =
|
|
6313
|
+
statusColor = chalk6.yellow;
|
|
6133
6314
|
} else {
|
|
6134
6315
|
statusText = "\u{1F534} Not started";
|
|
6135
|
-
statusColor =
|
|
6316
|
+
statusColor = chalk6.red;
|
|
6136
6317
|
}
|
|
6137
6318
|
const words = totalWordCount.get(locale) || 0;
|
|
6138
6319
|
totalWordsToTranslate += words;
|
|
@@ -6140,17 +6321,17 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6140
6321
|
locale,
|
|
6141
6322
|
statusColor(statusText),
|
|
6142
6323
|
`${stats.complete}/${totalSourceKeyCount} (${percentComplete}%)`,
|
|
6143
|
-
stats.missing > 0 ?
|
|
6144
|
-
stats.updated > 0 ?
|
|
6145
|
-
totalNeeded > 0 ?
|
|
6324
|
+
stats.missing > 0 ? chalk6.red(stats.missing.toString()) : "0",
|
|
6325
|
+
stats.updated > 0 ? chalk6.yellow(stats.updated.toString()) : "0",
|
|
6326
|
+
totalNeeded > 0 ? chalk6.magenta(totalNeeded.toString()) : "0",
|
|
6146
6327
|
words > 0 ? `~${words.toLocaleString()}` : "0"
|
|
6147
6328
|
]);
|
|
6148
6329
|
}
|
|
6149
6330
|
console.log(table.toString());
|
|
6150
|
-
console.log(
|
|
6331
|
+
console.log(chalk6.bold(`
|
|
6151
6332
|
\u{1F4CA} USAGE ESTIMATE:`));
|
|
6152
6333
|
console.log(
|
|
6153
|
-
`\u2022 WORDS TO BE CONSUMED: ~${
|
|
6334
|
+
`\u2022 WORDS TO BE CONSUMED: ~${chalk6.yellow.bold(totalWordsToTranslate.toLocaleString())} words across all languages`
|
|
6154
6335
|
);
|
|
6155
6336
|
console.log(` (Words are counted from source language for keys that need translation in target languages)`);
|
|
6156
6337
|
if (targetLocales.length > 1) {
|
|
@@ -6162,11 +6343,11 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6162
6343
|
}
|
|
6163
6344
|
}
|
|
6164
6345
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
6165
|
-
console.log(
|
|
6346
|
+
console.log(chalk6.bold(`
|
|
6166
6347
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
6167
6348
|
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path16, stats]) => {
|
|
6168
6349
|
if (stats.sourceKeys === 0) return;
|
|
6169
|
-
console.log(
|
|
6350
|
+
console.log(chalk6.bold(`
|
|
6170
6351
|
\u2022 ${path16}:`));
|
|
6171
6352
|
console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
|
|
6172
6353
|
const fileTable = new Table({
|
|
@@ -6184,13 +6365,13 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6184
6365
|
const total = stats.sourceKeys;
|
|
6185
6366
|
const completion = (complete / total * 100).toFixed(1);
|
|
6186
6367
|
let status = "\u2705 Complete";
|
|
6187
|
-
let statusColor =
|
|
6368
|
+
let statusColor = chalk6.green;
|
|
6188
6369
|
if (langStats.missing === total) {
|
|
6189
6370
|
status = "\u274C Not started";
|
|
6190
|
-
statusColor =
|
|
6371
|
+
statusColor = chalk6.red;
|
|
6191
6372
|
} else if (langStats.missing > 0 || langStats.updated > 0) {
|
|
6192
6373
|
status = `\u26A0\uFE0F ${completion}% complete`;
|
|
6193
|
-
statusColor =
|
|
6374
|
+
statusColor = chalk6.yellow;
|
|
6194
6375
|
}
|
|
6195
6376
|
let details = "";
|
|
6196
6377
|
if (langStats.missing > 0 || langStats.updated > 0) {
|
|
@@ -6210,16 +6391,16 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6210
6391
|
(locale) => languageStats[locale].missing === 0 && languageStats[locale].updated === 0
|
|
6211
6392
|
);
|
|
6212
6393
|
const missingLanguages = targetLocales.filter((locale) => languageStats[locale].complete === 0);
|
|
6213
|
-
console.log(
|
|
6394
|
+
console.log(chalk6.bold.green(`
|
|
6214
6395
|
\u{1F4A1} OPTIMIZATION TIPS:`));
|
|
6215
6396
|
if (missingLanguages.length > 0) {
|
|
6216
6397
|
console.log(
|
|
6217
|
-
`\u2022 ${
|
|
6398
|
+
`\u2022 ${chalk6.yellow(missingLanguages.join(", "))} ${missingLanguages.length === 1 ? "has" : "have"} no translations yet`
|
|
6218
6399
|
);
|
|
6219
6400
|
}
|
|
6220
6401
|
if (completeLanguages.length > 0) {
|
|
6221
6402
|
console.log(
|
|
6222
|
-
`\u2022 ${
|
|
6403
|
+
`\u2022 ${chalk6.green(completeLanguages.join(", "))} ${completeLanguages.length === 1 ? "is" : "are"} completely translated`
|
|
6223
6404
|
);
|
|
6224
6405
|
}
|
|
6225
6406
|
if (targetLocales.length > 1) {
|
|
@@ -6295,10 +6476,10 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6295
6476
|
}
|
|
6296
6477
|
|
|
6297
6478
|
// src/cli/cmd/may-the-fourth.ts
|
|
6298
|
-
import { Command as
|
|
6479
|
+
import { Command as Command16 } from "interactive-commander";
|
|
6299
6480
|
import * as cp from "node:child_process";
|
|
6300
6481
|
import figlet from "figlet";
|
|
6301
|
-
import
|
|
6482
|
+
import chalk7 from "chalk";
|
|
6302
6483
|
import { vice } from "gradient-string";
|
|
6303
6484
|
var colors2 = {
|
|
6304
6485
|
orange: "#ff6600",
|
|
@@ -6308,11 +6489,11 @@ var colors2 = {
|
|
|
6308
6489
|
grey: "#808080",
|
|
6309
6490
|
red: "#ff0000"
|
|
6310
6491
|
};
|
|
6311
|
-
var may_the_fourth_default = new
|
|
6492
|
+
var may_the_fourth_default = new Command16().command("may-the-fourth").description("May the Fourth be with you").helpOption("-h, --help", "Show help").action(async () => {
|
|
6312
6493
|
await renderClear();
|
|
6313
6494
|
await renderBanner();
|
|
6314
6495
|
await renderSpacer();
|
|
6315
|
-
console.log(
|
|
6496
|
+
console.log(chalk7.hex(colors2.yellow)("Loading the Star Wars movie..."));
|
|
6316
6497
|
await renderSpacer();
|
|
6317
6498
|
await new Promise((resolve, reject) => {
|
|
6318
6499
|
const ssh = cp.spawn("ssh", ["starwarstel.net"], {
|
|
@@ -6331,10 +6512,10 @@ var may_the_fourth_default = new Command12().command("may-the-fourth").descripti
|
|
|
6331
6512
|
});
|
|
6332
6513
|
await renderSpacer();
|
|
6333
6514
|
console.log(
|
|
6334
|
-
`${
|
|
6515
|
+
`${chalk7.hex(colors2.green)("We hope you enjoyed it! :)")} ${chalk7.hex(colors2.blue)("May the Fourth be with you! \u{1F680}")}`
|
|
6335
6516
|
);
|
|
6336
6517
|
await renderSpacer();
|
|
6337
|
-
console.log(
|
|
6518
|
+
console.log(chalk7.dim(`---`));
|
|
6338
6519
|
await renderSpacer();
|
|
6339
6520
|
await renderHero();
|
|
6340
6521
|
});
|
|
@@ -6357,19 +6538,19 @@ async function renderBanner() {
|
|
|
6357
6538
|
}
|
|
6358
6539
|
async function renderHero() {
|
|
6359
6540
|
console.log(
|
|
6360
|
-
`\u26A1\uFE0F ${
|
|
6541
|
+
`\u26A1\uFE0F ${chalk7.hex(colors2.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
6361
6542
|
);
|
|
6362
6543
|
console.log(" ");
|
|
6363
6544
|
console.log(
|
|
6364
|
-
|
|
6545
|
+
chalk7.hex(colors2.blue)("\u2B50 GitHub Repo: https://lingo.dev/go/gh")
|
|
6365
6546
|
);
|
|
6366
|
-
console.log(
|
|
6547
|
+
console.log(chalk7.hex(colors2.blue)("\u{1F4AC} 24/7 Support: hi@lingo.dev"));
|
|
6367
6548
|
}
|
|
6368
6549
|
|
|
6369
6550
|
// package.json
|
|
6370
6551
|
var package_default = {
|
|
6371
6552
|
name: "lingo.dev",
|
|
6372
|
-
version: "0.92.
|
|
6553
|
+
version: "0.92.18",
|
|
6373
6554
|
description: "Lingo.dev CLI",
|
|
6374
6555
|
private: false,
|
|
6375
6556
|
publishConfig: {
|
|
@@ -6537,39 +6718,39 @@ var package_default = {
|
|
|
6537
6718
|
};
|
|
6538
6719
|
|
|
6539
6720
|
// src/cli/cmd/run/index.ts
|
|
6540
|
-
import { Command as
|
|
6721
|
+
import { Command as Command17 } from "interactive-commander";
|
|
6541
6722
|
|
|
6542
6723
|
// src/cli/cmd/run/setup.ts
|
|
6543
|
-
import
|
|
6724
|
+
import chalk11 from "chalk";
|
|
6544
6725
|
import { Listr } from "listr2";
|
|
6545
6726
|
|
|
6546
6727
|
// src/cli/cmd/run/_const.ts
|
|
6547
|
-
import
|
|
6728
|
+
import chalk8 from "chalk";
|
|
6548
6729
|
import { ListrDefaultRendererLogLevels } from "listr2";
|
|
6549
6730
|
var commonTaskRendererOptions = {
|
|
6550
6731
|
color: {
|
|
6551
|
-
[ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ?
|
|
6732
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ? chalk8.hex(colors.green)(msg) : chalk8.hex(colors.green)("")
|
|
6552
6733
|
},
|
|
6553
6734
|
icon: {
|
|
6554
|
-
[ListrDefaultRendererLogLevels.COMPLETED]:
|
|
6735
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: chalk8.hex(colors.green)("\u2713")
|
|
6555
6736
|
}
|
|
6556
6737
|
};
|
|
6557
6738
|
|
|
6558
6739
|
// src/cli/localizer/lingodotdev.ts
|
|
6559
|
-
import
|
|
6560
|
-
import
|
|
6740
|
+
import dedent5 from "dedent";
|
|
6741
|
+
import chalk9 from "chalk";
|
|
6561
6742
|
import { LingoDotDevEngine as LingoDotDevEngine2 } from "@lingo.dev/_sdk";
|
|
6562
6743
|
function createLingoDotDevLocalizer(explicitApiKey) {
|
|
6563
6744
|
const { auth } = getSettings(explicitApiKey);
|
|
6564
6745
|
if (!auth) {
|
|
6565
6746
|
throw new Error(
|
|
6566
|
-
|
|
6567
|
-
You're trying to use ${
|
|
6747
|
+
dedent5`
|
|
6748
|
+
You're trying to use ${chalk9.hex(colors.green)("Lingo.dev")} provider, however, you are not authenticated.
|
|
6568
6749
|
|
|
6569
6750
|
To fix this issue:
|
|
6570
|
-
1. Run ${
|
|
6571
|
-
2. Use the ${
|
|
6572
|
-
3. Set ${
|
|
6751
|
+
1. Run ${chalk9.dim("lingo.dev login")} to authenticate, or
|
|
6752
|
+
2. Use the ${chalk9.dim("--api-key")} flag to provide an API key.
|
|
6753
|
+
3. Set ${chalk9.dim("LINGODOTDEV_API_KEY")} environment variable.
|
|
6573
6754
|
`
|
|
6574
6755
|
);
|
|
6575
6756
|
}
|
|
@@ -6614,22 +6795,22 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
6614
6795
|
// src/cli/localizer/explicit.ts
|
|
6615
6796
|
import { createAnthropic as createAnthropic2 } from "@ai-sdk/anthropic";
|
|
6616
6797
|
import { createOpenAI as createOpenAI2 } from "@ai-sdk/openai";
|
|
6617
|
-
import
|
|
6618
|
-
import
|
|
6798
|
+
import chalk10 from "chalk";
|
|
6799
|
+
import dedent6 from "dedent";
|
|
6619
6800
|
import { generateText as generateText2 } from "ai";
|
|
6620
6801
|
import { jsonrepair as jsonrepair3 } from "jsonrepair";
|
|
6621
6802
|
function createExplicitLocalizer(provider) {
|
|
6622
6803
|
switch (provider.id) {
|
|
6623
6804
|
default:
|
|
6624
6805
|
throw new Error(
|
|
6625
|
-
|
|
6626
|
-
You're trying to use unsupported provider: ${
|
|
6806
|
+
dedent6`
|
|
6807
|
+
You're trying to use unsupported provider: ${chalk10.dim(provider.id)}.
|
|
6627
6808
|
|
|
6628
6809
|
To fix this issue:
|
|
6629
6810
|
1. Switch to one of the supported providers, or
|
|
6630
|
-
2. Remove the ${
|
|
6811
|
+
2. Remove the ${chalk10.italic("provider")} node from your i18n.json configuration to switch to ${chalk10.hex(colors.green)("Lingo.dev")}
|
|
6631
6812
|
|
|
6632
|
-
${
|
|
6813
|
+
${chalk10.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
6633
6814
|
`
|
|
6634
6815
|
);
|
|
6635
6816
|
case "openai":
|
|
@@ -6654,14 +6835,14 @@ function createAiSdkLocalizer(params) {
|
|
|
6654
6835
|
const apiKey = process.env[params.apiKeyName];
|
|
6655
6836
|
if (!apiKey) {
|
|
6656
6837
|
throw new Error(
|
|
6657
|
-
|
|
6658
|
-
You're trying to use raw ${
|
|
6838
|
+
dedent6`
|
|
6839
|
+
You're trying to use raw ${chalk10.dim(params.id)} API for translation, however, ${chalk10.dim(params.apiKeyName)} environment variable is not set.
|
|
6659
6840
|
|
|
6660
6841
|
To fix this issue:
|
|
6661
|
-
1. Set ${
|
|
6662
|
-
2. Remove the ${
|
|
6842
|
+
1. Set ${chalk10.dim(params.apiKeyName)} in your environment variables, or
|
|
6843
|
+
2. Remove the ${chalk10.italic("provider")} node from your i18n.json configuration to switch to ${chalk10.hex(colors.green)("Lingo.dev")}
|
|
6663
6844
|
|
|
6664
|
-
${
|
|
6845
|
+
${chalk10.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
6665
6846
|
`
|
|
6666
6847
|
);
|
|
6667
6848
|
}
|
|
@@ -6748,7 +6929,7 @@ function createLocalizer(provider) {
|
|
|
6748
6929
|
|
|
6749
6930
|
// src/cli/cmd/run/setup.ts
|
|
6750
6931
|
async function setup(input2) {
|
|
6751
|
-
console.log(
|
|
6932
|
+
console.log(chalk11.hex(colors.orange)("[Setup]"));
|
|
6752
6933
|
return new Listr(
|
|
6753
6934
|
[
|
|
6754
6935
|
{
|
|
@@ -6794,7 +6975,7 @@ async function setup(input2) {
|
|
|
6794
6975
|
"Could not create localization provider. Please check your i18n.json configuration."
|
|
6795
6976
|
);
|
|
6796
6977
|
}
|
|
6797
|
-
task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${
|
|
6978
|
+
task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${chalk11.hex(colors.green)(ctx.localizer.id)} provider` : `Using raw ${chalk11.hex(colors.yellow)(ctx.localizer.id)} API`;
|
|
6798
6979
|
}
|
|
6799
6980
|
},
|
|
6800
6981
|
{
|
|
@@ -6803,10 +6984,10 @@ async function setup(input2) {
|
|
|
6803
6984
|
const authStatus = await ctx.localizer.checkAuth();
|
|
6804
6985
|
if (!authStatus.authenticated) {
|
|
6805
6986
|
throw new Error(
|
|
6806
|
-
`Failed to authenticate with ${
|
|
6987
|
+
`Failed to authenticate with ${chalk11.hex(colors.yellow)(ctx.localizer.id)} provider. Please check your API key and try again.`
|
|
6807
6988
|
);
|
|
6808
6989
|
}
|
|
6809
|
-
task.title = `Authenticated as ${
|
|
6990
|
+
task.title = `Authenticated as ${chalk11.hex(colors.yellow)(authStatus.username)}`;
|
|
6810
6991
|
}
|
|
6811
6992
|
},
|
|
6812
6993
|
{
|
|
@@ -6840,11 +7021,11 @@ async function setup(input2) {
|
|
|
6840
7021
|
}
|
|
6841
7022
|
|
|
6842
7023
|
// src/cli/cmd/run/plan.ts
|
|
6843
|
-
import
|
|
7024
|
+
import chalk12 from "chalk";
|
|
6844
7025
|
import { Listr as Listr2 } from "listr2";
|
|
6845
7026
|
import { resolveOverriddenLocale as resolveOverriddenLocale7 } from "@lingo.dev/_spec";
|
|
6846
7027
|
async function plan(input2) {
|
|
6847
|
-
console.log(
|
|
7028
|
+
console.log(chalk12.hex(colors.orange)("[Planning]"));
|
|
6848
7029
|
let buckets = getBuckets(input2.config);
|
|
6849
7030
|
if (input2.flags.bucket) {
|
|
6850
7031
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
@@ -6859,8 +7040,8 @@ async function plan(input2) {
|
|
|
6859
7040
|
title: "Locating content buckets",
|
|
6860
7041
|
task: async (ctx, task) => {
|
|
6861
7042
|
const bucketCount = buckets.length;
|
|
6862
|
-
const bucketFilter = input2.flags.bucket ? ` ${
|
|
6863
|
-
task.title = `Found ${
|
|
7043
|
+
const bucketFilter = input2.flags.bucket ? ` ${chalk12.dim(`(filtered by: ${chalk12.hex(colors.yellow)(input2.flags.bucket.join(", "))})`)}` : "";
|
|
7044
|
+
task.title = `Found ${chalk12.hex(colors.yellow)(bucketCount.toString())} bucket(s)${bucketFilter}`;
|
|
6864
7045
|
}
|
|
6865
7046
|
},
|
|
6866
7047
|
{
|
|
@@ -6871,8 +7052,8 @@ async function plan(input2) {
|
|
|
6871
7052
|
`No target locales found in config. Please add locales to your i18n.json config file.`
|
|
6872
7053
|
);
|
|
6873
7054
|
}
|
|
6874
|
-
const localeFilter = input2.flags.locale ? ` ${
|
|
6875
|
-
task.title = `Found ${
|
|
7055
|
+
const localeFilter = input2.flags.locale ? ` ${chalk12.dim(`(filtered by: ${chalk12.hex(colors.yellow)(input2.flags.locale.join(", "))})`)}` : "";
|
|
7056
|
+
task.title = `Found ${chalk12.hex(colors.yellow)(locales.length.toString())} target locale(s)${localeFilter}`;
|
|
6876
7057
|
}
|
|
6877
7058
|
},
|
|
6878
7059
|
{
|
|
@@ -6891,8 +7072,8 @@ async function plan(input2) {
|
|
|
6891
7072
|
patterns.push(bucketPath.pathPattern);
|
|
6892
7073
|
}
|
|
6893
7074
|
}
|
|
6894
|
-
const fileFilter = input2.flags.file ? ` ${
|
|
6895
|
-
task.title = `Found ${
|
|
7075
|
+
const fileFilter = input2.flags.file ? ` ${chalk12.dim(`(filtered by: ${chalk12.hex(colors.yellow)(input2.flags.file.join(", "))})`)}` : "";
|
|
7076
|
+
task.title = `Found ${chalk12.hex(colors.yellow)(patterns.length.toString())} path pattern(s)${fileFilter}`;
|
|
6896
7077
|
}
|
|
6897
7078
|
},
|
|
6898
7079
|
{
|
|
@@ -6929,7 +7110,7 @@ async function plan(input2) {
|
|
|
6929
7110
|
}
|
|
6930
7111
|
}
|
|
6931
7112
|
}
|
|
6932
|
-
task.title = `Prepared ${
|
|
7113
|
+
task.title = `Prepared ${chalk12.hex(colors.green)(ctx.tasks.length.toString())} translation task(s)`;
|
|
6933
7114
|
}
|
|
6934
7115
|
}
|
|
6935
7116
|
],
|
|
@@ -6940,10 +7121,10 @@ async function plan(input2) {
|
|
|
6940
7121
|
}
|
|
6941
7122
|
|
|
6942
7123
|
// src/cli/cmd/run/execute.ts
|
|
6943
|
-
import
|
|
7124
|
+
import chalk13 from "chalk";
|
|
6944
7125
|
import { Listr as Listr3 } from "listr2";
|
|
6945
7126
|
import pLimit from "p-limit";
|
|
6946
|
-
import
|
|
7127
|
+
import _32 from "lodash";
|
|
6947
7128
|
var MAX_WORKER_COUNT = 10;
|
|
6948
7129
|
async function execute(input2) {
|
|
6949
7130
|
const effectiveConcurrency = Math.min(
|
|
@@ -6951,17 +7132,17 @@ async function execute(input2) {
|
|
|
6951
7132
|
input2.tasks.length,
|
|
6952
7133
|
MAX_WORKER_COUNT
|
|
6953
7134
|
);
|
|
6954
|
-
console.log(
|
|
7135
|
+
console.log(chalk13.hex(colors.orange)(`[Localization]`));
|
|
6955
7136
|
return new Listr3(
|
|
6956
7137
|
[
|
|
6957
7138
|
{
|
|
6958
7139
|
title: "Initializing localization engine",
|
|
6959
7140
|
task: async (ctx, task) => {
|
|
6960
|
-
task.title = `Localization engine ${
|
|
7141
|
+
task.title = `Localization engine ${chalk13.hex(colors.green)("ready")} (${ctx.localizer.id})`;
|
|
6961
7142
|
}
|
|
6962
7143
|
},
|
|
6963
7144
|
{
|
|
6964
|
-
title: `Processing localization tasks ${
|
|
7145
|
+
title: `Processing localization tasks ${chalk13.dim(`(tasks: ${input2.tasks.length}, concurrency: ${effectiveConcurrency})`)}`,
|
|
6965
7146
|
task: (ctx, task) => {
|
|
6966
7147
|
if (input2.tasks.length < 1) {
|
|
6967
7148
|
task.title = `Skipping, nothing to localize.`;
|
|
@@ -6974,7 +7155,7 @@ async function execute(input2) {
|
|
|
6974
7155
|
const workerTasks = [];
|
|
6975
7156
|
for (let i = 0; i < workersCount; i++) {
|
|
6976
7157
|
const assignedTasks = ctx.tasks.filter(
|
|
6977
|
-
(
|
|
7158
|
+
(_33, idx) => idx % workersCount === i
|
|
6978
7159
|
);
|
|
6979
7160
|
workerTasks.push(
|
|
6980
7161
|
createWorkerTask({
|
|
@@ -7010,9 +7191,9 @@ function createWorkerStatusMessage(args) {
|
|
|
7010
7191
|
"[locale]",
|
|
7011
7192
|
args.assignedTask.targetLocale
|
|
7012
7193
|
);
|
|
7013
|
-
return `[${
|
|
7194
|
+
return `[${chalk13.hex(colors.yellow)(`${args.percentage}%`)}] Processing: ${chalk13.dim(
|
|
7014
7195
|
displayPath
|
|
7015
|
-
)} (${
|
|
7196
|
+
)} (${chalk13.hex(colors.yellow)(args.assignedTask.sourceLocale)} -> ${chalk13.hex(
|
|
7016
7197
|
colors.yellow
|
|
7017
7198
|
)(args.assignedTask.targetLocale)})`;
|
|
7018
7199
|
}
|
|
@@ -7029,7 +7210,7 @@ function createExecutionProgressMessage(ctx) {
|
|
|
7029
7210
|
ctx,
|
|
7030
7211
|
(_t, result) => result.status === "skipped"
|
|
7031
7212
|
);
|
|
7032
|
-
return `Processed ${
|
|
7213
|
+
return `Processed ${chalk13.green(succeededTasksCount)}/${ctx.tasks.length}, Failed ${chalk13.red(failedTasksCount)}, Skipped ${chalk13.dim(skippedTasksCount)}`;
|
|
7033
7214
|
}
|
|
7034
7215
|
function createLoaderForTask(assignedTask) {
|
|
7035
7216
|
const bucketLoader = createBucketLoader(
|
|
@@ -7073,7 +7254,7 @@ function createWorkerTask(args) {
|
|
|
7073
7254
|
targetData,
|
|
7074
7255
|
checksums
|
|
7075
7256
|
});
|
|
7076
|
-
const processableData =
|
|
7257
|
+
const processableData = _32.chain(sourceData).entries().filter(
|
|
7077
7258
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
7078
7259
|
).fromPairs().value();
|
|
7079
7260
|
if (!Object.keys(processableData).length) {
|
|
@@ -7094,13 +7275,13 @@ function createWorkerTask(args) {
|
|
|
7094
7275
|
});
|
|
7095
7276
|
}
|
|
7096
7277
|
);
|
|
7097
|
-
let finalTargetData =
|
|
7278
|
+
let finalTargetData = _32.merge(
|
|
7098
7279
|
{},
|
|
7099
7280
|
sourceData,
|
|
7100
7281
|
targetData,
|
|
7101
7282
|
processedTargetData
|
|
7102
7283
|
);
|
|
7103
|
-
finalTargetData =
|
|
7284
|
+
finalTargetData = _32.chain(finalTargetData).entries().map(([key, value]) => {
|
|
7104
7285
|
const renaming = delta.renamed.find(
|
|
7105
7286
|
([oldKey]) => oldKey === key
|
|
7106
7287
|
);
|
|
@@ -7160,7 +7341,7 @@ var flagsSchema2 = z2.object({
|
|
|
7160
7341
|
});
|
|
7161
7342
|
|
|
7162
7343
|
// src/cli/cmd/run/_render.ts
|
|
7163
|
-
import
|
|
7344
|
+
import chalk14 from "chalk";
|
|
7164
7345
|
import figlet2 from "figlet";
|
|
7165
7346
|
import { vice as vice2 } from "gradient-string";
|
|
7166
7347
|
import readline2 from "readline";
|
|
@@ -7183,7 +7364,7 @@ async function renderBanner2() {
|
|
|
7183
7364
|
}
|
|
7184
7365
|
async function renderHero2() {
|
|
7185
7366
|
console.log(
|
|
7186
|
-
`\u26A1\uFE0F ${
|
|
7367
|
+
`\u26A1\uFE0F ${chalk14.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
7187
7368
|
);
|
|
7188
7369
|
console.log("");
|
|
7189
7370
|
const label1 = "\u2B50 GitHub Repo:";
|
|
@@ -7191,13 +7372,13 @@ async function renderHero2() {
|
|
|
7191
7372
|
const label3 = "\u{1F4AC} 24/7 Support:";
|
|
7192
7373
|
const maxLabelWidth = 17;
|
|
7193
7374
|
console.log(
|
|
7194
|
-
`${
|
|
7375
|
+
`${chalk14.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${chalk14.hex(colors.blue)("https://lingo.dev/go/gh")}`
|
|
7195
7376
|
);
|
|
7196
7377
|
console.log(
|
|
7197
|
-
`${
|
|
7378
|
+
`${chalk14.hex(colors.blue)(label2.padEnd(maxLabelWidth + 1))} ${chalk14.hex(colors.blue)("https://lingo.dev/go/docs")}`
|
|
7198
7379
|
);
|
|
7199
7380
|
console.log(
|
|
7200
|
-
`${
|
|
7381
|
+
`${chalk14.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${chalk14.hex(colors.blue)("hi@lingo.dev")}`
|
|
7201
7382
|
);
|
|
7202
7383
|
}
|
|
7203
7384
|
async function pauseIfDebug(debug) {
|
|
@@ -7211,7 +7392,7 @@ async function waitForUserPrompt(message) {
|
|
|
7211
7392
|
output: process.stdout
|
|
7212
7393
|
});
|
|
7213
7394
|
return new Promise((resolve) => {
|
|
7214
|
-
rl.question(
|
|
7395
|
+
rl.question(chalk14.dim(`[${message}]
|
|
7215
7396
|
`), () => {
|
|
7216
7397
|
rl.close();
|
|
7217
7398
|
resolve();
|
|
@@ -7219,23 +7400,23 @@ async function waitForUserPrompt(message) {
|
|
|
7219
7400
|
});
|
|
7220
7401
|
}
|
|
7221
7402
|
async function renderSummary(ctx) {
|
|
7222
|
-
console.log(
|
|
7403
|
+
console.log(chalk14.hex(colors.green)("[Done]"));
|
|
7223
7404
|
const skippedTasksCount = Array.from(ctx.results.values()).filter(
|
|
7224
7405
|
(r) => r.status === "skipped"
|
|
7225
7406
|
).length;
|
|
7226
|
-
console.log(`\u2022 ${
|
|
7407
|
+
console.log(`\u2022 ${chalk14.hex(colors.yellow)(skippedTasksCount)} from cache`);
|
|
7227
7408
|
const succeededTasksCount = Array.from(ctx.results.values()).filter(
|
|
7228
7409
|
(r) => r.status === "success"
|
|
7229
7410
|
).length;
|
|
7230
|
-
console.log(`\u2022 ${
|
|
7411
|
+
console.log(`\u2022 ${chalk14.hex(colors.yellow)(succeededTasksCount)} processed`);
|
|
7231
7412
|
const failedTasksCount = Array.from(ctx.results.values()).filter(
|
|
7232
7413
|
(r) => r.status === "error"
|
|
7233
7414
|
).length;
|
|
7234
|
-
console.log(`\u2022 ${
|
|
7415
|
+
console.log(`\u2022 ${chalk14.hex(colors.yellow)(failedTasksCount)} failed`);
|
|
7235
7416
|
}
|
|
7236
7417
|
|
|
7237
7418
|
// src/cli/cmd/run/index.ts
|
|
7238
|
-
var run_default = new
|
|
7419
|
+
var run_default = new Command17().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
|
|
7239
7420
|
"--locale <locale>",
|
|
7240
7421
|
"Locale to process",
|
|
7241
7422
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
@@ -7309,7 +7490,7 @@ ${vice3(
|
|
|
7309
7490
|
|
|
7310
7491
|
Star the the repo :) https://github.com/LingoDotDev/lingo.dev
|
|
7311
7492
|
`
|
|
7312
|
-
).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(lockfile_default).addCommand(cleanup_default).addCommand(mcp_default).addCommand(ci_default).addCommand(status_default).addCommand(may_the_fourth_default, { hidden: true }).addCommand(run_default, { hidden: true }).exitOverride((err) => {
|
|
7493
|
+
).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(config_default2).addCommand(lockfile_default).addCommand(cleanup_default).addCommand(mcp_default).addCommand(ci_default).addCommand(status_default).addCommand(may_the_fourth_default, { hidden: true }).addCommand(run_default, { hidden: true }).exitOverride((err) => {
|
|
7313
7494
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
|
|
7314
7495
|
process.exit(0);
|
|
7315
7496
|
}
|