| 2 | import color from 'picocolors'; |
| 3 | |
| 4 | async function main() { |
| 5 | const defaultPath = 'my-project'; |
| 6 | |
| 7 | const result = await p.text({ |
| 8 | message: 'Enter the directory to bootstrap the project', |
| 9 | placeholder: ` (hit Enter to use '${defaultPath}')`, |
| 10 | defaultValue: defaultPath, |
| 11 | validate: (value) => { |
| 12 | if (!value) { |
| 13 | return 'Directory is required'; |
| 14 | } |
| 15 | if (value.includes(' ')) { |
| 16 | return 'Directory cannot contain spaces'; |
| 17 | } |
| 18 | return undefined; |
| 19 | }, |
| 20 | }); |
| 21 | |
| 22 | if (p.isCancel(result)) { |
| 23 | p.cancel('Operation cancelled.'); |
| 24 | process.exit(0); |
| 25 | } |
| 26 | |
| 27 | p.outro(`Let's bootstrap the project in ${color.cyan(result)}`); |
| 28 | } |
| 29 | |
| 30 | main().catch(console.error); |