UNPKG

@eightshone/sshman

Version:
77 lines â€ĸ 3.39 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import select from "@inquirer/select"; import colors from "yoctocolors-cjs"; import clipboard from "clipboardy"; import stringPadding from "../../../utils/stringPadding.js"; function displayConnection(sshConfig, index, passwordCopied) { return __awaiter(this, void 0, void 0, function* () { console.log(colors.dim("đŸ–Ĩī¸ Server name")); console.log(` ${sshConfig.name} `); console.log(colors.dim(`${stringPadding("🧑 Username", 44)} 🔑 ${sshConfig.usePassword ? "Password" : "Key"}`)); console.log(` ${stringPadding(sshConfig.username)} ${sshConfig.usePassword === true ? "********" : sshConfig.privateKey} `); console.log(colors.dim(`${stringPadding("🌐 Hostname", 44)} 🔌 Port`)); console.log(` ${stringPadding(sshConfig.host)} ${sshConfig.port} `); let answer = yield select({ message: "Select action", choices: [ { name: "🚀 Connect", value: "ssh-connect", description: "Connect to server", }, ...(sshConfig.usePassword ? [ { name: passwordCopied ? "✅ Password copied to clipboard" : "📋 Copy password to clipborad", value: "ssh-password", description: "Edit server password to clipboard", }, ] : []), { name: "âœī¸ Edit", value: "ssh-edit", description: "Edit server configuration", }, { name: "❌ Delete", value: "ssh-delete", description: "Delete server config", }, { name: "â†Šī¸ Servers list", value: "ssh-list", description: "Return to servers list", }, ], loop: false, default: passwordCopied ? "ssh-password" : "ssh-connect", }); console.clear(); let copyPassword = false; if (answer === "ssh-password" && sshConfig.usePassword) { clipboard.writeSync(sshConfig.password); copyPassword = true; answer = "ssh-display"; } return [ answer, [JSON.stringify(sshConfig), `${index}`, `${copyPassword}`], ]; }); } export default displayConnection; //# sourceMappingURL=display.js.map