How to use @expo/xdl - 10 common examples

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 / apps / test-suite / runner / Run.js View on Github external
payload = JSON.parse(chunk.msg);
          } catch (e) {
            return;
          }

          if (
            payload.type === 'initialize_packager_done' /* SDK <=22 */ ||
            payload.type === 'initialize_done'
          ) {
            resolve();
          }
        },
      },
    });
  });
  await Project.startAsync(testSuitePath);
  await packagerStarted;

  Log.collapsed('get url');
  const settings = await ProjectSettings.readPackagerInfoAsync(testSuitePath);
  const url = `exp://localhost:${settings.expoServerPort}`;
  console.log(`URL is ${url}`);

  Log.collapsed('sanity check manifest');
  const manifestResponse = await request.get({
    url: url.replace(/^exp/, 'http'),
  });
  const manifest = JSON.parse(manifestResponse.body);
  if (!manifest.name === 'test-suite') {
    throw new Error('Bad name in test-suite manifest');
  }
github expo / expo / apps / test-suite / runner / Run.js View on Github external
// Wait for and parse results
  const allDone = new Promise(resolve => {
    ProjectUtils.attachLoggerStream(testSuitePath, {
      type: 'raw',
      stream: {
        write: chunk => {
          if (chunk.msg.indexOf('[TEST-SUITE-END]') >= 0) {
            resolve(JSON.parse(chunk.msg));
          }
        },
      },
    });
  });
  const results = await allDone;
  await Project.stopAsync(testSuitePath);
  process.exit(results.failed);
}
github expo / expo-cli / packages / expo-cli / src / credentials / context.ts View on Github external
async init(projectDir: string) {
    const status = await Doctor.validateWithoutNetworkAsync(projectDir);
    if (status !== Doctor.FATAL) {
      /* This manager does not need to work in project context */
      const { exp } = await readConfigJsonAsync(projectDir);
      this._manifest = exp;
      this._hasProjectContext = true;
    }

    this._user = await UserManager.ensureLoggedInAsync();
    this._apiClient = ApiV2.clientForUser(this.user);
    this._iosApiClient = new IosApi(this._user);
  }
}
github expo / expo / tools / expotools / src / dynamic-macros / IosMacrosGenerator.ts View on Github external
infoPlistContents,
  keys
): Promise {
  const plistPath = path.dirname(buildConfigPlistPath);
  const plistName = path.basename(buildConfigPlistPath);

  if (!(await fs.exists(buildConfigPlistPath))) {
    await IosPlist.createBlankAsync(plistPath, plistName);
  }

  console.log(
    'Generating build config %s ...',
    chalk.cyan(path.relative(EXPO_DIR, buildConfigPlistPath))
  );

  const result = await IosPlist.modifyAsync(plistPath, plistName, config => {
    if (config.USE_GENERATED_DEFAULTS === false) {
      // this flag means don't generate anything, let the user override.
      return config;
    }

    for (const [name, value] of Object.entries(macros)) {
      config[name] = value || '';
    }

    config.EXPO_RUNTIME_VERSION = infoPlistContents.CFBundleVersion
      ? infoPlistContents.CFBundleVersion
      : infoPlistContents.CFBundleShortVersionString;

    if (!config.API_SERVER_ENDPOINT) {
      config.API_SERVER_ENDPOINT = 'https://exp.host/--/api/v2/';
    }
github expo / expo-cli / packages / expo-cli / src / commands / export.js View on Github external
throw new CommandError(
      'OUTPUT_DIR_EXISTS',
      `Output directory ${outputPath} already exists. Aborting export.`
    );
  }
  if (!options.publicUrl) {
    throw new CommandError('MISSING_PUBLIC_URL', 'Missing required option: --public-url');
  }
  // If we are not in dev mode, ensure that url is https
  if (!options.dev && !UrlUtils.isHttps(options.publicUrl)) {
    throw new CommandError('INVALID_PUBLIC_URL', '--public-url must be a valid HTTPS URL.');
  } else if (!validator.isURL(options.publicUrl, { protocols: ['http', 'https'] })) {
    console.warn(`Dev Mode: publicUrl ${options.publicUrl} does not conform to HTTP format.`);
  }

  const status = await Project.currentStatus(projectDir);

  let startedOurOwn = false;
  if (status !== 'running') {
    log('Unable to find an existing Expo CLI instance for this directory, starting a new one...');

    installExitHooks(projectDir);

    const startOpts = { reset: options.clear, nonPersistent: true };
    if (options.maxWorkers) {
      startOpts.maxWorkers = options.maxWorkers;
    }
    log('Exporting your app...');
    await Project.startAsync(projectDir, startOpts, !options.quiet);
    startedOurOwn = true;
  }
github expo / expo-cli / packages / expo-cli / src / credentials / context.ts View on Github external
async init(projectDir: string) {
    const status = await Doctor.validateWithoutNetworkAsync(projectDir);
    if (status !== Doctor.FATAL) {
      /* This manager does not need to work in project context */
      const { exp } = await readConfigJsonAsync(projectDir);
      this._manifest = exp;
      this._hasProjectContext = true;
    }

    this._user = await UserManager.ensureLoggedInAsync();
    this._apiClient = ApiV2.clientForUser(this.user);
    this._iosApiClient = new IosApi(this._user);
  }
}
github expo / expo / tools / expotools / src / commands / PromoteVersionsToProduction.ts View on Github external
async function action() {
  // Get from staging
  Config.api.host = STAGING_HOST;
  const versionsStaging = await Versions.versionsAsync();

  // since there is only one versions cache, we need to wait a small
  // amount of time so that the cache is invalidated before fetching from prod
  await new Promise(resolve => setTimeout(resolve, 10));

  Config.api.host = PRODUCTION_HOST;
  const versionsProd = await Versions.versionsAsync();
  const delta = jsondiffpatch.diff(versionsProd, versionsStaging);

  if (!delta) {
    console.log(chalk.yellow('There are no changes to apply in the configuration.'));
    return;
  }

  console.log(`Here is the diff from ${chalk.green('staging')} -> ${chalk.green('production')}:`);
  console.log(jsondiffpatch.formatters.console.format(delta, versionsProd));

  const { isCorrect } = await inquirer.prompt<{ isCorrect: boolean }>([
    {
      type: 'confirm',
      name: 'isCorrect',
      message: `Does this look correct? Type \`y\` to update ${chalk.green('production')} config.`,
github expo / expo / tools / expotools / src / commands / PromoteVersionsToProduction.ts View on Github external
async function action() {
  // Get from staging
  Config.api.host = STAGING_HOST;
  const versionsStaging = await Versions.versionsAsync();

  // since there is only one versions cache, we need to wait a small
  // amount of time so that the cache is invalidated before fetching from prod
  await new Promise(resolve => setTimeout(resolve, 10));

  Config.api.host = PRODUCTION_HOST;
  const versionsProd = await Versions.versionsAsync();
  const delta = jsondiffpatch.diff(versionsProd, versionsStaging);

  if (!delta) {
    console.log(chalk.yellow('There are no changes to apply in the configuration.'));
    return;
  }

  console.log(`Here is the diff from ${chalk.green('staging')} -> ${chalk.green('production')}:`);
github expo / expo-cli / packages / expo-cli / src / commands / publish-info.js View on Github external
.asyncActionProjectDir(async (projectDir, options) => {
      if (options.count && (isNaN(options.count) || options.count < 1 || options.count > 100)) {
        throw new Error('-n must be a number between 1 and 100 inclusive');
      }

      // TODO(ville): handle the API result for not authenticated user instead of checking upfront
      const user = await UserManager.ensureLoggedInAsync();
      const { exp } = await readConfigJsonAsync(projectDir);

      let result: any;
      if (process.env.EXPO_NEXT_API) {
        const api = ApiV2.clientForUser(user);
        result = await api.postAsync('publish/history', {
          owner: exp.owner,
          slug: await Project.getSlugAsync(projectDir, options),
          version: VERSION,
          releaseChannel: options.releaseChannel,
          count: options.count,
          platform: options.platform,
        });
      } else {
        // TODO(ville): move request from multipart/form-data to JSON once supported by the endpoint.
        let formData = new FormData();
        formData.append('queryType', 'history');
        if (exp.owner) {
          formData.append('owner', exp.owner);
        }
        formData.append('slug', await Project.getSlugAsync(projectDir, options));
github expo / expo-cli / packages / expo-cli / src / commands / export.js View on Github external
}

  const status = await Project.currentStatus(projectDir);

  let startedOurOwn = false;
  if (status !== 'running') {
    log('Unable to find an existing Expo CLI instance for this directory, starting a new one...');

    installExitHooks(projectDir);

    const startOpts = { reset: options.clear, nonPersistent: true };
    if (options.maxWorkers) {
      startOpts.maxWorkers = options.maxWorkers;
    }
    log('Exporting your app...');
    await Project.startAsync(projectDir, startOpts, !options.quiet);
    startedOurOwn = true;
  }

  // Make outputDir an absolute path if it isnt already
  const exportOptions = {
    dumpAssetmap: options.dumpAssetmap,
    dumpSourcemap: options.dumpSourcemap,
    isDev: options.dev,
  };
  const absoluteOutputDir = path.resolve(process.cwd(), options.outputDir);
  await Project.exportForAppHosting(
    projectDir,
    options.publicUrl,
    options.assetUrl,
    absoluteOutputDir,
    exportOptions