lingo.dev 0.103.0 → 0.105.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.mjs CHANGED
@@ -5602,7 +5602,9 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
5602
5602
  }
5603
5603
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
5604
5604
  const checksums = await deltaProcessor.createChecksums(sourceData);
5605
- await deltaProcessor.saveChecksums(checksums);
5605
+ if (!flags.locale?.length) {
5606
+ await deltaProcessor.saveChecksums(checksums);
5607
+ }
5606
5608
  }
5607
5609
  } catch (_error) {
5608
5610
  const error = new Error(
@@ -6499,127 +6501,6 @@ async function setup(input2) {
6499
6501
  // src/cli/cmd/run/plan.ts
6500
6502
  import chalk11 from "chalk";
6501
6503
  import { Listr as Listr2 } from "listr2";
6502
- import { resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
6503
- async function plan(input2) {
6504
- console.log(chalk11.hex(colors.orange)("[Planning]"));
6505
- let buckets = getBuckets(input2.config);
6506
- if (input2.flags.bucket) {
6507
- buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
6508
- }
6509
- const _sourceLocale = input2.flags.sourceLocale || input2.config.locale.source;
6510
- if (!_sourceLocale) {
6511
- throw new Error(
6512
- `No source locale provided. Use --source-locale to specify the source locale or add it to i18n.json (locale.source)`
6513
- );
6514
- }
6515
- const _targetLocales = input2.flags.targetLocale || input2.config.locale.targets;
6516
- if (!_targetLocales.length) {
6517
- throw new Error(
6518
- `No target locales provided. Use --target-locale to specify the target locales or add them to i18n.json (locale.targets)`
6519
- );
6520
- }
6521
- return new Listr2(
6522
- [
6523
- {
6524
- title: "Locating content buckets",
6525
- task: async (ctx, task) => {
6526
- const bucketCount = buckets.length;
6527
- const bucketFilter = input2.flags.bucket ? ` ${chalk11.dim(
6528
- `(filtered by: ${chalk11.hex(colors.yellow)(
6529
- input2.flags.bucket.join(", ")
6530
- )})`
6531
- )}` : "";
6532
- task.title = `Found ${chalk11.hex(colors.yellow)(
6533
- bucketCount.toString()
6534
- )} bucket(s)${bucketFilter}`;
6535
- }
6536
- },
6537
- {
6538
- title: "Detecting locales",
6539
- task: async (ctx, task) => {
6540
- task.title = `Found ${chalk11.hex(colors.yellow)(
6541
- _targetLocales.length.toString()
6542
- )} target locale(s)`;
6543
- }
6544
- },
6545
- {
6546
- title: "Locating localizable files",
6547
- task: async (ctx, task) => {
6548
- const patterns = [];
6549
- for (const bucket of buckets) {
6550
- for (const bucketPath of bucket.paths) {
6551
- if (input2.flags.file) {
6552
- if (!input2.flags.file.some(
6553
- (f) => bucketPath.pathPattern.includes(f)
6554
- )) {
6555
- continue;
6556
- }
6557
- }
6558
- patterns.push(bucketPath.pathPattern);
6559
- }
6560
- }
6561
- const fileFilter = input2.flags.file ? ` ${chalk11.dim(
6562
- `(filtered by: ${chalk11.hex(colors.yellow)(
6563
- input2.flags.file.join(", ")
6564
- )})`
6565
- )}` : "";
6566
- task.title = `Found ${chalk11.hex(colors.yellow)(
6567
- patterns.length.toString()
6568
- )} path pattern(s)${fileFilter}`;
6569
- }
6570
- },
6571
- {
6572
- title: "Computing translation tasks",
6573
- task: async (ctx, task) => {
6574
- for (const bucket of buckets) {
6575
- for (const bucketPath of bucket.paths) {
6576
- if (input2.flags.file) {
6577
- if (!input2.flags.file.some(
6578
- (f) => bucketPath.pathPattern.includes(f)
6579
- )) {
6580
- continue;
6581
- }
6582
- }
6583
- const sourceLocale = resolveOverriddenLocale6(
6584
- _sourceLocale,
6585
- bucketPath.delimiter
6586
- );
6587
- for (const _targetLocale of _targetLocales) {
6588
- const targetLocale = resolveOverriddenLocale6(
6589
- _targetLocale,
6590
- bucketPath.delimiter
6591
- );
6592
- if (sourceLocale === targetLocale) continue;
6593
- ctx.tasks.push({
6594
- sourceLocale,
6595
- targetLocale,
6596
- bucketType: bucket.type,
6597
- bucketPathPattern: bucketPath.pathPattern,
6598
- injectLocale: bucket.injectLocale || [],
6599
- lockedKeys: bucket.lockedKeys || [],
6600
- lockedPatterns: bucket.lockedPatterns || [],
6601
- onlyKeys: input2.flags.key || []
6602
- });
6603
- }
6604
- }
6605
- }
6606
- task.title = `Prepared ${chalk11.hex(colors.green)(
6607
- ctx.tasks.length.toString()
6608
- )} translation task(s)`;
6609
- }
6610
- }
6611
- ],
6612
- {
6613
- rendererOptions: commonTaskRendererOptions
6614
- }
6615
- ).run(input2);
6616
- }
6617
-
6618
- // src/cli/cmd/run/execute.ts
6619
- import chalk12 from "chalk";
6620
- import { Listr as Listr3 } from "listr2";
6621
- import pLimit from "p-limit";
6622
- import _33 from "lodash";
6623
6504
 
6624
6505
  // ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
6625
6506
  var balanced = (a, b, str) => {
@@ -8159,7 +8040,128 @@ minimatch.Minimatch = Minimatch;
8159
8040
  minimatch.escape = escape;
8160
8041
  minimatch.unescape = unescape;
8161
8042
 
8043
+ // src/cli/cmd/run/plan.ts
8044
+ import { resolveOverriddenLocale as resolveOverriddenLocale6 } from "@lingo.dev/_spec";
8045
+ async function plan(input2) {
8046
+ console.log(chalk11.hex(colors.orange)("[Planning]"));
8047
+ let buckets = getBuckets(input2.config);
8048
+ if (input2.flags.bucket) {
8049
+ buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
8050
+ }
8051
+ const _sourceLocale = input2.flags.sourceLocale || input2.config.locale.source;
8052
+ if (!_sourceLocale) {
8053
+ throw new Error(
8054
+ `No source locale provided. Use --source-locale to specify the source locale or add it to i18n.json (locale.source)`
8055
+ );
8056
+ }
8057
+ const _targetLocales = input2.flags.targetLocale || input2.config.locale.targets;
8058
+ if (!_targetLocales.length) {
8059
+ throw new Error(
8060
+ `No target locales provided. Use --target-locale to specify the target locales or add them to i18n.json (locale.targets)`
8061
+ );
8062
+ }
8063
+ return new Listr2(
8064
+ [
8065
+ {
8066
+ title: "Locating content buckets",
8067
+ task: async (ctx, task) => {
8068
+ const bucketCount = buckets.length;
8069
+ const bucketFilter = input2.flags.bucket ? ` ${chalk11.dim(
8070
+ `(filtered by: ${chalk11.hex(colors.yellow)(
8071
+ input2.flags.bucket.join(", ")
8072
+ )})`
8073
+ )}` : "";
8074
+ task.title = `Found ${chalk11.hex(colors.yellow)(
8075
+ bucketCount.toString()
8076
+ )} bucket(s)${bucketFilter}`;
8077
+ }
8078
+ },
8079
+ {
8080
+ title: "Detecting locales",
8081
+ task: async (ctx, task) => {
8082
+ task.title = `Found ${chalk11.hex(colors.yellow)(
8083
+ _targetLocales.length.toString()
8084
+ )} target locale(s)`;
8085
+ }
8086
+ },
8087
+ {
8088
+ title: "Locating localizable files",
8089
+ task: async (ctx, task) => {
8090
+ const patterns = [];
8091
+ for (const bucket of buckets) {
8092
+ for (const bucketPath of bucket.paths) {
8093
+ if (input2.flags.file) {
8094
+ if (!input2.flags.file.some(
8095
+ (f) => bucketPath.pathPattern.includes(f) || minimatch(bucketPath.pathPattern, f)
8096
+ )) {
8097
+ continue;
8098
+ }
8099
+ }
8100
+ patterns.push(bucketPath.pathPattern);
8101
+ }
8102
+ }
8103
+ const fileFilter = input2.flags.file ? ` ${chalk11.dim(
8104
+ `(filtered by: ${chalk11.hex(colors.yellow)(
8105
+ input2.flags.file.join(", ")
8106
+ )})`
8107
+ )}` : "";
8108
+ task.title = `Found ${chalk11.hex(colors.yellow)(
8109
+ patterns.length.toString()
8110
+ )} path pattern(s)${fileFilter}`;
8111
+ }
8112
+ },
8113
+ {
8114
+ title: "Computing translation tasks",
8115
+ task: async (ctx, task) => {
8116
+ for (const bucket of buckets) {
8117
+ for (const bucketPath of bucket.paths) {
8118
+ if (input2.flags.file) {
8119
+ if (!input2.flags.file.some(
8120
+ (f) => bucketPath.pathPattern.includes(f) || minimatch(bucketPath.pathPattern, f)
8121
+ )) {
8122
+ continue;
8123
+ }
8124
+ }
8125
+ const sourceLocale = resolveOverriddenLocale6(
8126
+ _sourceLocale,
8127
+ bucketPath.delimiter
8128
+ );
8129
+ for (const _targetLocale of _targetLocales) {
8130
+ const targetLocale = resolveOverriddenLocale6(
8131
+ _targetLocale,
8132
+ bucketPath.delimiter
8133
+ );
8134
+ if (sourceLocale === targetLocale) continue;
8135
+ ctx.tasks.push({
8136
+ sourceLocale,
8137
+ targetLocale,
8138
+ bucketType: bucket.type,
8139
+ bucketPathPattern: bucketPath.pathPattern,
8140
+ injectLocale: bucket.injectLocale || [],
8141
+ lockedKeys: bucket.lockedKeys || [],
8142
+ lockedPatterns: bucket.lockedPatterns || [],
8143
+ onlyKeys: input2.flags.key || []
8144
+ });
8145
+ }
8146
+ }
8147
+ }
8148
+ task.title = `Prepared ${chalk11.hex(colors.green)(
8149
+ ctx.tasks.length.toString()
8150
+ )} translation task(s)`;
8151
+ }
8152
+ }
8153
+ ],
8154
+ {
8155
+ rendererOptions: commonTaskRendererOptions
8156
+ }
8157
+ ).run(input2);
8158
+ }
8159
+
8162
8160
  // src/cli/cmd/run/execute.ts
8161
+ import chalk12 from "chalk";
8162
+ import { Listr as Listr3 } from "listr2";
8163
+ import pLimit from "p-limit";
8164
+ import _33 from "lodash";
8163
8165
  var MAX_WORKER_COUNT = 10;
8164
8166
  async function execute(input2) {
8165
8167
  const effectiveConcurrency = Math.min(
@@ -8358,7 +8360,9 @@ function createWorkerTask(args) {
8358
8360
  finalRenamedTargetData
8359
8361
  );
8360
8362
  const checksums2 = await deltaProcessor.createChecksums(sourceData);
8361
- await deltaProcessor.saveChecksums(checksums2);
8363
+ if (!args.ctx.flags.targetLocale?.length) {
8364
+ await deltaProcessor.saveChecksums(checksums2);
8365
+ }
8362
8366
  });
8363
8367
  return { status: "success" };
8364
8368
  } catch (error) {
@@ -8456,7 +8460,9 @@ async function getWatchPatterns(ctx) {
8456
8460
  }
8457
8461
  for (const bucketPath of bucket.paths) {
8458
8462
  if (ctx.flags.file) {
8459
- if (!ctx.flags.file.some((f) => bucketPath.pathPattern.includes(f))) {
8463
+ if (!ctx.flags.file.some(
8464
+ (f) => bucketPath.pathPattern.includes(f) || minimatch(bucketPath.pathPattern, f)
8465
+ )) {
8460
8466
  continue;
8461
8467
  }
8462
8468
  }
@@ -8571,7 +8577,7 @@ var run_default = new Command16().command("run").description("Run Lingo.dev loca
8571
8577
  (val, prev) => prev ? [...prev, val] : [val]
8572
8578
  ).option(
8573
8579
  "--file <file>",
8574
- "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.",
8580
+ "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.",
8575
8581
  (val, prev) => prev ? [...prev, val] : [val]
8576
8582
  ).option(
8577
8583
  "--key <key>",
@@ -9382,7 +9388,7 @@ var status_default = new Command18().command("status").description("Show the sta
9382
9388
  (val, prev) => prev ? [...prev, val] : [val]
9383
9389
  ).option(
9384
9390
  "--file [files...]",
9385
- "File to process. Process only a specific path, may contain asterisk * to match multiple files."
9391
+ "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."
9386
9392
  ).option(
9387
9393
  "--force",
9388
9394
  "Ignore lockfile and process all keys, useful for estimating full re-translation"
@@ -9429,7 +9435,9 @@ var status_default = new Command18().command("status").description("Show the sta
9429
9435
  if (flags.file?.length) {
9430
9436
  buckets = buckets.map((bucket) => {
9431
9437
  const paths = bucket.paths.filter(
9432
- (path17) => flags.file.find((file) => path17.pathPattern?.match(file))
9438
+ (path17) => flags.file.find(
9439
+ (file) => path17.pathPattern?.includes(file) || path17.pathPattern?.match(file) || minimatch(path17.pathPattern, file)
9440
+ )
9433
9441
  );
9434
9442
  return { ...bucket, paths };
9435
9443
  }).filter((bucket) => bucket.paths.length > 0);
@@ -9946,7 +9954,7 @@ async function renderHero2() {
9946
9954
  // package.json
9947
9955
  var package_default = {
9948
9956
  name: "lingo.dev",
9949
- version: "0.103.0",
9957
+ version: "0.105.0",
9950
9958
  description: "Lingo.dev CLI",
9951
9959
  private: false,
9952
9960
  publishConfig: {