UNPKG

cfn-forge

Version:

CloudFormation deployment automation tool with git-based workflows

77 lines (65 loc) 2.46 kB
/** * Pause Mode for CFN-Forge * * Shows welcome screen and waits for user input before exiting */ const readline = require('readline'); const chalk = require('chalk'); const { displayWelcomeBanner } = require('./welcome'); /** * Show welcome and wait for user input */ async function pauseMode() { displayWelcomeBanner(); const fs = require('fs'); const inProject = fs.existsSync('.cfn-forge.yaml'); if (inProject) { console.log(chalk.green('CFN-Forge project detected\n')); console.log(chalk.yellow('Common Commands:')); console.log(chalk.white(' Deploy your stack: ') + chalk.white('cfn-forge deploy')); console.log(chalk.white(' Watch for changes: ') + chalk.white('cfn-forge watch')); console.log(chalk.white(' Estimate costs: ') + chalk.white('cfn-forge cost')); console.log(chalk.white(' Manage parameters: ') + chalk.white('cfn-forge parameters')); console.log(chalk.white(' Validate templates: ') + chalk.white('cfn-forge validate')); } else { console.log(chalk.yellow('Quick Start:')); console.log(chalk.white(' 1. Initialize a project: ') + chalk.white('cfn-forge init')); console.log(chalk.white(' 2. Deploy your stack: ') + chalk.white('cfn-forge deploy')); console.log(chalk.white(' 3. Watch for changes: ') + chalk.white('cfn-forge watch')); } console.log(); console.log(chalk.white('For detailed help: ') + chalk.white('cfn-forge --help')); console.log(chalk.white('For specific command: ') + chalk.white('cfn-forge <command> --help')); console.log(); console.log(chalk.white('Documentation: ') + chalk.white('https://github.com/dmleblanc/cfn-forge')); console.log(chalk.white('Report issues: ') + chalk.white('https://github.com/dmleblanc/cfn-forge/issues')); console.log(); // Only wait for input if in a real terminal if (process.stdin.isTTY) { await waitForKeypress(); } } /** * Wait for user to press a key */ function waitForKeypress() { return new Promise((resolve) => { console.log(chalk.white('Press Enter to exit...')); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on('line', () => { rl.close(); resolve(); }); // Handle Ctrl+C rl.on('SIGINT', () => { console.log(chalk.white('\n\nGoodbye!\n')); process.exit(0); }); }); } module.exports = { pauseMode, };