lingo.dev 0.78.12 → 0.78.14

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
@@ -1810,8 +1810,10 @@ function createXcodeXcstringsLoader(defaultLocale) {
1810
1810
  }
1811
1811
 
1812
1812
  // src/cli/loaders/prettier.ts
1813
+ import fs9 from "fs";
1813
1814
  import path11 from "path";
1814
1815
  import prettier from "prettier";
1816
+ import { execSync } from "child_process";
1815
1817
  function createPrettierLoader(options) {
1816
1818
  return createLoader({
1817
1819
  async pull(locale, data) {
@@ -1824,7 +1826,7 @@ function createPrettierLoader(options) {
1824
1826
  if (!prettierConfig) {
1825
1827
  return data;
1826
1828
  }
1827
- const result = prettier.format(data, {
1829
+ const config = {
1828
1830
  ...prettierConfig || { printWidth: 2500, bracketSameLine: false },
1829
1831
  parser: options.parser,
1830
1832
  // For HTML parser, preserve comments and quotes
@@ -1833,8 +1835,22 @@ function createPrettierLoader(options) {
1833
1835
  singleQuote: false,
1834
1836
  embeddedLanguageFormatting: "off"
1835
1837
  } : {}
1836
- });
1837
- return result;
1838
+ };
1839
+ try {
1840
+ const result = await prettier.format(data, config);
1841
+ return result;
1842
+ } catch (error) {
1843
+ if (error instanceof Error && error.message.startsWith("Cannot find package")) {
1844
+ console.log();
1845
+ console.log("Prettier is missing some dependecies - installing all project dependencies");
1846
+ installDependencies();
1847
+ await prettier.clearConfigCache();
1848
+ const result = await prettier.format(data, config);
1849
+ return result;
1850
+ } else {
1851
+ throw error;
1852
+ }
1853
+ }
1838
1854
  }
1839
1855
  });
1840
1856
  }
@@ -1846,6 +1862,23 @@ async function loadPrettierConfig(filePath) {
1846
1862
  return {};
1847
1863
  }
1848
1864
  }
1865
+ async function installDependencies() {
1866
+ const packageManager = await getPackageManager();
1867
+ console.log(`Installing dependencies using ${packageManager}`);
1868
+ execSync(`${packageManager} install --frozen-lockfile`, { stdio: "inherit" });
1869
+ console.log(`Dependencies installed`);
1870
+ }
1871
+ async function getPackageManager() {
1872
+ const yarnLockfile = path11.resolve(process.cwd(), "yarn.lock");
1873
+ const pnpmLockfile = path11.resolve(process.cwd(), "pnpm-lock.yaml");
1874
+ if (fs9.existsSync(yarnLockfile)) {
1875
+ return "yarn";
1876
+ }
1877
+ if (fs9.existsSync(pnpmLockfile)) {
1878
+ return "pnpm";
1879
+ }
1880
+ return "npm";
1881
+ }
1849
1882
 
1850
1883
  // src/cli/loaders/unlocalizable.ts
1851
1884
  import _10 from "lodash";
@@ -2060,7 +2093,7 @@ function createSrtLoader() {
2060
2093
  }
2061
2094
 
2062
2095
  // src/cli/loaders/dato/index.ts
2063
- import fs9 from "fs";
2096
+ import fs10 from "fs";
2064
2097
  import JSON5 from "json5";
2065
2098
 
2066
2099
  // src/cli/loaders/dato/_base.ts
