lingo.dev 0.77.1 → 0.77.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.cjs CHANGED
@@ -289,6 +289,8 @@ function findLocaleFiles(bucket) {
289
289
  return findLocaleFilesWithExtension(".md");
290
290
  case "php":
291
291
  return findLocaleFilesWithExtension(".php");
292
+ case "po":
293
+ return findLocaleFilesWithExtension(".po");
292
294
  case "xcode-xcstrings":
293
295
  return findLocaleFilesForFilename("Localizable.xcstrings");
294
296
  case "xcode-strings":
@@ -434,10 +436,47 @@ function getDefaultContent(ext, source) {
434
436
  }
435
437
  }
436
438
 
439
+ // src/cli/utils/update-gitignore.ts
440
+
441
+
442
+ function updateGitignore() {
443
+ const cacheFile = "i18n.cache";
444
+ const projectRoot = findCurrentProjectRoot();
445
+ if (!projectRoot) {
446
+ return;
447
+ }
448
+ const gitignorePath = _path2.default.join(projectRoot, ".gitignore");
449
+ const gitignore = _fs2.default.readFileSync(gitignorePath, "utf8").split("\n");
450
+ const cacheIsIgnored = gitignore.includes(cacheFile);
451
+ if (!cacheIsIgnored) {
452
+ let content = "";
453
+ if (_fs2.default.existsSync(gitignorePath)) {
454
+ content = _fs2.default.readFileSync(gitignorePath, "utf8");
455
+ if (content !== "" && !content.endsWith("\n")) {
456
+ content += "\n";
457
+ }
458
+ }
459
+ content += `${cacheFile}
460
+ `;
461
+ _fs2.default.writeFileSync(gitignorePath, content);
462
+ }
463
+ }
464
+ function findCurrentProjectRoot() {
465
+ let currentDir = process.cwd();
466
+ while (currentDir !== _path2.default.parse(currentDir).root) {
467
+ const gitDirPath = _path2.default.join(currentDir, ".git");
468
+ if (_fs2.default.existsSync(gitDirPath) && _fs2.default.lstatSync(gitDirPath).isDirectory()) {
469
+ return currentDir;
470
+ }
471
+ currentDir = _path2.default.dirname(currentDir);
472
+ }
473
+ return null;
474
+ }
475
+
437
476
  // src/cli/cmd/init.ts
438
- var openUrl = (path11) => {
477
+ var openUrl = (path12) => {
439
478
  const settings = getSettings(void 0);
440
- _child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path11}`]);
479
+ _child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path12}`]);
441
480
  };
442
481
  var throwHelpError = (option, value) => {
443
482
  if (value === "help") {
@@ -586,6 +625,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
586
625
  } else {
587
626
  _ora2.default.call(void 0, ).succeed(`Authenticated as ${auth.email}`);
588
627
  }
628
+ updateGitignore();
589
629
  if (!isInteractive) {
590
630
  _ora2.default.call(void 0, ).info("Please see https://docs.lingo.dev/");
591
631
  }
@@ -758,8 +798,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
758
798
  } else if (type.target) {
759
799
  result.push(...targetPaths);
760
800
  }
761
- result.forEach((path11) => {
762
- console.log(path11);
801
+ result.forEach((path12) => {
802
+ console.log(path12);
763
803
  });
764
804
  }
765
805
  }
@@ -1299,9 +1339,9 @@ function createHtmlLoader() {
1299
1339
  const bDepth = b.split("/").length;
1300
1340
  return aDepth - bDepth;
1301
1341
  });
1302
- paths.forEach((path11) => {
1303
- const value = data[path11];
1304
- const [nodePath, attribute] = path11.split("#");
1342
+ paths.forEach((path12) => {
1343
+ const value = data[path12];
1344
+ const [nodePath, attribute] = path12.split("#");
1305
1345
  const [rootTag, ...indices] = nodePath.split("/");
1306
1346
  let parent = rootTag === "head" ? document.head : document.body;
1307
1347
  let current = parent;
@@ -2308,18 +2348,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
2308
2348
  }
2309
2349
  function serializeStructuredText(rawStructuredText) {
2310
2350
  return serializeStructuredTextNode(rawStructuredText);
2311
- function serializeStructuredTextNode(node, path11 = [], acc = {}) {
2351
+ function serializeStructuredTextNode(node, path12 = [], acc = {}) {
2312
2352
  if ("document" in node) {
2313
- return serializeStructuredTextNode(node.document, [...path11, "document"], acc);
2353
+ return serializeStructuredTextNode(node.document, [...path12, "document"], acc);
2314
2354
  }
2315
2355
  if (!_lodash2.default.isNil(node.value)) {
2316
- acc[[...path11, "value"].join(".")] = node.value;
2356
+ acc[[...path12, "value"].join(".")] = node.value;
2317
2357
  } else if (_lodash2.default.get(node, "type") === "block") {
2318
- acc[[...path11, "item"].join(".")] = serializeBlock(node.item);
2358
+ acc[[...path12, "item"].join(".")] = serializeBlock(node.item);
2319
2359
  }
2320
2360
  if (node.children) {
2321
2361
  for (let i = 0; i < node.children.length; i++) {
2322
- serializeStructuredTextNode(node.children[i], [...path11, i.toString()], acc);
2362
+ serializeStructuredTextNode(node.children[i], [...path12, i.toString()], acc);
2323
2363
  }
2324
2364
  }
2325
2365
  return acc;
@@ -2378,8 +2418,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
2378
2418
  }
2379
2419
  function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
2380
2420
  const result = _lodash2.default.cloneDeep(originalRawStructuredText);
2381
- for (const [path11, value] of _lodash2.default.entries(parsedStructuredText)) {
2382
- const realPath = _lodash2.default.chain(path11.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
2421
+ for (const [path12, value] of _lodash2.default.entries(parsedStructuredText)) {
2422
+ const realPath = _lodash2.default.chain(path12.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
2383
2423
  const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
2384
2424
  _lodash2.default.set(result, realPath, deserializedValue);
2385
2425
  }
@@ -2974,6 +3014,7 @@ function _tryParseJSON(line) {
2974
3014
 
2975
3015
  // src/cli/cmd/i18n.ts
2976
3016
  var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option("--key <key>", "Key to process").option("--frozen", `Don't update the translations and fail if an update is needed`).option("--force", "Ignore lockfile and process all keys").option("--verbose", "Show verbose output").option("--interactive", "Interactive mode").option("--api-key <api-key>", "Explicitly set the API key to use").option("--debug", "Debug mode").option("--strict", "Stop on first error").action(async function(options) {
3017
+ updateGitignore();
2977
3018
  const ora = _ora2.default.call(void 0, );
2978
3019
  const flags = parseFlags(options);
2979
3020
  if (flags.debug) {
@@ -3577,7 +3618,7 @@ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").descri
3577
3618
  // package.json
3578
3619
  var package_default = {
3579
3620
  name: "lingo.dev",
3580
- version: "0.77.1",
3621
+ version: "0.77.3",
3581
3622
  description: "Lingo.dev CLI",
3582
3623
  private: false,
3583
3624
  publishConfig: {