wp-host
Version:
Automated WordPress hosting deployment tool for bulk site creation with MySQL database management
181 lines โข 6.94 kB
JavaScript
;
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