()
| 136 | : getPkgManager() |
| 137 | |
| 138 | async function run(): Promise<void> { |
| 139 | const conf = new Conf({ projectName: 'create-next-app' }) |
| 140 | |
| 141 | if (opts.resetPreferences) { |
| 142 | const { resetPreferences } = await prompts({ |
| 143 | onState: onPromptState, |
| 144 | type: 'toggle', |
| 145 | name: 'resetPreferences', |
| 146 | message: 'Would you like to reset the saved preferences?', |
| 147 | initial: false, |
| 148 | active: 'Yes', |
| 149 | inactive: 'No', |
| 150 | }) |
| 151 | if (resetPreferences) { |
| 152 | conf.clear() |
| 153 | console.log('The preferences have been reset successfully!') |
| 154 | } |
| 155 | process.exit(0) |
| 156 | } |
| 157 | |
| 158 | if (typeof projectPath === 'string') { |
| 159 | projectPath = projectPath.trim() |
| 160 | } |
| 161 | |
| 162 | if (!projectPath) { |
| 163 | const res = await prompts({ |
| 164 | onState: onPromptState, |
| 165 | type: 'text', |
| 166 | name: 'path', |
| 167 | message: 'What is your project named?', |
| 168 | initial: 'my-app', |
| 169 | validate: (name) => { |
| 170 | const validation = validateNpmName(basename(resolve(name))) |
| 171 | if (validation.valid) { |
| 172 | return true |
| 173 | } |
| 174 | return 'Invalid project name: ' + validation.problems[0] |
| 175 | }, |
| 176 | }) |
| 177 | |
| 178 | if (typeof res.path === 'string') { |
| 179 | projectPath = res.path.trim() |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if (!projectPath) { |
| 184 | console.log( |
| 185 | '\nPlease specify the project directory:\n' + |
| 186 | ` ${cyan(opts.name())} ${green('<project-directory>')}\n` + |
| 187 | 'For example:\n' + |
| 188 | ` ${cyan(opts.name())} ${green('my-next-app')}\n\n` + |
| 189 | `Run ${cyan(`${opts.name()} --help`)} to see all options.` |
| 190 | ) |
| 191 | process.exit(1) |
| 192 | } |
| 193 | |
| 194 | const appPath = resolve(projectPath) |
| 195 | const appName = basename(appPath) |
no test coverage detected