MCPcopy
hub / github.com/callstack/haul / handler

Function handler

packages/haul-cli/src/commands/init.ts:331–367  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 11

getReactNativeVersionFunction · 0.90
checkProjectFunction · 0.85
createHaulProjectConfigFunction · 0.85
modifyBabelConfigFunction · 0.85
modifyXcodeProjectFunction · 0.85
modifyGradleBuildFunction · 0.85
addHaulScriptFunction · 0.85
installDependenciesFunction · 0.85
getRunScriptFunction · 0.85
completeMethod · 0.80
startMethod · 0.65

Tested by

no test coverage detected