UNPKG

@tensorify.io/cli

Version:

Official CLI for Tensorify.io - Build, test, and deploy machine learning plugins

59 lines 3.07 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 commander_1 = require("commander"); const login_1 = require("../commands/login"); const logout_1 = require("../commands/logout"); const whoami_1 = require("../commands/whoami"); const publish_1 = require("../commands/publish"); const chalk_1 = __importDefault(require("chalk")); const package_json_1 = __importDefault(require("../../package.json")); const packageVersion = package_json_1.default.version; // Set up the CLI program commander_1.program .name("tensorify") .description("Official CLI for Tensorify.io - Build, test, and deploy Tensorify plugins") .version(packageVersion, "-v, --version", "Show version number"); // Add commands commander_1.program.addCommand(login_1.loginCommand); commander_1.program.addCommand(logout_1.logoutCommand); commander_1.program.addCommand(whoami_1.whoamiCommand); commander_1.program.addCommand(publish_1.publishCommand); // Global error handling commander_1.program.exitOverride(); // Enhanced error handling with better debugging and user guidance process.on('unhandledRejection', (reason, promise) => { console.error(chalk_1.default.red("\n❌ Unhandled Rejection at:"), promise); console.error(chalk_1.default.red("Reason:"), reason); console.error(chalk_1.default.yellow("\n💡 This appears to be an unexpected error. Please try again.")); console.error(chalk_1.default.gray("If the problem persists, please report this issue to the Tensorify team.")); process.exit(1); }); process.on('uncaughtException', (error) => { console.error(chalk_1.default.red("\n❌ Uncaught Exception:"), error.message); console.error(chalk_1.default.yellow("\n💡 This appears to be an unexpected error. Please try again.")); console.error(chalk_1.default.gray("If the problem persists, please report this issue to the Tensorify team.")); process.exit(1); }); try { commander_1.program.parse(); } catch (err) { if (err.code !== "commander.version" && err.code !== "commander.help") { console.error(chalk_1.default.red("\n❌ CLI Error:"), err.message); // Provide helpful suggestions based on error type if (err.message.includes("Unknown command")) { console.error(chalk_1.default.yellow("\n💡 Did you mean one of these commands?")); console.error(chalk_1.default.gray(" • tensorify login - Authenticate with Tensorify")); console.error(chalk_1.default.gray(" • tensorify publish - Publish a plugin")); console.error(chalk_1.default.gray(" • tensorify whoami - Check current user")); console.error(chalk_1.default.gray(" • tensorify logout - Sign out")); console.error(chalk_1.default.gray("\nRun 'tensorify --help' for more information.")); } process.exit(1); } } //# sourceMappingURL=tensorify.js.map