UNPKG

@tastekim/chat-cli

Version:

πŸ’¬Connect with developers worldwide through an interactive terminal chat experience while you code!πŸ’»

173 lines β€’ 6.47 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.FeatureFlagManager = void 0; const fs = __importStar(require("fs")); const path = __importStar(require("path")); const os = __importStar(require("os")); class FeatureFlagManager { constructor() { this.configPath = path.join(os.homedir(), '.chat-cli', 'config.json'); this.config = this.loadConfig(); } static getInstance() { if (!FeatureFlagManager.instance) { FeatureFlagManager.instance = new FeatureFlagManager(); } return FeatureFlagManager.instance; } loadConfig() { try { if (fs.existsSync(this.configPath)) { const configData = fs.readFileSync(this.configPath, 'utf8'); const parsedConfig = JSON.parse(configData); // κΈ°λ³Έ μ„€μ •κ³Ό λ³‘ν•©ν•˜μ—¬ λˆ„λ½λœ ν•„λ“œ 보완 return { ...FeatureFlagManager.DEFAULT_CONFIG, ...parsedConfig, lastUpdated: new Date() }; } } catch (error) { console.warn('Failed to load config, using defaults:', error); } return { ...FeatureFlagManager.DEFAULT_CONFIG }; } saveConfig() { try { const configDir = path.dirname(this.configPath); if (!fs.existsSync(configDir)) { fs.mkdirSync(configDir, { recursive: true }); } this.config.lastUpdated = new Date(); fs.writeFileSync(this.configPath, JSON.stringify(this.config, null, 2)); } catch (error) { console.error('Failed to save config:', error); } } // κΈ°λŠ₯ ν”Œλž˜κ·Έ 확인 λ©”μ„œλ“œλ“€ isMultiRoomEnabled() { return this.config.enableMultiRoom; } isPrivateRoomsEnabled() { return this.config.enablePrivateRooms; } isUnreadIndicatorEnabled() { return this.config.enableUnreadIndicator; } isRoomTabsEnabled() { return this.config.enableRoomTabs; } getDefaultRoom() { return this.config.defaultRoom; } getMaxJoinedRooms() { return this.config.maxJoinedRooms; } // μ„€μ • μ—…λ°μ΄νŠΈ λ©”μ„œλ“œλ“€ enableMultiRoom(enable = true) { this.config.enableMultiRoom = enable; // Multi-room ν™œμ„±ν™” μ‹œ κ΄€λ ¨ κΈ°λŠ₯듀도 μžλ™ ν™œμ„±ν™” if (enable) { this.config.enableUnreadIndicator = true; this.config.enableRoomTabs = true; this.config.defaultRoom = 'lobby'; } this.saveConfig(); } enablePrivateRooms(enable = true) { this.config.enablePrivateRooms = enable; this.saveConfig(); } setDefaultRoom(room) { this.config.defaultRoom = room; this.saveConfig(); } setMaxJoinedRooms(max) { this.config.maxJoinedRooms = Math.max(1, Math.min(max, 10)); // 1-10 λ²”μœ„λ‘œ μ œν•œ this.saveConfig(); } // 전체 μ„€μ • 쑰회 getConfig() { return { ...this.config }; } // μ„€μ • μ΄ˆκΈ°ν™” resetToDefaults() { this.config = { ...FeatureFlagManager.DEFAULT_CONFIG }; this.saveConfig(); } // ν™˜κ²½λ³€μˆ˜ μ˜€λ²„λΌμ΄λ“œ 지원 checkEnvironmentOverrides() { if (process.env.CHAT_CLI_MULTI_ROOM === 'true') { this.config.enableMultiRoom = true; this.config.enableUnreadIndicator = true; this.config.enableRoomTabs = true; this.config.defaultRoom = 'lobby'; } if (process.env.CHAT_CLI_PRIVATE_ROOMS === 'true') { this.config.enablePrivateRooms = true; } if (process.env.CHAT_CLI_DEFAULT_ROOM) { this.config.defaultRoom = process.env.CHAT_CLI_DEFAULT_ROOM; } } // μ„€μ • μƒνƒœ ν‘œμ‹œ printCurrentConfig() { console.log('πŸ”§ Current Chat-CLI Configuration:'); console.log(` Multi-Room Mode: ${this.config.enableMultiRoom ? 'βœ… Enabled' : '❌ Disabled'}`); console.log(` Private Rooms: ${this.config.enablePrivateRooms ? 'βœ… Enabled' : '❌ Disabled'}`); console.log(` Unread Indicator: ${this.config.enableUnreadIndicator ? 'βœ… Enabled' : '❌ Disabled'}`); console.log(` Room Tabs: ${this.config.enableRoomTabs ? 'βœ… Enabled' : '❌ Disabled'}`); console.log(` Default Room: ${this.config.defaultRoom}`); console.log(` Max Joined Rooms: ${this.config.maxJoinedRooms}`); console.log(` Config Version: ${this.config.version}`); console.log(''); } } exports.FeatureFlagManager = FeatureFlagManager; // κΈ°λ³Έ μ„€μ • - λͺ¨λ“  μƒˆ κΈ°λŠ₯은 기본적으둜 λΉ„ν™œμ„±ν™” FeatureFlagManager.DEFAULT_CONFIG = { enableMultiRoom: false, enablePrivateRooms: false, enableUnreadIndicator: false, enableRoomTabs: false, defaultRoom: 'korean', // κΈ°μ‘΄ λ™μž‘ μœ μ§€ maxJoinedRooms: 5, version: '1.5.0', lastUpdated: new Date() }; //# sourceMappingURL=feature-flags.js.map