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.

155 lines (154 loc) 6.37 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; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.editCommand = editCommand; const inquirer_1 = __importDefault(require("inquirer")); const config_manager_1 = require("../lib/config-manager"); const chalk_1 = __importDefault(require("chalk")); const path = __importStar(require("path")); function editCommand(program) { program .command('edit [project]') .description('Edit a project configuration') .action(async (projectName) => { const configManager = new config_manager_1.ConfigManager(); const projects = configManager.getProjects(); if (projects.length === 0) { console.log(chalk_1.default.red('\nNo projects configured. Use "roku-pkg add" first.\n')); return; } // Select project if not specified if (!projectName) { const { selectedProject } = await inquirer_1.default.prompt([ { type: 'list', name: 'selectedProject', message: 'Select a project to edit:', choices: projects.map(p => p.name) } ]); projectName = selectedProject; } const project = configManager.getProject(projectName); if (!project) { console.log(chalk_1.default.red(`\nProject '${projectName}' not found.\n`)); return; } console.log(chalk_1.default.bold(`\n✏️ Editing ${chalk_1.default.cyan(project.name)}\n`)); const answers = await inquirer_1.default.prompt([ { type: 'input', name: 'name', message: 'Project name:', default: project.name, validate: (input) => { if (!input) return 'Project name is required'; if (!/^[a-zA-Z0-9_-]+$/.test(input)) { return 'Project name can only contain letters, numbers, hyphens, and underscores'; } // Check if new name conflicts with another project if (input !== project.name && configManager.getProject(input)) { return 'A project with this name already exists'; } return true; } }, { type: 'input', name: 'rootDir', message: 'Root directory of Roku app source:', default: project.rootDir || '', validate: (input) => input ? true : 'Root directory is required', filter: (input) => { // Expand ~ to home directory if (input.startsWith('~')) { return path.join(process.env.HOME || '', input.slice(1)); } // Convert relative paths to absolute if (!path.isAbsolute(input)) { return path.resolve(input); } return input; } }, { type: 'input', name: 'signKey', message: 'Signing key:', default: project.signKey, validate: (input) => input ? true : 'Signing key is required' }, { type: 'input', name: 'signPackageLocation', message: 'Signed package location:', default: project.signPackageLocation, validate: (input) => input ? true : 'Package location is required', filter: (input) => { // Expand ~ to home directory if (input.startsWith('~')) { return path.join(process.env.HOME || '', input.slice(1)); } return input; } }, { type: 'input', name: 'outputLocation', message: 'Output location:', default: project.outputLocation, filter: (input) => { if (input.startsWith('~')) { return path.join(process.env.HOME || '', input.slice(1)); } return input; } } ]); // If the name changed, remove the old project and add the new one if (answers.name !== project.name) { configManager.removeProject(project.name); configManager.addProject(answers); } else { configManager.updateProject(project.name, answers); } console.log(chalk_1.default.green(`\n✓ Project '${answers.name}' updated successfully\n`)); }); }