How to use the @react-native-community/cli-tools.logger.warn 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 / config / readConfigFromDisk.ts View on Github external
ios: config.ios,
      android: config.android,
    },
    assets: config.assets,
    commands: [],
    dependencies: {},
    // @ts-ignore - TODO: platforms can be empty, adjust types
    platforms: {},
    get reactNativePath() {
      return config.reactNativePath
        ? path.resolve(rootFolder, config.reactNativePath)
        : resolveReactNativePath(rootFolder);
    },
  };

  logger.warn(
    `Your project is using deprecated "${chalk.bold(
      'rnpm',
    )}" config that will stop working from next release. Please use a "${chalk.bold(
      'react-native.config.js',
    )}" file to configure the React Native CLI. ${MIGRATION_GUIDE}`,
  );

  return transformedConfig;
}
github react-native-community / cli / packages / cli / src / commands / bundle / saveAssets.ts View on Github external
function saveAssets(
  assets: AssetData[],
  platform: string,
  assetsDest: string | undefined,
) {
  if (!assetsDest) {
    logger.warn('Assets destination folder is not set, skipping...');
    return Promise.resolve();
  }

  const getAssetDestPath =
    platform === 'android' ? getAssetDestPathAndroid : getAssetDestPathIOS;

  const filesToCopy: CopiedFiles = Object.create(null); // Map src -> dest
  assets.forEach(asset => {
    const validScales = new Set(
      filterPlatformAssetScales(platform, asset.scales),
    );
    asset.scales.forEach((scale, idx) => {
      if (!validScales.has(scale)) {
        return;
      }
      const src = asset.files[idx];
github react-native-community / cli / packages / cli / src / commands / upgrade / upgrade.ts View on Github external
try {
    fs.writeFileSync(tmpPatchFile, patch);
    patchSuccess = await applyPatch(currentVersion, newVersion, tmpPatchFile);
  } catch (error) {
    throw new Error(error.stderr || error);
  } finally {
    try {
      fs.unlinkSync(tmpPatchFile);
    } catch (e) {
      // ignore
    }
    const {stdout} = await execa('git', ['status', '-s']);
    if (!patchSuccess) {
      if (stdout) {
        logger.warn(
          'Continuing after failure. Some of the files are upgraded but you will need to deal with conflicts manually',
        );
        await installDeps(newVersion);
        logger.info('Running "git status" to check what changed...');
        await execa('git', ['status'], {stdio: 'inherit'});
      } else {
        logger.error(
          'Patch failed to apply for unknown reason. Please fall back to manual way of upgrading',
        );
      }
    } else {
      await installDeps(newVersion);
      await installCocoaPodsDeps(projectDir, thirdPartyIOSDeps);
      logger.info('Running "git status" to check what changed...');
      await execa('git', ['status'], {stdio: 'inherit'});
    }
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / tryRunAdbReverse.ts View on Github external
) {
  try {
    const adbPath = getAdbPath();
    const adbArgs = ['reverse', `tcp:${packagerPort}`, `tcp:${packagerPort}`];

    // If a device is specified then tell adb to use it
    if (device) {
      adbArgs.unshift('-s', device);
    }

    logger.info('Connecting to the development server...');
    logger.debug(`Running command "${adbPath} ${adbArgs.join(' ')}"`);

    execFileSync(adbPath, adbArgs, {stdio: 'inherit'});
  } catch (e) {
    logger.warn(
      `Failed to connect to development server using "adb reverse": ${
        e.message
      }`,
    );
  }
}
github react-native-community / cli / packages / platform-ios / src / link / createGroupWithMessage.ts View on Github external
export default function createGroupWithMessage(project: any, path: string) {
  let group = getGroup(project, path);

  if (!group) {
    group = createGroup(project, path);

    logger.warn(
      `Group '${path}' does not exist in your Xcode project. We have created it automatically for you.`,
    );
  }

  return group;
}
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / getAdbPath.ts View on Github external
function checkAdbPath() {
  const adbPath = getAdbPath();
  const adbPathExists = fs.existsSync(adbPath);
  const adbCmdExists = checkCommandExists('adb');
  const adbNotFoundError = `"adb" not found in $location$. APK installation $prediction$ fail. Make sure you installed the Android SDK correctly. Read more at ${chalk.underline.dim(
    'https://facebook.github.io/react-native/docs/getting-started',
  )}`;
  if (!adbPathExists || !adbCmdExists) {
    const notFoundLocation = `${
      !adbCmdExists ? 'PATH environment variable' : adbPath
    }`;
    logger.warn(
      adbNotFoundError
        .replace('$location$', notFoundLocation)
        .replace('$prediction$', 'might'),
    );
  } else if (!adbPathExists && !adbCmdExists) {
    throw new CLIError(
      adbNotFoundError
        .replace('$location$', `PATH environment variable or ${adbPath}`)
        .replace('$prediction$', 'will'),
    );
  }
}
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / runOnAllDevices.ts View on Github external
packageNameWithSuffix: string,
  packageName: string,
  adbPath: string,
) {
  let devices = adb.getDevices(adbPath);
  if (devices.length === 0) {
    logger.info('Launching emulator...');
    const result = await tryLaunchEmulator(adbPath);
    if (result.success) {
      logger.info('Successfully launched emulator.');
      devices = adb.getDevices(adbPath);
    } else {
      logger.error(
        `Failed to launch emulator. Reason: ${chalk.dim(result.error || '')}.`,
      );
      logger.warn(
        'Please launch an emulator manually or connect a device. Otherwise app may fail to launch.',
      );
    }
  }

  try {
    const tasks = args.tasks || ['install' + toPascalCase(args.variant)];
    const gradleArgs = getTaskNames(args.appFolder, tasks);

    if (args.port != null) {
      gradleArgs.push('-PreactNativeDevServerPort=' + args.port);
    }

    logger.info('Installing the app...');
    logger.debug(
      `Running command "cd android && ${cmd} ${gradleArgs.join(' ')}"`,
github react-native-community / cli / packages / cli / src / tools / config / index.ts View on Github external
platforms: {
        ...acc.platforms,
        ...config.platforms,
      },
      haste: {
        providesModuleNodeModules: [
          ...acc.haste.providesModuleNodeModules,
          ...haste.providesModuleNodeModules,
        ],
        platforms: [...acc.haste.platforms, ...haste.platforms],
      },
    }) as Config;
  }, initialConfig);

  if (depsWithWarnings.length) {
    logger.warn(
      `The following packages use deprecated "rnpm" config that will stop working from next release:\n${depsWithWarnings
        .map(
          ([name, link]) =>
            `  - ${chalk.bold(name)}: ${chalk.dim(chalk.underline(link))}`,
        )
        .join(
          '\n',
        )}\nPlease notify their maintainers about it. You can find more details at ${chalk.dim.underline(
        'https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide',
      )}.`,
    );
  }

  return finalConfig;
}
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / getAdbPath.ts View on Github external
function checkAndroidSDKPath() {
  logger.info('here');
  const {ANDROID_HOME} = process.env;
  if (!ANDROID_HOME || !fs.existsSync(ANDROID_HOME)) {
    throw new CLIError(
      `Android SDK not found. Make sure you have set ANDROID_HOME environment variable in the system. Read more at ${chalk.underline.dim(
        'https://facebook.github.io/react-native/docs/getting-started#3-configure-the-android_home-environment-variable',
      )}`,
    );
  }
  if (ANDROID_HOME.includes(' ')) {
    logger.warn(
      `Android SDK path "${ANDROID_HOME}" contains whitespaces which can cause build and install errors. Consider moving the Android SDK to a non-whitespace path.`,
    );
  }
}