lingo.dev 0.78.8 → 0.78.10

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
@@ -602,9 +602,9 @@ function makeGitlabInitializer(spinner) {
602
602
 
603
603
  // src/cli/cmd/init.ts
604
604
  import open2 from "open";
605
- var openUrl = (path13) => {
605
+ var openUrl = (path14) => {
606
606
  const settings = getSettings(void 0);
607
- open2(`${settings.auth.webUrl}${path13}`, { wait: false });
607
+ open2(`${settings.auth.webUrl}${path14}`, { wait: false });
608
608
  };
609
609
  var throwHelpError = (option, value) => {
610
610
  if (value === "help") {
@@ -944,8 +944,8 @@ var files_default = new Command4().command("files").description("Print out the l
944
944
  } else if (type.target) {
945
945
  result.push(...targetPaths);
946
946
  }
947
- result.forEach((path13) => {
948
- console.log(path13);
947
+ result.forEach((path14) => {
948
+ console.log(path14);
949
949
  });
950
950
  }
951
951
  }
@@ -1513,9 +1513,9 @@ function createHtmlLoader() {
1513
1513
  const bDepth = b.split("/").length;
1514
1514
  return aDepth - bDepth;
1515
1515
  });
1516
- paths.forEach((path13) => {
1517
- const value = data[path13];
1518
- const [nodePath, attribute] = path13.split("#");
1516
+ paths.forEach((path14) => {
1517
+ const value = data[path14];
1518
+ const [nodePath, attribute] = path14.split("#");
1519
1519
  const [rootTag, ...indices] = nodePath.split("/");
1520
1520
  let parent = rootTag === "head" ? document.head : document.body;
1521
1521
  let current = parent;
@@ -1793,6 +1793,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1793
1793
  }
1794
1794
 
1795
1795
  // src/cli/loaders/prettier.ts
1796
+ import path11 from "path";
1796
1797
  import prettier from "prettier";
1797
1798
  function createPrettierLoader(options) {
1798
1799
  return createLoader({
@@ -1800,8 +1801,10 @@ function createPrettierLoader(options) {
1800
1801
  return data;
1801
1802
  },
1802
1803
  async push(locale, data) {
1803
- const prettierConfig = await loadPrettierConfig();
1804
- if (!prettierConfig && !options.alwaysFormat) {
1804
+ const draftPath = options.bucketPathPattern.replaceAll("[locale]", locale);
1805
+ const finalPath = path11.resolve(draftPath);
1806
+ const prettierConfig = await loadPrettierConfig(finalPath);
1807
+ if (!prettierConfig) {
1805
1808
  return data;
1806
1809
  }
1807
1810
  const result = prettier.format(data, {
@@ -1818,9 +1821,9 @@ function createPrettierLoader(options) {
1818
1821
  }
1819
1822
  });
1820
1823
  }
1821
- async function loadPrettierConfig() {
1824
+ async function loadPrettierConfig(filePath) {
1822
1825
  try {
1823
- const config = await prettier.resolveConfig(process.cwd());
1826
+ const config = await prettier.resolveConfig(filePath);
1824
1827
  return config;
1825
1828
  } catch (error) {
1826
1829
  return {};
@@ -2543,18 +2546,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
2543
2546
  }
2544
2547
  function serializeStructuredText(rawStructuredText) {
2545
2548
  return serializeStructuredTextNode(rawStructuredText);
2546
- function serializeStructuredTextNode(node, path13 = [], acc = {}) {
2549
+ function serializeStructuredTextNode(node, path14 = [], acc = {}) {
2547
2550
  if ("document" in node) {
2548
- return serializeStructuredTextNode(node.document, [...path13, "document"], acc);
2551
+ return serializeStructuredTextNode(node.document, [...path14, "document"], acc);
2549
2552
  }
2550
2553
  if (!_15.isNil(node.value)) {
2551
- acc[[...path13, "value"].join(".")] = node.value;
2554
+ acc[[...path14, "value"].join(".")] = node.value;
2552
2555
  } else if (_15.get(node, "type") === "block") {
2553
- acc[[...path13, "item"].join(".")] = serializeBlock(node.item);
2556
+ acc[[...path14, "item"].join(".")] = serializeBlock(node.item);
2554
2557
  }
2555
2558
  if (node.children) {
2556
2559
  for (let i = 0; i < node.children.length; i++) {
2557
- serializeStructuredTextNode(node.children[i], [...path13, i.toString()], acc);
2560
+ serializeStructuredTextNode(node.children[i], [...path14, i.toString()], acc);
2558
2561
  }
2559
2562
  }
2560
2563
  return acc;
@@ -2613,8 +2616,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
2613
2616
  }
2614
2617
  function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
2615
2618
  const result = _15.cloneDeep(originalRawStructuredText);
2616
- for (const [path13, value] of _15.entries(parsedStructuredText)) {
2617
- const realPath = _15.chain(path13.split(".")).flatMap((s) => !_15.isNaN(_15.toNumber(s)) ? ["children", s] : s).value();
2619
+ for (const [path14, value] of _15.entries(parsedStructuredText)) {
2620
+ const realPath = _15.chain(path14.split(".")).flatMap((s) => !_15.isNaN(_15.toNumber(s)) ? ["children", s] : s).value();
2618
2621
  const deserializedValue = createRawDatoValue(value, _15.get(originalRawStructuredText, realPath), true);
2619
2622
  _15.set(result, realPath, deserializedValue);
2620
2623
  }
@@ -2959,7 +2962,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
2959
2962
  case "html":
2960
2963
  return composeLoaders(
2961
2964
  createTextFileLoader(bucketPathPattern),
2962
- createPrettierLoader({ parser: "html", alwaysFormat: true }),
2965
+ createPrettierLoader({ parser: "html", bucketPathPattern }),
2963
2966
  createHtmlLoader(),
2964
2967
  createSyncLoader(),
2965
2968
  createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
@@ -2967,7 +2970,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
2967
2970
  case "json":
2968
2971
  return composeLoaders(
2969
2972
  createTextFileLoader(bucketPathPattern),
2970
- createPrettierLoader({ parser: "json" }),
2973
+ createPrettierLoader({ parser: "json", bucketPathPattern }),
2971
2974
  createJsonLoader(),
2972
2975
  createFlatLoader(),
2973
2976
  createSyncLoader(),
@@ -2976,7 +2979,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
2976
2979
  case "markdown":
2977
2980
  return composeLoaders(
2978
2981
  createTextFileLoader(bucketPathPattern),
2979
- createPrettierLoader({ parser: "markdown" }),
2982
+ createPrettierLoader({ parser: "markdown", bucketPathPattern }),
2980
2983
  createMarkdownLoader(),
2981
2984
  createSyncLoader(),
2982
2985
  createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
@@ -3026,7 +3029,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
3026
3029
  case "yaml":
3027
3030
  return composeLoaders(
3028
3031
  createTextFileLoader(bucketPathPattern),
3029
- createPrettierLoader({ parser: "yaml" }),
3032
+ createPrettierLoader({ parser: "yaml", bucketPathPattern }),
3030
3033
  createYamlLoader(),
3031
3034
  createFlatLoader(),
3032
3035
  createSyncLoader(),
@@ -3035,7 +3038,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
3035
3038
  case "yaml-root-key":
3036
3039
  return composeLoaders(
3037
3040
  createTextFileLoader(bucketPathPattern),
3038
- createPrettierLoader({ parser: "yaml" }),
3041
+ createPrettierLoader({ parser: "yaml", bucketPathPattern }),
3039
3042
  createYamlLoader(),
3040
3043
  createRootKeyLoader(true),
3041
3044
  createFlatLoader(),
@@ -3045,7 +3048,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
3045
3048
  case "flutter":
3046
3049
  return composeLoaders(
3047
3050
  createTextFileLoader(bucketPathPattern),
3048
- createPrettierLoader({ parser: "json" }),
3051
+ createPrettierLoader({ parser: "json", bucketPathPattern }),
3049
3052
  createJsonLoader(),
3050
3053
  createFlutterLoader(),
3051
3054
  createFlatLoader(),
@@ -3110,7 +3113,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
3110
3113
 
3111
3114
  // src/cli/utils/lockfile.ts
3112
3115
  import fs10 from "fs";
3113
- import path11 from "path";
3116
+ import path12 from "path";
3114
3117
  import Z3 from "zod";
3115
3118
  import YAML3 from "yaml";
3116
3119
  import { MD5 } from "object-hash";
@@ -3159,7 +3162,7 @@ function createLockfileHelper() {
3159
3162
  fs10.writeFileSync(lockfilePath, content);
3160
3163
  }
3161
3164
  function _getLockfilePath() {
3162
- return path11.join(process.cwd(), "i18n.lock");
3165
+ return path12.join(process.cwd(), "i18n.lock");
3163
3166
  }
3164
3167
  }
3165
3168
  var LockfileSchema = Z3.object({
@@ -3184,7 +3187,7 @@ import inquirer2 from "inquirer";
3184
3187
  import externalEditor from "external-editor";
3185
3188
 
3186
3189
  // src/cli/utils/cache.ts
3187
- import path12 from "path";
3190
+ import path13 from "path";
3188
3191
  import fs11 from "fs";
3189
3192
  var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
3190
3193
  const rows = Object.entries(sourceChunk).map(([key, source]) => ({
@@ -3234,7 +3237,7 @@ function _appendToCache(rows) {
3234
3237
  fs11.appendFileSync(cacheFilePath, lines);
3235
3238
  }
3236
3239
  function _getCacheFilePath() {
3237
- return path12.join(process.cwd(), "i18n.cache");
3240
+ return path13.join(process.cwd(), "i18n.cache");
3238
3241
  }
3239
3242
  function _buildJSONLines(rows) {
3240
3243
  return rows.map((row) => JSON.stringify(row)).join("\n") + "\n";
@@ -3896,7 +3899,7 @@ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model
3896
3899
  // package.json
3897
3900
  var package_default = {
3898
3901
  name: "lingo.dev",
3899
- version: "0.78.8",
3902
+ version: "0.78.10",
3900
3903
  description: "Lingo.dev CLI",
3901
3904
  private: false,
3902
3905
  publishConfig: {