UNPKG

roku-pkg-cli

Version:

A comprehensive CLI tool for managing multiple Roku projects with automated device discovery, build integration, and package generation. Perfect for CI/CD pipelines with full automation support.

114 lines (113 loc) 3.69 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.ConfigManager = void 0; const fs = __importStar(require("fs")); const path = __importStar(require("path")); const os = __importStar(require("os")); class ConfigManager { configPath; config = { rokuDevice: { ip: '', password: '' }, projects: [] }; constructor() { const configDir = path.join(os.homedir(), '.roku-pkg'); this.configPath = path.join(configDir, 'config.json'); // Ensure config directory exists if (!fs.existsSync(configDir)) { fs.mkdirSync(configDir, { recursive: true }); } this.loadConfig(); } loadConfig() { if (fs.existsSync(this.configPath)) { const data = fs.readFileSync(this.configPath, 'utf8'); this.config = JSON.parse(data); } else { this.config = { rokuDevice: { ip: '', password: '' }, projects: [] }; this.saveConfig(); } } saveConfig() { fs.writeFileSync(this.configPath, JSON.stringify(this.config, null, 2)); } getConfig() { return this.config; } getRokuDevice() { return this.config.rokuDevice; } setRokuDevice(device) { this.config.rokuDevice = device; this.saveConfig(); } getProjects() { return this.config.projects; } getProject(name) { return this.config.projects.find(p => p.name === name); } addProject(project) { this.config.projects.push(project); this.saveConfig(); } updateProject(name, updates) { const index = this.config.projects.findIndex(p => p.name === name); if (index !== -1) { this.config.projects[index] = { ...this.config.projects[index], ...updates }; this.saveConfig(); return true; } return false; } removeProject(name) { const index = this.config.projects.findIndex(p => p.name === name); if (index !== -1) { this.config.projects.splice(index, 1); this.saveConfig(); return true; } return false; } } exports.ConfigManager = ConfigManager;