lingo.dev 0.92.11 → 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
  }
@@ -2963,8 +2962,10 @@ function variableContentLoader() {
2963
2962
  const result = _16.mapValues(input2, (payload) => payload.value);
2964
2963
  return result;
2965
2964
  },
2966
- push: async (locale, data, originalInput) => {
2967
- const result = _16.cloneDeep(originalInput || {});
2965
+ push: async (locale, data, originalInput, defaultLocale, pullInput) => {
2966
+ const result = _16.cloneDeep(
2967
+ pullInput || {}
2968
+ );
2968
2969
  for (const [key, originalValueObj] of Object.entries(result)) {
2969
2970
  result[key] = {
2970
2971
  ...originalValueObj,
@@ -3217,15 +3218,15 @@ function parseTypeScript(input2) {
3217
3218
  function extractStringsFromDefaultExport(ast) {
3218
3219
  let extracted = {};
3219
3220
  traverse(ast, {
3220
- ExportDefaultDeclaration(path17) {
3221
- const { declaration } = path17.node;
3221
+ ExportDefaultDeclaration(path16) {
3222
+ const { declaration } = path16.node;
3222
3223
  const decl = unwrapTSAsExpression(declaration);
3223
3224
  if (t.isObjectExpression(decl)) {
3224
3225
  extracted = objectExpressionToObject(decl);
3225
3226
  } else if (t.isArrayExpression(decl)) {
3226
3227
  extracted = arrayExpressionToArray(decl);
3227
3228
  } else if (t.isIdentifier(decl)) {
3228
- const binding = path17.scope.bindings[decl.name];
3229
+ const binding = path16.scope.bindings[decl.name];
3229
3230
  if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
3230
3231
  const initRaw = binding.path.node.init;
3231
3232
  const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
@@ -3290,8 +3291,8 @@ function arrayExpressionToArray(arrayExpression) {
3290
3291
  function updateStringsInDefaultExport(ast, data) {
3291
3292
  let modified = false;
3292
3293
  traverse(ast, {
3293
- ExportDefaultDeclaration(path17) {
3294
- const { declaration } = path17.node;
3294
+ ExportDefaultDeclaration(path16) {
3295
+ const { declaration } = path16.node;
3295
3296
  const decl = unwrapTSAsExpression(declaration);
3296
3297
  if (t.isObjectExpression(decl)) {
3297
3298
  modified = updateStringsInObjectExpression(decl, data) || modified;
@@ -3300,7 +3301,7 @@ function updateStringsInDefaultExport(ast, data) {
3300
3301
  modified = updateStringsInArrayExpression(decl, data) || modified;
3301
3302
  }
3302
3303
  } else if (t.isIdentifier(decl)) {
3303
- modified = updateStringsInExportedIdentifier(path17, data) || modified;
3304
+ modified = updateStringsInExportedIdentifier(path16, data) || modified;
3304
3305
  }
3305
3306
  }
3306
3307
  });
@@ -3371,9 +3372,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
3371
3372
  });
3372
3373
  return modified;
3373
3374
  }
3374
- function updateStringsInExportedIdentifier(path17, data) {
3375
- const exportName = path17.node.declaration.name;
3376
- 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];
3377
3378
  if (!binding || !binding.path.node) return false;
3378
3379
  if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
3379
3380
  const initRaw = binding.path.node.init;
@@ -4284,7 +4285,6 @@ function createDeltaProcessor(fileKey) {
4284
4285
  }
4285
4286
 
4286
4287
  // src/cli/cmd/i18n.ts
4287
- import { flatten as flatten2, unflatten as unflatten2 } from "flat";
4288
4288
  var i18n_default = new Command6().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
4289
4289
  "--locale <locale>",
4290
4290
  "Locale to process",
@@ -4367,7 +4367,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4367
4367
  if (flags.file?.length) {
4368
4368
  buckets = buckets.map((bucket) => {
4369
4369
  const paths = bucket.paths.filter(
4370
- (path17) => flags.file.find((file) => path17.pathPattern?.includes(file))
4370
+ (path16) => flags.file.find((file) => path16.pathPattern?.includes(file))
4371
4371
  );
4372
4372
  return { ...bucket, paths };
4373
4373
  }).filter((bucket) => bucket.paths.length > 0);
@@ -4380,8 +4380,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4380
4380
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
4381
4381
  buckets.map((bucket) => {
4382
4382
  ora.info(` ${bucket.type}:`);
4383
- bucket.paths.forEach((path17) => {
4384
- ora.info(` - ${path17.pathPattern}`);
4383
+ bucket.paths.forEach((path16) => {
4384
+ ora.info(` - ${path16.pathPattern}`);
4385
4385
  });
4386
4386
  });
4387
4387
  }
@@ -4424,73 +4424,6 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4424
4424
  } else {
4425
4425
  ora.succeed("Localization cache loaded");
4426
4426
  }
4427
- for (const bucket of buckets) {
4428
- if (bucket.type !== "json") {
4429
- continue;
4430
- }
4431
- ora.start("Validating localization state...");
4432
- for (const bucketPath of bucket.paths) {
4433
- const sourceLocale = resolveOverriddenLocale3(
4434
- i18nConfig.locale.source,
4435
- bucketPath.delimiter
4436
- );
4437
- const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
4438
- const sourcePath = path14.join(
4439
- process.cwd(),
4440
- bucketPath.pathPattern.replace("[locale]", sourceLocale)
4441
- );
4442
- const sourceContent = tryReadFile(sourcePath, null);
4443
- const sourceData = JSON.parse(sourceContent || "{}");
4444
- const sourceFlattenedData = flatten2(sourceData, {
4445
- delimiter: "/",
4446
- transformKey(key) {
4447
- return encodeURIComponent(key);
4448
- }
4449
- });
4450
- for (const _targetLocale of targetLocales) {
4451
- const targetLocale = resolveOverriddenLocale3(
4452
- _targetLocale,
4453
- bucketPath.delimiter
4454
- );
4455
- const targetPath = path14.join(
4456
- process.cwd(),
4457
- bucketPath.pathPattern.replace("[locale]", targetLocale)
4458
- );
4459
- const targetContent = tryReadFile(targetPath, null);
4460
- const targetData = JSON.parse(targetContent || "{}");
4461
- const targetFlattenedData = flatten2(targetData, {
4462
- delimiter: "/",
4463
- transformKey(key) {
4464
- return encodeURIComponent(key);
4465
- }
4466
- });
4467
- const checksums = await deltaProcessor.loadChecksums();
4468
- const delta = await deltaProcessor.calculateDelta({
4469
- sourceData: sourceFlattenedData,
4470
- targetData: targetFlattenedData,
4471
- checksums
4472
- });
4473
- if (!delta.hasChanges) {
4474
- continue;
4475
- }
4476
- for (const [oldKey, newKey] of delta.renamed) {
4477
- targetFlattenedData[newKey] = targetFlattenedData[oldKey];
4478
- delete targetFlattenedData[oldKey];
4479
- }
4480
- const updatedTargetData = unflatten2(targetFlattenedData, {
4481
- delimiter: "/",
4482
- transformKey(key) {
4483
- return decodeURIComponent(key);
4484
- }
4485
- });
4486
- await writeFile(
4487
- targetPath,
4488
- JSON.stringify(updatedTargetData, null, 2)
4489
- );
4490
- }
4491
- }
4492
- ora.succeed("Localization state check completed");
4493
- }
4494
4427
  if (flags.frozen) {
4495
4428
  ora.start("Checking for lockfile updates...");
4496
4429
  let requiresUpdate = null;
@@ -4666,6 +4599,15 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
4666
4599
  targetData,
4667
4600
  processedTargetData
4668
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();
4669
4611
  if (flags.interactive) {
4670
4612
  bucketOra.stop();
4671
4613
  const reviewedData = await reviewChanges({
@@ -4921,7 +4863,7 @@ import Ora6 from "ora";
4921
4863
 
4922
4864
  // src/cli/utils/lockfile.ts
4923
4865
  import fs11 from "fs";
4924
- import path15 from "path";
4866
+ import path14 from "path";
4925
4867
  import Z4 from "zod";
4926
4868
  import YAML5 from "yaml";
4927
4869
  import { MD5 as MD52 } from "object-hash";
@@ -4970,7 +4912,7 @@ function createLockfileHelper() {
4970
4912
  fs11.writeFileSync(lockfilePath, content);
4971
4913
  }
4972
4914
  function _getLockfilePath() {
4973
- return path15.join(process.cwd(), "i18n.lock");
4915
+ return path14.join(process.cwd(), "i18n.lock");
4974
4916
  }
4975
4917
  }
4976
4918
  var LockfileSchema = Z4.object({
@@ -5177,7 +5119,7 @@ import { execSync as execSync2 } from "child_process";
5177
5119
 
5178
5120
  // src/cli/cmd/ci/flows/in-branch.ts
5179
5121
  import { execSync } from "child_process";
5180
- import path16 from "path";
5122
+ import path15 from "path";
5181
5123
 
5182
5124
  // src/cli/cmd/ci/flows/_base.ts
5183
5125
  var IntegrationFlow = class {
@@ -5273,7 +5215,7 @@ var InBranchFlow = class extends IntegrationFlow {
5273
5215
  return false;
5274
5216
  }
5275
5217
  }
5276
- const workingDir = path16.resolve(
5218
+ const workingDir = path15.resolve(
5277
5219
  process.cwd(),
5278
5220
  this.platformKit.config.workingDir
5279
5221
  );
@@ -5930,7 +5872,7 @@ var status_default = new Command11().command("status").description("Show the sta
5930
5872
  ora.succeed("Buckets retrieved");
5931
5873
  if (flags.file?.length) {
5932
5874
  buckets = buckets.map((bucket) => {
5933
- 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)));
5934
5876
  return { ...bucket, paths };
5935
5877
  }).filter((bucket) => bucket.paths.length > 0);
5936
5878
  if (buckets.length === 0) {
@@ -5940,8 +5882,8 @@ var status_default = new Command11().command("status").description("Show the sta
5940
5882
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
5941
5883
  buckets.map((bucket) => {
5942
5884
  ora.info(` ${bucket.type}:`);
5943
- bucket.paths.forEach((path17) => {
5944
- ora.info(` - ${path17.pathPattern}`);
5885
+ bucket.paths.forEach((path16) => {
5886
+ ora.info(` - ${path16.pathPattern}`);
5945
5887
  });
5946
5888
  });
5947
5889
  }
@@ -6170,10 +6112,10 @@ var status_default = new Command11().command("status").description("Show the sta
6170
6112
  if (flags.confirm && Object.keys(fileStats).length > 0) {
6171
6113
  console.log(chalk3.bold(`
6172
6114
  \u{1F4D1} BREAKDOWN BY FILE:`));
6173
- 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]) => {
6174
6116
  if (stats.sourceKeys === 0) return;
6175
6117
  console.log(chalk3.bold(`
6176
- \u2022 ${path17}:`));
6118
+ \u2022 ${path16}:`));
6177
6119
  console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
6178
6120
  const fileTable = new Table({
6179
6121
  head: ["Language", "Status", "Details"],
@@ -6375,7 +6317,7 @@ async function renderHero() {
6375
6317
  // package.json
6376
6318
  var package_default = {
6377
6319
  name: "lingo.dev",
6378
- version: "0.92.11",
6320
+ version: "0.92.13",
6379
6321
  description: "Lingo.dev CLI",
6380
6322
  private: false,
6381
6323
  publishConfig: {
@@ -7094,12 +7036,21 @@ function createWorkerTask(args) {
7094
7036
  });
7095
7037
  }
7096
7038
  );
7097
- const finalTargetData = _28.merge(
7039
+ let finalTargetData = _28.merge(
7098
7040
  {},
7099
7041
  sourceData,
7100
7042
  targetData,
7101
7043
  processedTargetData
7102
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();
7103
7054
  await args.ioLimiter(async () => {
7104
7055
  await bucketLoader.pull(assignedTask.sourceLocale);
7105
7056
  await bucketLoader.push(