lingo.dev 0.92.7 → 0.92.8

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
@@ -850,46 +850,67 @@ import Ora4 from "ora";
850
850
  import _5 from "lodash";
851
851
  import path9 from "path";
852
852
  import { glob as glob2 } from "glob";
853
- import { resolveOverriddenLocale } from "@lingo.dev/_spec";
853
+ import {
854
+ resolveOverriddenLocale
855
+ } from "@lingo.dev/_spec";
854
856
  function getBuckets(i18nConfig) {
855
- const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
856
- const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
857
- const excludeItems = bucketEntry.exclude?.map((item) => resolveBucketItem(item));
858
- const config = {
859
- type: bucketType,
860
- paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
861
- };
862
- if (bucketEntry.injectLocale) {
863
- config.injectLocale = bucketEntry.injectLocale;
864
- }
865
- if (bucketEntry.lockedKeys) {
866
- config.lockedKeys = bucketEntry.lockedKeys;
867
- }
868
- if (bucketEntry.lockedPatterns) {
869
- config.lockedPatterns = bucketEntry.lockedPatterns;
857
+ const result = Object.entries(i18nConfig.buckets).map(
858
+ ([bucketType, bucketEntry]) => {
859
+ const includeItems = bucketEntry.include.map(
860
+ (item) => resolveBucketItem(item)
861
+ );
862
+ const excludeItems = bucketEntry.exclude?.map(
863
+ (item) => resolveBucketItem(item)
864
+ );
865
+ const config = {
866
+ type: bucketType,
867
+ paths: extractPathPatterns(
868
+ i18nConfig.locale.source,
869
+ includeItems,
870
+ excludeItems
871
+ )
872
+ };
873
+ if (bucketEntry.injectLocale) {
874
+ config.injectLocale = bucketEntry.injectLocale;
875
+ }
876
+ if (bucketEntry.lockedKeys) {
877
+ config.lockedKeys = bucketEntry.lockedKeys;
878
+ }
879
+ if (bucketEntry.lockedPatterns) {
880
+ config.lockedPatterns = bucketEntry.lockedPatterns;
881
+ }
882
+ if (bucketEntry.ignoredKeys) {
883
+ config.ignoredKeys = bucketEntry.ignoredKeys;
884
+ }
885
+ return config;
870
886
  }
871
- return config;
872
- });
887
+ );
873
888
  return result;
874
889
  }
875
890
  function extractPathPatterns(sourceLocale, include, exclude) {
876
891
  const includedPatterns = include.flatMap(
877
- (pattern) => expandPlaceholderedGlob(pattern.path, resolveOverriddenLocale(sourceLocale, pattern.delimiter)).map(
878
- (pathPattern) => ({
879
- pathPattern,
880
- delimiter: pattern.delimiter
881
- })
882
- )
892
+ (pattern) => expandPlaceholderedGlob(
893
+ pattern.path,
894
+ resolveOverriddenLocale(sourceLocale, pattern.delimiter)
895
+ ).map((pathPattern) => ({
896
+ pathPattern,
897
+ delimiter: pattern.delimiter
898
+ }))
883
899
  );
884
900
  const excludedPatterns = exclude?.flatMap(
885
- (pattern) => expandPlaceholderedGlob(pattern.path, resolveOverriddenLocale(sourceLocale, pattern.delimiter)).map(
886
- (pathPattern) => ({
887
- pathPattern,
888
- delimiter: pattern.delimiter
889
- })
890
- )
901
+ (pattern) => expandPlaceholderedGlob(
902
+ pattern.path,
903
+ resolveOverriddenLocale(sourceLocale, pattern.delimiter)
904
+ ).map((pathPattern) => ({
905
+ pathPattern,
906
+ delimiter: pattern.delimiter
907
+ }))
908
+ );
909
+ const result = _5.differenceBy(
910
+ includedPatterns,
911
+ excludedPatterns ?? [],
912
+ (item) => item.pathPattern
891
913
  );
892
- const result = _5.differenceBy(includedPatterns, excludedPatterns ?? [], (item) => item.pathPattern);
893
914
  return result;
894
915
  }
895
916
  function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
@@ -908,12 +929,15 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
908
929
  });
909
930
  }
910
931
  const pathPatternChunks = pathPattern.split(path9.sep);
911
- const localeSegmentIndexes = pathPatternChunks.reduce((indexes, segment, index) => {
912
- if (segment.includes("[locale]")) {
913
- indexes.push(index);
914
- }
915
- return indexes;
916
- }, []);
932
+ const localeSegmentIndexes = pathPatternChunks.reduce(
933
+ (indexes, segment, index) => {
934
+ if (segment.includes("[locale]")) {
935
+ indexes.push(index);
936
+ }
937
+ return indexes;
938
+ },
939
+ []
940
+ );
917
941
  const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
