lingo.dev 0.92.15 → 0.92.17
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 +282 -105
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +489 -312
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
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
|
|
@@ -1096,7 +1271,8 @@ function createLoader(lDefinition) {
|
|
|
1096
1271
|
locale,
|
|
1097
1272
|
input2,
|
|
1098
1273
|
state.initCtx,
|
|
1099
|
-
state.defaultLocale
|
|
1274
|
+
state.defaultLocale,
|
|
1275
|
+
state.originalInput
|
|
1100
1276
|
);
|
|
1101
1277
|
state.pullOutput = result;
|
|
1102
1278
|
return result;
|
|
@@ -1144,7 +1320,7 @@ function createJsonLoader() {
|
|
|
1144
1320
|
|
|
1145
1321
|
// src/cli/loaders/flat.ts
|
|
1146
1322
|
import { flatten, unflatten } from "flat";
|
|
1147
|
-
import
|
|
1323
|
+
import _9 from "lodash";
|
|
1148
1324
|
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
1149
1325
|
function createFlatLoader() {
|
|
1150
1326
|
return composeLoaders(createDenormalizeLoader(), createNormalizeLoader());
|
|
@@ -1211,12 +1387,12 @@ function mapDenormalizedKeys(obj, denormalizedKeysMap) {
|
|
|
1211
1387
|
);
|
|
1212
1388
|
}
|
|
1213
1389
|
function denormalizeObjectKeys(obj) {
|
|
1214
|
-
if (
|
|
1215
|
-
return
|
|
1390
|
+
if (_9.isObject(obj) && !_9.isArray(obj)) {
|
|
1391
|
+
return _9.transform(
|
|
1216
1392
|
obj,
|
|
1217
1393
|
(result, value, key) => {
|
|
1218
1394
|
const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
|
|
1219
|
-
result[newKey] =
|
|
1395
|
+
result[newKey] = _9.isObject(value) && !_9.isDate(value) ? denormalizeObjectKeys(value) : value;
|
|
1220
1396
|
},
|
|
1221
1397
|
{}
|
|
1222
1398
|
);
|
|
@@ -1225,12 +1401,12 @@ function denormalizeObjectKeys(obj) {
|
|
|
1225
1401
|
}
|
|
1226
1402
|
}
|
|
1227
1403
|
function normalizeObjectKeys(obj) {
|
|
1228
|
-
if (
|
|
1229
|
-
return
|
|
1404
|
+
if (_9.isObject(obj) && !_9.isArray(obj)) {
|
|
1405
|
+
return _9.transform(
|
|
1230
1406
|
obj,
|
|
1231
1407
|
(result, value, key) => {
|
|
1232
1408
|
const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
|
|
1233
|
-
result[newKey] =
|
|
1409
|
+
result[newKey] = _9.isObject(value) && !_9.isDate(value) ? normalizeObjectKeys(value) : value;
|
|
1234
1410
|
},
|
|
1235
1411
|
{}
|
|
1236
1412
|
);
|
|
@@ -1249,7 +1425,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1249
1425
|
const trimmedResult = result.trim();
|
|
1250
1426
|
return trimmedResult;
|
|
1251
1427
|
},
|
|
1252
|
-
async push(locale, data,
|
|
1428
|
+
async push(locale, data, _33, originalLocale) {
|
|
1253
1429
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1254
1430
|
const finalPath = path10.resolve(draftPath);
|
|
1255
1431
|
const dirPath = path10.dirname(finalPath);
|
|
@@ -1345,15 +1521,15 @@ function createRootKeyLoader(replaceAll = false) {
|
|
|
1345
1521
|
}
|
|
1346
1522
|
|
|
1347
1523
|
// src/cli/loaders/flutter.ts
|
|
1348
|
-
import
|
|
1524
|
+
import _10 from "lodash";
|
|
1349
1525
|
function createFlutterLoader() {
|
|
1350
1526
|
return createLoader({
|
|
1351
1527
|
async pull(locale, input2) {
|
|
1352
|
-
const result =
|
|
1528
|
+
const result = _10.pickBy(input2, (value, key) => !key.startsWith("@"));
|
|
1353
1529
|
return result;
|
|
1354
1530
|
},
|
|
1355
1531
|
async push(locale, data, originalInput) {
|
|
1356
|
-
const result =
|
|
1532
|
+
const result = _10.merge({}, originalInput, { "@@locale": locale }, data);
|
|
1357
1533
|
return result;
|
|
1358
1534
|
}
|
|
1359
1535
|
});
|
|
@@ -1540,7 +1716,7 @@ function createAndroidLoader() {
|
|
|
1540
1716
|
// src/cli/loaders/csv.ts
|
|
1541
1717
|
import { parse } from "csv-parse/sync";
|
|
1542
1718
|
import { stringify } from "csv-stringify/sync";
|
|
1543
|
-
import
|
|
1719
|
+
import _11 from "lodash";
|
|
1544
1720
|
function createCsvLoader() {
|
|
1545
1721
|
return createLoader({
|
|
1546
1722
|
async pull(locale, _input) {
|
|
@@ -1549,7 +1725,7 @@ function createCsvLoader() {
|
|
|
1549
1725
|
skip_empty_lines: true
|
|
1550
1726
|
});
|
|
1551
1727
|
const result = {};
|
|
1552
|
-
|
|
1728
|
+
_11.forEach(input2, (row) => {
|
|
1553
1729
|
const key = row.id;
|
|
1554
1730
|
if (key && row[locale] && row[locale].trim() !== "") {
|
|
1555
1731
|
result[key] = row[locale];
|
|
@@ -1778,7 +1954,7 @@ function createPropertiesLoader() {
|
|
|
1778
1954
|
return result;
|
|
1779
1955
|
},
|
|
1780
1956
|
async push(locale, payload) {
|
|
1781
|
-
const result = Object.entries(payload).filter(([
|
|
1957
|
+
const result = Object.entries(payload).filter(([_33, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1782
1958
|
return result;
|
|
1783
1959
|
}
|
|
1784
1960
|
});
|
|
@@ -1864,7 +2040,7 @@ function createXcodeStringsdictLoader() {
|
|
|
1864
2040
|
}
|
|
1865
2041
|
|
|
1866
2042
|
// src/cli/loaders/xcode-xcstrings.ts
|
|
1867
|
-
import
|
|
2043
|
+
import _12 from "lodash";
|
|
1868
2044
|
function createXcodeXcstringsLoader(defaultLocale) {
|
|
1869
2045
|
return createLoader({
|
|
1870
2046
|
async pull(locale, input2, initCtx) {
|
|
@@ -1899,7 +2075,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1899
2075
|
async push(locale, payload, originalInput) {
|
|
1900
2076
|
const langDataToMerge = {};
|
|
1901
2077
|
langDataToMerge.strings = {};
|
|
1902
|
-
const input2 =
|
|
2078
|
+
const input2 = _12.cloneDeep(originalInput) || { sourceLanguage: locale, strings: {} };
|
|
1903
2079
|
for (const [key, value] of Object.entries(payload)) {
|
|
1904
2080
|
if (value === null || value === void 0) {
|
|
1905
2081
|
continue;
|
|
@@ -1945,7 +2121,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1945
2121
|
}
|
|
1946
2122
|
}
|
|
1947
2123
|
}
|
|
1948
|
-
const result =
|
|
2124
|
+
const result = _12.merge({}, originalInput, langDataToMerge);
|
|
1949
2125
|
return result;
|
|
1950
2126
|
}
|
|
1951
2127
|
});
|
|
@@ -2024,17 +2200,17 @@ async function formatDataWithPrettier(data, filePath, options) {
|
|
|
2024
2200
|
}
|
|
2025
2201
|
|
|
2026
2202
|
// src/cli/loaders/unlocalizable.ts
|
|
2027
|
-
import
|
|
2203
|
+
import _13 from "lodash";
|
|
2028
2204
|
import _isUrl from "is-url";
|
|
2029
2205
|
import { isValid, parseISO } from "date-fns";
|
|
2030
2206
|
function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys = false) {
|
|
2031
2207
|
const rules = {
|
|
2032
|
-
isEmpty: (v) =>
|
|
2208
|
+
isEmpty: (v) => _13.isEmpty(v),
|
|
2033
2209
|
isNumber: (v) => typeof v === "number" || /^[0-9]+$/.test(v),
|
|
2034
|
-
isBoolean: (v) =>
|
|
2035
|
-
isIsoDate: (v) =>
|
|
2036
|
-
isSystemId: (v) =>
|
|
2037
|
-
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)
|
|
2038
2214
|
};
|
|
2039
2215
|
return createLoader({
|
|
2040
2216
|
async pull(locale, input2) {
|
|
@@ -2045,18 +2221,18 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
2045
2221
|
}
|
|
2046
2222
|
}
|
|
2047
2223
|
return false;
|
|
2048
|
-
}).map(([key,
|
|
2049
|
-
const result =
|
|
2224
|
+
}).map(([key, _33]) => key);
|
|
2225
|
+
const result = _13.omitBy(input2, (_33, key) => passthroughKeys.includes(key));
|
|
2050
2226
|
if (returnUnlocalizedKeys) {
|
|
2051
|
-
result.unlocalizable =
|
|
2227
|
+
result.unlocalizable = _13.omitBy(input2, (_33, key) => !passthroughKeys.includes(key));
|
|
2052
2228
|
}
|
|
2053
2229
|
return result;
|
|
2054
2230
|
},
|
|
2055
2231
|
async push(locale, data, originalInput) {
|
|
2056
2232
|
if (isCacheRestore) {
|
|
2057
|
-
return
|
|
2233
|
+
return _13.merge({}, data);
|
|
2058
2234
|
}
|
|
2059
|
-
const result =
|
|
2235
|
+
const result = _13.merge({}, originalInput, data);
|
|
2060
2236
|
return result;
|
|
2061
2237
|
}
|
|
2062
2238
|
});
|
|
@@ -2069,7 +2245,7 @@ function _isIsoDate(v) {
|
|
|
2069
2245
|
}
|
|
2070
2246
|
|
|
2071
2247
|
// src/cli/loaders/po/index.ts
|
|
2072
|
-
import
|
|
2248
|
+
import _14 from "lodash";
|
|
2073
2249
|
import gettextParser from "gettext-parser";
|
|
2074
2250
|
function createPoLoader(params = { multiline: false }) {
|
|
2075
2251
|
return composeLoaders(createPoDataLoader(params), createPoContentLoader());
|
|
@@ -2082,7 +2258,7 @@ function createPoDataLoader(params) {
|
|
|
2082
2258
|
const sections = input2.split("\n\n").filter(Boolean);
|
|
2083
2259
|
for (const section of sections) {
|
|
2084
2260
|
const sectionPo = gettextParser.po.parse(section);
|
|
2085
|
-
const contextKey =
|
|
2261
|
+
const contextKey = _14.keys(sectionPo.translations)[0];
|
|
2086
2262
|
const entries = sectionPo.translations[contextKey];
|
|
2087
2263
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
2088
2264
|
if (msgid && entry.msgid) {
|
|
@@ -2101,13 +2277,13 @@ function createPoDataLoader(params) {
|
|
|
2101
2277
|
const originalSections = originalInput?.split("\n\n").filter(Boolean) || [];
|
|
2102
2278
|
const result = originalSections.map((section) => {
|
|
2103
2279
|
const sectionPo = gettextParser.po.parse(section);
|
|
2104
|
-
const contextKey =
|
|
2280
|
+
const contextKey = _14.keys(sectionPo.translations)[0];
|
|
2105
2281
|
const entries = sectionPo.translations[contextKey];
|
|
2106
2282
|
const msgid = Object.keys(entries).find((key) => entries[key].msgid);
|
|
2107
2283
|
if (!msgid) {
|
|
2108
2284
|
const currentSection = currentSections.find((cs) => {
|
|
2109
2285
|
const csPo = gettextParser.po.parse(cs);
|
|
2110
|
-
const csContextKey =
|
|
2286
|
+
const csContextKey = _14.keys(csPo.translations)[0];
|
|
2111
2287
|
const csEntries = csPo.translations[csContextKey];
|
|
2112
2288
|
const csMsgid = Object.keys(csEntries).find(
|
|
2113
2289
|
(key) => csEntries[key].msgid
|
|
@@ -2120,7 +2296,7 @@ function createPoDataLoader(params) {
|
|
|
2120
2296
|
return section;
|
|
2121
2297
|
}
|
|
2122
2298
|
if (data[msgid]) {
|
|
2123
|
-
const updatedPo =
|
|
2299
|
+
const updatedPo = _14.merge({}, sectionPo, {
|
|
2124
2300
|
translations: {
|
|
2125
2301
|
[contextKey]: {
|
|
2126
2302
|
[msgid]: {
|
|
@@ -2143,7 +2319,7 @@ function createPoDataLoader(params) {
|
|
|
2143
2319
|
function createPoContentLoader() {
|
|
2144
2320
|
return createLoader({
|
|
2145
2321
|
async pull(locale, input2, initCtx, originalLocale) {
|
|
2146
|
-
const result =
|
|
2322
|
+
const result = _14.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => {
|
|
2147
2323
|
const singularFallback = locale === originalLocale ? entry.msgid : null;
|
|
2148
2324
|
const pluralFallback = locale === originalLocale ? entry.msgid_plural || entry.msgid : null;
|
|
2149
2325
|
const hasPlural = entry.msgstr.length > 1;
|
|
@@ -2158,7 +2334,7 @@ function createPoContentLoader() {
|
|
|
2158
2334
|
return result;
|
|
2159
2335
|
},
|
|
2160
2336
|
async push(locale, data, originalInput) {
|
|
2161
|
-
const result =
|
|
2337
|
+
const result = _14.chain(originalInput).entries().map(([, entry]) => [
|
|
2162
2338
|
entry.msgid,
|
|
2163
2339
|
{
|
|
2164
2340
|
...entry,
|
|
@@ -2284,34 +2460,34 @@ var datoSettingsSchema = Z2.object({
|
|
|
2284
2460
|
});
|
|
2285
2461
|
|
|
2286
2462
|
// src/cli/loaders/dato/filter.ts
|
|
2287
|
-
import
|
|
2463
|
+
import _15 from "lodash";
|
|
2288
2464
|
function createDatoFilterLoader() {
|
|
2289
2465
|
return createLoader({
|
|
2290
2466
|
async pull(locale, input2) {
|
|
2291
2467
|
const result = {};
|
|
2292
|
-
for (const [modelId, modelInfo] of
|
|
2468
|
+
for (const [modelId, modelInfo] of _15.entries(input2)) {
|
|
2293
2469
|
result[modelId] = {};
|
|
2294
2470
|
for (const record of modelInfo.records) {
|
|
2295
|
-
result[modelId][record.id] =
|
|
2471
|
+
result[modelId][record.id] = _15.chain(modelInfo.fields).mapKeys((field) => field.api_key).mapValues((field) => _15.get(record, [field.api_key, locale])).value();
|
|
2296
2472
|
}
|
|
2297
2473
|
}
|
|
2298
2474
|
return result;
|
|
2299
2475
|
},
|
|
2300
2476
|
async push(locale, data, originalInput, originalLocale) {
|
|
2301
|
-
const result =
|
|
2302
|
-
for (const [modelId, modelInfo] of
|
|
2477
|
+
const result = _15.cloneDeep(originalInput || {});
|
|
2478
|
+
for (const [modelId, modelInfo] of _15.entries(result)) {
|
|
2303
2479
|
for (const record of modelInfo.records) {
|
|
2304
|
-
for (const [fieldId, fieldValue] of
|
|
2480
|
+
for (const [fieldId, fieldValue] of _15.entries(record)) {
|
|
2305
2481
|
const fieldInfo = modelInfo.fields.find((field) => field.api_key === fieldId);
|
|
2306
2482
|
if (fieldInfo) {
|
|
2307
|
-
const sourceFieldValue =
|
|
2308
|
-
const targetFieldValue =
|
|
2483
|
+
const sourceFieldValue = _15.get(fieldValue, [originalLocale]);
|
|
2484
|
+
const targetFieldValue = _15.get(data, [modelId, record.id, fieldId]);
|
|
2309
2485
|
if (targetFieldValue) {
|
|
2310
|
-
|
|
2486
|
+
_15.set(record, [fieldId, locale], targetFieldValue);
|
|
2311
2487
|
} else {
|
|
2312
|
-
|
|
2488
|
+
_15.set(record, [fieldId, locale], sourceFieldValue);
|
|
2313
2489
|
}
|
|
2314
|
-
|
|
2490
|
+
_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();
|
|
2315
2491
|
}
|
|
2316
2492
|
}
|
|
2317
2493
|
}
|
|
@@ -2322,10 +2498,10 @@ function createDatoFilterLoader() {
|
|
|
2322
2498
|
}
|
|
2323
2499
|
|
|
2324
2500
|
// src/cli/loaders/dato/api.ts
|
|
2325
|
-
import
|
|
2501
|
+
import _17 from "lodash";
|
|
2326
2502
|
|
|
2327
2503
|
// src/cli/loaders/dato/_utils.ts
|
|
2328
|
-
import
|
|
2504
|
+
import _16 from "lodash";
|
|
2329
2505
|
import { buildClient } from "@datocms/cma-client-node";
|
|
2330
2506
|
function createDatoClient(params) {
|
|
2331
2507
|
if (!params.apiKey) {
|
|
@@ -2500,7 +2676,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2500
2676
|
const result = {
|
|
2501
2677
|
models: {}
|
|
2502
2678
|
};
|
|
2503
|
-
const updatedConfig =
|
|
2679
|
+
const updatedConfig = _17.cloneDeep(config);
|
|
2504
2680
|
console.log(`Initializing DatoCMS loader...`);
|
|
2505
2681
|
const project = await dato.findProject();
|
|
2506
2682
|
const modelChoices = await getModelChoices(dato, config);
|
|
@@ -2518,7 +2694,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2518
2694
|
delete updatedConfig.models[modelId];
|
|
2519
2695
|
}
|
|
2520
2696
|
}
|
|
2521
|
-
for (const modelId of
|
|
2697
|
+
for (const modelId of _17.keys(updatedConfig.models)) {
|
|
2522
2698
|
const { modelName, fields } = await getModelFields(dato, modelId);
|
|
2523
2699
|
if (fields.length > 0) {
|
|
2524
2700
|
result.models[modelId] = { fields: [], records: [] };
|
|
@@ -2529,7 +2705,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2529
2705
|
const isLocalized = await updateFieldLocalization(dato, fieldInfo, selectedFields.includes(fieldInfo.id));
|
|
2530
2706
|
if (isLocalized) {
|
|
2531
2707
|
result.models[modelId].fields.push(fieldInfo);
|
|
2532
|
-
updatedConfig.models[modelId].fields =
|
|
2708
|
+
updatedConfig.models[modelId].fields = _17.uniq([
|
|
2533
2709
|
...updatedConfig.models[modelId].fields || [],
|
|
2534
2710
|
fieldInfo.api_key
|
|
2535
2711
|
]);
|
|
@@ -2548,7 +2724,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2548
2724
|
},
|
|
2549
2725
|
async pull(locale, input2, initCtx) {
|
|
2550
2726
|
const result = {};
|
|
2551
|
-
for (const modelId of
|
|
2727
|
+
for (const modelId of _17.keys(initCtx?.models || {})) {
|
|
2552
2728
|
let records = initCtx?.models[modelId].records || [];
|
|
2553
2729
|
const recordIds = records.map((record) => record.id);
|
|
2554
2730
|
records = await dato.findRecords(recordIds);
|
|
@@ -2563,7 +2739,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2563
2739
|
return result;
|
|
2564
2740
|
},
|
|
2565
2741
|
async push(locale, data, originalInput) {
|
|
2566
|
-
for (const modelId of
|
|
2742
|
+
for (const modelId of _17.keys(data)) {
|
|
2567
2743
|
for (let i = 0; i < data[modelId].records.length; i++) {
|
|
2568
2744
|
const record = data[modelId].records[i];
|
|
2569
2745
|
console.log(`Updating record ${i + 1}/${data[modelId].records.length} for model ${modelId}...`);
|
|
@@ -2577,7 +2753,7 @@ async function getModelFields(dato, modelId) {
|
|
|
2577
2753
|
const modelInfo = await dato.findModel(modelId);
|
|
2578
2754
|
return {
|
|
2579
2755
|
modelName: modelInfo.name,
|
|
2580
|
-
fields:
|
|
2756
|
+
fields: _17.filter(modelInfo.fields, (field) => field.type === "field")
|
|
2581
2757
|
};
|
|
2582
2758
|
}
|
|
2583
2759
|
async function getFieldDetails(dato, fields) {
|
|
@@ -2655,17 +2831,17 @@ async function promptModelSelection(choices) {
|
|
|
2655
2831
|
}
|
|
2656
2832
|
|
|
2657
2833
|
// src/cli/loaders/dato/extract.ts
|
|
2658
|
-
import
|
|
2834
|
+
import _18 from "lodash";
|
|
2659
2835
|
function createDatoExtractLoader() {
|
|
2660
2836
|
return createLoader({
|
|
2661
2837
|
async pull(locale, input2) {
|
|
2662
2838
|
const result = {};
|
|
2663
|
-
for (const [modelId, modelInfo] of
|
|
2664
|
-
for (const [recordId, record] of
|
|
2665
|
-
for (const [fieldName, fieldValue] of
|
|
2839
|
+
for (const [modelId, modelInfo] of _18.entries(input2)) {
|
|
2840
|
+
for (const [recordId, record] of _18.entries(modelInfo)) {
|
|
2841
|
+
for (const [fieldName, fieldValue] of _18.entries(record)) {
|
|
2666
2842
|
const parsedValue = createParsedDatoValue(fieldValue);
|
|
2667
2843
|
if (parsedValue) {
|
|
2668
|
-
|
|
2844
|
+
_18.set(result, [modelId, `_${recordId}`, fieldName], parsedValue);
|
|
2669
2845
|
}
|
|
2670
2846
|
}
|
|
2671
2847
|
}
|
|
@@ -2673,14 +2849,14 @@ function createDatoExtractLoader() {
|
|
|
2673
2849
|
return result;
|
|
2674
2850
|
},
|
|
2675
2851
|
async push(locale, data, originalInput) {
|
|
2676
|
-
const result =
|
|
2677
|
-
for (const [modelId, modelInfo] of
|
|
2678
|
-
for (const [virtualRecordId, record] of
|
|
2679
|
-
for (const [fieldName, fieldValue] of
|
|
2852
|
+
const result = _18.cloneDeep(originalInput || {});
|
|
2853
|
+
for (const [modelId, modelInfo] of _18.entries(data)) {
|
|
2854
|
+
for (const [virtualRecordId, record] of _18.entries(modelInfo)) {
|
|
2855
|
+
for (const [fieldName, fieldValue] of _18.entries(record)) {
|
|
2680
2856
|
const [, recordId] = virtualRecordId.split("_");
|
|
2681
|
-
const originalFieldValue =
|
|
2857
|
+
const originalFieldValue = _18.get(originalInput, [modelId, recordId, fieldName]);
|
|
2682
2858
|
const rawValue = createRawDatoValue(fieldValue, originalFieldValue, true);
|
|
2683
|
-
|
|
2859
|
+
_18.set(result, [modelId, recordId, fieldName], rawValue || originalFieldValue);
|
|
2684
2860
|
}
|
|
2685
2861
|
}
|
|
2686
2862
|
}
|
|
@@ -2689,25 +2865,25 @@ function createDatoExtractLoader() {
|
|
|
2689
2865
|
});
|
|
2690
2866
|
}
|
|
2691
2867
|
function detectDatoFieldType(rawDatoValue) {
|
|
2692
|
-
if (
|
|
2868
|
+
if (_18.has(rawDatoValue, "document") && _18.get(rawDatoValue, "schema") === "dast") {
|
|
2693
2869
|
return "structured_text";
|
|
2694
|
-
} else if (
|
|
2870
|
+
} else if (_18.has(rawDatoValue, "no_index") || _18.has(rawDatoValue, "twitter_card")) {
|
|
2695
2871
|
return "seo";
|
|
2696
|
-
} else if (
|
|
2872
|
+
} else if (_18.get(rawDatoValue, "type") === "item") {
|
|
2697
2873
|
return "single_block";
|
|
2698
|
-
} else if (
|
|
2874
|
+
} else if (_18.isArray(rawDatoValue) && _18.every(rawDatoValue, (item) => _18.get(item, "type") === "item")) {
|
|
2699
2875
|
return "rich_text";
|
|
2700
2876
|
} else if (_isFile(rawDatoValue)) {
|
|
2701
2877
|
return "file";
|
|
2702
|
-
} else if (
|
|
2878
|
+
} else if (_18.isArray(rawDatoValue) && _18.every(rawDatoValue, (item) => _isFile(item))) {
|
|
2703
2879
|
return "gallery";
|
|
2704
2880
|
} else if (_isJson(rawDatoValue)) {
|
|
2705
2881
|
return "json";
|
|
2706
|
-
} else if (
|
|
2882
|
+
} else if (_18.isString(rawDatoValue)) {
|
|
2707
2883
|
return "string";
|
|
2708
2884
|
} else if (_isVideo(rawDatoValue)) {
|
|
2709
2885
|
return "video";
|
|
2710
|
-
} else if (
|
|
2886
|
+
} else if (_18.isArray(rawDatoValue) && _18.every(rawDatoValue, (item) => _18.isString(item))) {
|
|
2711
2887
|
return "ref_list";
|
|
2712
2888
|
} else {
|
|
2713
2889
|
return null;
|
|
@@ -2769,9 +2945,9 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
2769
2945
|
if ("document" in node) {
|
|
2770
2946
|
return serializeStructuredTextNode(node.document, [...path16, "document"], acc);
|
|
2771
2947
|
}
|
|
2772
|
-
if (!
|
|
2948
|
+
if (!_18.isNil(node.value)) {
|
|
2773
2949
|
acc[[...path16, "value"].join(".")] = node.value;
|
|
2774
|
-
} else if (
|
|
2950
|
+
} else if (_18.get(node, "type") === "block") {
|
|
2775
2951
|
acc[[...path16, "item"].join(".")] = serializeBlock(node.item);
|
|
2776
2952
|
}
|
|
2777
2953
|
if (node.children) {
|
|
@@ -2783,44 +2959,44 @@ function serializeStructuredText(rawStructuredText) {
|
|
|
2783
2959
|
}
|
|
2784
2960
|
}
|
|
2785
2961
|
function serializeSeo(rawSeo) {
|
|
2786
|
-
return
|
|
2962
|
+
return _18.chain(rawSeo).pick(["title", "description"]).value();
|
|
2787
2963
|
}
|
|
2788
2964
|
function serializeBlock(rawBlock) {
|
|
2789
|
-
if (
|
|
2965
|
+
if (_18.get(rawBlock, "type") === "item" && _18.has(rawBlock, "id")) {
|
|
2790
2966
|
return serializeBlock(rawBlock.attributes);
|
|
2791
2967
|
}
|
|
2792
2968
|
const result = {};
|
|
2793
|
-
for (const [attributeName, attributeValue] of
|
|
2969
|
+
for (const [attributeName, attributeValue] of _18.entries(rawBlock)) {
|
|
2794
2970
|
result[attributeName] = createParsedDatoValue(attributeValue);
|
|
2795
2971
|
}
|
|
2796
2972
|
return result;
|
|
2797
2973
|
}
|
|
2798
2974
|
function serializeBlockList(rawBlockList) {
|
|
2799
|
-
return
|
|
2975
|
+
return _18.chain(rawBlockList).map((block) => serializeBlock(block)).value();
|
|
2800
2976
|
}
|
|
2801
2977
|
function serializeVideo(rawVideo) {
|
|
2802
|
-
return
|
|
2978
|
+
return _18.chain(rawVideo).pick(["title"]).value();
|
|
2803
2979
|
}
|
|
2804
2980
|
function serializeFile(rawFile) {
|
|
2805
|
-
return
|
|
2981
|
+
return _18.chain(rawFile).pick(["alt", "title"]).value();
|
|
2806
2982
|
}
|
|
2807
2983
|
function serializeGallery(rawGallery) {
|
|
2808
|
-
return
|
|
2984
|
+
return _18.chain(rawGallery).map((item) => serializeFile(item)).value();
|
|
2809
2985
|
}
|
|
2810
2986
|
function deserializeFile(parsedFile, originalRawFile) {
|
|
2811
|
-
return
|
|
2987
|
+
return _18.chain(parsedFile).defaults(originalRawFile).value();
|
|
2812
2988
|
}
|
|
2813
2989
|
function deserializeGallery(parsedGallery, originalRawGallery) {
|
|
2814
|
-
return
|
|
2990
|
+
return _18.chain(parsedGallery).map((item, i) => deserializeFile(item, originalRawGallery[i])).value();
|
|
2815
2991
|
}
|
|
2816
2992
|
function deserializeVideo(parsedVideo, originalRawVideo) {
|
|
2817
|
-
return
|
|
2993
|
+
return _18.chain(parsedVideo).defaults(originalRawVideo).value();
|
|
2818
2994
|
}
|
|
2819
2995
|
function deserializeBlock(payload, rawNode, isClean = false) {
|
|
2820
|
-
const result =
|
|
2821
|
-
for (const [attributeName, attributeValue] of
|
|
2996
|
+
const result = _18.cloneDeep(rawNode);
|
|
2997
|
+
for (const [attributeName, attributeValue] of _18.entries(rawNode.attributes)) {
|
|
2822
2998
|
const rawValue = createRawDatoValue(payload[attributeName], attributeValue, isClean);
|
|
2823
|
-
|
|
2999
|
+
_18.set(result, ["attributes", attributeName], rawValue);
|
|
2824
3000
|
}
|
|
2825
3001
|
if (isClean) {
|
|
2826
3002
|
delete result["id"];
|
|
@@ -2828,33 +3004,33 @@ function deserializeBlock(payload, rawNode, isClean = false) {
|
|
|
2828
3004
|
return result;
|
|
2829
3005
|
}
|
|
2830
3006
|
function deserializeSeo(parsedSeo, originalRawSeo) {
|
|
2831
|
-
return
|
|
3007
|
+
return _18.chain(parsedSeo).pick(["title", "description"]).defaults(originalRawSeo).value();
|
|
2832
3008
|
}
|
|
2833
3009
|
function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = false) {
|
|
2834
|
-
return
|
|
3010
|
+
return _18.chain(parsedBlockList).map((block, i) => deserializeBlock(block, originalRawBlockList[i], isClean)).value();
|
|
2835
3011
|
}
|
|
2836
3012
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2837
|
-
const result =
|
|
2838
|
-
for (const [path16, value] of
|
|
2839
|
-
const realPath =
|
|
2840
|
-
const deserializedValue = createRawDatoValue(value,
|
|
2841
|
-
|
|
3013
|
+
const result = _18.cloneDeep(originalRawStructuredText);
|
|
3014
|
+
for (const [path16, value] of _18.entries(parsedStructuredText)) {
|
|
3015
|
+
const realPath = _18.chain(path16.split(".")).flatMap((s) => !_18.isNaN(_18.toNumber(s)) ? ["children", s] : s).value();
|
|
3016
|
+
const deserializedValue = createRawDatoValue(value, _18.get(originalRawStructuredText, realPath), true);
|
|
3017
|
+
_18.set(result, realPath, deserializedValue);
|
|
2842
3018
|
}
|
|
2843
3019
|
return result;
|
|
2844
3020
|
}
|
|
2845
3021
|
function _isJson(rawDatoValue) {
|
|
2846
3022
|
try {
|
|
2847
|
-
return
|
|
3023
|
+
return _18.isString(rawDatoValue) && rawDatoValue.startsWith("{") && rawDatoValue.endsWith("}") && !!JSON.parse(rawDatoValue);
|
|
2848
3024
|
} catch (e) {
|
|
2849
3025
|
return false;
|
|
2850
3026
|
}
|
|
2851
3027
|
}
|
|
2852
3028
|
function _isFile(rawDatoValue) {
|
|
2853
|
-
return
|
|
3029
|
+
return _18.isObject(rawDatoValue) && ["alt", "title", "custom_data", "focal_point", "upload_id"].every((key) => _18.has(rawDatoValue, key));
|
|
2854
3030
|
}
|
|
2855
3031
|
function _isVideo(rawDatoValue) {
|
|
2856
|
-
return
|
|
2857
|
-
(key) =>
|
|
3032
|
+
return _18.isObject(rawDatoValue) && ["url", "title", "width", "height", "provider", "provider_uid", "thumbnail_url"].every(
|
|
3033
|
+
(key) => _18.has(rawDatoValue, key)
|
|
2858
3034
|
);
|
|
2859
3035
|
}
|
|
2860
3036
|
|
|
@@ -2915,18 +3091,19 @@ function createVttLoader() {
|
|
|
2915
3091
|
}
|
|
2916
3092
|
|
|
2917
3093
|
// src/cli/loaders/variable/index.ts
|
|
2918
|
-
import
|
|
3094
|
+
import _19 from "lodash";
|
|
2919
3095
|
function createVariableLoader(params) {
|
|
2920
3096
|
return composeLoaders(variableExtractLoader(params), variableContentLoader());
|
|
2921
3097
|
}
|
|
2922
3098
|
function variableExtractLoader(params) {
|
|
2923
3099
|
const specifierPattern = getFormatSpecifierPattern(params.type);
|
|
2924
3100
|
return createLoader({
|
|
2925
|
-
pull: async (locale, input2) => {
|
|
3101
|
+
pull: async (locale, input2, initXtx, originalLocale, originalInput) => {
|
|
2926
3102
|
const result = {};
|
|
2927
|
-
const inputValues =
|
|
3103
|
+
const inputValues = _19.omitBy(input2, _19.isEmpty);
|
|
2928
3104
|
for (const [key, value] of Object.entries(inputValues)) {
|
|
2929
|
-
const
|
|
3105
|
+
const originalValue = originalInput[key];
|
|
3106
|
+
const matches = originalValue.match(specifierPattern) || [];
|
|
2930
3107
|
result[key] = result[key] || {
|
|
2931
3108
|
value,
|
|
2932
3109
|
variables: []
|
|
@@ -2941,7 +3118,7 @@ function variableExtractLoader(params) {
|
|
|
2941
3118
|
}
|
|
2942
3119
|
return result;
|
|
2943
3120
|
},
|
|
2944
|
-
push: async (locale, data) => {
|
|
3121
|
+
push: async (locale, data, originalInput, originalDefaultLocale, pullInput, pullOutput) => {
|
|
2945
3122
|
const result = {};
|
|
2946
3123
|
for (const [key, valueObj] of Object.entries(data)) {
|
|
2947
3124
|
result[key] = valueObj.value;
|
|
@@ -2959,12 +3136,12 @@ function variableExtractLoader(params) {
|
|
|
2959
3136
|
function variableContentLoader() {
|
|
2960
3137
|
return createLoader({
|
|
2961
3138
|
pull: async (locale, input2) => {
|
|
2962
|
-
const result =
|
|
3139
|
+
const result = _19.mapValues(input2, (payload) => payload.value);
|
|
2963
3140
|
return result;
|
|
2964
3141
|
},
|
|
2965
3142
|
push: async (locale, data, originalInput, defaultLocale, pullInput) => {
|
|
2966
|
-
const result =
|
|
2967
|
-
|
|
3143
|
+
const result = _19.cloneDeep(
|
|
3144
|
+
originalInput || {}
|
|
2968
3145
|
);
|
|
2969
3146
|
for (const [key, originalValueObj] of Object.entries(result)) {
|
|
2970
3147
|
result[key] = {
|
|
@@ -2988,20 +3165,20 @@ function getFormatSpecifierPattern(type) {
|
|
|
2988
3165
|
}
|
|
2989
3166
|
|
|
2990
3167
|
// src/cli/loaders/sync.ts
|
|
2991
|
-
import
|
|
3168
|
+
import _20 from "lodash";
|
|
2992
3169
|
function createSyncLoader() {
|
|
2993
3170
|
return createLoader({
|
|
2994
|
-
async pull(locale, input2, originalInput) {
|
|
3171
|
+
async pull(locale, input2, initCtx, originalLocale, originalInput) {
|
|
2995
3172
|
if (!originalInput) {
|
|
2996
3173
|
return input2;
|
|
2997
3174
|
}
|
|
2998
|
-
return
|
|
3175
|
+
return _20.chain(originalInput).mapValues((value, key) => input2[key]).value();
|
|
2999
3176
|
},
|
|
3000
3177
|
async push(locale, data, originalInput) {
|
|
3001
3178
|
if (!originalInput) {
|
|
3002
3179
|
return data;
|
|
3003
3180
|
}
|
|
3004
|
-
return
|
|
3181
|
+
return _20.chain(originalInput || {}).mapValues((value, key) => data[key]).value();
|
|
3005
3182
|
}
|
|
3006
3183
|
});
|
|
3007
3184
|
}
|
|
@@ -3162,7 +3339,7 @@ function parseVueFile(input2) {
|
|
|
3162
3339
|
|
|
3163
3340
|
// src/cli/loaders/typescript/index.ts
|
|
3164
3341
|
import { parse as parse2 } from "@babel/parser";
|
|
3165
|
-
import
|
|
3342
|
+
import _21 from "lodash";
|
|
3166
3343
|
import babelTraverseModule from "@babel/traverse";
|
|
3167
3344
|
import * as t from "@babel/types";
|
|
3168
3345
|
import babelGenerateModule from "@babel/generator";
|
|
@@ -3198,7 +3375,7 @@ function createTypescriptLoader() {
|
|
|
3198
3375
|
},
|
|
3199
3376
|
push: async (locale, data, originalInput, defaultLocale, pullInput, pullOutput) => {
|
|
3200
3377
|
const ast = parseTypeScript(originalInput || "");
|
|
3201
|
-
const finalData =
|
|
3378
|
+
const finalData = _21.merge({}, pullOutput, data);
|
|
3202
3379
|
updateStringsInDefaultExport(ast, finalData);
|
|
3203
3380
|
const { code } = generate(ast, {
|
|
3204
3381
|
jsescOption: {
|
|
@@ -3399,7 +3576,7 @@ function getPropertyKey(prop) {
|
|
|
3399
3576
|
}
|
|
3400
3577
|
|
|
3401
3578
|
// src/cli/loaders/inject-locale.ts
|
|
3402
|
-
import
|
|
3579
|
+
import _22 from "lodash";
|
|
3403
3580
|
function createInjectLocaleLoader(injectLocaleKeys) {
|
|
3404
3581
|
return createLoader({
|
|
3405
3582
|
async pull(locale, data) {
|
|
@@ -3407,19 +3584,19 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
3407
3584
|
return data;
|
|
3408
3585
|
}
|
|
3409
3586
|
const omitKeys = injectLocaleKeys.filter((key) => {
|
|
3410
|
-
return
|
|
3587
|
+
return _22.get(data, key) === locale;
|
|
3411
3588
|
});
|
|
3412
|
-
const result =
|
|
3589
|
+
const result = _22.omit(data, omitKeys);
|
|
3413
3590
|
return result;
|
|
3414
3591
|
},
|
|
3415
3592
|
async push(locale, data, originalInput, originalLocale) {
|
|
3416
3593
|
if (!injectLocaleKeys) {
|
|
3417
3594
|
return data;
|
|
3418
3595
|
}
|
|
3419
|
-
const mergedData =
|
|
3596
|
+
const mergedData = _22.merge({}, originalInput, data);
|
|
3420
3597
|
injectLocaleKeys.forEach((key) => {
|
|
3421
|
-
if (
|
|
3422
|
-
|
|
3598
|
+
if (_22.get(mergedData, key) === originalLocale) {
|
|
3599
|
+
_22.set(mergedData, key, locale);
|
|
3423
3600
|
}
|
|
3424
3601
|
});
|
|
3425
3602
|
return mergedData;
|
|
@@ -3428,16 +3605,16 @@ function createInjectLocaleLoader(injectLocaleKeys) {
|
|
|
3428
3605
|
}
|
|
3429
3606
|
|
|
3430
3607
|
// src/cli/loaders/locked-keys.ts
|
|
3431
|
-
import
|
|
3608
|
+
import _23 from "lodash";
|
|
3432
3609
|
function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
|
|
3433
3610
|
return createLoader({
|
|
3434
|
-
pull: async (locale, data) =>
|
|
3611
|
+
pull: async (locale, data) => _23.chain(data).pickBy((value, key) => !lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value(),
|
|
3435
3612
|
push: async (locale, data, originalInput) => {
|
|
3436
|
-
const lockedSubObject =
|
|
3613
|
+
const lockedSubObject = _23.chain(originalInput).pickBy((value, key) => lockedKeys.some((lockedKey) => key.startsWith(lockedKey))).value();
|
|
3437
3614
|
if (isCacheRestore) {
|
|
3438
|
-
return
|
|
3615
|
+
return _23.merge({}, data, lockedSubObject);
|
|
3439
3616
|
} else {
|
|
3440
|
-
return
|
|
3617
|
+
return _23.merge({}, originalInput, data, lockedSubObject);
|
|
3441
3618
|
}
|
|
3442
3619
|
}
|
|
3443
3620
|
});
|
|
@@ -3490,7 +3667,7 @@ function md5(input2) {
|
|
|
3490
3667
|
}
|
|
3491
3668
|
|
|
3492
3669
|
// src/cli/loaders/mdx2/code-placeholder.ts
|
|
3493
|
-
import
|
|
3670
|
+
import _24 from "lodash";
|
|
3494
3671
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
3495
3672
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
3496
3673
|
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
@@ -3513,7 +3690,7 @@ ${match}
|
|
|
3513
3690
|
found = true;
|
|
3514
3691
|
}
|
|
3515
3692
|
} while (found);
|
|
3516
|
-
content =
|
|
3693
|
+
content = _24.chain(content).split("\n\n").map((section) => _24.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
3517
3694
|
return content;
|
|
3518
3695
|
}
|
|
3519
3696
|
function ensureTrailingFenceNewline(_content) {
|
|
@@ -3535,7 +3712,7 @@ ${match}
|
|
|
3535
3712
|
found = true;
|
|
3536
3713
|
}
|
|
3537
3714
|
} while (found);
|
|
3538
|
-
content =
|
|
3715
|
+
content = _24.chain(content).split("\n\n").map((section) => _24.trim(section, "\n")).filter(Boolean).join("\n\n").value();
|
|
3539
3716
|
return content;
|
|
3540
3717
|
}
|
|
3541
3718
|
function extractCodePlaceholders(content) {
|
|
@@ -3575,13 +3752,13 @@ function createMdxCodePlaceholderLoader() {
|
|
|
3575
3752
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
3576
3753
|
const sourceInfo = extractCodePlaceholders(originalInput ?? "");
|
|
3577
3754
|
const currentInfo = extractCodePlaceholders(pullInput ?? "");
|
|
3578
|
-
const codePlaceholders =
|
|
3755
|
+
const codePlaceholders = _24.merge(
|
|
3579
3756
|
sourceInfo.codePlaceholders,
|
|
3580
3757
|
currentInfo.codePlaceholders
|
|
3581
3758
|
);
|
|
3582
3759
|
let result = data;
|
|
3583
3760
|
for (const [placeholder, original] of Object.entries(codePlaceholders)) {
|
|
3584
|
-
const replacement = original.startsWith(">") ?
|
|
3761
|
+
const replacement = original.startsWith(">") ? _24.trimStart(original, "> ") : original;
|
|
3585
3762
|
result = result.replaceAll(placeholder, replacement);
|
|
3586
3763
|
}
|
|
3587
3764
|
return result;
|
|
@@ -3609,11 +3786,11 @@ function createLocalizableMdxDocumentLoader() {
|
|
|
3609
3786
|
}
|
|
3610
3787
|
|
|
3611
3788
|
// src/cli/loaders/mdx2/sections-split-2.ts
|
|
3612
|
-
import
|
|
3789
|
+
import _25 from "lodash";
|
|
3613
3790
|
function createMdxSectionsSplit2Loader() {
|
|
3614
3791
|
return createLoader({
|
|
3615
3792
|
async pull(locale, input2) {
|
|
3616
|
-
const sections =
|
|
3793
|
+
const sections = _25.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
|
|
3617
3794
|
const result = {
|
|
3618
3795
|
frontmatter: input2.frontmatter,
|
|
3619
3796
|
sections
|
|
@@ -3621,7 +3798,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3621
3798
|
return result;
|
|
3622
3799
|
},
|
|
3623
3800
|
async push(locale, data, originalInput, _originalLocale, pullInput) {
|
|
3624
|
-
const content =
|
|
3801
|
+
const content = _25.chain(data.sections).values().join("\n\n").value();
|
|
3625
3802
|
const result = {
|
|
3626
3803
|
frontmatter: data.frontmatter,
|
|
3627
3804
|
codePlaceholders: pullInput?.codePlaceholders || {},
|
|
@@ -3682,15 +3859,15 @@ function createMdxLockedPatternsLoader(defaultPatterns) {
|
|
|
3682
3859
|
}
|
|
3683
3860
|
|
|
3684
3861
|
// src/cli/loaders/ignored-keys.ts
|
|
3685
|
-
import
|
|
3862
|
+
import _26 from "lodash";
|
|
3686
3863
|
function createIgnoredKeysLoader(ignoredKeys) {
|
|
3687
3864
|
return createLoader({
|
|
3688
3865
|
pull: async (locale, data) => {
|
|
3689
|
-
const result =
|
|
3866
|
+
const result = _26.chain(data).omit(ignoredKeys).value();
|
|
3690
3867
|
return result;
|
|
3691
3868
|
},
|
|
3692
3869
|
push: async (locale, data, originalInput, originalLocale, pullInput) => {
|
|
3693
|
-
const result =
|
|
3870
|
+
const result = _26.merge({}, data, _26.pick(pullInput, ignoredKeys));
|
|
3694
3871
|
return result;
|
|
3695
3872
|
}
|
|
3696
3873
|
});
|
|
@@ -3967,14 +4144,14 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
3967
4144
|
}
|
|
3968
4145
|
|
|
3969
4146
|
// src/cli/cmd/i18n.ts
|
|
3970
|
-
import
|
|
4147
|
+
import chalk5 from "chalk";
|
|
3971
4148
|
import { createTwoFilesPatch } from "diff";
|
|
3972
4149
|
import inquirer2 from "inquirer";
|
|
3973
4150
|
import externalEditor from "external-editor";
|
|
3974
4151
|
|
|
3975
4152
|
// src/cli/processor/index.ts
|
|
3976
|
-
import
|
|
3977
|
-
import
|
|
4153
|
+
import chalk4 from "chalk";
|
|
4154
|
+
import dedent4 from "dedent";
|
|
3978
4155
|
|
|
3979
4156
|
// src/cli/processor/lingo.ts
|
|
3980
4157
|
import { LingoDotDevEngine } from "@lingo.dev/_sdk";
|
|
@@ -4005,7 +4182,7 @@ function createLingoLocalizer(params) {
|
|
|
4005
4182
|
|
|
4006
4183
|
// src/cli/processor/basic.ts
|
|
4007
4184
|
import { generateText } from "ai";
|
|
4008
|
-
import
|
|
4185
|
+
import _27 from "lodash";
|
|
4009
4186
|
function createBasicTranslator(model, systemPrompt) {
|
|
4010
4187
|
return async (input2, onProgress) => {
|
|
4011
4188
|
const chunks = extractPayloadChunks(input2.processableData);
|
|
@@ -4019,7 +4196,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
4019
4196
|
subResults.push(result2);
|
|
4020
4197
|
onProgress(i / chunks.length * 100, chunk, result2);
|
|
4021
4198
|
}
|
|
4022
|
-
const result =
|
|
4199
|
+
const result = _27.merge({}, ...subResults);
|
|
4023
4200
|
return result;
|
|
4024
4201
|
};
|
|
4025
4202
|
async function doJob(input2) {
|
|
@@ -4131,23 +4308,23 @@ function createProcessor(provider, params) {
|
|
|
4131
4308
|
}
|
|
4132
4309
|
}
|
|
4133
4310
|
function getPureModelProvider(provider) {
|
|
4134
|
-
const createMissingKeyErrorMessage = (providerId, envVar) =>
|
|
4135
|
-
You're trying to use raw ${
|
|
4311
|
+
const createMissingKeyErrorMessage = (providerId, envVar) => dedent4`
|
|
4312
|
+
You're trying to use raw ${chalk4.dim(providerId)} API for translation, however, ${chalk4.dim(envVar)} environment variable is not set.
|
|
4136
4313
|
|
|
4137
4314
|
To fix this issue:
|
|
4138
|
-
1. Set ${
|
|
4139
|
-
2. Remove the ${
|
|
4315
|
+
1. Set ${chalk4.dim(envVar)} in your environment variables, or
|
|
4316
|
+
2. Remove the ${chalk4.italic("provider")} node from your i18n.json configuration to switch to ${chalk4.hex(colors.green)("Lingo.dev")}
|
|
4140
4317
|
|
|
4141
|
-
${
|
|
4318
|
+
${chalk4.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4142
4319
|
`;
|
|
4143
|
-
const createUnsupportedProviderErrorMessage = (providerId) =>
|
|
4144
|
-
You're trying to use unsupported provider: ${
|
|
4320
|
+
const createUnsupportedProviderErrorMessage = (providerId) => dedent4`
|
|
4321
|
+
You're trying to use unsupported provider: ${chalk4.dim(providerId)}.
|
|
4145
4322
|
|
|
4146
4323
|
To fix this issue:
|
|
4147
4324
|
1. Switch to one of the supported providers, or
|
|
4148
|
-
2. Remove the ${
|
|
4325
|
+
2. Remove the ${chalk4.italic("provider")} node from your i18n.json configuration to switch to ${chalk4.hex(colors.green)("Lingo.dev")}
|
|
4149
4326
|
|
|
4150
|
-
${
|
|
4327
|
+
${chalk4.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4151
4328
|
`;
|
|
4152
4329
|
switch (provider?.id) {
|
|
4153
4330
|
case "openai":
|
|
@@ -4228,7 +4405,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
4228
4405
|
}
|
|
4229
4406
|
|
|
4230
4407
|
// src/cli/utils/delta.ts
|
|
4231
|
-
import
|
|
4408
|
+
import _28 from "lodash";
|
|
4232
4409
|
import z from "zod";
|
|
4233
4410
|
|
|
4234
4411
|
// src/cli/utils/fs.ts
|
|
@@ -4277,9 +4454,9 @@ function createDeltaProcessor(fileKey) {
|
|
|
4277
4454
|
return checkIfFileExists(lockfilePath);
|
|
4278
4455
|
},
|
|
4279
4456
|
async calculateDelta(params) {
|
|
4280
|
-
let added =
|
|
4281
|
-
let removed =
|
|
4282
|
-
const updated =
|
|
4457
|
+
let added = _28.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
|
|
4458
|
+
let removed = _28.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
|
|
4459
|
+
const updated = _28.filter(Object.keys(params.sourceData), (key) => {
|
|
4283
4460
|
return md5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
|
|
4284
4461
|
});
|
|
4285
4462
|
const renamed = [];
|
|
@@ -4328,14 +4505,14 @@ function createDeltaProcessor(fileKey) {
|
|
|
4328
4505
|
await this.saveLock(lockfileData);
|
|
4329
4506
|
},
|
|
4330
4507
|
async createChecksums(sourceData) {
|
|
4331
|
-
const checksums =
|
|
4508
|
+
const checksums = _28.mapValues(sourceData, (value) => md5(value));
|
|
4332
4509
|
return checksums;
|
|
4333
4510
|
}
|
|
4334
4511
|
};
|
|
4335
4512
|
}
|
|
4336
4513
|
|
|
4337
4514
|
// src/cli/cmd/i18n.ts
|
|
4338
|
-
var i18n_default = new
|
|
4515
|
+
var i18n_default = new Command10().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
4339
4516
|
"--locale <locale>",
|
|
4340
4517
|
"Locale to process",
|
|
4341
4518
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
@@ -4500,7 +4677,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4500
4677
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
4501
4678
|
const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
|
|
4502
4679
|
const savedChecksums = await deltaProcessor.loadChecksums();
|
|
4503
|
-
const updatedSourceData =
|
|
4680
|
+
const updatedSourceData = _29.pickBy(
|
|
4504
4681
|
sourceData,
|
|
4505
4682
|
(value, key) => sourceChecksums[key] !== savedChecksums[key]
|
|
4506
4683
|
);
|
|
@@ -4514,15 +4691,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4514
4691
|
bucketPath.delimiter
|
|
4515
4692
|
);
|
|
4516
4693
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
4517
|
-
const missingKeys =
|
|
4694
|
+
const missingKeys = _29.difference(
|
|
4518
4695
|
Object.keys(sourceData),
|
|
4519
4696
|
Object.keys(targetData)
|
|
4520
4697
|
);
|
|
4521
|
-
const extraKeys =
|
|
4698
|
+
const extraKeys = _29.difference(
|
|
4522
4699
|
Object.keys(targetData),
|
|
4523
4700
|
Object.keys(sourceData)
|
|
4524
4701
|
);
|
|
4525
|
-
const unlocalizableDataDiff = !
|
|
4702
|
+
const unlocalizableDataDiff = !_29.isEqual(
|
|
4526
4703
|
sourceUnlocalizable,
|
|
4527
4704
|
targetUnlocalizable
|
|
4528
4705
|
);
|
|
@@ -4604,13 +4781,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4604
4781
|
targetData,
|
|
4605
4782
|
checksums: checksums2
|
|
4606
4783
|
});
|
|
4607
|
-
let processableData =
|
|
4784
|
+
let processableData = _29.chain(sourceData).entries().filter(
|
|
4608
4785
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
|
|
4609
4786
|
).fromPairs().value();
|
|
4610
4787
|
if (flags.key) {
|
|
4611
|
-
processableData =
|
|
4788
|
+
processableData = _29.pickBy(
|
|
4612
4789
|
processableData,
|
|
4613
|
-
(
|
|
4790
|
+
(_33, key) => key === flags.key
|
|
4614
4791
|
);
|
|
4615
4792
|
}
|
|
4616
4793
|
if (flags.verbose) {
|
|
@@ -4643,13 +4820,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4643
4820
|
if (flags.verbose) {
|
|
4644
4821
|
bucketOra.info(JSON.stringify(processedTargetData, null, 2));
|
|
4645
4822
|
}
|
|
4646
|
-
let finalTargetData =
|
|
4823
|
+
let finalTargetData = _29.merge(
|
|
4647
4824
|
{},
|
|
4648
4825
|
sourceData,
|
|
4649
4826
|
targetData,
|
|
4650
4827
|
processedTargetData
|
|
4651
4828
|
);
|
|
4652
|
-
finalTargetData =
|
|
4829
|
+
finalTargetData = _29.chain(finalTargetData).entries().map(([key, value]) => {
|
|
4653
4830
|
const renaming = delta.renamed.find(
|
|
4654
4831
|
([oldKey, newKey]) => oldKey === key
|
|
4655
4832
|
);
|
|
@@ -4673,7 +4850,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4673
4850
|
`Applying changes to ${bucketPath} (${targetLocale})`
|
|
4674
4851
|
);
|
|
4675
4852
|
}
|
|
4676
|
-
const finalDiffSize =
|
|
4853
|
+
const finalDiffSize = _29.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
4677
4854
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
4678
4855
|
if (finalDiffSize > 0 || flags.force) {
|
|
4679
4856
|
bucketOra.succeed(
|
|
@@ -4800,7 +4977,7 @@ async function reviewChanges(args) {
|
|
|
4800
4977
|
if (currentStr === proposedStr && !args.force) {
|
|
4801
4978
|
console.log(
|
|
4802
4979
|
`
|
|
4803
|
-
${
|
|
4980
|
+
${chalk5.blue(args.pathPattern)} (${chalk5.yellow(args.targetLocale)}): ${chalk5.gray("No changes to review")}`
|
|
4804
4981
|
);
|
|
4805
4982
|
return args.proposedData;
|
|
4806
4983
|
}
|
|
@@ -4814,14 +4991,14 @@ ${chalk2.blue(args.pathPattern)} (${chalk2.yellow(args.targetLocale)}): ${chalk2
|
|
|
4814
4991
|
{ context: 3 }
|
|
4815
4992
|
);
|
|
4816
4993
|
const coloredDiff = patch.split("\n").map((line) => {
|
|
4817
|
-
if (line.startsWith("+")) return
|
|
4818
|
-
if (line.startsWith("-")) return
|
|
4819
|
-
if (line.startsWith("@")) return
|
|
4994
|
+
if (line.startsWith("+")) return chalk5.green(line);
|
|
4995
|
+
if (line.startsWith("-")) return chalk5.red(line);
|
|
4996
|
+
if (line.startsWith("@")) return chalk5.cyan(line);
|
|
4820
4997
|
return line;
|
|
4821
4998
|
}).join("\n");
|
|
4822
4999
|
console.log(
|
|
4823
5000
|
`
|
|
4824
|
-
Reviewing changes for ${
|
|
5001
|
+
Reviewing changes for ${chalk5.blue(args.pathPattern)} (${chalk5.yellow(args.targetLocale)}):`
|
|
4825
5002
|
);
|
|
4826
5003
|
console.log(coloredDiff);
|
|
4827
5004
|
const { action } = await inquirer2.prompt([
|
|
@@ -4844,7 +5021,7 @@ Reviewing changes for ${chalk2.blue(args.pathPattern)} (${chalk2.yellow(args.tar
|
|
|
4844
5021
|
return args.currentData;
|
|
4845
5022
|
}
|
|
4846
5023
|
const customData = { ...args.currentData };
|
|
4847
|
-
const changes =
|
|
5024
|
+
const changes = _29.reduce(
|
|
4848
5025
|
args.proposedData,
|
|
4849
5026
|
(result, value, key) => {
|
|
4850
5027
|
if (args.currentData[key] !== value) {
|
|
@@ -4856,32 +5033,32 @@ Reviewing changes for ${chalk2.blue(args.pathPattern)} (${chalk2.yellow(args.tar
|
|
|
4856
5033
|
);
|
|
4857
5034
|
for (const key of changes) {
|
|
4858
5035
|
console.log(`
|
|
4859
|
-
Editing value for: ${
|
|
4860
|
-
console.log(
|
|
5036
|
+
Editing value for: ${chalk5.cyan(key)}`);
|
|
5037
|
+
console.log(chalk5.gray("Source text:"), chalk5.blue(args.sourceData[key]));
|
|
4861
5038
|
console.log(
|
|
4862
|
-
|
|
4863
|
-
|
|
5039
|
+
chalk5.gray("Current value:"),
|
|
5040
|
+
chalk5.red(args.currentData[key] || "(empty)")
|
|
4864
5041
|
);
|
|
4865
5042
|
console.log(
|
|
4866
|
-
|
|
4867
|
-
|
|
5043
|
+
chalk5.gray("Suggested value:"),
|
|
5044
|
+
chalk5.green(args.proposedData[key])
|
|
4868
5045
|
);
|
|
4869
5046
|
console.log(
|
|
4870
|
-
|
|
5047
|
+
chalk5.gray(
|
|
4871
5048
|
"\nYour editor will open. Edit the text and save to continue."
|
|
4872
5049
|
)
|
|
4873
5050
|
);
|
|
4874
|
-
console.log(
|
|
5051
|
+
console.log(chalk5.gray("------------"));
|
|
4875
5052
|
try {
|
|
4876
5053
|
const editorContent = [
|
|
4877
5054
|
"# Edit the translation below.",
|
|
4878
5055
|
"# Lines starting with # will be ignored.",
|
|
4879
5056
|
"# Save and exit the editor to continue.",
|
|
4880
5057
|
"#",
|
|
4881
|
-
`# Source text (${
|
|
5058
|
+
`# Source text (${chalk5.blue("English")}):`,
|
|
4882
5059
|
`# ${args.sourceData[key]}`,
|
|
4883
5060
|
"#",
|
|
4884
|
-
`# Current value (${
|
|
5061
|
+
`# Current value (${chalk5.red(args.targetLocale)}):`,
|
|
4885
5062
|
`# ${args.currentData[key] || "(empty)"}`,
|
|
4886
5063
|
"#",
|
|
4887
5064
|
args.proposedData[key]
|
|
@@ -4892,13 +5069,13 @@ Editing value for: ${chalk2.cyan(key)}`);
|
|
|
4892
5069
|
customData[key] = customValue;
|
|
4893
5070
|
} else {
|
|
4894
5071
|
console.log(
|
|
4895
|
-
|
|
5072
|
+
chalk5.yellow("Empty value provided, keeping the current value.")
|
|
4896
5073
|
);
|
|
4897
5074
|
customData[key] = args.currentData[key] || args.proposedData[key];
|
|
4898
5075
|
}
|
|
4899
5076
|
} catch (error) {
|
|
4900
5077
|
console.log(
|
|
4901
|
-
|
|
5078
|
+
chalk5.red("Error while editing, keeping the suggested value.")
|
|
4902
5079
|
);
|
|
4903
5080
|
customData[key] = args.proposedData[key];
|
|
4904
5081
|
}
|
|
@@ -4907,7 +5084,7 @@ Editing value for: ${chalk2.cyan(key)}`);
|
|
|
4907
5084
|
}
|
|
4908
5085
|
|
|
4909
5086
|
// src/cli/cmd/lockfile.ts
|
|
4910
|
-
import { Command as
|
|
5087
|
+
import { Command as Command11 } from "interactive-commander";
|
|
4911
5088
|
import Z5 from "zod";
|
|
4912
5089
|
import Ora6 from "ora";
|
|
4913
5090
|
|
|
@@ -4917,7 +5094,7 @@ import path14 from "path";
|
|
|
4917
5094
|
import Z4 from "zod";
|
|
4918
5095
|
import YAML5 from "yaml";
|
|
4919
5096
|
import { MD5 as MD52 } from "object-hash";
|
|
4920
|
-
import
|
|
5097
|
+
import _30 from "lodash";
|
|
4921
5098
|
function createLockfileHelper() {
|
|
4922
5099
|
return {
|
|
4923
5100
|
isLockfileExists: () => {
|
|
@@ -4927,23 +5104,23 @@ function createLockfileHelper() {
|
|
|
4927
5104
|
registerSourceData: (pathPattern, sourceData) => {
|
|
4928
5105
|
const lockfile = _loadLockfile();
|
|
4929
5106
|
const sectionKey = MD52(pathPattern);
|
|
4930
|
-
const sectionChecksums =
|
|
5107
|
+
const sectionChecksums = _30.mapValues(sourceData, (value) => MD52(value));
|
|
4931
5108
|
lockfile.checksums[sectionKey] = sectionChecksums;
|
|
4932
5109
|
_saveLockfile(lockfile);
|
|
4933
5110
|
},
|
|
4934
5111
|
registerPartialSourceData: (pathPattern, partialSourceData) => {
|
|
4935
5112
|
const lockfile = _loadLockfile();
|
|
4936
5113
|
const sectionKey = MD52(pathPattern);
|
|
4937
|
-
const sectionChecksums =
|
|
4938
|
-
lockfile.checksums[sectionKey] =
|
|
5114
|
+
const sectionChecksums = _30.mapValues(partialSourceData, (value) => MD52(value));
|
|
5115
|
+
lockfile.checksums[sectionKey] = _30.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
|
|
4939
5116
|
_saveLockfile(lockfile);
|
|
4940
5117
|
},
|
|
4941
5118
|
extractUpdatedData: (pathPattern, sourceData) => {
|
|
4942
5119
|
const lockfile = _loadLockfile();
|
|
4943
5120
|
const sectionKey = MD52(pathPattern);
|
|
4944
|
-
const currentChecksums =
|
|
5121
|
+
const currentChecksums = _30.mapValues(sourceData, (value) => MD52(value));
|
|
4945
5122
|
const savedChecksums = lockfile.checksums[sectionKey] || {};
|
|
4946
|
-
const updatedData =
|
|
5123
|
+
const updatedData = _30.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
|
|
4947
5124
|
return updatedData;
|
|
4948
5125
|
}
|
|
4949
5126
|
};
|
|
@@ -4982,7 +5159,7 @@ var LockfileSchema = Z4.object({
|
|
|
4982
5159
|
|
|
4983
5160
|
// src/cli/cmd/lockfile.ts
|
|
4984
5161
|
import { resolveOverriddenLocale as resolveOverriddenLocale4 } from "@lingo.dev/_spec";
|
|
4985
|
-
var lockfile_default = new
|
|
5162
|
+
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) => {
|
|
4986
5163
|
const flags = flagsSchema.parse(options);
|
|
4987
5164
|
const ora = Ora6();
|
|
4988
5165
|
const lockfileHelper = createLockfileHelper();
|
|
@@ -5012,10 +5189,10 @@ var flagsSchema = Z5.object({
|
|
|
5012
5189
|
|
|
5013
5190
|
// src/cli/cmd/cleanup.ts
|
|
5014
5191
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
5015
|
-
import { Command as
|
|
5016
|
-
import
|
|
5192
|
+
import { Command as Command12 } from "interactive-commander";
|
|
5193
|
+
import _31 from "lodash";
|
|
5017
5194
|
import Ora7 from "ora";
|
|
5018
|
-
var cleanup_default = new
|
|
5195
|
+
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(
|
|
5019
5196
|
"--verbose",
|
|
5020
5197
|
"Show detailed output including:\n - List of keys that would be removed.\n - Processing steps."
|
|
5021
5198
|
).action(async function(options) {
|
|
@@ -5049,7 +5226,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
5049
5226
|
try {
|
|
5050
5227
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
5051
5228
|
const targetKeys = Object.keys(targetData);
|
|
5052
|
-
const keysToRemove =
|
|
5229
|
+
const keysToRemove = _31.difference(targetKeys, sourceKeys);
|
|
5053
5230
|
if (keysToRemove.length === 0) {
|
|
5054
5231
|
bucketOra.succeed(`[${targetLocale}] No keys to remove`);
|
|
5055
5232
|
continue;
|
|
@@ -5058,7 +5235,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
5058
5235
|
bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
|
|
5059
5236
|
}
|
|
5060
5237
|
if (!options.dryRun) {
|
|
5061
|
-
const cleanedData =
|
|
5238
|
+
const cleanedData = _31.pick(targetData, sourceKeys);
|
|
5062
5239
|
await bucketLoader.push(targetLocale, cleanedData);
|
|
5063
5240
|
bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
|
|
5064
5241
|
} else {
|
|
@@ -5108,12 +5285,12 @@ function displaySummary(results) {
|
|
|
5108
5285
|
}
|
|
5109
5286
|
|
|
5110
5287
|
// src/cli/cmd/mcp.ts
|
|
5111
|
-
import { Command as
|
|
5288
|
+
import { Command as Command13 } from "interactive-commander";
|
|
5112
5289
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5113
5290
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5114
5291
|
import Z6 from "zod";
|
|
5115
5292
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
5116
|
-
var mcp_default = new
|
|
5293
|
+
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) => {
|
|
5117
5294
|
const apiKey = program.args[0];
|
|
5118
5295
|
const settings = getSettings(apiKey);
|
|
5119
5296
|
if (!settings.auth.apiKey) {
|
|
@@ -5161,7 +5338,7 @@ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model
|
|
|
5161
5338
|
});
|
|
5162
5339
|
|
|
5163
5340
|
// src/cli/cmd/ci/index.ts
|
|
5164
|
-
import { Command as
|
|
5341
|
+
import { Command as Command14 } from "interactive-commander";
|
|
5165
5342
|
import createOra from "ora";
|
|
5166
5343
|
|
|
5167
5344
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
@@ -5824,7 +6001,7 @@ var getPlatformKit = () => {
|
|
|
5824
6001
|
};
|
|
5825
6002
|
|
|
5826
6003
|
// src/cli/cmd/ci/index.ts
|
|
5827
|
-
var ci_default = new
|
|
6004
|
+
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(
|
|
5828
6005
|
"--process-own-commits [boolean]",
|
|
5829
6006
|
"Process commits made by this action"
|
|
5830
6007
|
).action(async (options) => {
|
|
@@ -5877,12 +6054,12 @@ var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD
|
|
|
5877
6054
|
|
|
5878
6055
|
// src/cli/cmd/status.ts
|
|
5879
6056
|
import { bucketTypeSchema as bucketTypeSchema3, localeCodeSchema as localeCodeSchema2, resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
|
|
5880
|
-
import { Command as
|
|
6057
|
+
import { Command as Command15 } from "interactive-commander";
|
|
5881
6058
|
import Z11 from "zod";
|
|
5882
6059
|
import Ora8 from "ora";
|
|
5883
|
-
import
|
|
6060
|
+
import chalk6 from "chalk";
|
|
5884
6061
|
import Table from "cli-table3";
|
|
5885
|
-
var status_default = new
|
|
6062
|
+
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(
|
|
5886
6063
|
"--file [files...]",
|
|
5887
6064
|
"File to process. Process only a specific path, may contain asterisk * to match multiple files."
|
|
5888
6065
|
).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) {
|
|
@@ -6023,7 +6200,7 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6023
6200
|
languageStats[targetLocale].words += sourceWordCount;
|
|
6024
6201
|
totalWordCount.set(targetLocale, (totalWordCount.get(targetLocale) || 0) + sourceWordCount);
|
|
6025
6202
|
bucketOra.succeed(
|
|
6026
|
-
`[${sourceLocale} -> ${targetLocale}] ${
|
|
6203
|
+
`[${sourceLocale} -> ${targetLocale}] ${chalk6.red(`0% complete`)} (0/${sourceKeys.length} keys) - file not found`
|
|
6027
6204
|
);
|
|
6028
6205
|
continue;
|
|
6029
6206
|
}
|
|
@@ -6059,20 +6236,20 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6059
6236
|
const completionPercent = (completeKeys.length / totalKeysInFile * 100).toFixed(1);
|
|
6060
6237
|
if (missingKeys.length === 0 && updatedKeys.length === 0) {
|
|
6061
6238
|
bucketOra.succeed(
|
|
6062
|
-
`[${sourceLocale} -> ${targetLocale}] ${
|
|
6239
|
+
`[${sourceLocale} -> ${targetLocale}] ${chalk6.green(`100% complete`)} (${completeKeys.length}/${totalKeysInFile} keys)`
|
|
6063
6240
|
);
|
|
6064
6241
|
} else {
|
|
6065
|
-
const message = `[${sourceLocale} -> ${targetLocale}] ${parseFloat(completionPercent) > 50 ?
|
|
6242
|
+
const message = `[${sourceLocale} -> ${targetLocale}] ${parseFloat(completionPercent) > 50 ? chalk6.yellow(`${completionPercent}% complete`) : chalk6.red(`${completionPercent}% complete`)} (${completeKeys.length}/${totalKeysInFile} keys)`;
|
|
6066
6243
|
bucketOra.succeed(message);
|
|
6067
6244
|
if (flags.verbose) {
|
|
6068
6245
|
if (missingKeys.length > 0) {
|
|
6069
|
-
console.log(` ${
|
|
6246
|
+
console.log(` ${chalk6.red(`Missing:`)} ${missingKeys.length} keys, ~${wordsToTranslate} words`);
|
|
6070
6247
|
console.log(
|
|
6071
|
-
` ${
|
|
6248
|
+
` ${chalk6.dim(`Example missing: ${missingKeys.slice(0, 2).join(", ")}${missingKeys.length > 2 ? "..." : ""}`)}`
|
|
6072
6249
|
);
|
|
6073
6250
|
}
|
|
6074
6251
|
if (updatedKeys.length > 0) {
|
|
6075
|
-
console.log(` ${
|
|
6252
|
+
console.log(` ${chalk6.yellow(`Updated:`)} ${updatedKeys.length} keys that changed in source`);
|
|
6076
6253
|
}
|
|
6077
6254
|
}
|
|
6078
6255
|
}
|
|
@@ -6087,16 +6264,16 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6087
6264
|
}, 0);
|
|
6088
6265
|
const totalCompletedKeys = totalSourceKeyCount - totalKeysNeedingTranslation / targetLocales.length;
|
|
6089
6266
|
console.log();
|
|
6090
|
-
ora.succeed(
|
|
6091
|
-
console.log(
|
|
6267
|
+
ora.succeed(chalk6.green(`Localization status completed.`));
|
|
6268
|
+
console.log(chalk6.bold.cyan(`
|
|
6092
6269
|
\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`));
|
|
6093
|
-
console.log(
|
|
6094
|
-
console.log(
|
|
6095
|
-
console.log(
|
|
6270
|
+
console.log(chalk6.bold.cyan(`\u2551 LOCALIZATION STATUS REPORT \u2551`));
|
|
6271
|
+
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`));
|
|
6272
|
+
console.log(chalk6.bold(`
|
|
6096
6273
|
\u{1F4DD} SOURCE CONTENT:`));
|
|
6097
|
-
console.log(`\u2022 Source language: ${
|
|
6098
|
-
console.log(`\u2022 Source keys: ${
|
|
6099
|
-
console.log(
|
|
6274
|
+
console.log(`\u2022 Source language: ${chalk6.green(i18nConfig.locale.source)}`);
|
|
6275
|
+
console.log(`\u2022 Source keys: ${chalk6.yellow(totalSourceKeyCount.toString())} keys across all files`);
|
|
6276
|
+
console.log(chalk6.bold(`
|
|
6100
6277
|
\u{1F310} LANGUAGE BY LANGUAGE BREAKDOWN:`));
|
|
6101
6278
|
const table = new Table({
|
|
6102
6279
|
head: ["Language", "Status", "Complete", "Missing", "Updated", "Total Keys", "Words to Translate"],
|
|
@@ -6118,19 +6295,19 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6118
6295
|
let statusColor;
|
|
6119
6296
|
if (stats.missing === totalSourceKeyCount) {
|
|
6120
6297
|
statusText = "\u{1F534} Not started";
|
|
6121
|
-
statusColor =
|
|
6298
|
+
statusColor = chalk6.red;
|
|
6122
6299
|
} else if (stats.missing === 0 && stats.updated === 0) {
|
|
6123
6300
|
statusText = "\u2705 Complete";
|
|
6124
|
-
statusColor =
|
|
6301
|
+
statusColor = chalk6.green;
|
|
6125
6302
|
} else if (parseFloat(percentComplete) > 80) {
|
|
6126
6303
|
statusText = "\u{1F7E1} Almost done";
|
|
6127
|
-
statusColor =
|
|
6304
|
+
statusColor = chalk6.yellow;
|
|
6128
6305
|
} else if (parseFloat(percentComplete) > 0) {
|
|
6129
6306
|
statusText = "\u{1F7E0} In progress";
|
|
6130
|
-
statusColor =
|
|
6307
|
+
statusColor = chalk6.yellow;
|
|
6131
6308
|
} else {
|
|
6132
6309
|
statusText = "\u{1F534} Not started";
|
|
6133
|
-
statusColor =
|
|
6310
|
+
statusColor = chalk6.red;
|
|
6134
6311
|
}
|
|
6135
6312
|
const words = totalWordCount.get(locale) || 0;
|
|
6136
6313
|
totalWordsToTranslate += words;
|
|
@@ -6138,17 +6315,17 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6138
6315
|
locale,
|
|
6139
6316
|
statusColor(statusText),
|
|
6140
6317
|
`${stats.complete}/${totalSourceKeyCount} (${percentComplete}%)`,
|
|
6141
|
-
stats.missing > 0 ?
|
|
6142
|
-
stats.updated > 0 ?
|
|
6143
|
-
totalNeeded > 0 ?
|
|
6318
|
+
stats.missing > 0 ? chalk6.red(stats.missing.toString()) : "0",
|
|
6319
|
+
stats.updated > 0 ? chalk6.yellow(stats.updated.toString()) : "0",
|
|
6320
|
+
totalNeeded > 0 ? chalk6.magenta(totalNeeded.toString()) : "0",
|
|
6144
6321
|
words > 0 ? `~${words.toLocaleString()}` : "0"
|
|
6145
6322
|
]);
|
|
6146
6323
|
}
|
|
6147
6324
|
console.log(table.toString());
|
|
6148
|
-
console.log(
|
|
6325
|
+
console.log(chalk6.bold(`
|
|
6149
6326
|
\u{1F4CA} USAGE ESTIMATE:`));
|
|
6150
6327
|
console.log(
|
|
6151
|
-
`\u2022 WORDS TO BE CONSUMED: ~${
|
|
6328
|
+
`\u2022 WORDS TO BE CONSUMED: ~${chalk6.yellow.bold(totalWordsToTranslate.toLocaleString())} words across all languages`
|
|
6152
6329
|
);
|
|
6153
6330
|
console.log(` (Words are counted from source language for keys that need translation in target languages)`);
|
|
6154
6331
|
if (targetLocales.length > 1) {
|
|
@@ -6160,11 +6337,11 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6160
6337
|
}
|
|
6161
6338
|
}
|
|
6162
6339
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
6163
|
-
console.log(
|
|
6340
|
+
console.log(chalk6.bold(`
|
|
6164
6341
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
6165
6342
|
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path16, stats]) => {
|
|
6166
6343
|
if (stats.sourceKeys === 0) return;
|
|
6167
|
-
console.log(
|
|
6344
|
+
console.log(chalk6.bold(`
|
|
6168
6345
|
\u2022 ${path16}:`));
|
|
6169
6346
|
console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
|
|
6170
6347
|
const fileTable = new Table({
|
|
@@ -6182,13 +6359,13 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6182
6359
|
const total = stats.sourceKeys;
|
|
6183
6360
|
const completion = (complete / total * 100).toFixed(1);
|
|
6184
6361
|
let status = "\u2705 Complete";
|
|
6185
|
-
let statusColor =
|
|
6362
|
+
let statusColor = chalk6.green;
|
|
6186
6363
|
if (langStats.missing === total) {
|
|
6187
6364
|
status = "\u274C Not started";
|
|
6188
|
-
statusColor =
|
|
6365
|
+
statusColor = chalk6.red;
|
|
6189
6366
|
} else if (langStats.missing > 0 || langStats.updated > 0) {
|
|
6190
6367
|
status = `\u26A0\uFE0F ${completion}% complete`;
|
|
6191
|
-
statusColor =
|
|
6368
|
+
statusColor = chalk6.yellow;
|
|
6192
6369
|
}
|
|
6193
6370
|
let details = "";
|
|
6194
6371
|
if (langStats.missing > 0 || langStats.updated > 0) {
|
|
@@ -6208,16 +6385,16 @@ var status_default = new Command11().command("status").description("Show the sta
|
|
|
6208
6385
|
(locale) => languageStats[locale].missing === 0 && languageStats[locale].updated === 0
|
|
6209
6386
|
);
|
|
6210
6387
|
const missingLanguages = targetLocales.filter((locale) => languageStats[locale].complete === 0);
|
|
6211
|
-
console.log(
|
|
6388
|
+
console.log(chalk6.bold.green(`
|
|
6212
6389
|
\u{1F4A1} OPTIMIZATION TIPS:`));
|
|
6213
6390
|
if (missingLanguages.length > 0) {
|
|
6214
6391
|
console.log(
|
|
6215
|
-
`\u2022 ${
|
|
6392
|
+
`\u2022 ${chalk6.yellow(missingLanguages.join(", "))} ${missingLanguages.length === 1 ? "has" : "have"} no translations yet`
|
|
6216
6393
|
);
|
|
6217
6394
|
}
|
|
6218
6395
|
if (completeLanguages.length > 0) {
|
|
6219
6396
|
console.log(
|
|
6220
|
-
`\u2022 ${
|
|
6397
|
+
`\u2022 ${chalk6.green(completeLanguages.join(", "))} ${completeLanguages.length === 1 ? "is" : "are"} completely translated`
|
|
6221
6398
|
);
|
|
6222
6399
|
}
|
|
6223
6400
|
if (targetLocales.length > 1) {
|
|
@@ -6293,10 +6470,10 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6293
6470
|
}
|
|
6294
6471
|
|
|
6295
6472
|
// src/cli/cmd/may-the-fourth.ts
|
|
6296
|
-
import { Command as
|
|
6473
|
+
import { Command as Command16 } from "interactive-commander";
|
|
6297
6474
|
import * as cp from "node:child_process";
|
|
6298
6475
|
import figlet from "figlet";
|
|
6299
|
-
import
|
|
6476
|
+
import chalk7 from "chalk";
|
|
6300
6477
|
import { vice } from "gradient-string";
|
|
6301
6478
|
var colors2 = {
|
|
6302
6479
|
orange: "#ff6600",
|
|
@@ -6306,11 +6483,11 @@ var colors2 = {
|
|
|
6306
6483
|
grey: "#808080",
|
|
6307
6484
|
red: "#ff0000"
|
|
6308
6485
|
};
|
|
6309
|
-
var may_the_fourth_default = new
|
|
6486
|
+
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 () => {
|
|
6310
6487
|
await renderClear();
|
|
6311
6488
|
await renderBanner();
|
|
6312
6489
|
await renderSpacer();
|
|
6313
|
-
console.log(
|
|
6490
|
+
console.log(chalk7.hex(colors2.yellow)("Loading the Star Wars movie..."));
|
|
6314
6491
|
await renderSpacer();
|
|
6315
6492
|
await new Promise((resolve, reject) => {
|
|
6316
6493
|
const ssh = cp.spawn("ssh", ["starwarstel.net"], {
|
|
@@ -6329,10 +6506,10 @@ var may_the_fourth_default = new Command12().command("may-the-fourth").descripti
|
|
|
6329
6506
|
});
|
|
6330
6507
|
await renderSpacer();
|
|
6331
6508
|
console.log(
|
|
6332
|
-
`${
|
|
6509
|
+
`${chalk7.hex(colors2.green)("We hope you enjoyed it! :)")} ${chalk7.hex(colors2.blue)("May the Fourth be with you! \u{1F680}")}`
|
|
6333
6510
|
);
|
|
6334
6511
|
await renderSpacer();
|
|
6335
|
-
console.log(
|
|
6512
|
+
console.log(chalk7.dim(`---`));
|
|
6336
6513
|
await renderSpacer();
|
|
6337
6514
|
await renderHero();
|
|
6338
6515
|
});
|
|
@@ -6355,19 +6532,19 @@ async function renderBanner() {
|
|
|
6355
6532
|
}
|
|
6356
6533
|
async function renderHero() {
|
|
6357
6534
|
console.log(
|
|
6358
|
-
`\u26A1\uFE0F ${
|
|
6535
|
+
`\u26A1\uFE0F ${chalk7.hex(colors2.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
6359
6536
|
);
|
|
6360
6537
|
console.log(" ");
|
|
6361
6538
|
console.log(
|
|
6362
|
-
|
|
6539
|
+
chalk7.hex(colors2.blue)("\u2B50 GitHub Repo: https://lingo.dev/go/gh")
|
|
6363
6540
|
);
|
|
6364
|
-
console.log(
|
|
6541
|
+
console.log(chalk7.hex(colors2.blue)("\u{1F4AC} 24/7 Support: hi@lingo.dev"));
|
|
6365
6542
|
}
|
|
6366
6543
|
|
|
6367
6544
|
// package.json
|
|
6368
6545
|
var package_default = {
|
|
6369
6546
|
name: "lingo.dev",
|
|
6370
|
-
version: "0.92.
|
|
6547
|
+
version: "0.92.17",
|
|
6371
6548
|
description: "Lingo.dev CLI",
|
|
6372
6549
|
private: false,
|
|
6373
6550
|
publishConfig: {
|
|
@@ -6535,39 +6712,39 @@ var package_default = {
|
|
|
6535
6712
|
};
|
|
6536
6713
|
|
|
6537
6714
|
// src/cli/cmd/run/index.ts
|
|
6538
|
-
import { Command as
|
|
6715
|
+
import { Command as Command17 } from "interactive-commander";
|
|
6539
6716
|
|
|
6540
6717
|
// src/cli/cmd/run/setup.ts
|
|
6541
|
-
import
|
|
6718
|
+
import chalk11 from "chalk";
|
|
6542
6719
|
import { Listr } from "listr2";
|
|
6543
6720
|
|
|
6544
6721
|
// src/cli/cmd/run/_const.ts
|
|
6545
|
-
import
|
|
6722
|
+
import chalk8 from "chalk";
|
|
6546
6723
|
import { ListrDefaultRendererLogLevels } from "listr2";
|
|
6547
6724
|
var commonTaskRendererOptions = {
|
|
6548
6725
|
color: {
|
|
6549
|
-
[ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ?
|
|
6726
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ? chalk8.hex(colors.green)(msg) : chalk8.hex(colors.green)("")
|
|
6550
6727
|
},
|
|
6551
6728
|
icon: {
|
|
6552
|
-
[ListrDefaultRendererLogLevels.COMPLETED]:
|
|
6729
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: chalk8.hex(colors.green)("\u2713")
|
|
6553
6730
|
}
|
|
6554
6731
|
};
|
|
6555
6732
|
|
|
6556
6733
|
// src/cli/localizer/lingodotdev.ts
|
|
6557
|
-
import
|
|
6558
|
-
import
|
|
6734
|
+
import dedent5 from "dedent";
|
|
6735
|
+
import chalk9 from "chalk";
|
|
6559
6736
|
import { LingoDotDevEngine as LingoDotDevEngine2 } from "@lingo.dev/_sdk";
|
|
6560
6737
|
function createLingoDotDevLocalizer(explicitApiKey) {
|
|
6561
6738
|
const { auth } = getSettings(explicitApiKey);
|
|
6562
6739
|
if (!auth) {
|
|
6563
6740
|
throw new Error(
|
|
6564
|
-
|
|
6565
|
-
You're trying to use ${
|
|
6741
|
+
dedent5`
|
|
6742
|
+
You're trying to use ${chalk9.hex(colors.green)("Lingo.dev")} provider, however, you are not authenticated.
|
|
6566
6743
|
|
|
6567
6744
|
To fix this issue:
|
|
6568
|
-
1. Run ${
|
|
6569
|
-
2. Use the ${
|
|
6570
|
-
3. Set ${
|
|
6745
|
+
1. Run ${chalk9.dim("lingo.dev login")} to authenticate, or
|
|
6746
|
+
2. Use the ${chalk9.dim("--api-key")} flag to provide an API key.
|
|
6747
|
+
3. Set ${chalk9.dim("LINGODOTDEV_API_KEY")} environment variable.
|
|
6571
6748
|
`
|
|
6572
6749
|
);
|
|
6573
6750
|
}
|
|
@@ -6612,22 +6789,22 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
6612
6789
|
// src/cli/localizer/explicit.ts
|
|
6613
6790
|
import { createAnthropic as createAnthropic2 } from "@ai-sdk/anthropic";
|
|
6614
6791
|
import { createOpenAI as createOpenAI2 } from "@ai-sdk/openai";
|
|
6615
|
-
import
|
|
6616
|
-
import
|
|
6792
|
+
import chalk10 from "chalk";
|
|
6793
|
+
import dedent6 from "dedent";
|
|
6617
6794
|
import { generateText as generateText2 } from "ai";
|
|
6618
6795
|
import { jsonrepair as jsonrepair3 } from "jsonrepair";
|
|
6619
6796
|
function createExplicitLocalizer(provider) {
|
|
6620
6797
|
switch (provider.id) {
|
|
6621
6798
|
default:
|
|
6622
6799
|
throw new Error(
|
|
6623
|
-
|
|
6624
|
-
You're trying to use unsupported provider: ${
|
|
6800
|
+
dedent6`
|
|
6801
|
+
You're trying to use unsupported provider: ${chalk10.dim(provider.id)}.
|
|
6625
6802
|
|
|
6626
6803
|
To fix this issue:
|
|
6627
6804
|
1. Switch to one of the supported providers, or
|
|
6628
|
-
2. Remove the ${
|
|
6805
|
+
2. Remove the ${chalk10.italic("provider")} node from your i18n.json configuration to switch to ${chalk10.hex(colors.green)("Lingo.dev")}
|
|
6629
6806
|
|
|
6630
|
-
${
|
|
6807
|
+
${chalk10.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
6631
6808
|
`
|
|
6632
6809
|
);
|
|
6633
6810
|
case "openai":
|
|
@@ -6652,14 +6829,14 @@ function createAiSdkLocalizer(params) {
|
|
|
6652
6829
|
const apiKey = process.env[params.apiKeyName];
|
|
6653
6830
|
if (!apiKey) {
|
|
6654
6831
|
throw new Error(
|
|
6655
|
-
|
|
6656
|
-
You're trying to use raw ${
|
|
6832
|
+
dedent6`
|
|
6833
|
+
You're trying to use raw ${chalk10.dim(params.id)} API for translation, however, ${chalk10.dim(params.apiKeyName)} environment variable is not set.
|
|
6657
6834
|
|
|
6658
6835
|
To fix this issue:
|
|
6659
|
-
1. Set ${
|
|
6660
|
-
2. Remove the ${
|
|
6836
|
+
1. Set ${chalk10.dim(params.apiKeyName)} in your environment variables, or
|
|
6837
|
+
2. Remove the ${chalk10.italic("provider")} node from your i18n.json configuration to switch to ${chalk10.hex(colors.green)("Lingo.dev")}
|
|
6661
6838
|
|
|
6662
|
-
${
|
|
6839
|
+
${chalk10.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
6663
6840
|
`
|
|
6664
6841
|
);
|
|
6665
6842
|
}
|
|
@@ -6746,7 +6923,7 @@ function createLocalizer(provider) {
|
|
|
6746
6923
|
|
|
6747
6924
|
// src/cli/cmd/run/setup.ts
|
|
6748
6925
|
async function setup(input2) {
|
|
6749
|
-
console.log(
|
|
6926
|
+
console.log(chalk11.hex(colors.orange)("[Setup]"));
|
|
6750
6927
|
return new Listr(
|
|
6751
6928
|
[
|
|
6752
6929
|
{
|
|
@@ -6792,7 +6969,7 @@ async function setup(input2) {
|
|
|
6792
6969
|
"Could not create localization provider. Please check your i18n.json configuration."
|
|
6793
6970
|
);
|
|
6794
6971
|
}
|
|
6795
|
-
task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${
|
|
6972
|
+
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`;
|
|
6796
6973
|
}
|
|
6797
6974
|
},
|
|
6798
6975
|
{
|
|
@@ -6801,10 +6978,10 @@ async function setup(input2) {
|
|
|
6801
6978
|
const authStatus = await ctx.localizer.checkAuth();
|
|
6802
6979
|
if (!authStatus.authenticated) {
|
|
6803
6980
|
throw new Error(
|
|
6804
|
-
`Failed to authenticate with ${
|
|
6981
|
+
`Failed to authenticate with ${chalk11.hex(colors.yellow)(ctx.localizer.id)} provider. Please check your API key and try again.`
|
|
6805
6982
|
);
|
|
6806
6983
|
}
|
|
6807
|
-
task.title = `Authenticated as ${
|
|
6984
|
+
task.title = `Authenticated as ${chalk11.hex(colors.yellow)(authStatus.username)}`;
|
|
6808
6985
|
}
|
|
6809
6986
|
},
|
|
6810
6987
|
{
|
|
@@ -6838,11 +7015,11 @@ async function setup(input2) {
|
|
|
6838
7015
|
}
|
|
6839
7016
|
|
|
6840
7017
|
// src/cli/cmd/run/plan.ts
|
|
6841
|
-
import
|
|
7018
|
+
import chalk12 from "chalk";
|
|
6842
7019
|
import { Listr as Listr2 } from "listr2";
|
|
6843
7020
|
import { resolveOverriddenLocale as resolveOverriddenLocale7 } from "@lingo.dev/_spec";
|
|
6844
7021
|
async function plan(input2) {
|
|
6845
|
-
console.log(
|
|
7022
|
+
console.log(chalk12.hex(colors.orange)("[Planning]"));
|
|
6846
7023
|
let buckets = getBuckets(input2.config);
|
|
6847
7024
|
if (input2.flags.bucket) {
|
|
6848
7025
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
@@ -6857,8 +7034,8 @@ async function plan(input2) {
|
|
|
6857
7034
|
title: "Locating content buckets",
|
|
6858
7035
|
task: async (ctx, task) => {
|
|
6859
7036
|
const bucketCount = buckets.length;
|
|
6860
|
-
const bucketFilter = input2.flags.bucket ? ` ${
|
|
6861
|
-
task.title = `Found ${
|
|
7037
|
+
const bucketFilter = input2.flags.bucket ? ` ${chalk12.dim(`(filtered by: ${chalk12.hex(colors.yellow)(input2.flags.bucket.join(", "))})`)}` : "";
|
|
7038
|
+
task.title = `Found ${chalk12.hex(colors.yellow)(bucketCount.toString())} bucket(s)${bucketFilter}`;
|
|
6862
7039
|
}
|
|
6863
7040
|
},
|
|
6864
7041
|
{
|
|
@@ -6869,8 +7046,8 @@ async function plan(input2) {
|
|
|
6869
7046
|
`No target locales found in config. Please add locales to your i18n.json config file.`
|
|
6870
7047
|
);
|
|
6871
7048
|
}
|
|
6872
|
-
const localeFilter = input2.flags.locale ? ` ${
|
|
6873
|
-
task.title = `Found ${
|
|
7049
|
+
const localeFilter = input2.flags.locale ? ` ${chalk12.dim(`(filtered by: ${chalk12.hex(colors.yellow)(input2.flags.locale.join(", "))})`)}` : "";
|
|
7050
|
+
task.title = `Found ${chalk12.hex(colors.yellow)(locales.length.toString())} target locale(s)${localeFilter}`;
|
|
6874
7051
|
}
|
|
6875
7052
|
},
|
|
6876
7053
|
{
|
|
@@ -6889,8 +7066,8 @@ async function plan(input2) {
|
|
|
6889
7066
|
patterns.push(bucketPath.pathPattern);
|
|
6890
7067
|
}
|
|
6891
7068
|
}
|
|
6892
|
-
const fileFilter = input2.flags.file ? ` ${
|
|
6893
|
-
task.title = `Found ${
|
|
7069
|
+
const fileFilter = input2.flags.file ? ` ${chalk12.dim(`(filtered by: ${chalk12.hex(colors.yellow)(input2.flags.file.join(", "))})`)}` : "";
|
|
7070
|
+
task.title = `Found ${chalk12.hex(colors.yellow)(patterns.length.toString())} path pattern(s)${fileFilter}`;
|
|
6894
7071
|
}
|
|
6895
7072
|
},
|
|
6896
7073
|
{
|
|
@@ -6927,7 +7104,7 @@ async function plan(input2) {
|
|
|
6927
7104
|
}
|
|
6928
7105
|
}
|
|
6929
7106
|
}
|
|
6930
|
-
task.title = `Prepared ${
|
|
7107
|
+
task.title = `Prepared ${chalk12.hex(colors.green)(ctx.tasks.length.toString())} translation task(s)`;
|
|
6931
7108
|
}
|
|
6932
7109
|
}
|
|
6933
7110
|
],
|
|
@@ -6938,10 +7115,10 @@ async function plan(input2) {
|
|
|
6938
7115
|
}
|
|
6939
7116
|
|
|
6940
7117
|
// src/cli/cmd/run/execute.ts
|
|
6941
|
-
import
|
|
7118
|
+
import chalk13 from "chalk";
|
|
6942
7119
|
import { Listr as Listr3 } from "listr2";
|
|
6943
7120
|
import pLimit from "p-limit";
|
|
6944
|
-
import
|
|
7121
|
+
import _32 from "lodash";
|
|
6945
7122
|
var MAX_WORKER_COUNT = 10;
|
|
6946
7123
|
async function execute(input2) {
|
|
6947
7124
|
const effectiveConcurrency = Math.min(
|
|
@@ -6949,17 +7126,17 @@ async function execute(input2) {
|
|
|
6949
7126
|
input2.tasks.length,
|
|
6950
7127
|
MAX_WORKER_COUNT
|
|
6951
7128
|
);
|
|
6952
|
-
console.log(
|
|
7129
|
+
console.log(chalk13.hex(colors.orange)(`[Localization]`));
|
|
6953
7130
|
return new Listr3(
|
|
6954
7131
|
[
|
|
6955
7132
|
{
|
|
6956
7133
|
title: "Initializing localization engine",
|
|
6957
7134
|
task: async (ctx, task) => {
|
|
6958
|
-
task.title = `Localization engine ${
|
|
7135
|
+
task.title = `Localization engine ${chalk13.hex(colors.green)("ready")} (${ctx.localizer.id})`;
|
|
6959
7136
|
}
|
|
6960
7137
|
},
|
|
6961
7138
|
{
|
|
6962
|
-
title: `Processing localization tasks ${
|
|
7139
|
+
title: `Processing localization tasks ${chalk13.dim(`(tasks: ${input2.tasks.length}, concurrency: ${effectiveConcurrency})`)}`,
|
|
6963
7140
|
task: (ctx, task) => {
|
|
6964
7141
|
if (input2.tasks.length < 1) {
|
|
6965
7142
|
task.title = `Skipping, nothing to localize.`;
|
|
@@ -6972,7 +7149,7 @@ async function execute(input2) {
|
|
|
6972
7149
|
const workerTasks = [];
|
|
6973
7150
|
for (let i = 0; i < workersCount; i++) {
|
|
6974
7151
|
const assignedTasks = ctx.tasks.filter(
|
|
6975
|
-
(
|
|
7152
|
+
(_33, idx) => idx % workersCount === i
|
|
6976
7153
|
);
|
|
6977
7154
|
workerTasks.push(
|
|
6978
7155
|
createWorkerTask({
|
|
@@ -7008,9 +7185,9 @@ function createWorkerStatusMessage(args) {
|
|
|
7008
7185
|
"[locale]",
|
|
7009
7186
|
args.assignedTask.targetLocale
|
|
7010
7187
|
);
|
|
7011
|
-
return `[${
|
|
7188
|
+
return `[${chalk13.hex(colors.yellow)(`${args.percentage}%`)}] Processing: ${chalk13.dim(
|
|
7012
7189
|
displayPath
|
|
7013
|
-
)} (${
|
|
7190
|
+
)} (${chalk13.hex(colors.yellow)(args.assignedTask.sourceLocale)} -> ${chalk13.hex(
|
|
7014
7191
|
colors.yellow
|
|
7015
7192
|
)(args.assignedTask.targetLocale)})`;
|
|
7016
7193
|
}
|
|
@@ -7027,7 +7204,7 @@ function createExecutionProgressMessage(ctx) {
|
|
|
7027
7204
|
ctx,
|
|
7028
7205
|
(_t, result) => result.status === "skipped"
|
|
7029
7206
|
);
|
|
7030
|
-
return `Processed ${
|
|
7207
|
+
return `Processed ${chalk13.green(succeededTasksCount)}/${ctx.tasks.length}, Failed ${chalk13.red(failedTasksCount)}, Skipped ${chalk13.dim(skippedTasksCount)}`;
|
|
7031
7208
|
}
|
|
7032
7209
|
function createLoaderForTask(assignedTask) {
|
|
7033
7210
|
const bucketLoader = createBucketLoader(
|
|
@@ -7071,7 +7248,7 @@ function createWorkerTask(args) {
|
|
|
7071
7248
|
targetData,
|
|
7072
7249
|
checksums
|
|
7073
7250
|
});
|
|
7074
|
-
const processableData =
|
|
7251
|
+
const processableData = _32.chain(sourceData).entries().filter(
|
|
7075
7252
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
7076
7253
|
).fromPairs().value();
|
|
7077
7254
|
if (!Object.keys(processableData).length) {
|
|
@@ -7092,13 +7269,13 @@ function createWorkerTask(args) {
|
|
|
7092
7269
|
});
|
|
7093
7270
|
}
|
|
7094
7271
|
);
|
|
7095
|
-
let finalTargetData =
|
|
7272
|
+
let finalTargetData = _32.merge(
|
|
7096
7273
|
{},
|
|
7097
7274
|
sourceData,
|
|
7098
7275
|
targetData,
|
|
7099
7276
|
processedTargetData
|
|
7100
7277
|
);
|
|
7101
|
-
finalTargetData =
|
|
7278
|
+
finalTargetData = _32.chain(finalTargetData).entries().map(([key, value]) => {
|
|
7102
7279
|
const renaming = delta.renamed.find(
|
|
7103
7280
|
([oldKey]) => oldKey === key
|
|
7104
7281
|
);
|
|
@@ -7158,7 +7335,7 @@ var flagsSchema2 = z2.object({
|
|
|
7158
7335
|
});
|
|
7159
7336
|
|
|
7160
7337
|
// src/cli/cmd/run/_render.ts
|
|
7161
|
-
import
|
|
7338
|
+
import chalk14 from "chalk";
|
|
7162
7339
|
import figlet2 from "figlet";
|
|
7163
7340
|
import { vice as vice2 } from "gradient-string";
|
|
7164
7341
|
import readline2 from "readline";
|
|
@@ -7181,7 +7358,7 @@ async function renderBanner2() {
|
|
|
7181
7358
|
}
|
|
7182
7359
|
async function renderHero2() {
|
|
7183
7360
|
console.log(
|
|
7184
|
-
`\u26A1\uFE0F ${
|
|
7361
|
+
`\u26A1\uFE0F ${chalk14.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
7185
7362
|
);
|
|
7186
7363
|
console.log("");
|
|
7187
7364
|
const label1 = "\u2B50 GitHub Repo:";
|
|
@@ -7189,13 +7366,13 @@ async function renderHero2() {
|
|
|
7189
7366
|
const label3 = "\u{1F4AC} 24/7 Support:";
|
|
7190
7367
|
const maxLabelWidth = 17;
|
|
7191
7368
|
console.log(
|
|
7192
|
-
`${
|
|
7369
|
+
`${chalk14.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${chalk14.hex(colors.blue)("https://lingo.dev/go/gh")}`
|
|
7193
7370
|
);
|
|
7194
7371
|
console.log(
|
|
7195
|
-
`${
|
|
7372
|
+
`${chalk14.hex(colors.blue)(label2.padEnd(maxLabelWidth + 1))} ${chalk14.hex(colors.blue)("https://lingo.dev/go/docs")}`
|
|
7196
7373
|
);
|
|
7197
7374
|
console.log(
|
|
7198
|
-
`${
|
|
7375
|
+
`${chalk14.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${chalk14.hex(colors.blue)("hi@lingo.dev")}`
|
|
7199
7376
|
);
|
|
7200
7377
|
}
|
|
7201
7378
|
async function pauseIfDebug(debug) {
|
|
@@ -7209,7 +7386,7 @@ async function waitForUserPrompt(message) {
|
|
|
7209
7386
|
output: process.stdout
|
|
7210
7387
|
});
|
|
7211
7388
|
return new Promise((resolve) => {
|
|
7212
|
-
rl.question(
|
|
7389
|
+
rl.question(chalk14.dim(`[${message}]
|
|
7213
7390
|
`), () => {
|
|
7214
7391
|
rl.close();
|
|
7215
7392
|
resolve();
|
|
@@ -7217,23 +7394,23 @@ async function waitForUserPrompt(message) {
|
|
|
7217
7394
|
});
|
|
7218
7395
|
}
|
|
7219
7396
|
async function renderSummary(ctx) {
|
|
7220
|
-
console.log(
|
|
7397
|
+
console.log(chalk14.hex(colors.green)("[Done]"));
|
|
7221
7398
|
const skippedTasksCount = Array.from(ctx.results.values()).filter(
|
|
7222
7399
|
(r) => r.status === "skipped"
|
|
7223
7400
|
).length;
|
|
7224
|
-
console.log(`\u2022 ${
|
|
7401
|
+
console.log(`\u2022 ${chalk14.hex(colors.yellow)(skippedTasksCount)} from cache`);
|
|
7225
7402
|
const succeededTasksCount = Array.from(ctx.results.values()).filter(
|
|
7226
7403
|
(r) => r.status === "success"
|
|
7227
7404
|
).length;
|
|
7228
|
-
console.log(`\u2022 ${
|
|
7405
|
+
console.log(`\u2022 ${chalk14.hex(colors.yellow)(succeededTasksCount)} processed`);
|
|
7229
7406
|
const failedTasksCount = Array.from(ctx.results.values()).filter(
|
|
7230
7407
|
(r) => r.status === "error"
|
|
7231
7408
|
).length;
|
|
7232
|
-
console.log(`\u2022 ${
|
|
7409
|
+
console.log(`\u2022 ${chalk14.hex(colors.yellow)(failedTasksCount)} failed`);
|
|
7233
7410
|
}
|
|
7234
7411
|
|
|
7235
7412
|
// src/cli/cmd/run/index.ts
|
|
7236
|
-
var run_default = new
|
|
7413
|
+
var run_default = new Command17().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
|
|
7237
7414
|
"--locale <locale>",
|
|
7238
7415
|
"Locale to process",
|
|
7239
7416
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
@@ -7307,7 +7484,7 @@ ${vice3(
|
|
|
7307
7484
|
|
|
7308
7485
|
Star the the repo :) https://github.com/LingoDotDev/lingo.dev
|
|
7309
7486
|
`
|
|
7310
|
-
).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) => {
|
|
7487
|
+
).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) => {
|
|
7311
7488
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
|
|
7312
7489
|
process.exit(0);
|
|
7313
7490
|
}
|