UNPKG

wp-host

Version:

Automated WordPress hosting deployment tool for bulk site creation with MySQL database management

181 lines โ€ข 6.94 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PromptService = void 0; const inquirer_1 = __importDefault(require("inquirer")); class PromptService { /** * Prompt user for deployment options */ async promptDeploymentOptions() { console.log('\n๐Ÿš€ WordPress Hosting Automation'); console.log('=============================='); console.log('This tool will create databases, install WordPress, and configure your sites.'); console.log('You can also optionally generate application passwords and export results.\n'); const answers = await inquirer_1.default.prompt([ { type: 'confirm', name: 'cleanAllDirectories', message: '๐Ÿงน Automatically clean non-empty directories during installation?', default: false }, { type: 'confirm', name: 'generateAppPasswords', message: '๐Ÿ”‘ Generate application passwords for API access?', default: false }, { type: 'confirm', name: 'generateExport', message: '๐Ÿ“Š Export deployment results to spreadsheet?', default: false }, { type: 'input', name: 'exportPath', message: '๐Ÿ“ Export file path (optional):', when: (answers) => answers.generateExport, validate: (input) => { if (!input.trim()) return true; // Optional field if (!input.endsWith('.csv')) { return 'Export file must have .csv extension'; } return true; } } ]); return { cleanAllDirectories: answers.cleanAllDirectories, generateAppPasswords: answers.generateAppPasswords, generateExport: answers.generateExport, exportPath: answers.exportPath?.trim() || undefined }; } /** * Prompt for confirmation before destructive operations */ async promptConfirmation(operation, details = [], defaultValue = false) { console.log(`\nโš ๏ธ ${operation}`); if (details.length > 0) { console.log('This will:'); details.forEach(detail => console.log(` โ€ข ${detail}`)); } const { confirmed } = await inquirer_1.default.prompt([ { type: 'confirm', name: 'confirmed', message: 'Are you sure you want to continue?', default: defaultValue } ]); return confirmed; } /** * Prompt user to continue after showing results */ async promptContinue(message = 'Press Enter to continue...') { await inquirer_1.default.prompt([ { type: 'input', name: 'continue', message } ]); } /** * Show deployment preview and get confirmation */ async promptDeploymentPreview(sitesCount, options) { console.log('\n๐Ÿ“‹ Deployment Preview'); console.log('====================='); console.log(`๐Ÿ“Š Sites to deploy: ${sitesCount}`); console.log('๐Ÿ”ง Actions:'); console.log(' โ€ข Create MySQL databases and users'); console.log(' โ€ข Download and install WordPress'); console.log(' โ€ข Generate wp-config.php with security keys'); console.log(' โ€ข Set proper file permissions'); console.log(' โ€ข Complete WordPress setup wizard automatically'); if (options.generateAppPasswords) { console.log(' โ€ข Generate application passwords for API access'); } if (options.generateExport) { console.log(' โ€ข Export all deployment information to spreadsheet'); } const { confirmed } = await inquirer_1.default.prompt([ { type: 'confirm', name: 'confirmed', message: 'Ready to start deployment?', default: true } ]); return confirmed; } /** * Choose from multiple options */ async promptChoice(message, choices) { const { choice } = await inquirer_1.default.prompt([ { type: 'list', name: 'choice', message, choices: choices.map(c => ({ name: c.description ? `${c.name} - ${c.description}` : c.name, value: c.value })) } ]); return choice; } /** * Get text input from user */ async promptInput(message, defaultValue, validator) { const { input } = await inquirer_1.default.prompt([ { type: 'input', name: 'input', message, default: defaultValue, validate: validator } ]); return input.trim(); } /** * Display completion summary with next steps */ displayCompletionSummary(successful, total, hasAppPasswords, hasExport, exportPath) { console.log('\n๐ŸŽ‰ Deployment Complete!'); console.log('========================'); console.log(`โœ… Successfully deployed: ${successful}/${total} sites`); if (successful > 0) { console.log('\n๐ŸŒ Your WordPress sites are ready!'); console.log('๐Ÿ“ Next steps:'); console.log(' 1. Visit your site URLs to confirm everything works'); console.log(' 2. Log in to WordPress admin panels'); console.log(' 3. Install themes and plugins as needed'); if (hasAppPasswords) { console.log(' 4. Use application passwords for API/mobile access'); } if (hasExport && exportPath) { console.log(`\n๐Ÿ“Š All credentials saved to: ${exportPath}`); console.log(' โ€ข Share with your team or clients'); console.log(' โ€ข Use for documentation and backups'); console.log(' โ€ข Reference for API development'); } } if (successful < total) { const failed = total - successful; console.log(`\nโš ๏ธ ${failed} site(s) had issues - check the logs above for details`); } console.log('\n๐Ÿ› ๏ธ Need help? Check the README.md for troubleshooting tips'); } } exports.PromptService = PromptService; //# sourceMappingURL=prompt-service.js.map