UNPKG

@eightshone/sshman

Version:
51 lines 2.26 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 promptSSHConfig from "../promptSSHConfig.js"; import sshConnection from "../../functions/ssh.js"; import updateConfigs from "../../../utils/updateConfigs.js"; function newConnection(initialConfig, initialLogs) { return __awaiter(this, void 0, void 0, function* () { let config = Object.assign({}, initialConfig); let logs = [...initialLogs]; const saveConnection = yield select({ message: "Save connection", choices: [ { name: "✔️ YES", value: true, description: "Save this new conenction to the servers list", }, { name: "❌ No", value: false, description: "Connect without saving", }, { name: "↩️ Exit", value: null, description: "Exit to main menu", }, ], }); if (saveConnection !== null) { const sshConfig = yield promptSSHConfig(saveConnection, config); if (saveConnection) { // save new server config to the list of configs [config, logs] = yield updateConfigs(config, logs, sshConfig, saveConnection); } console.clear(); yield sshConnection(sshConfig); } return ["main", config, logs]; }); } export default newConnection; //# sourceMappingURL=new.js.map