@@ -2659,12 +2692,12 @@ function _isVideo(rawDatoValue) {
2659
2692
  // src/cli/loaders/dato/index.ts
2660
2693
  function createDatoLoader(configFilePath) {
2661
2694
  try {
2662
- const configContent = fs9.readFileSync(configFilePath, "utf-8");
2695
+ const configContent = fs10.readFileSync(configFilePath, "utf-8");
2663
2696
  const datoConfig = datoConfigSchema.parse(JSON5.parse(configContent));
2664
2697
  return composeLoaders(
2665
2698
  createDatoApiLoader(
2666
2699
  datoConfig,
2667
- (updatedConfig) => fs9.writeFileSync(configFilePath, JSON5.stringify(updatedConfig, null, 2))
2700
+ (updatedConfig) => fs10.writeFileSync(configFilePath, JSON5.stringify(updatedConfig, null, 2))
2668
2701
  ),
2669
2702
  createDatoFilterLoader(),
2670
2703
  createDatoExtractLoader()
@@ -3129,7 +3162,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
3129
3162
  }
3130
3163
 
3131
3164
  // src/cli/utils/lockfile.ts
3132
- import fs10 from "fs";
3165
+ import fs11 from "fs";
3133
3166
  import path12 from "path";
3134
3167
  import Z3 from "zod";
3135
3168
  import YAML3 from "yaml";
@@ -3139,7 +3172,7 @@ function createLockfileHelper() {
3139
3172
  return {
3140
3173
  isLockfileExists: () => {
3141
3174
  const lockfilePath = _getLockfilePath();
3142
- return fs10.existsSync(lockfilePath);
3175
+ return fs11.existsSync(lockfilePath);
3143
3176
  },
3144
3177
  registerSourceData: (pathPattern, sourceData) => {
3145
3178
  const lockfile = _loadLockfile();
@@ -3166,17 +3199,17 @@ function createLockfileHelper() {
3166
3199
  };
3167
3200
  function _loadLockfile() {
3168
3201
  const lockfilePath = _getLockfilePath();
3169
- if (!fs10.existsSync(lockfilePath)) {
3202
+ if (!fs11.existsSync(lockfilePath)) {
3170
3203
  return LockfileSchema.parse({});
3171
3204
  }
3172
- const content = fs10.readFileSync(lockfilePath, "utf-8");
3205
+ const content = fs11.readFileSync(lockfilePath, "utf-8");
3173
3206
  const result = LockfileSchema.parse(YAML3.parse(content));
3174
3207
  return result;
3175
3208
  }
3176
3209
  function _saveLockfile(lockfile) {
3177
3210
  const lockfilePath = _getLockfilePath();
3178
3211
  const content = YAML3.stringify(lockfile);
3179
- fs10.writeFileSync(lockfilePath, content);
3212
+ fs11.writeFileSync(lockfilePath, content);
3180
3213
  }
3181
3214
  function _getLockfilePath() {
3182
3215
  return path12.join(process.cwd(), "i18n.lock");
@@ -3205,7 +3238,7 @@ import externalEditor from "external-editor";
3205
3238
 
3206
3239
  // src/cli/utils/cache.ts
3207
3240
  import path13 from "path";
3208
- import fs11 from "fs";
3241
+ import fs12 from "fs";
3209
3242
  var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
3210
3243
  const rows = Object.entries(sourceChunk).map(([key, source]) => ({
3211
3244
  targetLocale,
@@ -3235,23 +3268,23 @@ function getNormalizedCache() {
3235
3268
  function deleteCache() {
3236
3269
  const cacheFilePath = _getCacheFilePath();
3237
3270
  try {
3238
- fs11.unlinkSync(cacheFilePath);
3271
+ fs12.unlinkSync(cacheFilePath);
3239
3272
  } catch (e) {
3240
3273
  }
3241
3274
  }
3242
3275
  function _loadCache() {
3243
3276
  const cacheFilePath = _getCacheFilePath();
3244
- if (!fs11.existsSync(cacheFilePath)) {
3277
+ if (!fs12.existsSync(cacheFilePath)) {
3245
3278
  return [];
3246
3279
  }
3247
- const content = fs11.readFileSync(cacheFilePath, "utf-8");
3280
+ const content = fs12.readFileSync(cacheFilePath, "utf-8");
3248
3281
  const result = _parseJSONLines(content);
3249
3282
  return result;
3250
3283
  }
3251
3284
  function _appendToCache(rows) {
3252
3285
  const cacheFilePath = _getCacheFilePath();
3253
3286
  const lines = _buildJSONLines(rows);
3254
- fs11.appendFileSync(cacheFilePath, lines);
3287
+ fs12.appendFileSync(cacheFilePath, lines);
3255
3288
  }
3256
3289
  function _getCacheFilePath() {
3257
3290
  return path13.join(process.cwd(), "i18n.cache");
@@ -3916,7 +3949,7 @@ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model
3916
3949
  // package.json
3917
3950
  var package_default = {
3918
3951
  name: "lingo.dev",
3919
- version: "0.78.12",
3952
+ version: "0.78.14",
3920
3953
  description: "Lingo.dev CLI",
3921
3954
  private: false,
3922
3955
  publishConfig: {