lingo-linter-tool 1.0.2 β†’ 1.0.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.
@@ -27,42 +27,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.healIssues = void 0;
30
+ const child_process_1 = require("child_process");
30
31
  const fs = __importStar(require("fs"));
31
32
  const path = __importStar(require("path"));
32
33
  const chalk_1 = __importDefault(require("chalk"));
33
- const child_process_1 = require("child_process");
34
- function getSourceText(localesDir, key) {
35
- try {
36
- const enPath = path.join(localesDir, "en.json");
37
- if (!fs.existsSync(enPath))
38
- return null;
39
- const raw = fs.readFileSync(enPath, "utf-8");
40
- const json = JSON.parse(raw);
41
- const keys = key.split(".");
42
- let current = json;
43
- for (const k of keys) {
44
- if (current[k] === undefined)
45
- return null;
46
- current = current[k];
34
+ async function healIssues(issues, localesDir) {
35
+ console.log(chalk_1.default.blue("\n🩹 Initializing Lingo.dev Official Sync..."));
36
+ const missingKeys = issues.filter((i) => i.ruleId === "missing-keys");
37
+ if (missingKeys.length === 0)
38
+ return;
39
+ const enPath = path.join(localesDir, "en.json");
40
+ const enContent = JSON.parse(fs.readFileSync(enPath, "utf-8"));
41
+ let hasChanges = false;
42
+ missingKeys.forEach((issue) => {
43
+ if (issue.key && !enContent[issue.key]) {
44
+ const humanText = issue.key.split(".").pop() || issue.key;
45
+ enContent[issue.key] = humanText;
46
+ hasChanges = true;
47
+ console.log(chalk_1.default.gray(` βž• Added source key: "${issue.key}"`));
47
48
  }
48
- return typeof current === "string" ? current : null;
49
+ });
50
+ if (hasChanges) {
51
+ fs.writeFileSync(enPath, JSON.stringify(enContent, null, 2));
49
52
  }
50
- catch (e) {
51
- return null;
52
- }
53
- }
54
- async function healIssues(issues, localesDir) {
55
- console.log(chalk_1.default.blue("\n🩹 Initializing Lingo.dev Auto-Healer..."));
56
53
  try {
57
- console.log("πŸš€ Triggering Lingo.dev CLI Sync...");
58
- (0, child_process_1.execSync)(`npx lingo sync --locales ${localesDir}`, {
54
+ console.log(chalk_1.default.magenta("πŸš€ Triggering 'npx lingo.dev run' to generate translations..."));
55
+ (0, child_process_1.execSync)("npx lingo.dev run --force", {
59
56
  stdio: "inherit",
57
+ cwd: path.dirname(localesDir),
60
58
  });
61
- console.log("βœ…Lingo Sync Complete.");
62
- return;
59
+ console.log(chalk_1.default.green("\nβœ… Lingo.dev successfully healed your files!"));
63
60
  }
64
- catch (e) {
65
- console.error("❌ Lingo CLI failed:", e);
61
+ 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"));
66
64
  }
67
65
  }
68
66
  exports.healIssues = healIssues;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "lingo-linter-tool",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Localization linter and self-healing tool",
5
5
  "bin": {
6
- "lingo": "./dist/cli.js"
6
+ "lingo-lint": "./dist/cli.js"
7
7
  },
8
8
  "files": [
9
9
  "dist",