lingo.dev 0.87.1 → 0.87.2

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
@@ -998,7 +998,7 @@ import {
998
998
  } from "@lingo.dev/_spec";
999
999
  import { Command as Command6 } from "interactive-commander";
1000
1000
  import Z3 from "zod";
1001
- import _22 from "lodash";
1001
+ import _23 from "lodash";
1002
1002
  import * as path14 from "path";
1003
1003
  import Ora5 from "ora";
1004
1004
 
@@ -1218,7 +1218,7 @@ function createTextFileLoader(pathPattern) {
1218
1218
  const trimmedResult = result.trim();
1219
1219
  return trimmedResult;
1220
1220
  },
1221
- async push(locale, data, _25, originalLocale) {
1221
+ async push(locale, data, _26, originalLocale) {
1222
1222
  const draftPath = pathPattern.replaceAll("[locale]", locale);
1223
1223
  const finalPath = path10.resolve(draftPath);
1224
1224
  const dirPath = path10.dirname(finalPath);
@@ -1659,7 +1659,7 @@ function createPropertiesLoader() {
1659
1659
  return result;
1660
1660
  },
1661
1661
  async push(locale, payload) {
1662
- const result = Object.entries(payload).filter(([_25, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1662
+ const result = Object.entries(payload).filter(([_26, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1663
1663
  return result;
1664
1664
  }
1665
1665
  });
@@ -1926,10 +1926,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
1926
1926
  }
1927
1927
  }
1928
1928
  return false;
1929
- }).map(([key, _25]) => key);
1930
- const result = _10.omitBy(input2, (_25, key) => passthroughKeys.includes(key));
1929
+ }).map(([key, _26]) => key);
1930
+ const result = _10.omitBy(input2, (_26, key) => passthroughKeys.includes(key));
1931
1931
  if (returnUnlocalizedKeys) {
1932
- result.unlocalizable = _10.omitBy(input2, (_25, key) => !passthroughKeys.includes(key));
1932
+ result.unlocalizable = _10.omitBy(input2, (_26, key) => !passthroughKeys.includes(key));
1933
1933
  }
1934
1934
  return result;
1935
1935
  },
@@ -3098,16 +3098,33 @@ function md5(input2) {
3098
3098
  }
3099
3099
 
3100
3100
  // src/cli/loaders/mdx2/code-placeholder.ts
