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.
- package/dist/healer/index.js +25 -27
- package/package.json +2 -2
package/dist/healer/index.js
CHANGED
|
@@ -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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
|
58
|
-
(0, child_process_1.execSync)(
|
|
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
|
|
62
|
-
return;
|
|
59
|
+
console.log(chalk_1.default.green("\nβ
Lingo.dev successfully healed your files!"));
|
|
63
60
|
}
|
|
64
|
-
catch (
|
|
65
|
-
console.error("β Lingo CLI
|
|
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