UNPKG

@iosifnicolae22/remote-shell

Version:

Run any terminal application and control it remotely from your mobile device. Perfect for maxing out vibe coding sessions with Claude Code on the go!

2 lines (1 loc) • 1.63 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfigManager=void 0;const os_1=require("os");const path_1=require("path");const fs_1=require("fs");class ConfigManager{configDir;configFile;constructor(){this.configDir=(0,path_1.join)((0,os_1.homedir)(),".remote-shell"),this.configFile=(0,path_1.join)(this.configDir,"config.json"),this.ensureConfigDir()}ensureConfigDir(){(0,fs_1.existsSync)(this.configDir)||(0,fs_1.mkdirSync)(this.configDir,{recursive:!0})}getConfig(){const o="true"===process.env.REMOTE_SHELL_DEVELOPMENT||"development"===process.env.NODE_ENV;const e={websocketHost:o?process.env.REMOTE_TERMINAL_WEBSOCKET_HOST||"ws://localhost:3001":process.env.REMOTE_TERMINAL_WEBSOCKET_HOST||"wss://remote-shell.bringes.io",hostname:o?process.env.REMOTE_TERMINAL_HOSTNAME||"localhost:3001":process.env.REMOTE_TERMINAL_HOSTNAME||"https://remote-shell.bringes.io"};if(!(0,fs_1.existsSync)(this.configFile))return e;try{const o=(0,fs_1.readFileSync)(this.configFile,"utf8");const s=JSON.parse(o);return{...e,...s}}catch(o){return console.warn("Failed to parse config file, using defaults:",o),e}}setConfig(o,e){const s=this.getConfig();s[o]=e;try{(0,fs_1.writeFileSync)(this.configFile,JSON.stringify(s,null,2),"utf8"),console.log(`āœ… Set ${o} to ${e}`)}catch(o){throw console.error(`āŒ Failed to save config: ${o}`),o}}showConfig(){const o=this.getConfig();console.log("\nšŸ“‹ Current configuration:"),console.log(` websocketHost: ${o.websocketHost}`),console.log(` hostname: ${o.hostname}`),console.log(`\nšŸ’¾ Config file: ${this.configFile}\n`)}}exports.ConfigManager=ConfigManager;