How to use the @expo/xdl.Versions.gteSdkVersion function in @expo/xdl

To help you get started, we’ve selected a few @expo/xdl 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 expo / expo-cli / packages / expo-cli / src / commands / eject / Eject.ts View on Github external
async function ejectToBareAsync(projectRoot: string): Promise {
  const useYarn = ConfigUtils.isUsingYarn(projectRoot);
  const npmOrYarn = useYarn ? 'yarn' : 'npm';
  const { configPath, configName } = ConfigUtils.findConfigFile(projectRoot);
  const { exp, pkg } = await ConfigUtils.readConfigJsonAsync(projectRoot);

  const configBuffer = await fse.readFile(configPath);
  const appJson = configName === 'app.json' ? JSON.parse(configBuffer.toString()) : {};

  /**
   * Perform validations
   */
  if (!exp.sdkVersion) throw new Error(`Couldn't read ${configName}`);

  if (!Versions.gteSdkVersion(exp, '34.0.0')) {
    throw new Error(`Ejecting to a bare project is only available for SDK 34 and higher`);
  }

  // Validate that the template exists
  let sdkMajorVersionNumber = semver.major(exp.sdkVersion);
  let templateSpec = npmPackageArg(`expo-template-bare-minimum@sdk-${sdkMajorVersionNumber}`);
  try {
    await pacote.manifest(templateSpec);
  } catch (e) {
    if (e.code === 'E404') {
      throw new Error(
        `Unable to eject because an eject template for SDK ${sdkMajorVersionNumber} was not found`
      );
    } else {
      throw e;
    }
github expo / expo-cli / packages / expo-cli / src / commands / upgrade.ts View on Github external
if (!isGitStatusClean) {
    let answer = await prompt({
      type: 'confirm',
      name: 'ignoreDirtyGit',
      message: `Would you like to proceed?`,
    });

    if (!answer.ignoreDirtyGit) {
      return;
    }

    log.newLine();
  }

  // Give people a chance to bail out if they're updating from a super old version because YMMV
  if (!Versions.gteSdkVersion(exp, '33.0.0')) {
    let answer = await prompt({
      type: 'confirm',
      name: 'attemptOldUpdate',
      message: `This command works best on SDK 33 and higher. We can try updating for you, but you will likely need to follow up with the instructions from https://docs.expo.io/versions/latest/workflow/upgrading-expo-sdk-walkthrough/. Continue anyways?`,
    });

    if (!answer.attemptOldUpdate) {
      return;
    }

    log.newLine();
  }

  // Can't upgrade if we don't have a SDK version (tapping on head meme)
  if (!exp.sdkVersion) {
    if (workflow === 'bare') {
github expo / expo-cli / packages / expo-cli / src / commands / start.js View on Github external
async function validateDependenciesVersions(projectDir, exp, pkg) {
  if (!Versions.gteSdkVersion(exp, '33.0.0')) {
    return;
  }

  const bundleNativeModulesPath = attempt(() =>
    ConfigUtils.resolveModule('expo/bundledNativeModules.json', projectDir, exp)
  );
  if (isError(bundleNativeModulesPath)) {
    log.warn(
      `Your project is in SDK version >= 33.0.0, but the ${chalk.underline(
        'expo'
      )} package version seems to be older.`
    );
    return;
  }

  const bundledNativeModules = await JsonFile.readAsync(bundleNativeModulesPath);
github expo / expo-cli / packages / expo-cli / src / commands / upgrade.ts View on Github external
        v => semver.lte('33.0.0', v) && !Versions.gteSdkVersion(exp, v)
      );
github expo / expo-cli / packages / expo-cli / src / commands / install.ts View on Github external
async function installAsync(packages: string[], options: PackageManager.CreateForProjectOptions) {
  const { projectRoot, workflow } = await findProjectRootAsync(process.cwd());
  const packageManager = PackageManager.createForProject(projectRoot, {
    npm: options.npm,
    yarn: options.yarn,
    log,
  });

  if (workflow === 'bare') {
    return await packageManager.addAsync(...packages);
  }

  const { exp } = await ConfigUtils.readConfigJsonAsync(projectRoot);
  if (!Versions.gteSdkVersion(exp, '33.0.0')) {
    throw new CommandError(
      'UNSUPPORTED_SDK_VERSION',
      `expo install is only available for managed apps using Expo SDK version 33 or higher. Current version: ${exp.sdkVersion}.`
    );
  }

  if (!fs.existsSync(path.join(exp.nodeModulesPath || projectRoot, 'node_modules'))) {
    log.warn(`node_modules not found, running ${packageManager.name} install command.`);
    await packageManager.installAsync();
  }

  const bundledNativeModules = await JsonFile.readAsync(
    ConfigUtils.resolveModule('expo/bundledNativeModules.json', projectRoot, exp)
  );

  const nativeModules = [];