918
942
  const sourcePaths = glob2.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => path9.relative(process.cwd(), fullpath));
919
943
  const placeholderedPaths = sourcePaths.map((sourcePath) => {
@@ -1001,7 +1025,7 @@ import {
1001
1025
  } from "@lingo.dev/_spec";
1002
1026
  import { Command as Command6 } from "interactive-commander";
1003
1027
  import Z3 from "zod";
1004
- import _24 from "lodash";
1028
+ import _25 from "lodash";
1005
1029
  import * as path14 from "path";
1006
1030
  import Ora5 from "ora";
1007
1031
 
@@ -1226,7 +1250,7 @@ function createTextFileLoader(pathPattern) {
1226
1250
  const trimmedResult = result.trim();
1227
1251
  return trimmedResult;
1228
1252
  },
1229
- async push(locale, data, _27, originalLocale) {
1253
+ async push(locale, data, _28, originalLocale) {
1230
1254
  const draftPath = pathPattern.replaceAll("[locale]", locale);
1231
1255
  const finalPath = path10.resolve(draftPath);
1232
1256
  const dirPath = path10.dirname(finalPath);
@@ -1752,7 +1776,7 @@ function createPropertiesLoader() {
1752
1776
  return result;
1753
1777
  },
1754
1778
  async push(locale, payload) {
1755
- const result = Object.entries(payload).filter(([_27, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1779
+ const result = Object.entries(payload).filter(([_28, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1756
1780
  return result;
1757
1781
  }
1758
1782
  });
@@ -2019,10 +2043,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
2019
2043
  }
2020
2044
  }
2021
2045
  return false;
2022
- }).map(([key, _27]) => key);
2023
- const result = _10.omitBy(input2, (_27, key) => passthroughKeys.includes(key));
2046
+ }).map(([key, _28]) => key);
2047
+ const result = _10.omitBy(input2, (_28, key) => passthroughKeys.includes(key));
2024
2048
  if (returnUnlocalizedKeys) {
2025
- result.unlocalizable = _10.omitBy(input2, (_27, key) => !passthroughKeys.includes(key));
2049
+ result.unlocalizable = _10.omitBy(input2, (_28, key) => !passthroughKeys.includes(key));
2026
2050
  }
2027
2051
  return result;
2028
2052
  },
@@ -3653,8 +3677,23 @@ function createMdxLockedPatternsLoader(defaultPatterns) {
3653
3677
  });
3654
3678
  }
3655
3679
 
3680
+ // src/cli/loaders/ignored-keys.ts
3681
+ import _23 from "lodash";
3682
+ function createIgnoredKeysLoader(ignoredKeys) {
3683
+ return createLoader({
3684
+ pull: async (locale, data) => {
3685
+ const result = _23.chain(data).omit(ignoredKeys).value();
3686
+ return result;
3687
+ },
3688
+ push: async (locale, data, originalInput, originalLocale, pullInput) => {
3689
+ const result = _23.merge({}, data, _23.pick(pullInput, ignoredKeys));
3690
+ return result;
3691
+ }
3692
+ });
3693
+ }
3694
+
3656
3695
  // src/cli/loaders/index.ts
