How to use the @expo/config.readConfigJson 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 / 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 / packages / jest-expo-puppeteer / src / index.ts View on Github external
export function withExpoPuppeteer(config: any = {}): { [key: string]: any } {
  const {
    mode = process.env.EXPO_WEB_E2E_ENV,
    preventRebuild,
    server = {},
    launch = {},
    projectRoot,
    ...partConfig
  } = config;
  const projectPath = path.resolve(projectRoot || process.cwd());

  // @ts-ignore: ProjectConfig doesn't declare "web" -- either fix this or the declaration
  const { web = {} } = readConfigJson(projectPath);

  const hasServerSideRendering = web.use === 'nextjs';
  const defaultPort = hasServerSideRendering ? 8000 : 5000;
  const { port: serverPort = defaultPort } = server;
  let defaultURL;
  let command;

  // Tell Expo CLI to use the same port on which the test runner expects there to be a server
  process.env.WEB_PORT = serverPort;

  if (mode === 'production') {
    defaultURL = `http://localhost:${serverPort}`;

    const outputBuildPath = (web.build || {}).output || 'web-build';

    const buildFolder = path.resolve(projectPath, outputBuildPath);
github expo / expo-cli / packages / xdl / src / Project.ts View on Github external
const manifestHandler = async (req: express.Request, res: express.Response) => {
    try {
      // We intentionally don't `await`. We want to continue trying even
      // if there is a potential error in the package.json and don't want to slow
      // down the request
      Doctor.validateWithNetworkAsync(projectRoot);
      let { exp: manifest } = readConfigJson(projectRoot);
      // Get packager opts and then copy into bundleUrlPackagerOpts
      let packagerOpts = await ProjectSettings.getPackagerOptsAsync(projectRoot);
      let bundleUrlPackagerOpts = JSON.parse(JSON.stringify(packagerOpts));
      bundleUrlPackagerOpts.urlType = 'http';
      if (bundleUrlPackagerOpts.hostType === 'redirect') {
        bundleUrlPackagerOpts.hostType = 'tunnel';
      }
      manifest.xde = true; // deprecated
      manifest.developer = {
        tool: Config.developerTool,
        projectRoot,
      };
      manifest.packagerOpts = packagerOpts;
      manifest.env = {};
      for (let key of Object.keys(process.env)) {
        if (shouldExposeEnvironmentVariableInManifest(key)) {
github expo / expo / packages / jest-expo-puppeteer / build / index.js View on Github external
function withExpoPuppeteer(config = {}) {
    const { mode = process.env.EXPO_WEB_E2E_ENV, preventRebuild, server = {}, launch = {}, projectRoot } = config, partConfig = __rest(config, ["mode", "preventRebuild", "server", "launch", "projectRoot"]);
    const projectPath = path_1.default.resolve(projectRoot || process.cwd());
    // @ts-ignore: ProjectConfig doesn't declare "web" -- either fix this or the declaration
    const { web = {} } = config_1.readConfigJson(projectPath);
    const hasServerSideRendering = web.use === 'nextjs';
    const defaultPort = hasServerSideRendering ? 8000 : 5000;
    const { port: serverPort = defaultPort } = server;
    let defaultURL;
    let command;
    // Tell Expo CLI to use the same port on which the test runner expects there to be a server
    process.env.WEB_PORT = serverPort;
    if (mode === 'production') {
        defaultURL = `http://localhost:${serverPort}`;
        const outputBuildPath = (web.build || {}).output || 'web-build';
        const buildFolder = path_1.default.resolve(projectPath, outputBuildPath);
        const serveCommand = `serve ${buildFolder}`;
        const commands = [serveCommand];
        const hasBuild = fs_1.default.existsSync(buildFolder);
        if (!preventRebuild || !hasBuild) {
            const buildCommand = `node ${require.resolve('./build-expo.js')} ${projectPath}`;
github expo / expo-cli / packages / dev-server / src / MetroDevServer.ts View on Github external
function getMetroInstance(projectRoot: string): any {
  const { exp } = readConfigJson(projectRoot, true, true);
  const Metro = require(resolveModule('metro', projectRoot, exp));
  return Metro;
}