How to use the @expo/config.writeConfigJsonAsync 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 / 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 / expo-cli / src / commands / upgrade.ts View on Github external
}

  let packageManager = PackageManager.createForProject(projectRoot, {
    npm: options.npm,
    yarn: options.yarn,
    log,
  });

  log.addNewLineIfNone();
  log(chalk.underline.bold('Installing the expo package...'));
  log.addNewLineIfNone();
  await packageManager.addAsync(`expo@^${targetSdkVersionString}`);

  log.addNewLineIfNone();
  log(chalk.underline.bold('Updating sdkVersion in app.json...'));
  await ConfigUtils.writeConfigJsonAsync(projectRoot, { sdkVersion: targetSdkVersionString });

  log(chalk.bold.underline('Updating packages to compatible versions (where known)...'));
  log.addNewLineIfNone();

  // Get all updated packages
  let updates = await getUpdatedDependenciesAsync(projectRoot, workflow, targetSdkVersion);

  // Split updated packages by dependencies and devDependencies
  let devDependencies = _.pickBy(updates, (_version, name) => _.has(pkg.devDependencies, name));
  let devDependenciesAsStringArray = Object.keys(devDependencies).map(
    name => `${name}@${updates[name]}`
  );
  let dependencies = _.pickBy(updates, (_version, name) => _.has(pkg.dependencies, name));
  let dependenciesAsStringArray = Object.keys(dependencies).map(name => `${name}@${updates[name]}`);

  // Install dev dependencies
github expo / expo-cli / packages / expo-cli / src / commands / permissions.ts View on Github external
async function writePermissionsToIOSAsync(
  projectDir: string,
  { ios = {} }: ExpoConfig,
  permissions: { [permission: string]: string | undefined }
): Promise {
  console.log(
    chalk.magenta(
      `${CHEVRON} Saving selection to the ${chalk.underline`expo.ios.infoPlist`} object in your universal ${chalk.bold`app.json`}...`
    )
  );

  await writeConfigJsonAsync(projectDir, {
    ios: {
      ...ios,
      infoPlist: {
        ...(ios.infoPlist || {}),
        ...permissions,
      },
    },
  });
}
github expo / expo-cli / packages / dev-tools / server / graphql / GraphQLSchema.js View on Github external
async setProjectConfig(parent, { input }, context) {
      const currentProject = context.getCurrentProject();
      const filteredInput = {
        ...input,
        githubUrl: input.githubUrl.match(/^https:\/\/github.com\//) ? input.githubUrl : undefined,
      };
      const { exp } = await writeConfigJsonAsync(currentProject.projectDir, filteredInput);
      return {
        ...currentProject,
        config: exp,
      };
    },
    async sendProjectUrl(parent, { recipient }, context) {