lingo.dev 0.87.1 → 0.87.3

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