()
| 51 | } |
| 52 | |
| 53 | async function promptForToken(): Promise<string> { |
| 54 | const rl = readline.createInterface({ input, output }) |
| 55 | |
| 56 | console.log(chalk.yellow('\nNo CLI_API_TOKEN found.')) |
| 57 | console.log(chalk.gray('Where to find the token:')) |
| 58 | console.log(chalk.gray(' 1. Check the server startup logs (first run shows generated token)')) |
| 59 | console.log(chalk.gray(' 2. Read ~/.hapi/settings.json on the server')) |
| 60 | console.log(chalk.gray(' 3. Ask your server administrator (if token is set via env var)\n')) |
| 61 | |
| 62 | try { |
| 63 | const token = await rl.question(chalk.cyan('Enter CLI_API_TOKEN: ')) |
| 64 | if (!token.trim()) { |
| 65 | throw new Error('Token cannot be empty') |
| 66 | } |
| 67 | console.log(chalk.green(`\nToken saved to ${configuration.settingsFile}`)) |
| 68 | return token.trim() |
| 69 | } finally { |
| 70 | rl.close() |
| 71 | } |
| 72 | } |
no test coverage detected