lingo.dev 0.92.12 → 0.92.13

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
@@ -621,9 +621,9 @@ function makeGitlabInitializer(spinner) {
621
621
 
622
622
  // src/cli/cmd/init.ts
623
623
  import open2 from "open";
624
- var openUrl = (path17) => {
624
+ var openUrl = (path16) => {
625
625
  const settings = getSettings(void 0);
626
- open2(`${settings.auth.webUrl}${path17}`, { wait: false });
626
+ open2(`${settings.auth.webUrl}${path16}`, { wait: false });
627
627
  };
628
628
  var throwHelpError = (option, value) => {
629
629
  if (value === "help") {
@@ -997,8 +997,8 @@ var files_default = new Command4().command("files").description("Print out the l
997
997
  } else if (type.target) {
998
998
  result.push(...targetPaths);
999
999
  }
1000
- result.forEach((path17) => {
1001
- console.log(path17);
1000
+ result.forEach((path16) => {
1001
+ console.log(path16);
1002
1002
  });
1003
1003
  }
1004
1004
  }
@@ -1026,7 +1026,6 @@ import {
1026
1026
  import { Command as Command6 } from "interactive-commander";
1027
1027
  import Z3 from "zod";
1028
1028
  import _25 from "lodash";
1029
- import * as path14 from "path";
1030
1029
  import Ora5 from "ora";
1031
1030
 
1032
1031
  // src/cli/loaders/_utils.ts
@@ -1674,9 +1673,9 @@ function createHtmlLoader() {
1674
1673
  const bDepth = b.split("/").length;
1675
1674
  return aDepth - bDepth;
1676
1675
  });
1677
- paths.forEach((path17) => {
1678
- const value = data[path17];
1679
- const [nodePath, attribute] = path17.split("#");
1676
+ paths.forEach((path16) => {
1677
+ const value = data[path16];
1678
+ const [nodePath, attribute] = path16.split("#");
1680
1679
  const [rootTag, ...indices] = nodePath.split("/");
1681
1680
  let parent = rootTag === "head" ? document.head : document.body;
1682
1681
  let current = parent;
@@ -2766,18 +2765,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
2766
2765
  }
2767
2766
  function serializeStructuredText(rawStructuredText) {
2768
2767
  return serializeStructuredTextNode(rawStructuredText);
2769
- function serializeStructuredTextNode(node, path17 = [], acc = {}) {
2768
+ function serializeStructuredTextNode(node, path16 = [], acc = {}) {
2770
2769
  if ("document" in node) {
2771
- return serializeStructuredTextNode(node.document, [...path17, "document"], acc);
2770
+ return serializeStructuredTextNode(node.document, [...path16, "document"], acc);
2772
2771
  }
2773
2772
  if (!_15.isNil(node.value)) {
2774
- acc[[...path17, "value"].join(".")] = node.value;
2773
+ acc[[...path16, "value"].join(".")] = node.value;
2775
2774
  } else if (_15.get(node, "type") === "block") {
2776
- acc[[...path17, "item"].join(".")] = serializeBlock(node.item);
2775
+ acc[[...path16, "item"].join(".")] = serializeBlock(node.item);
2777
2776
  }
2778
2777
  if (node.children) {
2779
2778
  for (let i = 0; i < node.children.length; i++) {
2780
- serializeStructuredTextNode(node.children[i], [...path17, i.toString()], acc);
2779
+ serializeStructuredTextNode(node.children[i], [...path16, i.toString()], acc);
2781
2780
  }
2782
2781
  }
2783
2782
  return acc;
@@ -2836,8 +2835,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
2836
2835
  }
2837
2836
  function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
2838
2837
  const result = _15.cloneDeep(originalRawStructuredText);
2839
- for (const [path17, value] of _15.entries(parsedStructuredText)) {
2840
- const realPath = _15.chain(path17.split(".")).flatMap((s) => !_15.isNaN(_15.toNumber(s)) ? ["children", s] : s).value();
2838
+ for (const [path16, value] of _15.entries(parsedStructuredText)) {
2839
+ const realPath = _15.chain(path16.split(".")).flatMap((s) => !_15.isNaN(_15.toNumber(s)) ? ["children", s] : s).value();
2841
2840
  const deserializedValue = createRawDatoValue(value, _15.get(originalRawStructuredText, realPath), true);
2842
2841
  _15.set(result, realPath, deserializedValue);
2843
2842
  }
@@ -3219,15 +3218,15 @@ function parseTypeScript(input2) {
3219
3218
  function extractStringsFromDefaultExport(ast) {
3220
3219
  let extracted = {};
3221
3220
  traverse(ast, {
3222
- ExportDefaultDeclaration(path17) {
3223
- const { declaration } = path17.node;
3221
+ ExportDefaultDeclaration(path16) {
3222
+ const { declaration } = path16.node;
3224
3223
  const decl = unwrapTSAsExpression(declaration);
3225
3224
  if (t.isObjectExpression(decl)) {
3226
3225
  extracted = objectExpressionToObject(decl);
3227
3226
  } else if (t.isArrayExpression(decl)) {
3228
3227
  extracted = arrayExpressionToArray(decl);
3229
3228
  } else if (t.isIdentifier(decl)) {
3230
- const binding = path17.scope.bindings[decl.name];
3229
+ const binding = path16.scope.bindings[decl.name];
3231
3230
  if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
3232
3231
  const initRaw = binding.path.node.init;
3233
3232
  const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
@@ -3292,8 +3291,8 @@ function arrayExpressionToArray(arrayExpression) {
3292
3291
  function updateStringsInDefaultExport(ast, data) {
3293
3292
  let modified = false;
3294
3293
  traverse(ast, {
3295
- ExportDefaultDeclaration(path17) {
3296
- const { declaration } = path17.node;
3294
+ ExportDefaultDeclaration(path16) {
3295
+ const { declaration } = path16.node;
3297
3296
  const decl = unwrapTSAsExpression(declaration);
3298
3297
  if (t.isObjectExpression(decl)) {
3299
3298
  modified = updateStringsInObjectExpression(decl, data) || modified;
@@ -3302,7 +3301,7 @@ function updateStringsInDefaultExport(ast, data) {
3302
3301
  modified = updateStringsInArrayExpression(decl, data) || modified;
3303
3302
  }
3304
3303
  } else if (t.isIdentifier(decl)) {
3305
- modified = updateStringsInExportedIdentifier(path17, data) || modified;
3304
+ modified = updateStringsInExportedIdentifier(path16, data) || modified;
3306
3305
  }
3307
3306
  }
3308
3307
  });
@@ -3373,9 +3372,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
3373
3372
  });
3374
3373
  return modified;
3375
3374
  }
3376
- function updateStringsInExportedIdentifier(path17, data) {
3377
- const exportName = path17.node.declaration.name;
3378
- const binding = path17.scope.bindings[exportName];
3375
+ function updateStringsInExportedIdentifier(path16, data) {
3376
+ const exportName = path16.node.declaration.name;
3377
+ const binding = path16.scope.bindings[exportName];
3379
3378
  if (!binding || !binding.path.node) return false;
3380
3379
  if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
3381
3380
  const initRaw = binding.path.node.init;
@@ -4286,7 +4285,6 @@ function createDeltaProcessor(fileKey) {
4286
4285
  }
4287
4286
 
4288
4287
  // src/cli/cmd/i18n.ts
4289
- import { flatten as flatten2, unflatten as unflatten2 } from "flat";
4290
4288
  var i18n_default = new Command6().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
4291
4289
  "--locale <locale>",
4292
4290
  "Locale to process",
@@ -4369,7 +4367,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4369
4367
  if (flags.file?.length) {
4370
4368
  buckets = buckets.map((bucket) => {
4371
4369
  const paths = bucket.paths.filter(
4372
- (path17) => flags.file.find((file) => path17.pathPattern?.includes(file))
4370
+ (path16) => flags.file.find((file) => path16.pathPattern?.includes(file))
4373
4371
  );
4374
4372
  return { ...bucket, paths };
4375
4373
  }).filter((bucket) => bucket.paths.length > 0);
@@ -4382,8 +4380,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4382
4380
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
4383
4381
  buckets.map((bucket) => {
4384
4382
  ora.info(` ${bucket.type}:`);
4385
- bucket.paths.forEach((path17) => {
4386
- ora.info(` - ${path17.pathPattern}`);
4383
+ bucket.paths.forEach((path16) => {
4384
+ ora.info(` - ${path16.pathPattern}`);
4387
4385
  });
4388
4386
  });
4389
4387
  }
@@ -4426,73 +4424,6 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4426
4424
  } else {
4427
4425
  ora.succeed("Localization cache loaded");
4428
4426
  }
4429
- for (const bucket of buckets) {
4430
- if (bucket.type !== "json") {
4431
- continue;
4432
- }
4433
- ora.start("Validating localization state...");
4434
- for (const bucketPath of bucket.paths) {
4435
- const sourceLocale = resolveOverriddenLocale3(
4436
- i18nConfig.locale.source,
4437
- bucketPath.delimiter
4438
- );
4439
- const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
4440
- const sourcePath = path14.join(
4441
- process.cwd(),
4442
- bucketPath.pathPattern.replace("[locale]", sourceLocale)
4443
- );
4444
- const sourceContent = tryReadFile(sourcePath, null);
4445
- const sourceData = JSON.parse(sourceContent || "{}");
4446
- const sourceFlattenedData = flatten2(sourceData, {
4447
- delimiter: "/",
4448
- transformKey(key) {
4449
- return encodeURIComponent(key);
4450
- }
4451
- });
4452
- for (const _targetLocale of targetLocales) {
4453
- const targetLocale = resolveOverriddenLocale3(
4454
- _targetLocale,
4455
- bucketPath.delimiter
4456
- );
4457
- const targetPath = path14.join(
4458
- process.cwd(),
4459
- bucketPath.pathPattern.replace("[locale]", targetLocale)
4460
- );
4461
- const targetContent = tryReadFile(targetPath, null);
4462
- const targetData = JSON.parse(targetContent || "{}");
4463
- const targetFlattenedData = flatten2(targetData, {
4464
- delimiter: "/",
4465
- transformKey(key) {
4466
- return encodeURIComponent(key);
4467
- }
4468
- });
4469
- const checksums = await deltaProcessor.loadChecksums();
4470
- const delta = await deltaProcessor.calculateDelta({
4471
- sourceData: sourceFlattenedData,
4472
- targetData: targetFlattenedData,
4473
- checksums
4474
- });
4475
- if (!delta.hasChanges) {
4476
- continue;
4477
- }
4478
- for (const [oldKey, newKey] of delta.renamed) {
4479
- targetFlattenedData[newKey] = targetFlattenedData[oldKey];
4480
- delete targetFlattenedData[oldKey];
4481
- }
4482
- const updatedTargetData = unflatten2(targetFlattenedData, {
4483
- delimiter: "/",
4484
- transformKey(key) {
4485
- return decodeURIComponent(key);
4486
- }
4487
- });
4488
- await writeFile(
4489
- targetPath,
4490
- JSON.stringify(updatedTargetData, null, 2)
4491
- );
4492
- }
4493
- }
4494
- ora.succeed("Localization state check completed");
4495
- }
4496
4427
  if (flags.frozen) {
4497
4428
  ora.start("Checking for lockfile updates...");
4498
4429
  let requiresUpdate = null;
@@ -4668,6 +4599,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4668
4599
  targetData,
4669
4600
  processedTargetData
4670
4601
  );
4602
+ finalTargetData = _25.chain(finalTargetData).entries().map(([key, value]) => {
4603
+ const renaming = delta.renamed.find(
4604
+ ([oldKey, newKey]) => oldKey === key
4605
+ );
4606
+ if (!renaming) {
4607
+ return [key, value];
4608
+ }
4609
+ return [renaming[1], value];
4610
+ }).fromPairs().value();
4671
4611
  if (flags.interactive) {
4672
4612
  bucketOra.stop();
4673
4613
  const reviewedData = await reviewChanges({
@@ -4923,7 +4863,7 @@ import Ora6 from "ora";
4923
4863
 
4924
4864
  // src/cli/utils/lockfile.ts
4925
4865
  import fs11 from "fs";
4926
- import path15 from "path";
4866
+ import path14 from "path";
4927
4867
  import Z4 from "zod";
4928
4868
  import YAML5 from "yaml";
4929
4869
  import { MD5 as MD52 } from "object-hash";
@@ -4972,7 +4912,7 @@ function createLockfileHelper() {
4972
4912
  fs11.writeFileSync(lockfilePath, content);
4973
4913
  }
4974
4914
  function _getLockfilePath() {
4975
- return path15.join(process.cwd(), "i18n.lock");
4915
+ return path14.join(process.cwd(), "i18n.lock");
4976
4916
  }
4977
4917
  }
4978
4918
  var LockfileSchema = Z4.object({
@@ -5179,7 +5119,7 @@ import { execSync as execSync2 } from "child_process";
5179
5119
 
5180
5120
  // src/cli/cmd/ci/flows/in-branch.ts
5181
5121
  import { execSync } from "child_process";
5182
- import path16 from "path";
5122
+ import path15 from "path";
5183
5123
 
5184
5124
  // src/cli/cmd/ci/flows/_base.ts
5185
5125
  var IntegrationFlow = class {
@@ -5275,7 +5215,7 @@ var InBranchFlow = class extends IntegrationFlow {
5275
5215
  return false;
5276
5216
  }
5277
5217
  }
5278
- const workingDir = path16.resolve(
5218
+ const workingDir = path15.resolve(
5279
5219
  process.cwd(),
5280
5220
  this.platformKit.config.workingDir
5281
5221
  );
@@ -5932,7 +5872,7 @@ var status_default = new Command11().command("status").description("Show the sta
5932
5872
  ora.succeed("Buckets retrieved");
5933
5873
  if (flags.file?.length) {
5934
5874
  buckets = buckets.map((bucket) => {
5935
- const paths = bucket.paths.filter((path17) => flags.file.find((file) => path17.pathPattern?.match(file)));
5875
+ const paths = bucket.paths.filter((path16) => flags.file.find((file) => path16.pathPattern?.match(file)));
5936
5876
  return { ...bucket, paths };
5937
5877
  }).filter((bucket) => bucket.paths.length > 0);
5938
5878
  if (buckets.length === 0) {
@@ -5942,8 +5882,8 @@ var status_default = new Command11().command("status").description("Show the sta
5942
5882
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
5943
5883
  buckets.map((bucket) => {
5944
5884
  ora.info(` ${bucket.type}:`);
5945
- bucket.paths.forEach((path17) => {
5946
- ora.info(` - ${path17.pathPattern}`);
5885
+ bucket.paths.forEach((path16) => {
5886
+ ora.info(` - ${path16.pathPattern}`);
5947
5887
  });
5948
5888
  });
5949
5889
  }
@@ -6172,10 +6112,10 @@ var status_default = new Command11().command("status").description("Show the sta
6172
6112
  if (flags.confirm && Object.keys(fileStats).length > 0) {
6173
6113
  console.log(chalk3.bold(`
6174
6114
  \u{1F4D1} BREAKDOWN BY FILE:`));
6175
- Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path17, stats]) => {
6115
+ Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path16, stats]) => {
6176
6116
  if (stats.sourceKeys === 0) return;
6177
6117
  console.log(chalk3.bold(`
6178
- \u2022 ${path17}:`));
6118
+ \u2022 ${path16}:`));
6179
6119
  console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
6180
6120
  const fileTable = new Table({
6181
6121
  head: ["Language", "Status", "Details"],
@@ -6377,7 +6317,7 @@ async function renderHero() {
6377
6317
  // package.json
6378
6318
  var package_default = {
6379
6319
  name: "lingo.dev",
6380
- version: "0.92.12",
6320
+ version: "0.92.13",
6381
6321
  description: "Lingo.dev CLI",
6382
6322
  private: false,
6383
6323
  publishConfig: {
@@ -7096,12 +7036,21 @@ function createWorkerTask(args) {
7096
7036
  });
7097
7037
  }
7098
7038
  );
7099
- const finalTargetData = _28.merge(
7039
+ let finalTargetData = _28.merge(
7100
7040
  {},
7101
7041
  sourceData,
7102
7042
  targetData,
7103
7043
  processedTargetData
7104
7044
  );
7045
+ finalTargetData = _28.chain(finalTargetData).entries().map(([key, value]) => {
7046
+ const renaming = delta.renamed.find(
7047
+ ([oldKey]) => oldKey === key
7048
+ );
7049
+ if (!renaming) {
7050
+ return [key, value];
7051
+ }
7052
+ return [renaming[1], value];
7053
+ }).fromPairs().value();
7105
7054
  await args.ioLimiter(async () => {
7106
7055
  await bucketLoader.pull(assignedTask.sourceLocale);
7107
7056
  await bucketLoader.push(