How to use @expo/config - 10 common examples

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 / permissions.ts View on Github external
console.log(
    chalk.magenta(
      `${CHEVRON} Saving selection to the ${chalk.underline`expo.android.permissions`} array in the ${chalk.bold`app.json`}...`
    )
  );
  if (isExpo) {
    if (selectedAll) {
      console.log(
        chalk.magenta(
          `${CHEVRON} Expo will default to using all permissions in your project by deleting the ${chalk.underline`expo.android.permissions`} array.`
        )
      );
    }
  }

  await writeConfigJsonAsync(projectDir, {
    android: {
      ...(exp.android || {}),
      // An empty array means no permissions
      // No value means all permissions
      permissions: selectedAll
        ? undefined
        : answer.map((permission: string) => {
            if (permission.startsWith('android.permission.')) {
              return permission.split('.').pop();
            }
            return permission;
          }),
    },
  });

  if (!isExpo) {
github expo / expo-cli / packages / webpack-config / src / Diagnosis.ts View on Github external
async function logAutoConfigValuesAsync(env: Environment) {
  const locations = env.locations || (await getPathsAsync(env.projectRoot));

  const { exp: config } = readConfigJson(env.projectRoot, true, true);

  const standardConfig = ensurePWAConfig({}, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });
  const pwaConfig = ensurePWAConfig(config, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });

  // @ts-ignore
  const nonStandard = diff(standardConfig, pwaConfig);

  let obj = {};

  for (const diff of nonStandard) {
    // console.log(chalk.bold(diff.path.join('/') + ': ') + chalk.bgRed(JSON.stringify(diff.rhs, null, 2)));
github expo / expo-cli / packages / webpack-config / src / utils / Diagnosis.ts View on Github external
async function logAutoConfigValuesAsync(env: Environment) {
  const locations = env.locations || (await getPathsAsync(env.projectRoot));

  const { exp: config } = readConfigJson(env.projectRoot);

  const standardConfig = ensurePWAConfig({}, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });
  const pwaConfig = ensurePWAConfig(config, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });

  // @ts-ignore
  const nonStandard = diff(standardConfig, pwaConfig);

  let obj = {};

  for (const diff of nonStandard) {
    // console.log(chalk.bold(diff.path.join('/') + ': ') + chalk.bgRed(JSON.stringify(diff.rhs, null, 2)));
github expo / expo-cli / packages / webpack-config / src / Diagnosis.ts View on Github external
async function logAutoConfigValuesAsync(env: Environment) {
  const locations = env.locations || (await getPathsAsync(env.projectRoot));

  const { exp: config } = readConfigJson(env.projectRoot, true, true);

  const standardConfig = ensurePWAConfig({}, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });
  const pwaConfig = ensurePWAConfig(config, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });

  // @ts-ignore
  const nonStandard = diff(standardConfig, pwaConfig);

  let obj = {};

  for (const diff of nonStandard) {
    // console.log(chalk.bold(diff.path.join('/') + ': ') + chalk.bgRed(JSON.stringify(diff.rhs, null, 2)));

    // TODO: Bacon: add support for array updates: https://www.npmjs.com/package/deep-diff#differences
    if (diff.kind !== 'A') {
github expo / expo-cli / packages / webpack-config / src / utils / Diagnosis.ts View on Github external
async function logAutoConfigValuesAsync(env: Environment) {
  const locations = env.locations || (await getPathsAsync(env.projectRoot));

  const { exp: config } = readConfigJson(env.projectRoot);

  const standardConfig = ensurePWAConfig({}, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });
  const pwaConfig = ensurePWAConfig(config, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });

  // @ts-ignore
  const nonStandard = diff(standardConfig, pwaConfig);

  let obj = {};

  for (const diff of nonStandard) {
    // console.log(chalk.bold(diff.path.join('/') + ': ') + chalk.bgRed(JSON.stringify(diff.rhs, null, 2)));

    // TODO: Bacon: add support for array updates: https://www.npmjs.com/package/deep-diff#differences
    if (diff.kind !== 'A') {
      setDeepValue(diff.path, obj, diff);
    }
  }
github expo / expo-cli / packages / webpack-config / src / utils / Diagnosis.ts View on Github external
async function logAutoConfigValuesAsync(env: Environment) {
  const locations = env.locations || (await getPathsAsync(env.projectRoot));

  const { exp: config } = readConfigJson(env.projectRoot);

  const standardConfig = ensurePWAConfig({}, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });
  const pwaConfig = ensurePWAConfig(config, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });

  // @ts-ignore
  const nonStandard = diff(standardConfig, pwaConfig);

  let obj = {};

  for (const diff of nonStandard) {
    // console.log(chalk.bold(diff.path.join('/') + ': ') + chalk.bgRed(JSON.stringify(diff.rhs, null, 2)));

    // TODO: Bacon: add support for array updates: https://www.npmjs.com/package/deep-diff#differences
    if (diff.kind !== 'A') {
github expo / expo-cli / packages / webpack-config / src / Diagnosis.ts View on Github external
async function logAutoConfigValuesAsync(env: Environment) {
  const locations = env.locations || (await getPathsAsync(env.projectRoot));

  const { exp: config } = readConfigJson(env.projectRoot, true, true);

  const standardConfig = ensurePWAConfig({}, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });
  const pwaConfig = ensurePWAConfig(config, locations.absolute, {
    templateIcon: locations.template.get('icon.png'),
  });

  // @ts-ignore
  const nonStandard = diff(standardConfig, pwaConfig);

  let obj = {};

  for (const diff of nonStandard) {
    // console.log(chalk.bold(diff.path.join('/') + ': ') + chalk.bgRed(JSON.stringify(diff.rhs, null, 2)));

    // TODO: Bacon: add support for array updates: https://www.npmjs.com/package/deep-diff#differences
    if (diff.kind !== 'A') {
      setDeepValue(diff.path, obj, diff);
    }
  }
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