(name, verbose, version, template, useYarn, usePnp)
| 233 | } |
| 234 | |
| 235 | function createApp(name, verbose, version, template, useYarn, usePnp) { |
| 236 | const unsupportedNodeVersion = !semver.satisfies( |
| 237 | // Coerce strings with metadata (i.e. `15.0.0-nightly`). |
| 238 | semver.coerce(process.version), |
| 239 | '>=14' |
| 240 | ); |
| 241 | |
| 242 | if (unsupportedNodeVersion) { |
| 243 | console.log( |
| 244 | chalk.yellow( |
| 245 | `You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` + |
| 246 | `Please update to Node 14 or higher for a better, fully supported experience.\n` |
| 247 | ) |
| 248 | ); |
| 249 | // Fall back to latest supported react-scripts on Node 4 |
| 250 | version = 'react-scripts@0.9.x'; |
| 251 | } |
| 252 | |
| 253 | const root = path.resolve(name); |
| 254 | const appName = path.basename(root); |
| 255 | |
| 256 | checkAppName(appName); |
| 257 | fs.ensureDirSync(name); |
| 258 | if (!isSafeToCreateProjectIn(root, name)) { |
| 259 | process.exit(1); |
| 260 | } |
| 261 | console.log(); |
| 262 | |
| 263 | console.log(`Creating a new React app in ${chalk.green(root)}.`); |
| 264 | console.log(); |
| 265 | |
| 266 | const packageJson = { |
| 267 | name: appName, |
| 268 | version: '0.1.0', |
| 269 | private: true, |
| 270 | }; |
| 271 | fs.writeFileSync( |
| 272 | path.join(root, 'package.json'), |
| 273 | JSON.stringify(packageJson, null, 2) + os.EOL |
| 274 | ); |
| 275 | |
| 276 | const originalDirectory = process.cwd(); |
| 277 | process.chdir(root); |
| 278 | if (!useYarn && !checkThatNpmCanReadCwd()) { |
| 279 | process.exit(1); |
| 280 | } |
| 281 | |
| 282 | if (!useYarn) { |
| 283 | const npmInfo = checkNpmVersion(); |
| 284 | if (!npmInfo.hasMinNpm) { |
| 285 | if (npmInfo.npmVersion) { |
| 286 | console.log( |
| 287 | chalk.yellow( |
| 288 | `You are using npm ${npmInfo.npmVersion} so the project will be bootstrapped with an old unsupported version of tools.\n\n` + |
| 289 | `Please update to npm 6 or higher for a better, fully supported experience.\n` |
| 290 | ) |
| 291 | ); |
| 292 | } |
no test coverage detected