lingo.dev 0.102.4 → 0.104.0
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 +163 -130
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +159 -126
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -4
package/build/cli.mjs
CHANGED
|
@@ -4564,6 +4564,28 @@ function reorderKeys(data, originalInput) {
|
|
|
4564
4564
|
return orderedData;
|
|
4565
4565
|
}
|
|
4566
4566
|
|
|
4567
|
+
// src/cli/loaders/txt.ts
|
|
4568
|
+
function createTxtLoader() {
|
|
4569
|
+
return createLoader({
|
|
4570
|
+
async pull(locale, input2) {
|
|
4571
|
+
const result = {};
|
|
4572
|
+
if (input2 !== void 0 && input2 !== null && input2 !== "") {
|
|
4573
|
+
const lines = input2.split("\n");
|
|
4574
|
+
lines.forEach((line, index) => {
|
|
4575
|
+
result[String(index + 1)] = line;
|
|
4576
|
+
});
|
|
4577
|
+
}
|
|
4578
|
+
return result;
|
|
4579
|
+
},
|
|
4580
|
+
async push(locale, payload) {
|
|
4581
|
+
const sortedEntries = Object.entries(payload).sort(
|
|
4582
|
+
([a], [b]) => parseInt(a) - parseInt(b)
|
|
4583
|
+
);
|
|
4584
|
+
return sortedEntries.map(([_34, value]) => value).join("\n");
|
|
4585
|
+
}
|
|
4586
|
+
});
|
|
4587
|
+
}
|
|
4588
|
+
|
|
4567
4589
|
// src/cli/loaders/index.ts
|
|
4568
4590
|
function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns, ignoredKeys) {
|
|
4569
4591
|
switch (bucketType) {
|
|
@@ -4788,6 +4810,13 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
4788
4810
|
createIgnoredKeysLoader(ignoredKeys || []),
|
|
4789
4811
|
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
4790
4812
|
);
|
|
4813
|
+
case "txt":
|
|
4814
|
+
return composeLoaders(
|
|
4815
|
+
createTextFileLoader(bucketPathPattern),
|
|
4816
|
+
createTxtLoader(),
|
|
4817
|
+
createSyncLoader(),
|
|
4818
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
4819
|
+
);
|
|
4791
4820
|
}
|
|
4792
4821
|
}
|
|
4793
4822
|
|
|
@@ -6470,127 +6499,6 @@ async function setup(input2) {
|
|
|
6470
6499
|
// src/cli/cmd/run/plan.ts
|
|
6471
6500
|
import chalk11 from "chalk";
|
|
6472
6501
|
import { Listr as Listr2 } from "listr2";
|
|
6473
|
-
import { resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
|
|
6474
|
-
async function plan(input2) {
|
|
6475
|
-
console.log(chalk11.hex(colors.orange)("[Planning]"));
|
|
6476
|
-
let buckets = getBuckets(input2.config);
|
|
6477
|
-
if (input2.flags.bucket) {
|
|
6478
|
-
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
6479
|
-
}
|
|
6480
|
-
const _sourceLocale = input2.flags.sourceLocale || input2.config.locale.source;
|
|
6481
|
-
if (!_sourceLocale) {
|
|
6482
|
-
throw new Error(
|
|
6483
|
-
`No source locale provided. Use --source-locale to specify the source locale or add it to i18n.json (locale.source)`
|
|
6484
|
-
);
|
|
6485
|
-
}
|
|
6486
|
-
const _targetLocales = input2.flags.targetLocale || input2.config.locale.targets;
|
|
6487
|
-
if (!_targetLocales.length) {
|
|
6488
|
-
throw new Error(
|
|
6489
|
-
`No target locales provided. Use --target-locale to specify the target locales or add them to i18n.json (locale.targets)`
|
|
6490
|
-
);
|
|
6491
|
-
}
|
|
6492
|
-
return new Listr2(
|
|
6493
|
-
[
|
|
6494
|
-
{
|
|
6495
|
-
title: "Locating content buckets",
|
|
6496
|
-
task: async (ctx, task) => {
|
|
6497
|
-
const bucketCount = buckets.length;
|
|
6498
|
-
const bucketFilter = input2.flags.bucket ? ` ${chalk11.dim(
|
|
6499
|
-
`(filtered by: ${chalk11.hex(colors.yellow)(
|
|
6500
|
-
input2.flags.bucket.join(", ")
|
|
6501
|
-
)})`
|
|
6502
|
-
)}` : "";
|
|
6503
|
-
task.title = `Found ${chalk11.hex(colors.yellow)(
|
|
6504
|
-
bucketCount.toString()
|
|
6505
|
-
)} bucket(s)${bucketFilter}`;
|
|
6506
|
-
}
|
|
6507
|
-
},
|
|
6508
|
-
{
|
|
6509
|
-
title: "Detecting locales",
|
|
6510
|
-
task: async (ctx, task) => {
|
|
6511
|
-
task.title = `Found ${chalk11.hex(colors.yellow)(
|
|
6512
|
-
_targetLocales.length.toString()
|
|
6513
|
-
)} target locale(s)`;
|
|
6514
|
-
}
|
|
6515
|
-
},
|
|
6516
|
-
{
|
|
6517
|
-
title: "Locating localizable files",
|
|
6518
|
-
task: async (ctx, task) => {
|
|
6519
|
-
const patterns = [];
|
|
6520
|
-
for (const bucket of buckets) {
|
|
6521
|
-
for (const bucketPath of bucket.paths) {
|
|
6522
|
-
if (input2.flags.file) {
|
|
6523
|
-
if (!input2.flags.file.some(
|
|
6524
|
-
(f) => bucketPath.pathPattern.includes(f)
|
|
6525
|
-
)) {
|
|
6526
|
-
continue;
|
|
6527
|
-
}
|
|
6528
|
-
}
|
|
6529
|
-
patterns.push(bucketPath.pathPattern);
|
|
6530
|
-
}
|
|
6531
|
-
}
|
|
6532
|
-
const fileFilter = input2.flags.file ? ` ${chalk11.dim(
|
|
6533
|
-
`(filtered by: ${chalk11.hex(colors.yellow)(
|
|
6534
|
-
input2.flags.file.join(", ")
|
|
6535
|
-
)})`
|
|
6536
|
-
)}` : "";
|
|
6537
|
-
task.title = `Found ${chalk11.hex(colors.yellow)(
|
|
6538
|
-
patterns.length.toString()
|
|
6539
|
-
)} path pattern(s)${fileFilter}`;
|
|
6540
|
-
}
|
|
6541
|
-
},
|
|
6542
|
-
{
|
|
6543
|
-
title: "Computing translation tasks",
|
|
6544
|
-
task: async (ctx, task) => {
|
|
6545
|
-
for (const bucket of buckets) {
|
|
6546
|
-
for (const bucketPath of bucket.paths) {
|
|
6547
|
-
if (input2.flags.file) {
|
|
6548
|
-
if (!input2.flags.file.some(
|
|
6549
|
-
(f) => bucketPath.pathPattern.includes(f)
|
|
6550
|
-
)) {
|
|
6551
|
-
continue;
|
|
6552
|
-
}
|
|
6553
|
-
}
|
|
6554
|
-
const sourceLocale = resolveOverriddenLocale6(
|
|
6555
|
-
_sourceLocale,
|
|
6556
|
-
bucketPath.delimiter
|
|
6557
|
-
);
|
|
6558
|
-
for (const _targetLocale of _targetLocales) {
|
|
6559
|
-
const targetLocale = resolveOverriddenLocale6(
|
|
6560
|
-
_targetLocale,
|
|
6561
|
-
bucketPath.delimiter
|
|
6562
|
-
);
|
|
6563
|
-
if (sourceLocale === targetLocale) continue;
|
|
6564
|
-
ctx.tasks.push({
|
|
6565
|
-
sourceLocale,
|
|
6566
|
-
targetLocale,
|
|
6567
|
-
bucketType: bucket.type,
|
|
6568
|
-
bucketPathPattern: bucketPath.pathPattern,
|
|
6569
|
-
injectLocale: bucket.injectLocale || [],
|
|
6570
|
-
lockedKeys: bucket.lockedKeys || [],
|
|
6571
|
-
lockedPatterns: bucket.lockedPatterns || [],
|
|
6572
|
-
onlyKeys: input2.flags.key || []
|
|
6573
|
-
});
|
|
6574
|
-
}
|
|
6575
|
-
}
|
|
6576
|
-
}
|
|
6577
|
-
task.title = `Prepared ${chalk11.hex(colors.green)(
|
|
6578
|
-
ctx.tasks.length.toString()
|
|
6579
|
-
)} translation task(s)`;
|
|
6580
|
-
}
|
|
6581
|
-
}
|
|
6582
|
-
],
|
|
6583
|
-
{
|
|
6584
|
-
rendererOptions: commonTaskRendererOptions
|
|
6585
|
-
}
|
|
6586
|
-
).run(input2);
|
|
6587
|
-
}
|
|
6588
|
-
|
|
6589
|
-
// src/cli/cmd/run/execute.ts
|
|
6590
|
-
import chalk12 from "chalk";
|
|
6591
|
-
import { Listr as Listr3 } from "listr2";
|
|
6592
|
-
import pLimit from "p-limit";
|
|
6593
|
-
import _33 from "lodash";
|
|
6594
6502
|
|
|
6595
6503
|
// ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
6596
6504
|
var balanced = (a, b, str) => {
|
|
@@ -8130,7 +8038,128 @@ minimatch.Minimatch = Minimatch;
|
|
|
8130
8038
|
minimatch.escape = escape;
|
|
8131
8039
|
minimatch.unescape = unescape;
|
|
8132
8040
|
|
|
8041
|
+
// src/cli/cmd/run/plan.ts
|
|
8042
|
+
import { resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
|
|
8043
|
+
async function plan(input2) {
|
|
8044
|
+
console.log(chalk11.hex(colors.orange)("[Planning]"));
|
|
8045
|
+
let buckets = getBuckets(input2.config);
|
|
8046
|
+
if (input2.flags.bucket) {
|
|
8047
|
+
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
8048
|
+
}
|
|
8049
|
+
const _sourceLocale = input2.flags.sourceLocale || input2.config.locale.source;
|
|
8050
|
+
if (!_sourceLocale) {
|
|
8051
|
+
throw new Error(
|
|
8052
|
+
`No source locale provided. Use --source-locale to specify the source locale or add it to i18n.json (locale.source)`
|
|
8053
|
+
);
|
|
8054
|
+
}
|
|
8055
|
+
const _targetLocales = input2.flags.targetLocale || input2.config.locale.targets;
|
|
8056
|
+
if (!_targetLocales.length) {
|
|
8057
|
+
throw new Error(
|
|
8058
|
+
`No target locales provided. Use --target-locale to specify the target locales or add them to i18n.json (locale.targets)`
|
|
8059
|
+
);
|
|
8060
|
+
}
|
|
8061
|
+
return new Listr2(
|
|
8062
|
+
[
|
|
8063
|
+
{
|
|
8064
|
+
title: "Locating content buckets",
|
|
8065
|
+
task: async (ctx, task) => {
|
|
8066
|
+
const bucketCount = buckets.length;
|
|
8067
|
+
const bucketFilter = input2.flags.bucket ? ` ${chalk11.dim(
|
|
8068
|
+
`(filtered by: ${chalk11.hex(colors.yellow)(
|
|
8069
|
+
input2.flags.bucket.join(", ")
|
|
8070
|
+
)})`
|
|
8071
|
+
)}` : "";
|
|
8072
|
+
task.title = `Found ${chalk11.hex(colors.yellow)(
|
|
8073
|
+
bucketCount.toString()
|
|
8074
|
+
)} bucket(s)${bucketFilter}`;
|
|
8075
|
+
}
|
|
8076
|
+
},
|
|
8077
|
+
{
|
|
8078
|
+
title: "Detecting locales",
|
|
8079
|
+
task: async (ctx, task) => {
|
|
8080
|
+
task.title = `Found ${chalk11.hex(colors.yellow)(
|
|
8081
|
+
_targetLocales.length.toString()
|
|
8082
|
+
)} target locale(s)`;
|
|
8083
|
+
}
|
|
8084
|
+
},
|
|
8085
|
+
{
|
|
8086
|
+
title: "Locating localizable files",
|
|
8087
|
+
task: async (ctx, task) => {
|
|
8088
|
+
const patterns = [];
|
|
8089
|
+
for (const bucket of buckets) {
|
|
8090
|
+
for (const bucketPath of bucket.paths) {
|
|
8091
|
+
if (input2.flags.file) {
|
|
8092
|
+
if (!input2.flags.file.some(
|
|
8093
|
+
(f) => bucketPath.pathPattern.includes(f) || minimatch(bucketPath.pathPattern, f)
|
|
8094
|
+
)) {
|
|
8095
|
+
continue;
|
|
8096
|
+
}
|
|
8097
|
+
}
|
|
8098
|
+
patterns.push(bucketPath.pathPattern);
|
|
8099
|
+
}
|
|
8100
|
+
}
|
|
8101
|
+
const fileFilter = input2.flags.file ? ` ${chalk11.dim(
|
|
8102
|
+
`(filtered by: ${chalk11.hex(colors.yellow)(
|
|
8103
|
+
input2.flags.file.join(", ")
|
|
8104
|
+
)})`
|
|
8105
|
+
)}` : "";
|
|
8106
|
+
task.title = `Found ${chalk11.hex(colors.yellow)(
|
|
8107
|
+
patterns.length.toString()
|
|
8108
|
+
)} path pattern(s)${fileFilter}`;
|
|
8109
|
+
}
|
|
8110
|
+
},
|
|
8111
|
+
{
|
|
8112
|
+
title: "Computing translation tasks",
|
|
8113
|
+
task: async (ctx, task) => {
|
|
8114
|
+
for (const bucket of buckets) {
|
|
8115
|
+
for (const bucketPath of bucket.paths) {
|
|
8116
|
+
if (input2.flags.file) {
|
|
8117
|
+
if (!input2.flags.file.some(
|
|
8118
|
+
(f) => bucketPath.pathPattern.includes(f) || minimatch(bucketPath.pathPattern, f)
|
|
8119
|
+
)) {
|
|
8120
|
+
continue;
|
|
8121
|
+
}
|
|
8122
|
+
}
|
|
8123
|
+
const sourceLocale = resolveOverriddenLocale6(
|
|
8124
|
+
_sourceLocale,
|
|
8125
|
+
bucketPath.delimiter
|
|
8126
|
+
);
|
|
8127
|
+
for (const _targetLocale of _targetLocales) {
|
|
8128
|
+
const targetLocale = resolveOverriddenLocale6(
|
|
8129
|
+
_targetLocale,
|
|
8130
|
+
bucketPath.delimiter
|
|
8131
|
+
);
|
|
8132
|
+
if (sourceLocale === targetLocale) continue;
|
|
8133
|
+
ctx.tasks.push({
|
|
8134
|
+
sourceLocale,
|
|
8135
|
+
targetLocale,
|
|
8136
|
+
bucketType: bucket.type,
|
|
8137
|
+
bucketPathPattern: bucketPath.pathPattern,
|
|
8138
|
+
injectLocale: bucket.injectLocale || [],
|
|
8139
|
+
lockedKeys: bucket.lockedKeys || [],
|
|
8140
|
+
lockedPatterns: bucket.lockedPatterns || [],
|
|
8141
|
+
onlyKeys: input2.flags.key || []
|
|
8142
|
+
});
|
|
8143
|
+
}
|
|
8144
|
+
}
|
|
8145
|
+
}
|
|
8146
|
+
task.title = `Prepared ${chalk11.hex(colors.green)(
|
|
8147
|
+
ctx.tasks.length.toString()
|
|
8148
|
+
)} translation task(s)`;
|
|
8149
|
+
}
|
|
8150
|
+
}
|
|
8151
|
+
],
|
|
8152
|
+
{
|
|
8153
|
+
rendererOptions: commonTaskRendererOptions
|
|
8154
|
+
}
|
|
8155
|
+
).run(input2);
|
|
8156
|
+
}
|
|
8157
|
+
|
|
8133
8158
|
// src/cli/cmd/run/execute.ts
|
|
8159
|
+
import chalk12 from "chalk";
|
|
8160
|
+
import { Listr as Listr3 } from "listr2";
|
|
8161
|
+
import pLimit from "p-limit";
|
|
8162
|
+
import _33 from "lodash";
|
|
8134
8163
|
var MAX_WORKER_COUNT = 10;
|
|
8135
8164
|
async function execute(input2) {
|
|
8136
8165
|
const effectiveConcurrency = Math.min(
|
|
@@ -8427,7 +8456,9 @@ async function getWatchPatterns(ctx) {
|
|
|
8427
8456
|
}
|
|
8428
8457
|
for (const bucketPath of bucket.paths) {
|
|
8429
8458
|
if (ctx.flags.file) {
|
|
8430
|
-
if (!ctx.flags.file.some(
|
|
8459
|
+
if (!ctx.flags.file.some(
|
|
8460
|
+
(f) => bucketPath.pathPattern.includes(f) || minimatch(bucketPath.pathPattern, f)
|
|
8461
|
+
)) {
|
|
8431
8462
|
continue;
|
|
8432
8463
|
}
|
|
8433
8464
|
}
|
|
@@ -8542,7 +8573,7 @@ var run_default = new Command16().command("run").description("Run Lingo.dev loca
|
|
|
8542
8573
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
8543
8574
|
).option(
|
|
8544
8575
|
"--file <file>",
|
|
8545
|
-
"File to process. Process only files that
|
|
8576
|
+
"File to process. Process only files that match this glob pattern in their path. Use quotes around patterns to prevent shell expansion (e.g., --file '**/*.json'). Useful if you have a lot of files and want to focus on a specific one. Specify more files separated by commas or spaces. Accepts glob patterns.",
|
|
8546
8577
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
8547
8578
|
).option(
|
|
8548
8579
|
"--key <key>",
|
|
@@ -9353,7 +9384,7 @@ var status_default = new Command18().command("status").description("Show the sta
|
|
|
9353
9384
|
(val, prev) => prev ? [...prev, val] : [val]
|
|
9354
9385
|
).option(
|
|
9355
9386
|
"--file [files...]",
|
|
9356
|
-
"File to process. Process only
|
|
9387
|
+
"File to process. Process only files that include this string in their path. Useful if you have a lot of files and want to focus on a specific one. Specify more files separated by commas or spaces."
|
|
9357
9388
|
).option(
|
|
9358
9389
|
"--force",
|
|
9359
9390
|
"Ignore lockfile and process all keys, useful for estimating full re-translation"
|
|
@@ -9400,7 +9431,9 @@ var status_default = new Command18().command("status").description("Show the sta
|
|
|
9400
9431
|
if (flags.file?.length) {
|
|
9401
9432
|
buckets = buckets.map((bucket) => {
|
|
9402
9433
|
const paths = bucket.paths.filter(
|
|
9403
|
-
(path17) => flags.file.find(
|
|
9434
|
+
(path17) => flags.file.find(
|
|
9435
|
+
(file) => path17.pathPattern?.includes(file) || path17.pathPattern?.match(file) || minimatch(path17.pathPattern, file)
|
|
9436
|
+
)
|
|
9404
9437
|
);
|
|
9405
9438
|
return { ...bucket, paths };
|
|
9406
9439
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -9917,7 +9950,7 @@ async function renderHero2() {
|
|
|
9917
9950
|
// package.json
|
|
9918
9951
|
var package_default = {
|
|
9919
9952
|
name: "lingo.dev",
|
|
9920
|
-
version: "0.
|
|
9953
|
+
version: "0.104.0",
|
|
9921
9954
|
description: "Lingo.dev CLI",
|
|
9922
9955
|
private: false,
|
|
9923
9956
|
publishConfig: {
|