()
| 329 | command: 'init', |
| 330 | describe: 'Generates necessary configuration files', |
| 331 | async handler() { |
| 332 | let exitCode = 0; |
| 333 | try { |
| 334 | const cwd = process.cwd(); |
| 335 | const rnVersion = getReactNativeVersion(cwd); |
| 336 | |
| 337 | if (!rnVersion) { |
| 338 | runtime.logger.error( |
| 339 | 'Cannot find React Native. Are you in React Native project?' |
| 340 | ); |
| 341 | runtime.complete(1); |
| 342 | } |
| 343 | |
| 344 | const babelPreset = '@haul-bundler/babel-preset-react-native'; |
| 345 | const haulPreset = `@haul-bundler/preset-${rnVersion!.major}.${ |
| 346 | rnVersion!.minor |
| 347 | }`; |
| 348 | |
| 349 | const progress = ora().start(); |
| 350 | |
| 351 | await checkProject(progress, cwd, runtime); |
| 352 | await createHaulProjectConfig(progress, cwd, runtime, haulPreset); |
| 353 | await modifyBabelConfig(progress, cwd, runtime, babelPreset); |
| 354 | await modifyXcodeProject(progress, cwd); |
| 355 | await modifyGradleBuild(progress, cwd); |
| 356 | const scriptName = await addHaulScript(progress, cwd); |
| 357 | await installDependencies(progress, { babelPreset, haulPreset }); |
| 358 | progress.succeed( |
| 359 | `You can now start Haul by running '${getRunScript(scriptName)}'` |
| 360 | ); |
| 361 | } catch (error) { |
| 362 | runtime.logger.error('Command failed with error:', error); |
| 363 | exitCode = 1; |
| 364 | } finally { |
| 365 | runtime.complete(exitCode); |
| 366 | } |
| 367 | }, |
| 368 | }; |
| 369 | } |
nothing calls this directly
no test coverage detected