UNPKG

lingotags

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://img.shields.io/npm/v/lingotags.svg)](https://www.npmjs.com/package/lingotags)

108 lines 4.03 kB
#!/usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const init_1 = require("../cli/init"); const translationGenerator_1 = require("../translationGenerator"); const configUtils_1 = require("../utils/configUtils"); const utils_1 = require("../utils/utils"); const run = async () => { try { const command = process.argv[2] || "help"; console.log("Running command:", command); switch (command) { case "version": case "v": const packagePath = path_1.default.join(__dirname, "../../package.json"); const packageJson = JSON.parse(fs_1.default.readFileSync(packagePath, "utf-8")); console.log(`lingotags v${packageJson.version}`); break; case "init": await (0, init_1.initConfig)(); break; case "generate": case "gen": case "g": try { console.log("Attempting to load config..."); const config = (0, configUtils_1.loadConfig)(); console.log("Config loaded:", config); if (!config) { console.error("Config file not found. Please run 'npm run tags init' first"); process.exit(1); } console.log("Starting Keys generation..."); await (0, translationGenerator_1.generateTranslationTags)(config); console.log("Keys generation complete"); } catch (error) { console.error("Error details:", { name: error.name, message: error.message, stack: error.stack, }); process.exit(1); } break; case "revert": case "r": try { const config = (0, configUtils_1.loadConfig)(); const manifestPath = process.argv[3] || config.manifest; (0, utils_1.revertFromManifest)(manifestPath); console.log("✅ Successfully reverted changes"); process.exit(0); } catch (error) { console.error("Revert failed:", error.message); process.exit(1); } break; case "help": default: console.log(`Usage: lingotags <command> Commands: init Create configuration file generate Run translation generation (alias: gen, g) revert Revert changes from manifest file (alias: r) help Show this help message Options: version,v Show version number`); } } catch (error) { console.error("Unexpected error details:", { name: error.name, message: error.message, stack: error.stack, }); process.exit(1); } }; process.on("uncaughtException", (error) => { console.error("Uncaught Exception details:", { name: error.name, message: error.message, stack: error.stack, }); process.exit(1); }); process.on("unhandledRejection", (reason, promise) => { console.error("Unhandled Rejection details:", { reason: reason instanceof Error ? { name: reason.name, message: reason.message, stack: reason.stack, } : reason, promise, }); process.exit(1); }); run(); //# sourceMappingURL=index.js.map