lingo.dev 0.93.13 → 0.94.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.cjs +156 -105
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +290 -239
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -4
package/build/cli.mjs
CHANGED
|
@@ -7,10 +7,6 @@ import { vice as vice3 } from "gradient-string";
|
|
|
7
7
|
// src/cli/cmd/auth.ts
|
|
8
8
|
import { Command } from "interactive-commander";
|
|
9
9
|
import Ora from "ora";
|
|
10
|
-
import express from "express";
|
|
11
|
-
import cors from "cors";
|
|
12
|
-
import open from "open";
|
|
13
|
-
import readline from "readline/promises";
|
|
14
10
|
|
|
15
11
|
// src/cli/utils/settings.ts
|
|
16
12
|
import os from "os";
|
|
@@ -237,19 +233,27 @@ function createAuthenticator(params) {
|
|
|
237
233
|
}
|
|
238
234
|
|
|
239
235
|
// src/cli/cmd/auth.ts
|
|
240
|
-
var auth_default = new Command().command("auth").description("
|
|
236
|
+
var auth_default = new Command().command("auth").description("Show current authentication status").helpOption("-h, --help", "Show help").option(
|
|
237
|
+
"--login",
|
|
238
|
+
"Login to your account (deprecated: use 'lingo.dev login' instead)"
|
|
239
|
+
).option(
|
|
240
|
+
"--logout",
|
|
241
|
+
"Logout from your account (deprecated: use 'lingo.dev logout' instead)"
|
|
242
|
+
).action(async (options) => {
|
|
241
243
|
try {
|
|
242
|
-
let settings = await getSettings(void 0);
|
|
243
|
-
if (options.logout) {
|
|
244
|
-
settings.auth.apiKey = "";
|
|
245
|
-
await saveSettings(settings);
|
|
246
|
-
}
|
|
247
244
|
if (options.login) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
245
|
+
Ora().warn(
|
|
246
|
+
"\u26A0\uFE0F DEPRECATED: '--login' is deprecated. Please use 'lingo.dev login' instead."
|
|
247
|
+
);
|
|
248
|
+
process.exit(1);
|
|
252
249
|
}
|
|
250
|
+
if (options.logout) {
|
|
251
|
+
Ora().warn(
|
|
252
|
+
"\u26A0\uFE0F DEPRECATED: '--logout' is deprecated. Please use 'lingo.dev logout' instead."
|
|
253
|
+
);
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
const settings = await getSettings(void 0);
|
|
253
257
|
const authenticator = createAuthenticator({
|
|
254
258
|
apiUrl: settings.auth.apiUrl,
|
|
255
259
|
apiKey: settings.auth.apiKey
|
|
@@ -265,8 +269,122 @@ var auth_default = new Command().command("auth").description("Authenticate with
|
|
|
265
269
|
process.exit(1);
|
|
266
270
|
}
|
|
267
271
|
});
|
|
272
|
+
|
|
273
|
+
// src/cli/cmd/login.ts
|
|
274
|
+
import { Command as Command2 } from "interactive-commander";
|
|
275
|
+
import Ora2 from "ora";
|
|
276
|
+
import express from "express";
|
|
277
|
+
import cors from "cors";
|
|
278
|
+
import open from "open";
|
|
279
|
+
import readline2 from "readline/promises";
|
|
280
|
+
|
|
281
|
+
// src/cli/utils/ui.ts
|
|
282
|
+
import chalk from "chalk";
|
|
283
|
+
import figlet from "figlet";
|
|
284
|
+
import { vice } from "gradient-string";
|
|
285
|
+
import readline from "readline";
|
|
286
|
+
|
|
287
|
+
// src/cli/constants.ts
|
|
288
|
+
var colors = {
|
|
289
|
+
orange: "#ff6600",
|
|
290
|
+
green: "#6ae300",
|
|
291
|
+
blue: "#0090ff",
|
|
292
|
+
yellow: "#ffcc00",
|
|
293
|
+
grey: "#808080",
|
|
294
|
+
red: "#ff0000"
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// src/cli/utils/ui.ts
|
|
298
|
+
async function renderClear() {
|
|
299
|
+
console.log("\x1Bc");
|
|
300
|
+
}
|
|
301
|
+
async function renderSpacer() {
|
|
302
|
+
console.log(" ");
|
|
303
|
+
}
|
|
304
|
+
async function renderBanner() {
|
|
305
|
+
console.log(
|
|
306
|
+
vice(
|
|
307
|
+
figlet.textSync("LINGO.DEV", {
|
|
308
|
+
font: "ANSI Shadow",
|
|
309
|
+
horizontalLayout: "default",
|
|
310
|
+
verticalLayout: "default"
|
|
311
|
+
})
|
|
312
|
+
)
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
async function renderHero() {
|
|
316
|
+
console.log(
|
|
317
|
+
`\u26A1\uFE0F ${chalk.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
318
|
+
);
|
|
319
|
+
console.log("");
|
|
320
|
+
const label1 = "\u2B50 GitHub Repo:";
|
|
321
|
+
const label2 = "\u{1F4DA} Docs:";
|
|
322
|
+
const label3 = "\u{1F4AC} 24/7 Support:";
|
|
323
|
+
const maxLabelWidth = 17;
|
|
324
|
+
console.log(
|
|
325
|
+
`${chalk.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${chalk.hex(colors.blue)("https://lingo.dev/go/gh")}`
|
|
326
|
+
);
|
|
327
|
+
console.log(
|
|
328
|
+
`${chalk.hex(colors.blue)(label2.padEnd(maxLabelWidth + 1))} ${chalk.hex(colors.blue)("https://lingo.dev/go/docs")}`
|
|
329
|
+
);
|
|
330
|
+
console.log(
|
|
331
|
+
`${chalk.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${chalk.hex(colors.blue)("hi@lingo.dev")}`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
async function waitForUserPrompt(message) {
|
|
335
|
+
const rl = readline.createInterface({
|
|
336
|
+
input: process.stdin,
|
|
337
|
+
output: process.stdout
|
|
338
|
+
});
|
|
339
|
+
return new Promise((resolve) => {
|
|
340
|
+
rl.question(chalk.dim(`[${message}]
|
|
341
|
+
`), () => {
|
|
342
|
+
rl.close();
|
|
343
|
+
resolve();
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
async function pauseIfDebug(debug) {
|
|
348
|
+
if (debug) {
|
|
349
|
+
await waitForUserPrompt("Press Enter to continue...");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async function renderSummary(results) {
|
|
353
|
+
console.log(chalk.hex(colors.green)("[Done]"));
|
|
354
|
+
const skippedTasksCount = Array.from(results.values()).filter(
|
|
355
|
+
(r) => r.status === "skipped"
|
|
356
|
+
).length;
|
|
357
|
+
console.log(`\u2022 ${chalk.hex(colors.yellow)(skippedTasksCount)} from cache`);
|
|
358
|
+
const succeededTasksCount = Array.from(results.values()).filter(
|
|
359
|
+
(r) => r.status === "success"
|
|
360
|
+
).length;
|
|
361
|
+
console.log(`\u2022 ${chalk.hex(colors.yellow)(succeededTasksCount)} processed`);
|
|
362
|
+
const failedTasksCount = Array.from(results.values()).filter(
|
|
363
|
+
(r) => r.status === "error"
|
|
364
|
+
).length;
|
|
365
|
+
console.log(`\u2022 ${chalk.hex(colors.yellow)(failedTasksCount)} failed`);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/cli/cmd/login.ts
|
|
369
|
+
var login_default = new Command2().command("login").description("Authenticate with Lingo.dev API").helpOption("-h, --help", "Show help").action(async () => {
|
|
370
|
+
try {
|
|
371
|
+
await renderClear();
|
|
372
|
+
await renderSpacer();
|
|
373
|
+
await renderBanner();
|
|
374
|
+
await renderHero();
|
|
375
|
+
await renderSpacer();
|
|
376
|
+
const settings = await getSettings(void 0);
|
|
377
|
+
const apiKey = await login(settings.auth.webUrl);
|
|
378
|
+
settings.auth.apiKey = apiKey;
|
|
379
|
+
await saveSettings(settings);
|
|
380
|
+
Ora2().succeed("Successfully logged in");
|
|
381
|
+
} catch (error) {
|
|
382
|
+
Ora2().fail(error.message);
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
268
386
|
async function login(webAppUrl) {
|
|
269
|
-
await
|
|
387
|
+
await readline2.createInterface({
|
|
270
388
|
input: process.stdin,
|
|
271
389
|
output: process.stdout
|
|
272
390
|
}).question(
|
|
@@ -278,7 +396,7 @@ Press Enter to open the browser for authentication.
|
|
|
278
396
|
Having issues? Put LINGODOTDEV_API_KEY in your .env file instead.
|
|
279
397
|
`.trim() + "\n"
|
|
280
398
|
);
|
|
281
|
-
const spinner =
|
|
399
|
+
const spinner = Ora2().start("Waiting for the API key");
|
|
282
400
|
const apiKey = await waitForApiKey(async (port) => {
|
|
283
401
|
await open(`${webAppUrl}/app/cli?port=${port}`, { wait: false });
|
|
284
402
|
});
|
|
@@ -304,9 +422,29 @@ async function waitForApiKey(cb) {
|
|
|
304
422
|
});
|
|
305
423
|
}
|
|
306
424
|
|
|
425
|
+
// src/cli/cmd/logout.ts
|
|
426
|
+
import { Command as Command3 } from "interactive-commander";
|
|
427
|
+
import Ora3 from "ora";
|
|
428
|
+
var logout_default = new Command3().command("logout").description("Sign out from Lingo.dev API").helpOption("-h, --help", "Show help").action(async () => {
|
|
429
|
+
try {
|
|
430
|
+
await renderClear();
|
|
431
|
+
await renderSpacer();
|
|
432
|
+
await renderBanner();
|
|
433
|
+
await renderHero();
|
|
434
|
+
await renderSpacer();
|
|
435
|
+
const settings = await getSettings(void 0);
|
|
436
|
+
settings.auth.apiKey = "";
|
|
437
|
+
await saveSettings(settings);
|
|
438
|
+
Ora3().succeed("Successfully logged out");
|
|
439
|
+
} catch (error) {
|
|
440
|
+
Ora3().fail(error.message);
|
|
441
|
+
process.exit(1);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
307
445
|
// src/cli/cmd/init.ts
|
|
308
446
|
import { InteractiveCommand, InteractiveOption } from "interactive-commander";
|
|
309
|
-
import
|
|
447
|
+
import Ora4 from "ora";
|
|
310
448
|
|
|
311
449
|
// src/cli/utils/config.ts
|
|
312
450
|
import _ from "lodash";
|
|
@@ -741,7 +879,7 @@ var init_default = new InteractiveCommand().command("init").description("Initial
|
|
|
741
879
|
).action(async (options) => {
|
|
742
880
|
const settings = getSettings(void 0);
|
|
743
881
|
const isInteractive = options.interactive;
|
|
744
|
-
const spinner =
|
|
882
|
+
const spinner = Ora4().start("Initializing Lingo.dev project");
|
|
745
883
|
let existingConfig = await getConfig(false);
|
|
746
884
|
if (existingConfig && !options.force) {
|
|
747
885
|
spinner.fail("Lingo.dev project already initialized");
|
|
@@ -832,33 +970,33 @@ var init_default = new InteractiveCommand().command("init").description("Initial
|
|
|
832
970
|
});
|
|
833
971
|
const auth2 = await newAuthenticator.whoami();
|
|
834
972
|
if (auth2) {
|
|
835
|
-
|
|
973
|
+
Ora4().succeed(`Authenticated as ${auth2?.email}`);
|
|
836
974
|
} else {
|
|
837
|
-
|
|
975
|
+
Ora4().fail("Authentication failed.");
|
|
838
976
|
}
|
|
839
977
|
}
|
|
840
978
|
} else {
|
|
841
|
-
|
|
979
|
+
Ora4().warn("You are not logged in. Run `npx lingo.dev@latest auth --login` to login.");
|
|
842
980
|
}
|
|
843
981
|
} else {
|
|
844
|
-
|
|
982
|
+
Ora4().succeed(`Authenticated as ${auth.email}`);
|
|
845
983
|
}
|
|
846
984
|
updateGitignore();
|
|
847
985
|
if (!isInteractive) {
|
|
848
|
-
|
|
986
|
+
Ora4().info("Please see https://docs.lingo.dev/");
|
|
849
987
|
}
|
|
850
988
|
});
|
|
851
989
|
|
|
852
990
|
// src/cli/cmd/show/index.ts
|
|
853
|
-
import { Command as
|
|
991
|
+
import { Command as Command7 } from "interactive-commander";
|
|
854
992
|
|
|
855
993
|
// src/cli/cmd/show/config.ts
|
|
856
|
-
import { Command as
|
|
994
|
+
import { Command as Command4 } from "interactive-commander";
|
|
857
995
|
import _4 from "lodash";
|
|
858
996
|
import fs7 from "fs";
|
|
859
997
|
import path8 from "path";
|
|
860
998
|
import { defaultConfig as defaultConfig2 } from "@lingo.dev/_spec";
|
|
861
|
-
var config_default = new
|
|
999
|
+
var config_default = new Command4().command("config").description("Print out the current configuration").helpOption("-h, --help", "Show help").action(async (options) => {
|
|
862
1000
|
const fileConfig = loadReplexicaFileConfig();
|
|
863
1001
|
const config = _4.merge({}, defaultConfig2, fileConfig);
|
|
864
1002
|
console.log(JSON.stringify(config, null, 2));
|
|
@@ -875,11 +1013,11 @@ function loadReplexicaFileConfig() {
|
|
|
875
1013
|
}
|
|
876
1014
|
|
|
877
1015
|
// src/cli/cmd/show/locale.ts
|
|
878
|
-
import { Command as
|
|
879
|
-
import
|
|
1016
|
+
import { Command as Command5 } from "interactive-commander";
|
|
1017
|
+
import Ora5 from "ora";
|
|
880
1018
|
import { localeCodes } from "@lingo.dev/_spec";
|
|
881
|
-
var locale_default = new
|
|
882
|
-
const ora =
|
|
1019
|
+
var locale_default = new Command5().command("locale").description("Print out the list of locales").helpOption("-h, --help", "Show help").argument("<type>", 'Type of locales to show, either "sources" or "targets"').action(async (type) => {
|
|
1020
|
+
const ora = Ora5();
|
|
883
1021
|
try {
|
|
884
1022
|
switch (type) {
|
|
885
1023
|
default:
|
|
@@ -901,8 +1039,8 @@ var locale_default = new Command3().command("locale").description("Print out the
|
|
|
901
1039
|
});
|
|
902
1040
|
|
|
903
1041
|
// src/cli/cmd/show/files.ts
|
|
904
|
-
import { Command as
|
|
905
|
-
import
|
|
1042
|
+
import { Command as Command6 } from "interactive-commander";
|
|
1043
|
+
import Ora6 from "ora";
|
|
906
1044
|
|
|
907
1045
|
// src/cli/utils/buckets.ts
|
|
908
1046
|
import _5 from "lodash";
|
|
@@ -1027,8 +1165,8 @@ function resolveBucketItem(bucketItem) {
|
|
|
1027
1165
|
|
|
1028
1166
|
// src/cli/cmd/show/files.ts
|
|
1029
1167
|
import { resolveOverriddenLocale as resolveOverriddenLocale2 } from "@lingo.dev/_spec";
|
|
1030
|
-
var files_default = new
|
|
1031
|
-
const ora =
|
|
1168
|
+
var files_default = new Command6().command("files").description("Print out the list of files managed by Lingo.dev").option("--source", "Only show source files, files containing the original translations").option("--target", "Only show target files, files containing translated content").helpOption("-h, --help", "Show help").action(async (type) => {
|
|
1169
|
+
const ora = Ora6();
|
|
1032
1170
|
try {
|
|
1033
1171
|
try {
|
|
1034
1172
|
const i18nConfig = await getConfig();
|
|
@@ -1073,24 +1211,24 @@ var files_default = new Command4().command("files").description("Print out the l
|
|
|
1073
1211
|
});
|
|
1074
1212
|
|
|
1075
1213
|
// src/cli/cmd/show/index.ts
|
|
1076
|
-
var show_default = new
|
|
1214
|
+
var show_default = new Command7().command("show").description("Prints out the current configuration").helpOption("-h, --help", "Show help").addCommand(config_default).addCommand(locale_default).addCommand(files_default);
|
|
1077
1215
|
|
|
1078
1216
|
// src/cli/cmd/config/index.ts
|
|
1079
|
-
import { Command as
|
|
1217
|
+
import { Command as Command11 } from "interactive-commander";
|
|
1080
1218
|
|
|
1081
1219
|
// src/cli/cmd/config/set.ts
|
|
1082
|
-
import { Command as
|
|
1083
|
-
import
|
|
1220
|
+
import { Command as Command8 } from "interactive-commander";
|
|
1221
|
+
import chalk2 from "chalk";
|
|
1084
1222
|
import dedent from "dedent";
|
|
1085
1223
|
import _6 from "lodash";
|
|
1086
|
-
var set_default = new
|
|
1224
|
+
var set_default = new Command8().name("set").description("Set a configuration key to a value").addHelpText("afterAll", `
|
|
1087
1225
|
Available keys:
|
|
1088
1226
|
${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key to set").argument("<value>", "New value").helpOption("-h, --help", "Show help").action(async (key, value) => {
|
|
1089
1227
|
if (!SETTINGS_KEYS.includes(key)) {
|
|
1090
1228
|
console.error(
|
|
1091
1229
|
dedent`
|
|
1092
|
-
${
|
|
1093
|
-
Run ${
|
|
1230
|
+
${chalk2.red("\u2716")} Unknown configuration key: ${chalk2.bold(key)}
|
|
1231
|
+
Run ${chalk2.dim("lingo.dev config set --help")} to see available keys.
|
|
1094
1232
|
`
|
|
1095
1233
|
);
|
|
1096
1234
|
process.exitCode = 1;
|
|
@@ -1101,11 +1239,11 @@ Available keys:
|
|
|
1101
1239
|
_6.set(updated, key, value);
|
|
1102
1240
|
try {
|
|
1103
1241
|
saveSettings(updated);
|
|
1104
|
-
console.log(`${
|
|
1242
|
+
console.log(`${chalk2.green("\u2714")} Set ${chalk2.bold(key)}`);
|
|
1105
1243
|
} catch (err) {
|
|
1106
1244
|
console.error(
|
|
1107
|
-
|
|
1108
|
-
`\u2716 Failed to save configuration: ${
|
|
1245
|
+
chalk2.red(
|
|
1246
|
+
`\u2716 Failed to save configuration: ${chalk2.dim(
|
|
1109
1247
|
err instanceof Error ? err.message : String(err)
|
|
1110
1248
|
)}`
|
|
1111
1249
|
)
|
|
@@ -1115,18 +1253,18 @@ Available keys:
|
|
|
1115
1253
|
});
|
|
1116
1254
|
|
|
1117
1255
|
// src/cli/cmd/config/unset.ts
|
|
1118
|
-
import { Command as
|
|
1119
|
-
import
|
|
1256
|
+
import { Command as Command9 } from "interactive-commander";
|
|
1257
|
+
import chalk3 from "chalk";
|
|
1120
1258
|
import dedent2 from "dedent";
|
|
1121
1259
|
import _7 from "lodash";
|
|
1122
|
-
var unset_default = new
|
|
1260
|
+
var unset_default = new Command9().name("unset").description("Remove a configuration key").addHelpText("afterAll", `
|
|
1123
1261
|
Available keys:
|
|
1124
1262
|
${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key to remove").helpOption("-h, --help", "Show help").action(async (key) => {
|
|
1125
1263
|
if (!SETTINGS_KEYS.includes(key)) {
|
|
1126
1264
|
console.error(
|
|
1127
1265
|
dedent2`
|
|
1128
|
-
${
|
|
1129
|
-
Run ${
|
|
1266
|
+
${chalk3.red("\u2716")} Unknown configuration key: ${chalk3.bold(key)}
|
|
1267
|
+
Run ${chalk3.dim("lingo.dev config unset --help")} to see available keys.
|
|
1130
1268
|
`
|
|
1131
1269
|
);
|
|
1132
1270
|
process.exitCode = 1;
|
|
@@ -1135,7 +1273,7 @@ Available keys:
|
|
|
1135
1273
|
const settings = loadSystemSettings();
|
|
1136
1274
|
const currentValue = _7.get(settings, key);
|
|
1137
1275
|
if (!_7.trim(String(currentValue || ""))) {
|
|
1138
|
-
console.log(`${
|
|
1276
|
+
console.log(`${chalk3.cyan("\u2139")} ${chalk3.bold(key)} is not set.`);
|
|
1139
1277
|
return;
|
|
1140
1278
|
} else {
|
|
1141
1279
|
const updated = _7.cloneDeep(settings);
|
|
@@ -1143,12 +1281,12 @@ Available keys:
|
|
|
1143
1281
|
try {
|
|
1144
1282
|
saveSettings(updated);
|
|
1145
1283
|
console.log(
|
|
1146
|
-
`${
|
|
1284
|
+
`${chalk3.green("\u2714")} Removed configuration key ${chalk3.bold(key)}`
|
|
1147
1285
|
);
|
|
1148
1286
|
} catch (err) {
|
|
1149
1287
|
console.error(
|
|
1150
|
-
|
|
1151
|
-
`\u2716 Failed to save configuration: ${
|
|
1288
|
+
chalk3.red(
|
|
1289
|
+
`\u2716 Failed to save configuration: ${chalk3.dim(
|
|
1152
1290
|
err instanceof Error ? err.message : String(err)
|
|
1153
1291
|
)}`
|
|
1154
1292
|
)
|
|
@@ -1159,18 +1297,18 @@ Available keys:
|
|
|
1159
1297
|
});
|
|
1160
1298
|
|
|
1161
1299
|
// src/cli/cmd/config/get.ts
|
|
1162
|
-
import { Command as
|
|
1163
|
-
import
|
|
1300
|
+
import { Command as Command10 } from "interactive-commander";
|
|
1301
|
+
import chalk4 from "chalk";
|
|
1164
1302
|
import _8 from "lodash";
|
|
1165
1303
|
import dedent3 from "dedent";
|
|
1166
|
-
var get_default = new
|
|
1304
|
+
var get_default = new Command10().name("get").description("Get the value of a configuration key").addHelpText("afterAll", `
|
|
1167
1305
|
Available keys:
|
|
1168
1306
|
${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key").helpOption("-h, --help", "Show help").action(async (key) => {
|
|
1169
1307
|
if (!SETTINGS_KEYS.includes(key)) {
|
|
1170
1308
|
console.error(
|
|
1171
1309
|
dedent3`
|
|
1172
|
-
${
|
|
1173
|
-
Run ${
|
|
1310
|
+
${chalk4.red("\u2716")} Unknown configuration key: ${chalk4.bold(key)}
|
|
1311
|
+
Run ${chalk4.dim("lingo.dev config get --help")} to see available keys.
|
|
1174
1312
|
`
|
|
1175
1313
|
);
|
|
1176
1314
|
process.exitCode = 1;
|
|
@@ -1179,7 +1317,7 @@ Available keys:
|
|
|
1179
1317
|
const settings = loadSystemSettings();
|
|
1180
1318
|
const value = _8.get(settings, key);
|
|
1181
1319
|
if (!value) {
|
|
1182
|
-
console.log(`${
|
|
1320
|
+
console.log(`${chalk4.cyan("\u2139")} ${chalk4.bold(key)} is not set.`);
|
|
1183
1321
|
return;
|
|
1184
1322
|
}
|
|
1185
1323
|
if (typeof value === "object") {
|
|
@@ -1190,7 +1328,7 @@ Available keys:
|
|
|
1190
1328
|
});
|
|
1191
1329
|
|
|
1192
1330
|
// src/cli/cmd/config/index.ts
|
|
1193
|
-
var config_default2 = new
|
|
1331
|
+
var config_default2 = new Command11().command("config").description("Manage Lingo.dev CLI configuration").helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
|
|
1194
1332
|
|
|
1195
1333
|
// src/cli/cmd/i18n.ts
|
|
1196
1334
|
import {
|
|
@@ -1198,10 +1336,10 @@ import {
|
|
|
1198
1336
|
localeCodeSchema,
|
|
1199
1337
|
resolveOverriddenLocale as resolveOverriddenLocale3
|
|
1200
1338
|
} from "@lingo.dev/_spec";
|
|
1201
|
-
import { Command as
|
|
1339
|
+
import { Command as Command12 } from "interactive-commander";
|
|
1202
1340
|
import Z3 from "zod";
|
|
1203
1341
|
import _29 from "lodash";
|
|
1204
|
-
import
|
|
1342
|
+
import Ora7 from "ora";
|
|
1205
1343
|
|
|
1206
1344
|
// src/cli/loaders/_utils.ts
|
|
1207
1345
|
function composeLoaders(...loaders) {
|
|
@@ -4180,13 +4318,13 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
4180
4318
|
}
|
|
4181
4319
|
|
|
4182
4320
|
// src/cli/cmd/i18n.ts
|
|
4183
|
-
import
|
|
4321
|
+
import chalk6 from "chalk";
|
|
4184
4322
|
import { createTwoFilesPatch } from "diff";
|
|
4185
4323
|
import inquirer2 from "inquirer";
|
|
4186
4324
|
import externalEditor from "external-editor";
|
|
4187
4325
|
|
|
4188
4326
|
// src/cli/processor/index.ts
|
|
4189
|
-
import
|
|
4327
|
+
import chalk5 from "chalk";
|
|
4190
4328
|
import dedent4 from "dedent";
|
|
4191
4329
|
|
|
4192
4330
|
// src/cli/processor/lingo.ts
|
|
@@ -4320,18 +4458,6 @@ function countWordsInRecord(payload) {
|
|
|
4320
4458
|
|
|
4321
4459
|
// src/cli/processor/index.ts
|
|
4322
4460
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
4323
|
-
|
|
4324
|
-
// src/cli/constants.ts
|
|
4325
|
-
var colors = {
|
|
4326
|
-
orange: "#ff6600",
|
|
4327
|
-
green: "#6ae300",
|
|
4328
|
-
blue: "#0090ff",
|
|
4329
|
-
yellow: "#ffcc00",
|
|
4330
|
-
grey: "#808080",
|
|
4331
|
-
red: "#ff0000"
|
|
4332
|
-
};
|
|
4333
|
-
|
|
4334
|
-
// src/cli/processor/index.ts
|
|
4335
4461
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
4336
4462
|
function createProcessor(provider, params) {
|
|
4337
4463
|
if (!provider) {
|
|
@@ -4345,22 +4471,22 @@ function createProcessor(provider, params) {
|
|
|
4345
4471
|
}
|
|
4346
4472
|
function getPureModelProvider(provider) {
|
|
4347
4473
|
const createMissingKeyErrorMessage = (providerId, envVar) => dedent4`
|
|
4348
|
-
You're trying to use raw ${
|
|
4474
|
+
You're trying to use raw ${chalk5.dim(providerId)} API for translation, however, ${chalk5.dim(envVar)} environment variable is not set.
|
|
4349
4475
|
|
|
4350
4476
|
To fix this issue:
|
|
4351
|
-
1. Set ${
|
|
4352
|
-
2. Remove the ${
|
|
4477
|
+
1. Set ${chalk5.dim(envVar)} in your environment variables, or
|
|
4478
|
+
2. Remove the ${chalk5.italic("provider")} node from your i18n.json configuration to switch to ${chalk5.hex(colors.green)("Lingo.dev")}
|
|
4353
4479
|
|
|
4354
|
-
${
|
|
4480
|
+
${chalk5.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4355
4481
|
`;
|
|
4356
4482
|
const createUnsupportedProviderErrorMessage = (providerId) => dedent4`
|
|
4357
|
-
You're trying to use unsupported provider: ${
|
|
4483
|
+
You're trying to use unsupported provider: ${chalk5.dim(providerId)}.
|
|
4358
4484
|
|
|
4359
4485
|
To fix this issue:
|
|
4360
4486
|
1. Switch to one of the supported providers, or
|
|
4361
|
-
2. Remove the ${
|
|
4487
|
+
2. Remove the ${chalk5.italic("provider")} node from your i18n.json configuration to switch to ${chalk5.hex(colors.green)("Lingo.dev")}
|
|
4362
4488
|
|
|
4363
|
-
${
|
|
4489
|
+
${chalk5.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
4364
4490
|
`;
|
|
4365
4491
|
switch (provider?.id) {
|
|
4366
4492
|
case "openai":
|
|
@@ -4548,7 +4674,7 @@ function createDeltaProcessor(fileKey) {
|
|
|
4548
4674
|
}
|
|
4549
4675
|
|
|
4550
4676
|
// src/cli/cmd/i18n.ts
|
|
4551
|
-
var i18n_default = new
|
|
4677
|
+
var i18n_default = new Command12().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
|
|
4552
4678
|
"--locale <locale>",
|
|
4553
4679
|
"Locale to process",
|
|
4554
4680
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
@@ -4585,7 +4711,7 @@ var i18n_default = new Command10().command("i18n").description("Run Localization
|
|
|
4585
4711
|
"Stop processing on first error instead of continuing with other locales/buckets"
|
|
4586
4712
|
).action(async function(options) {
|
|
4587
4713
|
updateGitignore();
|
|
4588
|
-
const ora =
|
|
4714
|
+
const ora = Ora7();
|
|
4589
4715
|
const flags = parseFlags(options);
|
|
4590
4716
|
if (flags.debug) {
|
|
4591
4717
|
const { debug } = await inquirer2.prompt([
|
|
@@ -4775,7 +4901,7 @@ var i18n_default = new Command10().command("i18n").description("Run Localization
|
|
|
4775
4901
|
console.log();
|
|
4776
4902
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
4777
4903
|
for (const bucketPath of bucket.paths) {
|
|
4778
|
-
const bucketOra =
|
|
4904
|
+
const bucketOra = Ora7({ indent: 2 }).info(
|
|
4779
4905
|
`Processing path: ${bucketPath.pathPattern}`
|
|
4780
4906
|
);
|
|
4781
4907
|
const sourceLocale = resolveOverriddenLocale3(
|
|
@@ -5013,7 +5139,7 @@ async function reviewChanges(args) {
|
|
|
5013
5139
|
if (currentStr === proposedStr && !args.force) {
|
|
5014
5140
|
console.log(
|
|
5015
5141
|
`
|
|
5016
|
-
${
|
|
5142
|
+
${chalk6.blue(args.pathPattern)} (${chalk6.yellow(args.targetLocale)}): ${chalk6.gray("No changes to review")}`
|
|
5017
5143
|
);
|
|
5018
5144
|
return args.proposedData;
|
|
5019
5145
|
}
|
|
@@ -5027,14 +5153,14 @@ ${chalk5.blue(args.pathPattern)} (${chalk5.yellow(args.targetLocale)}): ${chalk5
|
|
|
5027
5153
|
{ context: 3 }
|
|
5028
5154
|
);
|
|
5029
5155
|
const coloredDiff = patch.split("\n").map((line) => {
|
|
5030
|
-
if (line.startsWith("+")) return
|
|
5031
|
-
if (line.startsWith("-")) return
|
|
5032
|
-
if (line.startsWith("@")) return
|
|
5156
|
+
if (line.startsWith("+")) return chalk6.green(line);
|
|
5157
|
+
if (line.startsWith("-")) return chalk6.red(line);
|
|
5158
|
+
if (line.startsWith("@")) return chalk6.cyan(line);
|
|
5033
5159
|
return line;
|
|
5034
5160
|
}).join("\n");
|
|
5035
5161
|
console.log(
|
|
5036
5162
|
`
|
|
5037
|
-
Reviewing changes for ${
|
|
5163
|
+
Reviewing changes for ${chalk6.blue(args.pathPattern)} (${chalk6.yellow(args.targetLocale)}):`
|
|
5038
5164
|
);
|
|
5039
5165
|
console.log(coloredDiff);
|
|
5040
5166
|
const { action } = await inquirer2.prompt([
|
|
@@ -5069,32 +5195,32 @@ Reviewing changes for ${chalk5.blue(args.pathPattern)} (${chalk5.yellow(args.tar
|
|
|
5069
5195
|
);
|
|
5070
5196
|
for (const key of changes) {
|
|
5071
5197
|
console.log(`
|
|
5072
|
-
Editing value for: ${
|
|
5073
|
-
console.log(
|
|
5198
|
+
Editing value for: ${chalk6.cyan(key)}`);
|
|
5199
|
+
console.log(chalk6.gray("Source text:"), chalk6.blue(args.sourceData[key]));
|
|
5074
5200
|
console.log(
|
|
5075
|
-
|
|
5076
|
-
|
|
5201
|
+
chalk6.gray("Current value:"),
|
|
5202
|
+
chalk6.red(args.currentData[key] || "(empty)")
|
|
5077
5203
|
);
|
|
5078
5204
|
console.log(
|
|
5079
|
-
|
|
5080
|
-
|
|
5205
|
+
chalk6.gray("Suggested value:"),
|
|
5206
|
+
chalk6.green(args.proposedData[key])
|
|
5081
5207
|
);
|
|
5082
5208
|
console.log(
|
|
5083
|
-
|
|
5209
|
+
chalk6.gray(
|
|
5084
5210
|
"\nYour editor will open. Edit the text and save to continue."
|
|
5085
5211
|
)
|
|
5086
5212
|
);
|
|
5087
|
-
console.log(
|
|
5213
|
+
console.log(chalk6.gray("------------"));
|
|
5088
5214
|
try {
|
|
5089
5215
|
const editorContent = [
|
|
5090
5216
|
"# Edit the translation below.",
|
|
5091
5217
|
"# Lines starting with # will be ignored.",
|
|
5092
5218
|
"# Save and exit the editor to continue.",
|
|
5093
5219
|
"#",
|
|
5094
|
-
`# Source text (${
|
|
5220
|
+
`# Source text (${chalk6.blue("English")}):`,
|
|
5095
5221
|
`# ${args.sourceData[key]}`,
|
|
5096
5222
|
"#",
|
|
5097
|
-
`# Current value (${
|
|
5223
|
+
`# Current value (${chalk6.red(args.targetLocale)}):`,
|
|
5098
5224
|
`# ${args.currentData[key] || "(empty)"}`,
|
|
5099
5225
|
"#",
|
|
5100
5226
|
args.proposedData[key]
|
|
@@ -5105,13 +5231,13 @@ Editing value for: ${chalk5.cyan(key)}`);
|
|
|
5105
5231
|
customData[key] = customValue;
|
|
5106
5232
|
} else {
|
|
5107
5233
|
console.log(
|
|
5108
|
-
|
|
5234
|
+
chalk6.yellow("Empty value provided, keeping the current value.")
|
|
5109
5235
|
);
|
|
5110
5236
|
customData[key] = args.currentData[key] || args.proposedData[key];
|
|
5111
5237
|
}
|
|
5112
5238
|
} catch (error) {
|
|
5113
5239
|
console.log(
|
|
5114
|
-
|
|
5240
|
+
chalk6.red("Error while editing, keeping the suggested value.")
|
|
5115
5241
|
);
|
|
5116
5242
|
customData[key] = args.proposedData[key];
|
|
5117
5243
|
}
|
|
@@ -5120,9 +5246,9 @@ Editing value for: ${chalk5.cyan(key)}`);
|
|
|
5120
5246
|
}
|
|
5121
5247
|
|
|
5122
5248
|
// src/cli/cmd/lockfile.ts
|
|
5123
|
-
import { Command as
|
|
5249
|
+
import { Command as Command13 } from "interactive-commander";
|
|
5124
5250
|
import Z5 from "zod";
|
|
5125
|
-
import
|
|
5251
|
+
import Ora8 from "ora";
|
|
5126
5252
|
|
|
5127
5253
|
// src/cli/utils/lockfile.ts
|
|
5128
5254
|
import fs11 from "fs";
|
|
@@ -5195,9 +5321,9 @@ var LockfileSchema = Z4.object({
|
|
|
5195
5321
|
|
|
5196
5322
|
// src/cli/cmd/lockfile.ts
|
|
5197
5323
|
import { resolveOverriddenLocale as resolveOverriddenLocale4 } from "@lingo.dev/_spec";
|
|
5198
|
-
var lockfile_default = new
|
|
5324
|
+
var lockfile_default = new Command13().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) => {
|
|
5199
5325
|
const flags = flagsSchema.parse(options);
|
|
5200
|
-
const ora =
|
|
5326
|
+
const ora = Ora8();
|
|
5201
5327
|
const lockfileHelper = createLockfileHelper();
|
|
5202
5328
|
if (lockfileHelper.isLockfileExists() && !flags.force) {
|
|
5203
5329
|
ora.warn(`Lockfile won't be created because it already exists. Use --force to overwrite.`);
|
|
@@ -5225,14 +5351,14 @@ var flagsSchema = Z5.object({
|
|
|
5225
5351
|
|
|
5226
5352
|
// src/cli/cmd/cleanup.ts
|
|
5227
5353
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
5228
|
-
import { Command as
|
|
5354
|
+
import { Command as Command14 } from "interactive-commander";
|
|
5229
5355
|
import _31 from "lodash";
|
|
5230
|
-
import
|
|
5231
|
-
var cleanup_default = new
|
|
5356
|
+
import Ora9 from "ora";
|
|
5357
|
+
var cleanup_default = new Command14().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(
|
|
5232
5358
|
"--verbose",
|
|
5233
5359
|
"Show detailed output including:\n - List of keys that would be removed.\n - Processing steps."
|
|
5234
5360
|
).action(async function(options) {
|
|
5235
|
-
const ora =
|
|
5361
|
+
const ora = Ora9();
|
|
5236
5362
|
const results = [];
|
|
5237
5363
|
try {
|
|
5238
5364
|
ora.start("Loading configuration...");
|
|
@@ -5249,7 +5375,7 @@ var cleanup_default = new Command12().command("cleanup").description("Remove key
|
|
|
5249
5375
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
5250
5376
|
for (const bucketConfig of bucket.paths) {
|
|
5251
5377
|
const sourceLocale = resolveOverriddenLocale5(i18nConfig.locale.source, bucketConfig.delimiter);
|
|
5252
|
-
const bucketOra =
|
|
5378
|
+
const bucketOra = Ora9({ indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
5253
5379
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
5254
5380
|
isCacheRestore: false,
|
|
5255
5381
|
defaultLocale: sourceLocale
|
|
@@ -5321,12 +5447,12 @@ function displaySummary(results) {
|
|
|
5321
5447
|
}
|
|
5322
5448
|
|
|
5323
5449
|
// src/cli/cmd/mcp.ts
|
|
5324
|
-
import { Command as
|
|
5450
|
+
import { Command as Command15 } from "interactive-commander";
|
|
5325
5451
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5326
5452
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5327
5453
|
import Z6 from "zod";
|
|
5328
5454
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
5329
|
-
var mcp_default = new
|
|
5455
|
+
var mcp_default = new Command15().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_33, program) => {
|
|
5330
5456
|
const apiKey = program.args[0];
|
|
5331
5457
|
const settings = getSettings(apiKey);
|
|
5332
5458
|
if (!settings.auth.apiKey) {
|
|
@@ -5374,7 +5500,7 @@ var mcp_default = new Command13().command("mcp").description("Use Lingo.dev mode
|
|
|
5374
5500
|
});
|
|
5375
5501
|
|
|
5376
5502
|
// src/cli/cmd/ci/index.ts
|
|
5377
|
-
import { Command as
|
|
5503
|
+
import { Command as Command17 } from "interactive-commander";
|
|
5378
5504
|
import createOra from "ora";
|
|
5379
5505
|
|
|
5380
5506
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
@@ -5401,39 +5527,39 @@ function escapeShellArg(arg) {
|
|
|
5401
5527
|
}
|
|
5402
5528
|
|
|
5403
5529
|
// src/cli/cmd/run/index.ts
|
|
5404
|
-
import { Command as
|
|
5530
|
+
import { Command as Command16 } from "interactive-commander";
|
|
5405
5531
|
|
|
5406
5532
|
// src/cli/cmd/run/setup.ts
|
|
5407
|
-
import
|
|
5533
|
+
import chalk10 from "chalk";
|
|
5408
5534
|
import { Listr } from "listr2";
|
|
5409
5535
|
|
|
5410
5536
|
// src/cli/cmd/run/_const.ts
|
|
5411
|
-
import
|
|
5537
|
+
import chalk7 from "chalk";
|
|
5412
5538
|
import { ListrDefaultRendererLogLevels } from "listr2";
|
|
5413
5539
|
var commonTaskRendererOptions = {
|
|
5414
5540
|
color: {
|
|
5415
|
-
[ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ?
|
|
5541
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: (msg) => msg ? chalk7.hex(colors.green)(msg) : chalk7.hex(colors.green)("")
|
|
5416
5542
|
},
|
|
5417
5543
|
icon: {
|
|
5418
|
-
[ListrDefaultRendererLogLevels.COMPLETED]:
|
|
5544
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: chalk7.hex(colors.green)("\u2713")
|
|
5419
5545
|
}
|
|
5420
5546
|
};
|
|
5421
5547
|
|
|
5422
5548
|
// src/cli/localizer/lingodotdev.ts
|
|
5423
5549
|
import dedent5 from "dedent";
|
|
5424
|
-
import
|
|
5550
|
+
import chalk8 from "chalk";
|
|
5425
5551
|
import { LingoDotDevEngine as LingoDotDevEngine2 } from "@lingo.dev/_sdk";
|
|
5426
5552
|
function createLingoDotDevLocalizer(explicitApiKey) {
|
|
5427
5553
|
const { auth } = getSettings(explicitApiKey);
|
|
5428
5554
|
if (!auth) {
|
|
5429
5555
|
throw new Error(
|
|
5430
5556
|
dedent5`
|
|
5431
|
-
You're trying to use ${
|
|
5557
|
+
You're trying to use ${chalk8.hex(colors.green)("Lingo.dev")} provider, however, you are not authenticated.
|
|
5432
5558
|
|
|
5433
5559
|
To fix this issue:
|
|
5434
|
-
1. Run ${
|
|
5435
|
-
2. Use the ${
|
|
5436
|
-
3. Set ${
|
|
5560
|
+
1. Run ${chalk8.dim("lingo.dev login")} to authenticate, or
|
|
5561
|
+
2. Use the ${chalk8.dim("--api-key")} flag to provide an API key.
|
|
5562
|
+
3. Set ${chalk8.dim("LINGODOTDEV_API_KEY")} environment variable.
|
|
5437
5563
|
`
|
|
5438
5564
|
);
|
|
5439
5565
|
}
|
|
@@ -5478,7 +5604,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
5478
5604
|
// src/cli/localizer/explicit.ts
|
|
5479
5605
|
import { createAnthropic as createAnthropic2 } from "@ai-sdk/anthropic";
|
|
5480
5606
|
import { createOpenAI as createOpenAI2 } from "@ai-sdk/openai";
|
|
5481
|
-
import
|
|
5607
|
+
import chalk9 from "chalk";
|
|
5482
5608
|
import dedent6 from "dedent";
|
|
5483
5609
|
import { generateText as generateText2 } from "ai";
|
|
5484
5610
|
import { jsonrepair as jsonrepair3 } from "jsonrepair";
|
|
@@ -5487,13 +5613,13 @@ function createExplicitLocalizer(provider) {
|
|
|
5487
5613
|
default:
|
|
5488
5614
|
throw new Error(
|
|
5489
5615
|
dedent6`
|
|
5490
|
-
You're trying to use unsupported provider: ${
|
|
5616
|
+
You're trying to use unsupported provider: ${chalk9.dim(provider.id)}.
|
|
5491
5617
|
|
|
5492
5618
|
To fix this issue:
|
|
5493
5619
|
1. Switch to one of the supported providers, or
|
|
5494
|
-
2. Remove the ${
|
|
5620
|
+
2. Remove the ${chalk9.italic("provider")} node from your i18n.json configuration to switch to ${chalk9.hex(colors.green)("Lingo.dev")}
|
|
5495
5621
|
|
|
5496
|
-
${
|
|
5622
|
+
${chalk9.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
5497
5623
|
`
|
|
5498
5624
|
);
|
|
5499
5625
|
case "openai":
|
|
@@ -5519,13 +5645,13 @@ function createAiSdkLocalizer(params) {
|
|
|
5519
5645
|
if (!apiKey) {
|
|
5520
5646
|
throw new Error(
|
|
5521
5647
|
dedent6`
|
|
5522
|
-
You're trying to use raw ${
|
|
5648
|
+
You're trying to use raw ${chalk9.dim(params.id)} API for translation, however, ${chalk9.dim(params.apiKeyName)} environment variable is not set.
|
|
5523
5649
|
|
|
5524
5650
|
To fix this issue:
|
|
5525
|
-
1. Set ${
|
|
5526
|
-
2. Remove the ${
|
|
5651
|
+
1. Set ${chalk9.dim(params.apiKeyName)} in your environment variables, or
|
|
5652
|
+
2. Remove the ${chalk9.italic("provider")} node from your i18n.json configuration to switch to ${chalk9.hex(colors.green)("Lingo.dev")}
|
|
5527
5653
|
|
|
5528
|
-
${
|
|
5654
|
+
${chalk9.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
5529
5655
|
`
|
|
5530
5656
|
);
|
|
5531
5657
|
}
|
|
@@ -5612,7 +5738,7 @@ function createLocalizer(provider, apiKey) {
|
|
|
5612
5738
|
|
|
5613
5739
|
// src/cli/cmd/run/setup.ts
|
|
5614
5740
|
async function setup(input2) {
|
|
5615
|
-
console.log(
|
|
5741
|
+
console.log(chalk10.hex(colors.orange)("[Setup]"));
|
|
5616
5742
|
return new Listr(
|
|
5617
5743
|
[
|
|
5618
5744
|
{
|
|
@@ -5655,7 +5781,7 @@ async function setup(input2) {
|
|
|
5655
5781
|
"Could not create localization provider. Please check your i18n.json configuration."
|
|
5656
5782
|
);
|
|
5657
5783
|
}
|
|
5658
|
-
task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${
|
|
5784
|
+
task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${chalk10.hex(colors.green)(ctx.localizer.id)} provider` : `Using raw ${chalk10.hex(colors.yellow)(ctx.localizer.id)} API`;
|
|
5659
5785
|
}
|
|
5660
5786
|
},
|
|
5661
5787
|
{
|
|
@@ -5664,10 +5790,10 @@ async function setup(input2) {
|
|
|
5664
5790
|
const authStatus = await ctx.localizer.checkAuth();
|
|
5665
5791
|
if (!authStatus.authenticated) {
|
|
5666
5792
|
throw new Error(
|
|
5667
|
-
`Failed to authenticate with ${
|
|
5793
|
+
`Failed to authenticate with ${chalk10.hex(colors.yellow)(ctx.localizer.id)} provider. Please check your API key and try again.`
|
|
5668
5794
|
);
|
|
5669
5795
|
}
|
|
5670
|
-
task.title = `Authenticated as ${
|
|
5796
|
+
task.title = `Authenticated as ${chalk10.hex(colors.yellow)(authStatus.username)}`;
|
|
5671
5797
|
}
|
|
5672
5798
|
},
|
|
5673
5799
|
{
|
|
@@ -5701,11 +5827,11 @@ async function setup(input2) {
|
|
|
5701
5827
|
}
|
|
5702
5828
|
|
|
5703
5829
|
// src/cli/cmd/run/plan.ts
|
|
5704
|
-
import
|
|
5830
|
+
import chalk11 from "chalk";
|
|
5705
5831
|
import { Listr as Listr2 } from "listr2";
|
|
5706
5832
|
import { resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
|
|
5707
5833
|
async function plan(input2) {
|
|
5708
|
-
console.log(
|
|
5834
|
+
console.log(chalk11.hex(colors.orange)("[Planning]"));
|
|
5709
5835
|
let buckets = getBuckets(input2.config);
|
|
5710
5836
|
if (input2.flags.bucket) {
|
|
5711
5837
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
@@ -5728,14 +5854,14 @@ async function plan(input2) {
|
|
|
5728
5854
|
title: "Locating content buckets",
|
|
5729
5855
|
task: async (ctx, task) => {
|
|
5730
5856
|
const bucketCount = buckets.length;
|
|
5731
|
-
const bucketFilter = input2.flags.bucket ? ` ${
|
|
5732
|
-
task.title = `Found ${
|
|
5857
|
+
const bucketFilter = input2.flags.bucket ? ` ${chalk11.dim(`(filtered by: ${chalk11.hex(colors.yellow)(input2.flags.bucket.join(", "))})`)}` : "";
|
|
5858
|
+
task.title = `Found ${chalk11.hex(colors.yellow)(bucketCount.toString())} bucket(s)${bucketFilter}`;
|
|
5733
5859
|
}
|
|
5734
5860
|
},
|
|
5735
5861
|
{
|
|
5736
5862
|
title: "Detecting locales",
|
|
5737
5863
|
task: async (ctx, task) => {
|
|
5738
|
-
task.title = `Found ${
|
|
5864
|
+
task.title = `Found ${chalk11.hex(colors.yellow)(_targetLocales.length.toString())} target locale(s)`;
|
|
5739
5865
|
}
|
|
5740
5866
|
},
|
|
5741
5867
|
{
|
|
@@ -5754,8 +5880,8 @@ async function plan(input2) {
|
|
|
5754
5880
|
patterns.push(bucketPath.pathPattern);
|
|
5755
5881
|
}
|
|
5756
5882
|
}
|
|
5757
|
-
const fileFilter = input2.flags.file ? ` ${
|
|
5758
|
-
task.title = `Found ${
|
|
5883
|
+
const fileFilter = input2.flags.file ? ` ${chalk11.dim(`(filtered by: ${chalk11.hex(colors.yellow)(input2.flags.file.join(", "))})`)}` : "";
|
|
5884
|
+
task.title = `Found ${chalk11.hex(colors.yellow)(patterns.length.toString())} path pattern(s)${fileFilter}`;
|
|
5759
5885
|
}
|
|
5760
5886
|
},
|
|
5761
5887
|
{
|
|
@@ -5792,7 +5918,7 @@ async function plan(input2) {
|
|
|
5792
5918
|
}
|
|
5793
5919
|
}
|
|
5794
5920
|
}
|
|
5795
|
-
task.title = `Prepared ${
|
|
5921
|
+
task.title = `Prepared ${chalk11.hex(colors.green)(ctx.tasks.length.toString())} translation task(s)`;
|
|
5796
5922
|
}
|
|
5797
5923
|
}
|
|
5798
5924
|
],
|
|
@@ -5803,7 +5929,7 @@ async function plan(input2) {
|
|
|
5803
5929
|
}
|
|
5804
5930
|
|
|
5805
5931
|
// src/cli/cmd/run/execute.ts
|
|
5806
|
-
import
|
|
5932
|
+
import chalk12 from "chalk";
|
|
5807
5933
|
import { Listr as Listr3 } from "listr2";
|
|
5808
5934
|
import pLimit from "p-limit";
|
|
5809
5935
|
import _32 from "lodash";
|
|
@@ -5814,17 +5940,17 @@ async function execute(input2) {
|
|
|
5814
5940
|
input2.tasks.length,
|
|
5815
5941
|
MAX_WORKER_COUNT
|
|
5816
5942
|
);
|
|
5817
|
-
console.log(
|
|
5943
|
+
console.log(chalk12.hex(colors.orange)(`[Localization]`));
|
|
5818
5944
|
return new Listr3(
|
|
5819
5945
|
[
|
|
5820
5946
|
{
|
|
5821
5947
|
title: "Initializing localization engine",
|
|
5822
5948
|
task: async (ctx, task) => {
|
|
5823
|
-
task.title = `Localization engine ${
|
|
5949
|
+
task.title = `Localization engine ${chalk12.hex(colors.green)("ready")} (${ctx.localizer.id})`;
|
|
5824
5950
|
}
|
|
5825
5951
|
},
|
|
5826
5952
|
{
|
|
5827
|
-
title: `Processing localization tasks ${
|
|
5953
|
+
title: `Processing localization tasks ${chalk12.dim(`(tasks: ${input2.tasks.length}, concurrency: ${effectiveConcurrency})`)}`,
|
|
5828
5954
|
task: (ctx, task) => {
|
|
5829
5955
|
if (input2.tasks.length < 1) {
|
|
5830
5956
|
task.title = `Skipping, nothing to localize.`;
|
|
@@ -5873,9 +5999,9 @@ function createWorkerStatusMessage(args) {
|
|
|
5873
5999
|
"[locale]",
|
|
5874
6000
|
args.assignedTask.targetLocale
|
|
5875
6001
|
);
|
|
5876
|
-
return `[${
|
|
6002
|
+
return `[${chalk12.hex(colors.yellow)(`${args.percentage}%`)}] Processing: ${chalk12.dim(
|
|
5877
6003
|
displayPath
|
|
5878
|
-
)} (${
|
|
6004
|
+
)} (${chalk12.hex(colors.yellow)(args.assignedTask.sourceLocale)} -> ${chalk12.hex(
|
|
5879
6005
|
colors.yellow
|
|
5880
6006
|
)(args.assignedTask.targetLocale)})`;
|
|
5881
6007
|
}
|
|
@@ -5892,7 +6018,7 @@ function createExecutionProgressMessage(ctx) {
|
|
|
5892
6018
|
ctx,
|
|
5893
6019
|
(_t, result) => result.status === "skipped"
|
|
5894
6020
|
);
|
|
5895
|
-
return `Processed ${
|
|
6021
|
+
return `Processed ${chalk12.green(succeededTasksCount)}/${ctx.tasks.length}, Failed ${chalk12.red(failedTasksCount)}, Skipped ${chalk12.dim(skippedTasksCount)}`;
|
|
5896
6022
|
}
|
|
5897
6023
|
function createLoaderForTask(assignedTask) {
|
|
5898
6024
|
const bucketLoader = createBucketLoader(
|
|
@@ -6022,84 +6148,9 @@ var flagsSchema2 = z2.object({
|
|
|
6022
6148
|
targetLocale: z2.array(z2.string()).optional()
|
|
6023
6149
|
});
|
|
6024
6150
|
|
|
6025
|
-
// src/cli/cmd/run/_render.ts
|
|
6026
|
-
import chalk12 from "chalk";
|
|
6027
|
-
import figlet from "figlet";
|
|
6028
|
-
import { vice } from "gradient-string";
|
|
6029
|
-
import readline2 from "readline";
|
|
6030
|
-
async function renderClear() {
|
|
6031
|
-
console.log("\x1Bc");
|
|
6032
|
-
}
|
|
6033
|
-
async function renderSpacer() {
|
|
6034
|
-
console.log(" ");
|
|
6035
|
-
}
|
|
6036
|
-
async function renderBanner() {
|
|
6037
|
-
console.log(
|
|
6038
|
-
vice(
|
|
6039
|
-
figlet.textSync("LINGO.DEV", {
|
|
6040
|
-
font: "ANSI Shadow",
|
|
6041
|
-
horizontalLayout: "default",
|
|
6042
|
-
verticalLayout: "default"
|
|
6043
|
-
})
|
|
6044
|
-
)
|
|
6045
|
-
);
|
|
6046
|
-
}
|
|
6047
|
-
async function renderHero() {
|
|
6048
|
-
console.log(
|
|
6049
|
-
`\u26A1\uFE0F ${chalk12.hex(colors.green)("Lingo.dev")} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
6050
|
-
);
|
|
6051
|
-
console.log("");
|
|
6052
|
-
const label1 = "\u2B50 GitHub Repo:";
|
|
6053
|
-
const label2 = "\u{1F4DA} Docs:";
|
|
6054
|
-
const label3 = "\u{1F4AC} 24/7 Support:";
|
|
6055
|
-
const maxLabelWidth = 17;
|
|
6056
|
-
console.log(
|
|
6057
|
-
`${chalk12.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${chalk12.hex(colors.blue)("https://lingo.dev/go/gh")}`
|
|
6058
|
-
);
|
|
6059
|
-
console.log(
|
|
6060
|
-
`${chalk12.hex(colors.blue)(label2.padEnd(maxLabelWidth + 1))} ${chalk12.hex(colors.blue)("https://lingo.dev/go/docs")}`
|
|
6061
|
-
);
|
|
6062
|
-
console.log(
|
|
6063
|
-
`${chalk12.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${chalk12.hex(colors.blue)("hi@lingo.dev")}`
|
|
6064
|
-
);
|
|
6065
|
-
}
|
|
6066
|
-
async function pauseIfDebug(debug) {
|
|
6067
|
-
if (debug) {
|
|
6068
|
-
await waitForUserPrompt("Press Enter to continue...");
|
|
6069
|
-
}
|
|
6070
|
-
}
|
|
6071
|
-
async function waitForUserPrompt(message) {
|
|
6072
|
-
const rl = readline2.createInterface({
|
|
6073
|
-
input: process.stdin,
|
|
6074
|
-
output: process.stdout
|
|
6075
|
-
});
|
|
6076
|
-
return new Promise((resolve) => {
|
|
6077
|
-
rl.question(chalk12.dim(`[${message}]
|
|
6078
|
-
`), () => {
|
|
6079
|
-
rl.close();
|
|
6080
|
-
resolve();
|
|
6081
|
-
});
|
|
6082
|
-
});
|
|
6083
|
-
}
|
|
6084
|
-
async function renderSummary(ctx) {
|
|
6085
|
-
console.log(chalk12.hex(colors.green)("[Done]"));
|
|
6086
|
-
const skippedTasksCount = Array.from(ctx.results.values()).filter(
|
|
6087
|
-
(r) => r.status === "skipped"
|
|
6088
|
-
).length;
|
|
6089
|
-
console.log(`\u2022 ${chalk12.hex(colors.yellow)(skippedTasksCount)} from cache`);
|
|
6090
|
-
const succeededTasksCount = Array.from(ctx.results.values()).filter(
|
|
6091
|
-
(r) => r.status === "success"
|
|
6092
|
-
).length;
|
|
6093
|
-
console.log(`\u2022 ${chalk12.hex(colors.yellow)(succeededTasksCount)} processed`);
|
|
6094
|
-
const failedTasksCount = Array.from(ctx.results.values()).filter(
|
|
6095
|
-
(r) => r.status === "error"
|
|
6096
|
-
).length;
|
|
6097
|
-
console.log(`\u2022 ${chalk12.hex(colors.yellow)(failedTasksCount)} failed`);
|
|
6098
|
-
}
|
|
6099
|
-
|
|
6100
6151
|
// src/cli/cmd/run/index.ts
|
|
6101
6152
|
import chalk13 from "chalk";
|
|
6102
|
-
var run_default = new
|
|
6153
|
+
var run_default = new Command16().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
|
|
6103
6154
|
"--source-locale <source-locale>",
|
|
6104
6155
|
"Locale to use as source locale. Defaults to i18n.json locale.source",
|
|
6105
6156
|
(val, prev) => {
|
|
@@ -6175,7 +6226,7 @@ var run_default = new Command14().command("run").description("Run Lingo.dev loca
|
|
|
6175
6226
|
await renderSpacer();
|
|
6176
6227
|
await execute(ctx);
|
|
6177
6228
|
await renderSpacer();
|
|
6178
|
-
await renderSummary(ctx);
|
|
6229
|
+
await renderSummary(ctx.results);
|
|
6179
6230
|
await renderSpacer();
|
|
6180
6231
|
} catch (error) {
|
|
6181
6232
|
process.exit(1);
|
|
@@ -6828,7 +6879,7 @@ var getPlatformKit = () => {
|
|
|
6828
6879
|
};
|
|
6829
6880
|
|
|
6830
6881
|
// src/cli/cmd/ci/index.ts
|
|
6831
|
-
var ci_default = new
|
|
6882
|
+
var ci_default = new Command17().command("ci").description("Run Lingo.dev CI/CD action").helpOption("-h, --help", "Show help").option("--parallel [boolean]", "Run in parallel mode", parseBooleanArg).option("--api-key <key>", "API key").option(
|
|
6832
6883
|
"--pull-request [boolean]",
|
|
6833
6884
|
"Create a pull request with the changes",
|
|
6834
6885
|
parseBooleanArg
|
|
@@ -6896,16 +6947,16 @@ function parseBooleanArg(val) {
|
|
|
6896
6947
|
|
|
6897
6948
|
// src/cli/cmd/status.ts
|
|
6898
6949
|
import { bucketTypeSchema as bucketTypeSchema4, localeCodeSchema as localeCodeSchema3, resolveOverriddenLocale as resolveOverriddenLocale7 } from "@lingo.dev/_spec";
|
|
6899
|
-
import { Command as
|
|
6950
|
+
import { Command as Command18 } from "interactive-commander";
|
|
6900
6951
|
import Z11 from "zod";
|
|
6901
|
-
import
|
|
6952
|
+
import Ora10 from "ora";
|
|
6902
6953
|
import chalk14 from "chalk";
|
|
6903
6954
|
import Table from "cli-table3";
|
|
6904
|
-
var status_default = new
|
|
6955
|
+
var status_default = new Command18().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(
|
|
6905
6956
|
"--file [files...]",
|
|
6906
6957
|
"File to process. Process only a specific path, may contain asterisk * to match multiple files."
|
|
6907
6958
|
).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) {
|
|
6908
|
-
const ora =
|
|
6959
|
+
const ora = Ora10();
|
|
6909
6960
|
const flags = parseFlags2(options);
|
|
6910
6961
|
let authId = null;
|
|
6911
6962
|
try {
|
|
@@ -6978,7 +7029,7 @@ var status_default = new Command16().command("status").description("Show the sta
|
|
|
6978
7029
|
console.log();
|
|
6979
7030
|
ora.info(`Analyzing bucket: ${bucket.type}`);
|
|
6980
7031
|
for (const bucketPath of bucket.paths) {
|
|
6981
|
-
const bucketOra =
|
|
7032
|
+
const bucketOra = Ora10({ indent: 2 }).info(`Analyzing path: ${bucketPath.pathPattern}`);
|
|
6982
7033
|
const sourceLocale = resolveOverriddenLocale7(i18nConfig.locale.source, bucketPath.delimiter);
|
|
6983
7034
|
const bucketLoader = createBucketLoader(
|
|
6984
7035
|
bucket.type,
|
|
@@ -7312,7 +7363,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
7312
7363
|
}
|
|
7313
7364
|
|
|
7314
7365
|
// src/cli/cmd/may-the-fourth.ts
|
|
7315
|
-
import { Command as
|
|
7366
|
+
import { Command as Command19 } from "interactive-commander";
|
|
7316
7367
|
import * as cp from "node:child_process";
|
|
7317
7368
|
import figlet2 from "figlet";
|
|
7318
7369
|
import chalk15 from "chalk";
|
|
@@ -7325,7 +7376,7 @@ var colors2 = {
|
|
|
7325
7376
|
grey: "#808080",
|
|
7326
7377
|
red: "#ff0000"
|
|
7327
7378
|
};
|
|
7328
|
-
var may_the_fourth_default = new
|
|
7379
|
+
var may_the_fourth_default = new Command19().command("may-the-fourth").description("May the Fourth be with you").helpOption("-h, --help", "Show help").action(async () => {
|
|
7329
7380
|
await renderClear2();
|
|
7330
7381
|
await renderBanner2();
|
|
7331
7382
|
await renderSpacer2();
|
|
@@ -7386,7 +7437,7 @@ async function renderHero2() {
|
|
|
7386
7437
|
// package.json
|
|
7387
7438
|
var package_default = {
|
|
7388
7439
|
name: "lingo.dev",
|
|
7389
|
-
version: "0.
|
|
7440
|
+
version: "0.94.1",
|
|
7390
7441
|
description: "Lingo.dev CLI",
|
|
7391
7442
|
private: false,
|
|
7392
7443
|
publishConfig: {
|
|
@@ -7628,7 +7679,7 @@ ${vice3(
|
|
|
7628
7679
|
|
|
7629
7680
|
Star the the repo :) https://github.com/LingoDotDev/lingo.dev
|
|
7630
7681
|
`
|
|
7631
|
-
).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) => {
|
|
7682
|
+
).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(login_default).addCommand(logout_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) => {
|
|
7632
7683
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
|
|
7633
7684
|
process.exit(0);
|
|
7634
7685
|
}
|