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.cjs
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
|
|
|
@@ -6471,127 +6500,6 @@ async function setup(input2) {
|
|
|
6471
6500
|
|
|
6472
6501
|
|
|
6473
6502
|
|
|
6474
|
-
async function plan(input2) {
|
|
6475
|
-
console.log(_chalk2.default.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 (0, _listr2.Listr)(
|
|
6493
|
-
[
|
|
6494
|
-
{
|
|
6495
|
-
title: "Locating content buckets",
|
|
6496
|
-
task: async (ctx, task) => {
|
|
6497
|
-
const bucketCount = buckets.length;
|
|
6498
|
-
const bucketFilter = input2.flags.bucket ? ` ${_chalk2.default.dim(
|
|
6499
|
-
`(filtered by: ${_chalk2.default.hex(colors.yellow)(
|
|
6500
|
-
input2.flags.bucket.join(", ")
|
|
6501
|
-
)})`
|
|
6502
|
-
)}` : "";
|
|
6503
|
-
task.title = `Found ${_chalk2.default.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 ${_chalk2.default.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 ? ` ${_chalk2.default.dim(
|
|
6533
|
-
`(filtered by: ${_chalk2.default.hex(colors.yellow)(
|
|
6534
|
-
input2.flags.file.join(", ")
|
|
6535
|
-
)})`
|
|
6536
|
-
)}` : "";
|
|
6537
|
-
task.title = `Found ${_chalk2.default.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 = __spec.resolveOverriddenLocale.call(void 0,
|
|
6555
|
-
_sourceLocale,
|
|
6556
|
-
bucketPath.delimiter
|
|
6557
|
-
);
|
|
6558
|
-
for (const _targetLocale of _targetLocales) {
|
|
6559
|
-
const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
|
|
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 ${_chalk2.default.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
|
-
|
|
6591
|
-
|
|
6592
|
-
var _plimit = require('p-limit'); var _plimit2 = _interopRequireDefault(_plimit);
|
|
6593
|
-
|
|
6594
|
-
|
|
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) => {
|
|
6597
6505
|
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
@@ -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
|
+
|
|
8043
|
+
async function plan(input2) {
|
|
8044
|
+
console.log(_chalk2.default.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 (0, _listr2.Listr)(
|
|
8062
|
+
[
|
|
8063
|
+
{
|
|
8064
|
+
title: "Locating content buckets",
|
|
8065
|
+
task: async (ctx, task) => {
|
|
8066
|
+
const bucketCount = buckets.length;
|
|
8067
|
+
const bucketFilter = input2.flags.bucket ? ` ${_chalk2.default.dim(
|
|
8068
|
+
`(filtered by: ${_chalk2.default.hex(colors.yellow)(
|
|
8069
|
+
input2.flags.bucket.join(", ")
|
|
8070
|
+
)})`
|
|
8071
|
+
)}` : "";
|
|
8072
|
+
task.title = `Found ${_chalk2.default.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 ${_chalk2.default.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 ? ` ${_chalk2.default.dim(
|
|
8102
|
+
`(filtered by: ${_chalk2.default.hex(colors.yellow)(
|
|
8103
|
+
input2.flags.file.join(", ")
|
|
8104
|
+
)})`
|
|
8105
|
+
)}` : "";
|
|
8106
|
+
task.title = `Found ${_chalk2.default.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 = __spec.resolveOverriddenLocale.call(void 0,
|
|
8124
|
+
_sourceLocale,
|
|
8125
|
+
bucketPath.delimiter
|
|
8126
|
+
);
|
|
8127
|
+
for (const _targetLocale of _targetLocales) {
|
|
8128
|
+
const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
|
|
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 ${_chalk2.default.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
|
+
|
|
8160
|
+
|
|
8161
|
+
var _plimit = require('p-limit'); var _plimit2 = _interopRequireDefault(_plimit);
|
|
8162
|
+
|
|
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 (0, _interactivecommander.Command)().command("run").descri
|
|
|
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 (0, _interactivecommander.Command)().command("status").
|
|
|
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 (0, _interactivecommander.Command)().command("status").
|
|
|
9400
9431
|
if (_optionalChain([flags, 'access', _262 => _262.file, 'optionalAccess', _263 => _263.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) => _optionalChain([path17, 'access', _264 => _264.pathPattern, 'optionalAccess', _265 => _265.includes, 'call', _266 => _266(file)]) || _optionalChain([path17, 'access', _267 => _267.pathPattern, 'optionalAccess', _268 => _268.match, 'call', _269 => _269(file)]) || minimatch(path17.pathPattern, file)
|
|
9436
|
+
)
|
|
9404
9437
|
);
|
|
9405
9438
|
return { ...bucket, paths };
|
|
9406
9439
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -9419,7 +9452,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
9419
9452
|
});
|
|
9420
9453
|
}
|
|
9421
9454
|
}
|
|
9422
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
9455
|
+
const targetLocales = _optionalChain([flags, 'access', _270 => _270.locale, 'optionalAccess', _271 => _271.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
9423
9456
|
let totalSourceKeyCount = 0;
|
|
9424
9457
|
let uniqueKeysToTranslate = 0;
|
|
9425
9458
|
let totalExistingTranslations = 0;
|
|
@@ -9823,12 +9856,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
9823
9856
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
9824
9857
|
docUrl: "bucketNotFound"
|
|
9825
9858
|
});
|
|
9826
|
-
} else if (_optionalChain([flags, 'access',
|
|
9859
|
+
} else if (_optionalChain([flags, 'access', _272 => _272.locale, 'optionalAccess', _273 => _273.some, 'call', _274 => _274((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
9827
9860
|
throw new CLIError({
|
|
9828
9861
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
9829
9862
|
docUrl: "localeTargetNotFound"
|
|
9830
9863
|
});
|
|
9831
|
-
} else if (_optionalChain([flags, 'access',
|
|
9864
|
+
} else if (_optionalChain([flags, 'access', _275 => _275.bucket, 'optionalAccess', _276 => _276.some, 'call', _277 => _277(
|
|
9832
9865
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
9833
9866
|
)])) {
|
|
9834
9867
|
throw new CLIError({
|
|
@@ -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: {
|
|
@@ -10192,7 +10225,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
10192
10225
|
if (options.file && options.file.length) {
|
|
10193
10226
|
buckets = buckets.map((bucket) => {
|
|
10194
10227
|
const paths = bucket.paths.filter(
|
|
10195
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
10228
|
+
(bucketPath) => _optionalChain([options, 'access', _278 => _278.file, 'optionalAccess', _279 => _279.some, 'call', _280 => _280((f) => bucketPath.pathPattern.includes(f))])
|
|
10196
10229
|
);
|
|
10197
10230
|
return { ...bucket, paths };
|
|
10198
10231
|
}).filter((bucket) => bucket.paths.length > 0);
|