3657
- function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns) {
3696
+ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns, ignoredKeys) {
3658
3697
  switch (bucketType) {
3659
3698
  default:
3660
3699
  throw new Error(`Unsupported bucket type: ${bucketType}`);
@@ -3913,6 +3952,8 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
3913
3952
  createTypescriptLoader(),
3914
3953
  createFlatLoader(),
3915
3954
  createSyncLoader(),
3955
+ createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3956
+ createIgnoredKeysLoader(ignoredKeys || []),
3916
3957
  createUnlocalizableLoader(
3917
3958
  options.isCacheRestore,
3918
3959
  options.returnUnlocalizedKeys
@@ -4098,7 +4139,7 @@ async function trackEvent(distinctId, event, properties) {
4098
4139
  }
4099
4140
 
4100
4141
  // src/cli/utils/delta.ts
4101
- import _23 from "lodash";
4142
+ import _24 from "lodash";
4102
4143
  import z from "zod";
4103
4144
 
4104
4145
  // src/cli/utils/fs.ts
@@ -4147,9 +4188,9 @@ function createDeltaProcessor(fileKey) {
4147
4188
  return checkIfFileExists(lockfilePath);
4148
4189
  },
4149
4190
  async calculateDelta(params) {
4150
- let added = _23.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
4151
- let removed = _23.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
4152
- const updated = _23.filter(Object.keys(params.sourceData), (key) => {
4191
+ let added = _24.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
4192
+ let removed = _24.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
4193
+ const updated = _24.filter(Object.keys(params.sourceData), (key) => {
4153
4194
  return md5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
4154
4195
  });
4155
4196
  const renamed = [];
@@ -4198,7 +4239,7 @@ function createDeltaProcessor(fileKey) {
4198
4239
  await this.saveLock(lockfileData);
4199
4240
  },
4200
4241
  async createChecksums(sourceData) {
4201
- const checksums = _23.mapValues(sourceData, (value) => md5(value));
4242
+ const checksums = _24.mapValues(sourceData, (value) => md5(value));
4202
4243
  return checksums;
4203
4244
  }
4204
4245
  };
@@ -4328,7 +4369,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4328
4369
  injectLocale: bucket.injectLocale
4329
4370
  },
4330
4371
  bucket.lockedKeys,
4331
- bucket.lockedPatterns
4372
+ bucket.lockedPatterns,
4373
+ bucket.ignoredKeys
4332
4374
  );
4333
4375
  bucketLoader.setDefaultLocale(sourceLocale);
4334
4376
  await bucketLoader.init();
@@ -4437,7 +4479,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4437
4479
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
4438
4480
  const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
4439
4481
  const savedChecksums = await deltaProcessor.loadChecksums();
4440
- const updatedSourceData = _24.pickBy(
4482
+ const updatedSourceData = _25.pickBy(
4441
4483
  sourceData,
4442
4484
  (value, key) => sourceChecksums[key] !== savedChecksums[key]
4443
4485
  );
@@ -4451,15 +4493,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4451
4493
  bucketPath.delimiter
4452
4494
  );
4453
4495
  const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
4454
- const missingKeys = _24.difference(
4496
+ const missingKeys = _25.difference(
4455
4497
  Object.keys(sourceData),
4456
4498
  Object.keys(targetData)
4457
4499
  );
4458
- const extraKeys = _24.difference(
4500
+ const extraKeys = _25.difference(
4459
4501
  Object.keys(targetData),
4460
4502
  Object.keys(sourceData)
4461
4503
  );
4462
- const unlocalizableDataDiff = !_24.isEqual(
4504
+ const unlocalizableDataDiff = !_25.isEqual(
4463
4505
  sourceUnlocalizable,
4464
4506
  targetUnlocalizable
4465
4507
  );
@@ -4515,7 +4557,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4515
4557
  injectLocale: bucket.injectLocale
4516
4558
  },
4517
4559
  bucket.lockedKeys,
4518
- bucket.lockedPatterns
4560
+ bucket.lockedPatterns,
4561
+ bucket.ignoredKeys
4519
4562
  );
4520
4563
  bucketLoader.setDefaultLocale(sourceLocale);
4521
4564
  await bucketLoader.init();
@@ -4540,13 +4583,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4540
4583
  targetData,
4541
4584
  checksums: checksums2
4542
4585
  });
4543
- let processableData = _24.chain(sourceData).entries().filter(
4586
+ let processableData = _25.chain(sourceData).entries().filter(
4544
4587
  ([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
4545
4588
  ).fromPairs().value();
4546
4589
  if (flags.key) {
4547
- processableData = _24.pickBy(
4590
+ processableData = _25.pickBy(
4548
4591
  processableData,
4549
- (_27, key) => key === flags.key
4592
+ (_28, key) => key === flags.key
4550
4593
  );
4551
4594
  }
4552
4595
  if (flags.verbose) {
@@ -4587,7 +4630,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4587
4630
  if (flags.verbose) {
4588
4631
  bucketOra.info(JSON.stringify(processedTargetData, null, 2));
4589
4632
  }
4590
- let finalTargetData = _24.merge(
4633
+ let finalTargetData = _25.merge(
4591
4634
  {},
4592
4635
  sourceData,
4593
4636
  targetData,
@@ -4608,7 +4651,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4608
4651
  `Applying changes to ${bucketPath} (${targetLocale})`
4609
4652
  );
4610
4653
  }
4611
- const finalDiffSize = _24.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
4654
+ const finalDiffSize = _25.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
4612
4655
  await bucketLoader.push(targetLocale, finalTargetData);
4613
4656
  if (finalDiffSize > 0 || flags.force) {
4614
4657
  bucketOra.succeed(
@@ -4779,7 +4822,7 @@ Reviewing changes for ${chalk.blue(args.pathPattern)} (${chalk.yellow(args.targe
4779
4822
  return args.currentData;
4780
4823
  }
4781
4824
  const customData = { ...args.currentData };
4782
- const changes = _24.reduce(
4825
+ const changes = _25.reduce(
4783
4826
  args.proposedData,
4784
4827
  (result, value, key) => {
4785
4828
  if (args.currentData[key] !== value) {
@@ -4852,7 +4895,7 @@ import path15 from "path";
4852
4895
  import Z4 from "zod";
4853
4896
  import YAML5 from "yaml";
4854
4897
  import { MD5 as MD52 } from "object-hash";
4855
- import _25 from "lodash";
4898
+ import _26 from "lodash";
4856
4899
  function createLockfileHelper() {
4857
4900
  return {
4858
4901
  isLockfileExists: () => {
@@ -4862,23 +4905,23 @@ function createLockfileHelper() {
4862
4905
  registerSourceData: (pathPattern, sourceData) => {
4863
4906
  const lockfile = _loadLockfile();
4864
4907
  const sectionKey = MD52(pathPattern);
4865
- const sectionChecksums = _25.mapValues(sourceData, (value) => MD52(value));
4908
+ const sectionChecksums = _26.mapValues(sourceData, (value) => MD52(value));
4866
4909
  lockfile.checksums[sectionKey] = sectionChecksums;
4867
4910
  _saveLockfile(lockfile);
4868
4911
  },
4869
4912
  registerPartialSourceData: (pathPattern, partialSourceData) => {
4870
4913
  const lockfile = _loadLockfile();
4871
4914
  const sectionKey = MD52(pathPattern);
4872
- const sectionChecksums = _25.mapValues(partialSourceData, (value) => MD52(value));
4873
- lockfile.checksums[sectionKey] = _25.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
4915
+ const sectionChecksums = _26.mapValues(partialSourceData, (value) => MD52(value));
4916
+ lockfile.checksums[sectionKey] = _26.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
4874
4917
  _saveLockfile(lockfile);
4875
4918
  },
4876
4919
  extractUpdatedData: (pathPattern, sourceData) => {
4877
4920
  const lockfile = _loadLockfile();
4878
4921
  const sectionKey = MD52(pathPattern);
4879
- const currentChecksums = _25.mapValues(sourceData, (value) => MD52(value));
4922
+ const currentChecksums = _26.mapValues(sourceData, (value) => MD52(value));
4880
4923
  const savedChecksums = lockfile.checksums[sectionKey] || {};
4881
- const updatedData = _25.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
4924
+ const updatedData = _26.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
4882
4925
  return updatedData;
4883
4926
  }
4884
4927
  };
@@ -4948,7 +4991,7 @@ var flagsSchema = Z5.object({
4948
4991
  // src/cli/cmd/cleanup.ts
4949
4992
  import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
4950
4993
  import { Command as Command8 } from "interactive-commander";
4951
- import _26 from "lodash";
4994
+ import _27 from "lodash";
4952
4995
  import Ora7 from "ora";
4953
4996
  var cleanup_default = new Command8().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(
4954
4997
  "--verbose",
@@ -4984,7 +5027,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
4984
5027
  try {
4985
5028
  const targetData = await bucketLoader.pull(targetLocale);
4986
5029
  const targetKeys = Object.keys(targetData);
4987
- const keysToRemove = _26.difference(targetKeys, sourceKeys);
5030
+ const keysToRemove = _27.difference(targetKeys, sourceKeys);
4988
5031
  if (keysToRemove.length === 0) {
4989
5032
  bucketOra.succeed(`[${targetLocale}] No keys to remove`);
4990
5033
  continue;
@@ -4993,7 +5036,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
4993
5036
  bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
4994
5037
  }
4995
5038
  if (!options.dryRun) {
4996
- const cleanedData = _26.pick(targetData, sourceKeys);
5039
+ const cleanedData = _27.pick(targetData, sourceKeys);
4997
5040
  await bucketLoader.push(targetLocale, cleanedData);
4998
5041
  bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
4999
5042
  } else {
@@ -5048,7 +5091,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
5048
5091
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5049
5092
  import Z6 from "zod";
5050
5093
  import { ReplexicaEngine } from "@lingo.dev/_sdk";
5051
- var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_27, program) => {
5094
+ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_28, program) => {
5052
5095
  const apiKey = program.args[0];
5053
5096
  const settings = getSettings(apiKey);
5054
5097
  if (!settings.auth.apiKey) {
@@ -6302,7 +6345,7 @@ async function renderHero() {
6302
6345
  // package.json
6303
6346
  var package_default = {
6304
6347
  name: "lingo.dev",
6305
- version: "0.92.7",
6348
+ version: "0.92.8",
6306
6349
  description: "Lingo.dev CLI",
6307
6350
  private: false,
6308
6351
  publishConfig: {