lingo-linter-tool 1.0.3 → 1.0.4

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.
@@ -32,35 +32,52 @@ const fs = __importStar(require("fs"));
32
32
  const path = __importStar(require("path"));
33
33
  const chalk_1 = __importDefault(require("chalk"));
34
34
  async function healIssues(issues, localesDir) {
35
- console.log(chalk_1.default.blue("\n🩹 Initializing Lingo.dev Official Sync..."));
35
+ console.log(chalk_1.default.blue("\n🩹 Initializing Lingo.dev Integration..."));
36
36
  const missingKeys = issues.filter((i) => i.ruleId === "missing-keys");
37
37
  if (missingKeys.length === 0)
38
38
  return;
39
+ const projectRoot = path.dirname(localesDir);
40
+ const configPath = path.join(projectRoot, "i18n.json");
41
+ if (!fs.existsSync(configPath)) {
42
+ console.log(chalk_1.default.yellow("āš ļø i18n.json not found. Auto-generating default config..."));
43
+ const defaultConfig = {
44
+ source: "en",
45
+ targets: ["fr", "de", "es"],
46
+ localesDir: "./" + path.basename(localesDir),
47
+ provider: "openai",
48
+ };
49
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
50
+ console.log(chalk_1.default.green("āœ… Created i18n.json"));
51
+ }
39
52
  const enPath = path.join(localesDir, "en.json");
40
- const enContent = JSON.parse(fs.readFileSync(enPath, "utf-8"));
53
+ let enContent = {};
54
+ try {
55
+ enContent = JSON.parse(fs.readFileSync(enPath, "utf-8"));
56
+ }
57
+ catch (e) {
58
+ }
41
59
  let hasChanges = false;
42
60
  missingKeys.forEach((issue) => {
43
61
  if (issue.key && !enContent[issue.key]) {
44
62
  const humanText = issue.key.split(".").pop() || issue.key;
45
63
  enContent[issue.key] = humanText;
46
64
  hasChanges = true;
47
- console.log(chalk_1.default.gray(` āž• Added source key: "${issue.key}"`));
48
65
  }
49
66
  });
50
67
  if (hasChanges) {
51
68
  fs.writeFileSync(enPath, JSON.stringify(enContent, null, 2));
69
+ console.log(chalk_1.default.gray(" āž• Injected missing keys into source (en.json)"));
52
70
  }
53
71
  try {
54
- console.log(chalk_1.default.magenta("šŸš€ Triggering 'npx lingo.dev run' to generate translations..."));
72
+ console.log(chalk_1.default.magenta("šŸš€ Triggering Lingo.dev AI Translation..."));
55
73
  (0, child_process_1.execSync)("npx lingo.dev run --force", {
56
74
  stdio: "inherit",
57
- cwd: path.dirname(localesDir),
75
+ cwd: projectRoot,
58
76
  });
59
- console.log(chalk_1.default.green("\nāœ… Lingo.dev successfully healed your files!"));
77
+ console.log(chalk_1.default.green("\nāœ… Auto-Healing Complete!"));
60
78
  }
61
79
  catch (error) {
62
- console.error(chalk_1.default.red("āŒ Failed to run Lingo.dev CLI. Is it installed in the target app?"));
63
- console.error(chalk_1.default.yellow("šŸ‘‰ Try running: npm install -D lingo.dev"));
80
+ console.error(chalk_1.default.red("āŒ Failed to run lingo.dev CLI."));
64
81
  }
65
82
  }
66
83
  exports.healIssues = healIssues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lingo-linter-tool",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Localization linter and self-healing tool",
5
5
  "bin": {
6
6
  "lingo-lint": "./dist/cli.js"