lingo.dev 0.101.0 → 0.102.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 +150 -5
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +191 -46
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -2
package/build/cli.cjs
CHANGED
|
@@ -4542,9 +4542,7 @@ function reorderKeys(data, originalInput) {
|
|
|
4542
4542
|
const dataKeys = new Set(Object.keys(data));
|
|
4543
4543
|
for (const key of originalKeys) {
|
|
4544
4544
|
if (dataKeys.has(key)) {
|
|
4545
|
-
|
|
4546
|
-
orderedData[key] = reorderKeys(data[key], originalInput[key]);
|
|
4547
|
-
}
|
|
4545
|
+
orderedData[key] = reorderKeys(data[key], originalInput[key]);
|
|
4548
4546
|
dataKeys.delete(key);
|
|
4549
4547
|
}
|
|
4550
4548
|
}
|
|
@@ -8260,6 +8258,9 @@ function createWorkerTask(args) {
|
|
|
8260
8258
|
)])
|
|
8261
8259
|
).fromPairs().value();
|
|
8262
8260
|
if (!Object.keys(processableData).length) {
|
|
8261
|
+
await args.ioLimiter(async () => {
|
|
8262
|
+
await bucketLoader.push(assignedTask.targetLocale, targetData);
|
|
8263
|
+
});
|
|
8263
8264
|
return { status: "skipped" };
|
|
8264
8265
|
}
|
|
8265
8266
|
const processedTargetData = await args.ctx.localizer.localize(
|
|
@@ -8344,6 +8345,135 @@ function processRenamedKeys(delta, targetData) {
|
|
|
8344
8345
|
}).fromPairs().value();
|
|
8345
8346
|
}
|
|
8346
8347
|
|
|
8348
|
+
// src/cli/cmd/run/watch.ts
|
|
8349
|
+
var _chokidar = require('chokidar'); var chokidar = _interopRequireWildcard(_chokidar);
|
|
8350
|
+
|
|
8351
|
+
async function watch2(ctx) {
|
|
8352
|
+
const debounceDelay = ctx.flags.debounce || 5e3;
|
|
8353
|
+
console.log(_chalk2.default.hex(colors.orange)("[Watch Mode]"));
|
|
8354
|
+
console.log(
|
|
8355
|
+
`\u{1F440} Watching for changes... (Press ${_chalk2.default.yellow("Ctrl+C")} to stop)`
|
|
8356
|
+
);
|
|
8357
|
+
console.log(_chalk2.default.dim(` Debounce delay: ${debounceDelay}ms`));
|
|
8358
|
+
console.log("");
|
|
8359
|
+
const state = {
|
|
8360
|
+
isRunning: false,
|
|
8361
|
+
pendingChanges: /* @__PURE__ */ new Set()
|
|
8362
|
+
};
|
|
8363
|
+
const watchPatterns = await getWatchPatterns(ctx);
|
|
8364
|
+
if (watchPatterns.length === 0) {
|
|
8365
|
+
console.log(_chalk2.default.yellow("\u26A0\uFE0F No source files found to watch"));
|
|
8366
|
+
return;
|
|
8367
|
+
}
|
|
8368
|
+
console.log(_chalk2.default.dim(`Watching ${watchPatterns.length} file pattern(s):`));
|
|
8369
|
+
watchPatterns.forEach((pattern) => {
|
|
8370
|
+
console.log(_chalk2.default.dim(` \u2022 ${pattern}`));
|
|
8371
|
+
});
|
|
8372
|
+
console.log("");
|
|
8373
|
+
const watcher = chokidar.watch(watchPatterns, {
|
|
8374
|
+
ignoreInitial: true,
|
|
8375
|
+
persistent: true,
|
|
8376
|
+
awaitWriteFinish: {
|
|
8377
|
+
stabilityThreshold: 500,
|
|
8378
|
+
pollInterval: 100
|
|
8379
|
+
}
|
|
8380
|
+
});
|
|
8381
|
+
watcher.on("change", (path17) => {
|
|
8382
|
+
handleFileChange(path17, state, ctx);
|
|
8383
|
+
});
|
|
8384
|
+
watcher.on("add", (path17) => {
|
|
8385
|
+
handleFileChange(path17, state, ctx);
|
|
8386
|
+
});
|
|
8387
|
+
watcher.on("unlink", (path17) => {
|
|
8388
|
+
handleFileChange(path17, state, ctx);
|
|
8389
|
+
});
|
|
8390
|
+
watcher.on("error", (error) => {
|
|
8391
|
+
console.error(
|
|
8392
|
+
_chalk2.default.red(
|
|
8393
|
+
`Watch error: ${error instanceof Error ? error.message : String(error)}`
|
|
8394
|
+
)
|
|
8395
|
+
);
|
|
8396
|
+
});
|
|
8397
|
+
process.on("SIGINT", () => {
|
|
8398
|
+
console.log(_chalk2.default.yellow("\n\n\u{1F6D1} Stopping watch mode..."));
|
|
8399
|
+
watcher.close();
|
|
8400
|
+
process.exit(0);
|
|
8401
|
+
});
|
|
8402
|
+
await new Promise(() => {
|
|
8403
|
+
});
|
|
8404
|
+
}
|
|
8405
|
+
async function getWatchPatterns(ctx) {
|
|
8406
|
+
if (!ctx.config) return [];
|
|
8407
|
+
const buckets = getBuckets(ctx.config);
|
|
8408
|
+
const patterns = [];
|
|
8409
|
+
for (const bucket of buckets) {
|
|
8410
|
+
if (ctx.flags.bucket && !ctx.flags.bucket.includes(bucket.type)) {
|
|
8411
|
+
continue;
|
|
8412
|
+
}
|
|
8413
|
+
for (const bucketPath of bucket.paths) {
|
|
8414
|
+
if (ctx.flags.file) {
|
|
8415
|
+
if (!ctx.flags.file.some((f) => bucketPath.pathPattern.includes(f))) {
|
|
8416
|
+
continue;
|
|
8417
|
+
}
|
|
8418
|
+
}
|
|
8419
|
+
const sourceLocale = ctx.flags.sourceLocale || ctx.config.locale.source;
|
|
8420
|
+
const sourcePattern = bucketPath.pathPattern.replace(
|
|
8421
|
+
"[locale]",
|
|
8422
|
+
sourceLocale
|
|
8423
|
+
);
|
|
8424
|
+
patterns.push(sourcePattern);
|
|
8425
|
+
}
|
|
8426
|
+
}
|
|
8427
|
+
return patterns;
|
|
8428
|
+
}
|
|
8429
|
+
function handleFileChange(filePath, state, ctx) {
|
|
8430
|
+
const debounceDelay = ctx.flags.debounce || 5e3;
|
|
8431
|
+
state.pendingChanges.add(filePath);
|
|
8432
|
+
console.log(_chalk2.default.dim(`\u{1F4DD} File changed: ${filePath}`));
|
|
8433
|
+
if (state.debounceTimer) {
|
|
8434
|
+
clearTimeout(state.debounceTimer);
|
|
8435
|
+
}
|
|
8436
|
+
state.debounceTimer = setTimeout(async () => {
|
|
8437
|
+
if (state.isRunning) {
|
|
8438
|
+
console.log(
|
|
8439
|
+
_chalk2.default.yellow("\u23F3 Translation already in progress, skipping...")
|
|
8440
|
+
);
|
|
8441
|
+
return;
|
|
8442
|
+
}
|
|
8443
|
+
await triggerRetranslation(state, ctx);
|
|
8444
|
+
}, debounceDelay);
|
|
8445
|
+
}
|
|
8446
|
+
async function triggerRetranslation(state, ctx) {
|
|
8447
|
+
if (state.isRunning) return;
|
|
8448
|
+
state.isRunning = true;
|
|
8449
|
+
try {
|
|
8450
|
+
const changedFiles = Array.from(state.pendingChanges);
|
|
8451
|
+
state.pendingChanges.clear();
|
|
8452
|
+
console.log(_chalk2.default.hex(colors.green)("\n\u{1F504} Triggering retranslation..."));
|
|
8453
|
+
console.log(_chalk2.default.dim(`Changed files: ${changedFiles.join(", ")}`));
|
|
8454
|
+
console.log("");
|
|
8455
|
+
const runCtx = {
|
|
8456
|
+
...ctx,
|
|
8457
|
+
tasks: [],
|
|
8458
|
+
results: /* @__PURE__ */ new Map()
|
|
8459
|
+
};
|
|
8460
|
+
await plan(runCtx);
|
|
8461
|
+
if (runCtx.tasks.length === 0) {
|
|
8462
|
+
console.log(_chalk2.default.dim("\u2728 No translation tasks needed"));
|
|
8463
|
+
} else {
|
|
8464
|
+
await execute(runCtx);
|
|
8465
|
+
await renderSummary(runCtx.results);
|
|
8466
|
+
}
|
|
8467
|
+
console.log(_chalk2.default.hex(colors.green)("\u2705 Retranslation completed"));
|
|
8468
|
+
console.log(_chalk2.default.dim("\u{1F440} Continuing to watch for changes...\n"));
|
|
8469
|
+
} catch (error) {
|
|
8470
|
+
console.error(_chalk2.default.red(`\u274C Retranslation failed: ${error.message}`));
|
|
8471
|
+
console.log(_chalk2.default.dim("\u{1F440} Continuing to watch for changes...\n"));
|
|
8472
|
+
} finally {
|
|
8473
|
+
state.isRunning = false;
|
|
8474
|
+
}
|
|
8475
|
+
}
|
|
8476
|
+
|
|
8347
8477
|
// src/cli/cmd/run/_types.ts
|
|
8348
8478
|
|
|
8349
8479
|
|
|
@@ -8362,7 +8492,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
8362
8492
|
concurrency: _zod.z.number().positive().default(10),
|
|
8363
8493
|
debug: _zod.z.boolean().default(false),
|
|
8364
8494
|
sourceLocale: _zod.z.string().optional(),
|
|
8365
|
-
targetLocale: _zod.z.array(_zod.z.string()).optional()
|
|
8495
|
+
targetLocale: _zod.z.array(_zod.z.string()).optional(),
|
|
8496
|
+
watch: _zod.z.boolean().default(false),
|
|
8497
|
+
debounce: _zod.z.number().positive().default(5e3)
|
|
8498
|
+
// 5 seconds default
|
|
8366
8499
|
});
|
|
8367
8500
|
|
|
8368
8501
|
// src/cli/cmd/run/_utils.ts
|
|
@@ -8413,6 +8546,13 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
8413
8546
|
"--concurrency <concurrency>",
|
|
8414
8547
|
"Number of concurrent tasks to run",
|
|
8415
8548
|
(val) => parseInt(val)
|
|
8549
|
+
).option(
|
|
8550
|
+
"--watch",
|
|
8551
|
+
"Watch source files for changes and automatically retranslate"
|
|
8552
|
+
).option(
|
|
8553
|
+
"--debounce <milliseconds>",
|
|
8554
|
+
"Debounce delay in milliseconds for watch mode (default: 5000ms)",
|
|
8555
|
+
(val) => parseInt(val)
|
|
8416
8556
|
).action(async (args) => {
|
|
8417
8557
|
let authId = null;
|
|
8418
8558
|
try {
|
|
@@ -8442,6 +8582,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
8442
8582
|
await renderSpacer();
|
|
8443
8583
|
await renderSummary(ctx.results);
|
|
8444
8584
|
await renderSpacer();
|
|
8585
|
+
if (ctx.flags.watch) {
|
|
8586
|
+
await watch2(ctx);
|
|
8587
|
+
}
|
|
8445
8588
|
trackEvent(authId, "cmd.run.success", {
|
|
8446
8589
|
config: ctx.config,
|
|
8447
8590
|
flags: ctx.flags
|
|
@@ -9759,7 +9902,7 @@ async function renderHero2() {
|
|
|
9759
9902
|
// package.json
|
|
9760
9903
|
var package_default = {
|
|
9761
9904
|
name: "lingo.dev",
|
|
9762
|
-
version: "0.
|
|
9905
|
+
version: "0.102.1",
|
|
9763
9906
|
description: "Lingo.dev CLI",
|
|
9764
9907
|
private: false,
|
|
9765
9908
|
publishConfig: {
|
|
@@ -9894,6 +10037,7 @@ var package_default = {
|
|
|
9894
10037
|
ai: "^4.3.15",
|
|
9895
10038
|
bitbucket: "^2.12.0",
|
|
9896
10039
|
chalk: "^5.4.1",
|
|
10040
|
+
chokidar: "^4.0.3",
|
|
9897
10041
|
"cli-progress": "^3.12.0",
|
|
9898
10042
|
"cli-table3": "^0.6.5",
|
|
9899
10043
|
cors: "^2.8.5",
|
|
@@ -9962,6 +10106,7 @@ var package_default = {
|
|
|
9962
10106
|
},
|
|
9963
10107
|
devDependencies: {
|
|
9964
10108
|
"@types/babel__generator": "^7.27.0",
|
|
10109
|
+
"@types/chokidar": "^2.1.7",
|
|
9965
10110
|
"@types/cli-progress": "^3.11.6",
|
|
9966
10111
|
"@types/cors": "^2.8.17",
|
|
9967
10112
|
"@types/diff": "^7.0.0",
|