3101
- import { unified } from "unified";
3102
- import remarkParse from "remark-parse";
3103
- import remarkGfm from "remark-gfm";
3104
- import { VFile } from "vfile";
3105
- import remarkMdx from "remark-mdx";
3101
+ import _20 from "lodash";
3102
+ var unindentedFenceRegex = /(?<!\n\n)```([\s\S]*?)```(?!\n\n)/g;
3103
+ var indentedFenceRegex = /```([\s\S]*?)```/g;
3104
+ function ensureTrailingFenceNewline(_content) {
3105
+ let found = false;
3106
+ let content = _content;
3107
+ do {
3108
+ found = false;
3109
+ const matches = content.match(unindentedFenceRegex);
3110
+ if (matches) {
3111
+ const match = matches[0];
3112
+ content = content.replace(match, `
3113
+
3114
+ ${match}
3115
+
3116
+ `);
3117
+ found = true;
3118
+ }
3119
+ } while (found);
3120
+ content = _20.chain(content).split("\n\n").filter(Boolean).join("\n\n").value();
3121
+ return content;
3122
+ }
3106
3123
  function extractCodePlaceholders(content) {
3107
3124
  let finalContent = content;
3125
+ finalContent = ensureTrailingFenceNewline(finalContent);
3108
3126
  const codePlaceholders = {};
3109
- const codeBlockRegex = /^```.*\n([\s\S]*?)^```$/gm;
3110
- const codeBlockMatches = finalContent.matchAll(codeBlockRegex);
3127
+ const codeBlockMatches = finalContent.matchAll(indentedFenceRegex);
3111
3128
  for (const match of codeBlockMatches) {
3112
3129
  const codeBlock = match[0];
3113
3130
  const codeBlockHash = md5(codeBlock);
@@ -3159,11 +3176,11 @@ function createLocalizableMdxDocumentLoader() {
3159
3176
  }
3160
3177
 
3161
3178
  // src/cli/loaders/mdx2/sections-split-2.ts
3162
- import _20 from "lodash";
3179
+ import _21 from "lodash";
3163
3180
  function createMdxSectionsSplit2Loader() {
3164
3181
  return createLoader({
3165
3182
  async pull(locale, input2) {
3166
- const sections = _20.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
3183
+ const sections = _21.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
3167
3184
  const result = {
3168
3185
  frontmatter: input2.frontmatter,
3169
3186
  sections
@@ -3171,7 +3188,7 @@ function createMdxSectionsSplit2Loader() {
3171
3188
  return result;
3172
3189
  },
3173
3190
  async push(locale, data, originalInput, _originalLocale, pullInput) {
3174
- const content = _20.chain(data.sections).values().join("\n\n").value();
3191
+ const content = _21.chain(data.sections).values().join("\n\n").value();
3175
3192
  const result = {
3176
3193
  frontmatter: data.frontmatter,
3177
3194
  codePlaceholders: pullInput?.codePlaceholders || {},
@@ -3607,7 +3624,7 @@ async function trackEvent(distinctId, event, properties) {
3607
3624
  }
3608
3625
 
3609
3626
  // src/cli/utils/delta.ts
3610
- import _21 from "lodash";
3627
+ import _22 from "lodash";
3611
3628
  import z from "zod";
3612
3629
 
3613
3630
  // src/cli/utils/fs.ts
@@ -3656,9 +3673,9 @@ function createDeltaProcessor(fileKey) {
3656
3673
  return checkIfFileExists(lockfilePath);
3657
3674
  },
3658
3675
  async calculateDelta(params) {
3659
- let added = _21.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
3660
- let removed = _21.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
3661
- const updated = _21.filter(Object.keys(params.sourceData), (key) => {
3676
+ let added = _22.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
3677
+ let removed = _22.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
3678
+ const updated = _22.filter(Object.keys(params.sourceData), (key) => {
3662
3679
  return md5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
3663
3680
  });
3664
3681
  const renamed = [];
@@ -3707,7 +3724,7 @@ function createDeltaProcessor(fileKey) {
3707
3724
  await this.saveLock(lockfileData);
3708
3725
  },
3709
3726
  async createChecksums(sourceData) {
3710
- const checksums = _21.mapValues(sourceData, (value) => md5(value));
3727
+ const checksums = _22.mapValues(sourceData, (value) => md5(value));
3711
3728
  return checksums;
3712
3729
  }
3713
3730
  };
@@ -3939,7 +3956,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
3939
3956
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3940
3957
  const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
3941
3958
  const savedChecksums = await deltaProcessor.loadChecksums();
3942
- const updatedSourceData = _22.pickBy(
3959
+ const updatedSourceData = _23.pickBy(
3943
3960
  sourceData,
3944
3961
  (value, key) => sourceChecksums[key] !== savedChecksums[key]
3945
3962
  );
@@ -3953,15 +3970,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
3953
3970
  bucketPath.delimiter
3954
3971
  );
3955
3972
  const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
3956
- const missingKeys = _22.difference(
3973
+ const missingKeys = _23.difference(
3957
3974
  Object.keys(sourceData),
3958
3975
  Object.keys(targetData)
3959
3976
  );
3960
- const extraKeys = _22.difference(
3977
+ const extraKeys = _23.difference(
3961
3978
  Object.keys(targetData),
3962
3979
  Object.keys(sourceData)
3963
3980
  );
3964
- const unlocalizableDataDiff = !_22.isEqual(
3981
+ const unlocalizableDataDiff = !_23.isEqual(
3965
3982
  sourceUnlocalizable,
3966
3983
  targetUnlocalizable
3967
3984
  );
@@ -4041,13 +4058,13 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4041
4058
  targetData,
4042
4059
  checksums: checksums2
4043
4060
  });
4044
- let processableData = _22.chain(sourceData).entries().filter(
4061
+ let processableData = _23.chain(sourceData).entries().filter(
4045
4062
  ([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
4046
4063
  ).fromPairs().value();
4047
4064
  if (flags.key) {
4048
- processableData = _22.pickBy(
4065
+ processableData = _23.pickBy(
4049
4066
  processableData,
4050
- (_25, key) => key === flags.key
4067
+ (_26, key) => key === flags.key
4051
4068
  );
4052
4069
  }
4053
4070
  if (flags.verbose) {
@@ -4088,7 +4105,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4088
4105
  if (flags.verbose) {
4089
4106
  bucketOra.info(JSON.stringify(processedTargetData, null, 2));
4090
4107
  }
4091
- let finalTargetData = _22.merge(
4108
+ let finalTargetData = _23.merge(
4092
4109
  {},
4093
4110
  sourceData,
4094
4111
  targetData,
@@ -4109,7 +4126,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4109
4126
  `Applying changes to ${bucketPath} (${targetLocale})`
4110
4127
  );
4111
4128
  }
4112
- const finalDiffSize = _22.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
4129
+ const finalDiffSize = _23.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
4113
4130
  await bucketLoader.push(targetLocale, finalTargetData);
4114
4131
  if (finalDiffSize > 0 || flags.force) {
4115
4132
  bucketOra.succeed(
@@ -4277,7 +4294,7 @@ Reviewing changes for ${chalk.blue(args.pathPattern)} (${chalk.yellow(args.targe
4277
4294
  return args.currentData;
4278
4295
  }
4279
4296
  const customData = { ...args.currentData };
4280
- const changes = _22.reduce(
4297
+ const changes = _23.reduce(
4281
4298
  args.proposedData,
4282
4299
  (result, value, key) => {
4283
4300
  if (args.currentData[key] !== value) {
@@ -4350,7 +4367,7 @@ import path15 from "path";
4350
4367
  import Z4 from "zod";
4351
4368
  import YAML4 from "yaml";
4352
4369
  import { MD5 as MD52 } from "object-hash";
4353
- import _23 from "lodash";
4370
+ import _24 from "lodash";
4354
4371
  function createLockfileHelper() {
4355
4372
  return {
4356
4373
  isLockfileExists: () => {
@@ -4360,23 +4377,23 @@ function createLockfileHelper() {
4360
4377
  registerSourceData: (pathPattern, sourceData) => {
4361
4378
  const lockfile = _loadLockfile();
4362
4379
  const sectionKey = MD52(pathPattern);
4363
- const sectionChecksums = _23.mapValues(sourceData, (value) => MD52(value));
4380
+ const sectionChecksums = _24.mapValues(sourceData, (value) => MD52(value));
4364
4381
  lockfile.checksums[sectionKey] = sectionChecksums;
4365
4382
  _saveLockfile(lockfile);
4366
4383
  },
4367
4384
  registerPartialSourceData: (pathPattern, partialSourceData) => {
4368
4385
  const lockfile = _loadLockfile();
4369
4386
  const sectionKey = MD52(pathPattern);
4370
- const sectionChecksums = _23.mapValues(partialSourceData, (value) => MD52(value));
4371
- lockfile.checksums[sectionKey] = _23.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
4387
+ const sectionChecksums = _24.mapValues(partialSourceData, (value) => MD52(value));
4388
+ lockfile.checksums[sectionKey] = _24.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
4372
4389
  _saveLockfile(lockfile);
4373
4390
  },
4374
4391
  extractUpdatedData: (pathPattern, sourceData) => {
4375
4392
  const lockfile = _loadLockfile();
4376
4393
  const sectionKey = MD52(pathPattern);
4377
- const currentChecksums = _23.mapValues(sourceData, (value) => MD52(value));
4394
+ const currentChecksums = _24.mapValues(sourceData, (value) => MD52(value));
4378
4395
  const savedChecksums = lockfile.checksums[sectionKey] || {};
4379
- const updatedData = _23.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
4396
+ const updatedData = _24.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
4380
4397
  return updatedData;
4381
4398
  }
4382
4399
  };
@@ -4446,7 +4463,7 @@ var flagsSchema = Z5.object({
4446
4463
  // src/cli/cmd/cleanup.ts
4447
4464
  import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
4448
4465
  import { Command as Command8 } from "interactive-commander";
4449
- import _24 from "lodash";
4466
+ import _25 from "lodash";
4450
4467
  import Ora7 from "ora";
4451
4468
  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(
4452
4469
  "--verbose",
@@ -4482,7 +4499,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
4482
4499
  try {
4483
4500
  const targetData = await bucketLoader.pull(targetLocale);
4484
4501
  const targetKeys = Object.keys(targetData);
4485
- const keysToRemove = _24.difference(targetKeys, sourceKeys);
4502
+ const keysToRemove = _25.difference(targetKeys, sourceKeys);
4486
4503
  if (keysToRemove.length === 0) {
4487
4504
  bucketOra.succeed(`[${targetLocale}] No keys to remove`);
4488
4505
  continue;
@@ -4491,7 +4508,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
4491
4508
  bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
4492
4509
  }
4493
4510
  if (!options.dryRun) {
4494
- const cleanedData = _24.pick(targetData, sourceKeys);
4511
+ const cleanedData = _25.pick(targetData, sourceKeys);
4495
4512
  await bucketLoader.push(targetLocale, cleanedData);
4496
4513
  bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
4497
4514
  } else {
@@ -4546,7 +4563,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
4546
4563
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4547
4564
  import Z6 from "zod";
4548
4565
  import { ReplexicaEngine } from "@lingo.dev/_sdk";
4549
- 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 (_25, program) => {
4566
+ 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 (_26, program) => {
4550
4567
  const apiKey = program.args[0];
4551
4568
  const settings = getSettings(apiKey);
4552
4569
  if (!settings.auth.apiKey) {
@@ -5627,7 +5644,7 @@ function validateParams2(i18nConfig, flags) {
5627
5644
  // package.json
5628
5645
  var package_default = {
5629
5646
  name: "lingo.dev",
5630
- version: "0.87.1",
5647
+ version: "0.87.2",
5631
5648
  description: "Lingo.dev CLI",
5632
5649
  private: false,
5633
5650
  publishConfig: {