How to use the @react-native-community/cli-tools.logger.log function in @react-native-community/cli-tools

To help you get started, we’ve selected a few @react-native-community/cli-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-native-community / cli / packages / cli / src / tools / installPods.ts View on Github external
async function updatePods(loader: ora.Ora) {
  try {
    loader.start(
      `Updating CocoaPods repositories ${chalk.dim(
        '(this may take a few minutes)',
      )}`,
    );
    await execa('pod', ['repo', 'update']);
  } catch (error) {
    // "pod" command outputs errors to stdout (at least some of them)
    logger.log(error.stderr || error.stdout);
    loader.fail();

    throw new Error(
      `Failed to update CocoaPods repositories for iOS project.\nPlease try again manually: "pod repo update".\nCocoaPods documentation: ${chalk.dim.underline(
        'https://cocoapods.org/',
      )}`,
    );
  }
}
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / runOnAllDevices.ts View on Github external
function createInstallError(error: Error & {stderr: string}) {
  const stderr = (error.stderr || '').toString();
  const docs =
    'https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment';
  let message = `Make sure you have the Android development environment set up: ${chalk.underline.dim(
    docs,
  )}`;

  // Pass the error message from the command to stdout because we pipe it to
  // parent process so it's not visible
  logger.log(stderr);

  // Handle some common failures and make the errors more helpful
  if (stderr.includes('No connected devices')) {
    message =
      'Make sure you have an Android emulator running or a device connected';
  } else if (
    stderr.includes('licences have not been accepted') ||
    stderr.includes('accept the SDK license')
  ) {
    message = `Please accept all necessary SDK licenses using SDK Manager: "${chalk.bold(
      '$ANDROID_HOME/tools/bin/sdkmanager --licenses',
    )}"`;
  }

  return new CLIError(`Failed to install the app. ${message}.`, error);
}
github react-native-community / cli / packages / cli / src / tools / installPods.ts View on Github external
}

    if (shouldUpdatePods) {
      await updatePods(loader);
    }

    try {
      loader.start(
        `Installing CocoaPods dependencies ${chalk.dim(
          '(this may take a few minutes)',
        )}`,
      );
      await execa('pod', ['install']);
    } catch (error) {
      // "pod" command outputs errors to stdout (at least some of them)
      logger.log(error.stderr || error.stdout);

      throw new Error(
        `Failed to install CocoaPods dependencies for iOS project, which is required by this template.\nPlease try again manually: "cd ./${projectName}/ios && pod install".\nCocoaPods documentation: ${chalk.dim.underline(
          'https://cocoapods.org/',
        )}`,
      );
    }
  } catch (error) {
    throw error;
  } finally {
    process.chdir('..');
  }
}
github react-native-community / cli / packages / cli / src / commands / doctor / healthchecks / common.ts View on Github external
const logMessage = (message?: string) => {
  const indentation = '   ';

  if (typeof message !== 'string') {
    logger.log();

    return;
  }

  const messageByLine = message.split('\n');

  return logger.log(`${indentation}${messageByLine.join(`\n${indentation}`)}`);
};
github react-native-community / cli / packages / cli / src / commands / init / init.ts View on Github external
async function createFromTemplate({
  projectName,
  templateName,
  npm,
  directory,
  projectTitle,
}: TemplateOptions) {
  logger.debug('Initializing new project');
  logger.log(banner);

  const projectDirectory = await setProjectDirectory(directory);

  const Loader = getLoader();
  const loader = new Loader({text: 'Downloading template'});
  const templateSourceDir = fs.mkdtempSync(
    path.join(os.tmpdir(), 'rncli-init-template-'),
  );

  try {
    loader.start();
    let {uri, name} = await processTemplateName(templateName);

    await installTemplatePackage(uri, templateSourceDir, npm);

    loader.succeed();
github react-native-community / cli / packages / cli / src / commands / doctor / doctor.ts View on Github external
const printCategory = ({label, key}: {label: string; key: number}) => {
  if (key > 0) {
    logger.log();
  }

  logger.log(chalk.dim(label));
};
github react-native-community / cli / packages / cli / src / commands / doctor / printFixOptions.ts View on Github external
const printOptions = () => {
  logger.log();
  logger.log(chalk.bold('Usage'));
  printOption(
    `${chalk.dim('Press')} ${KEYS.FIX_ALL_ISSUES} ${chalk.dim(
      'to try to fix issues.',
    )}`,
  );
  printOption(
    `${chalk.dim('Press')} ${KEYS.FIX_ERRORS} ${chalk.dim(
      'to try to fix errors.',
    )}`,
  );
  printOption(
    `${chalk.dim('Press')} ${KEYS.FIX_WARNINGS} ${chalk.dim(
      'to try to fix warnings.',
    )}`,
  );
github react-native-community / cli / packages / cli / src / commands / doctor / printFixOptions.ts View on Github external
const printOptions = () => {
  logger.log();
  logger.log(chalk.bold('Usage'));
  printOption(
    `${chalk.dim('Press')} ${KEYS.FIX_ALL_ISSUES} ${chalk.dim(
      'to try to fix issues.',
    )}`,
  );
  printOption(
    `${chalk.dim('Press')} ${KEYS.FIX_ERRORS} ${chalk.dim(
      'to try to fix errors.',
    )}`,
  );
  printOption(
    `${chalk.dim('Press')} ${KEYS.FIX_WARNINGS} ${chalk.dim(
      'to try to fix warnings.',
    )}`,
  );
  printOption(`${chalk.dim('Press')} Enter ${chalk.dim('to exit.')}`);