How to use the @expo/config.readConfigJsonAsync function in @expo/config

To help you get started, we’ve selected a few @expo/config 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 / build / BaseBuilder.js View on Github external
async prepareProjectInfo(): Promise {
    // always use local json to unify behaviour between regular apps and self hosted ones
    const { exp } = await readConfigJsonAsync(this.projectDir);
    this.manifest = exp;
    this.user = await UserManager.ensureLoggedInAsync();

    await this.checkProjectConfig();
  }
github expo / expo-cli / packages / xdl / src / Project.ts View on Github external
async function getConfigAsync(
  projectRoot: string,
  options: {
    current?: boolean;
    mode?: string;
    platform?: 'android' | 'ios' | 'all';
    expIds?: Array;
    type?: string;
    releaseChannel?: string;
    bundleIdentifier?: string;
    publicUrl?: string;
  } = {}
) {
  if (!options.publicUrl) {
    // get the manifest from the project directory
    const { exp, pkg } = await readConfigJsonAsync(projectRoot);
    const configName = configFilename(projectRoot);
    return {
      exp,
      pkg,
      configName: configFilename(projectRoot),
      configPrefix: configName === 'app.json' ? 'expo.' : '',
    };
  } else {
    // get the externally hosted manifest
    return {
      exp: await ThirdParty.getManifest(options.publicUrl, options),
      configName: options.publicUrl,
      configPrefix: '',
      pkg: {},
    };
  }
github expo / expo-cli / packages / xdl / src / UrlUtils.ts View on Github external
opts = defaultOpts;
  } else {
    opts = Object.assign({}, defaultOpts, opts);
  }

  let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);

  let protocol;
  if (opts.urlType === 'http') {
    protocol = 'http';
  } else if (opts.urlType === 'no-protocol') {
    protocol = null;
  } else {
    protocol = 'exp';

    let { exp } = await readConfigJsonAsync(projectRoot);
    if (exp.detach) {
      if (exp.scheme && Versions.gteSdkVersion(exp, '27.0.0')) {
        protocol = exp.scheme;
      } else if (exp.detach.scheme) {
        // must keep this fallback in place for older projects
        // and those detached with an older version of xdl
        protocol = exp.detach.scheme;
      }
    }
  }

  let hostname;
  let port;

  const proxyURL = isPackager
    ? process.env.EXPO_PACKAGER_PROXY_URL
github expo / expo-cli / packages / xdl / src / Project.ts View on Github external
export async function startReactNativeServerAsync(
  projectRoot: string,
  options: StartOptions = {},
  verbose: boolean = true
): Promise {
  _assertValidProjectRoot(projectRoot);
  await stopReactNativeServerAsync(projectRoot);
  await Watchman.addToPathAsync(); // Attempt to fix watchman if it's hanging
  await Watchman.unblockAndGetVersionAsync(projectRoot);

  let { exp } = await readConfigJsonAsync(projectRoot);

  let packagerPort = await _getFreePortAsync(19001); // Create packager options

  const customLogReporterPath: string = require.resolve(path.join(__dirname, 'reporter'));

  let packagerOpts: { [key: string]: any } = {
    port: packagerPort,
    customLogReporterPath,
    // TODO: Bacon: Support .mjs (short-lived JS modules extension that some packages use)
    sourceExts: getManagedExtensions([], { isTS: true, isReact: true, isModern: false }),
  };

  if (options.nonPersistent && Versions.lteSdkVersion(exp, '32.0.0')) {
    packagerOpts.nonPersistent = true;
  }
github expo / expo-cli / packages / xdl / src / project / ExpSchema.ts View on Github external
export async function validatorFromProjectRoot(projectRoot: string): Promise {
  const { exp } = await ConfigUtils.readConfigJsonAsync(projectRoot);
  if (!exp.sdkVersion) throw new Error(`Couldn't read local manifest`);
  const schema = await getSchemaAsync(exp.sdkVersion);
  const validator = new Schemer(schema);
  return validator;
}
github expo / expo-cli / packages / expo-cli / src / commands / start / TerminalUI.js View on Github external
const printUsage = async (projectDir, options = {}) => {
  const { dev } = await ProjectSettings.readAsync(projectDir);
  const { exp } = await readConfigJsonAsync(projectDir);
  const openDevToolsAtStartup = await UserSettings.getAsync('openDevToolsAtStartup', true);
  const username = await UserManager.getCurrentUsernameAsync();
  const devMode = dev ? 'development' : 'production';
  const androidInfo = `${b`a`} to run on ${u`A`}ndroid device/emulator`;
  const iosInfo = process.platform === 'darwin' ? `${b`i`} to run on ${u`i`}OS simulator` : '';
  const webInfo = exp.platforms.includes('web') ? `${b`w`} to run on ${u`w`}eb` : '';
  const platformInfo = [androidInfo, iosInfo, webInfo].filter(Boolean).join(', or ');
  log.nested(`
 \u203A Press ${platformInfo}.
 \u203A Press ${b`c`} to show info on ${u`c`}onnecting new devices.
 \u203A Press ${b`d`} to open DevTools in the default web browser.
 \u203A Press ${b`shift-d`} to ${
    openDevToolsAtStartup ? 'disable' : 'enable'
  } automatically opening ${u`D`}evTools at startup.${
    options.webOnly ? '' : `\n \u203A Press ${b`e`} to send an app link with ${u`e`}mail.`
  }
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)
  );
github expo / expo-cli / packages / xdl / src / Webpack.ts View on Github external
export async function getProjectNameAsync(projectRoot: string): Promise {
  const { exp } = await ConfigUtils.readConfigJsonAsync(projectRoot, true);
  const { webName } = ConfigUtils.getNameFromConfig(exp);
  return webName;
}