| 3 | import color from 'picocolors'; |
| 4 | |
| 5 | async function main() { |
| 6 | console.clear(); |
| 7 | |
| 8 | await setTimeout(1000); |
| 9 | |
| 10 | p.updateSettings({ |
| 11 | aliases: { |
| 12 | w: 'up', |
| 13 | s: 'down', |
| 14 | a: 'left', |
| 15 | d: 'right', |
| 16 | }, |
| 17 | }); |
| 18 | |
| 19 | p.intro(`${color.bgCyan(color.black(' create-app '))}`); |
| 20 | |
| 21 | const project = await p.group( |
| 22 | { |
| 23 | path: () => |
| 24 | p.text({ |
| 25 | message: 'Where should we create your project?', |
| 26 | placeholder: './sparkling-solid', |
| 27 | validate: (value) => { |
| 28 | if (!value) return 'Please enter a path.'; |
| 29 | if (value[0] !== '.') return 'Please enter a relative path.'; |
| 30 | }, |
| 31 | }), |
| 32 | password: () => |
| 33 | p.password({ |
| 34 | message: 'Provide a password', |
| 35 | validate: (value) => { |
| 36 | if (!value) return 'Please enter a password.'; |
| 37 | if (value.length < 5) return 'Password should have at least 5 characters.'; |
| 38 | }, |
| 39 | }), |
| 40 | type: ({ results }) => |
| 41 | p.select({ |
| 42 | message: `Pick a project type within "${results.path}"`, |
| 43 | initialValue: 'ts', |
| 44 | maxItems: 5, |
| 45 | options: [ |
| 46 | { value: 'ts', label: 'TypeScript' }, |
| 47 | { value: 'js', label: 'JavaScript' }, |
| 48 | { value: 'rust', label: 'Rust' }, |
| 49 | { value: 'go', label: 'Go' }, |
| 50 | { value: 'python', label: 'Python' }, |
| 51 | { value: 'coffee', label: 'CoffeeScript', hint: 'oh no' }, |
| 52 | ], |
| 53 | }), |
| 54 | tools: () => |
| 55 | p.multiselect({ |
| 56 | message: 'Select additional tools.', |
| 57 | initialValues: ['prettier', 'eslint'], |
| 58 | options: [ |
| 59 | { value: 'prettier', label: 'Prettier', hint: 'recommended' }, |
| 60 | { value: 'eslint', label: 'ESLint', hint: 'recommended' }, |
| 61 | { value: 'stylelint', label: 'Stylelint' }, |
| 62 | { value: 'gh-action', label: 'GitHub Action' }, |