How to use the @expo/xdl.UserSettings.getAsync function in @expo/xdl

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-cli / packages / expo-cli / src / askUser.ts View on Github external
async function askForSendToAsync(): Promise {
  var sendToFromSettings = await UserSettings.getAsync('sendTo', null);
  console.log("Enter an email address and we'll send a link to your phone.");
  var answers = await prompt(
    [
      {
        type: 'input',
        name: 'sendTo',
        message:
          'Your email address' + (sendToFromSettings ? ' (space to not send anything)' : '') + ':',
        default: sendToFromSettings || undefined,
      },
    ],
    { nonInteractiveHelp: 'Please specify email address with --send-to.' }
  );
  let recipient = answers.sendTo.trim();
  await UserSettings.mergeAsync({ sendTo: recipient });
  return recipient;
github expo / expo-cli / packages / expo-cli / src / commands / send.ts View on Github external
log.raw(url);

  let shouldQuit = false;
  if (await urlOpts.handleMobileOptsAsync(projectDir, options)) {
    shouldQuit = true;
  }

  if (shouldQuit) {
    return;
  }

  var recipient;
  if (typeof options.sendTo !== 'boolean') {
    recipient = options.sendTo;
  } else {
    recipient = await UserSettings.getAsync('sendTo', null);
  }

  if (!recipient) {
    recipient = await askUser.askForSendToAsync();
  }

  if (recipient) {
    await sendTo.sendUrlAsync(url, recipient);
  } else {
    log.gray("(Not sending anything because you didn't specify a recipient.)");
  }

  process.exit();
}
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.`
  }
 \u203A Press ${b`p`} to toggle ${u`p`}roduction mode. (current mode: ${i(devMode)})
github expo / expo-cli / packages / expo-cli / src / commands / start.js View on Github external
async function tryOpeningDevToolsAsync({ rootPath, exp, options }): Promise {
  const devToolsUrl = await DevToolsServer.startAsync(rootPath);
  log(`Expo DevTools is running at ${chalk.underline(devToolsUrl)}`);

  if (!options.nonInteractive && !exp.isDetached) {
    if (await UserSettings.getAsync('openDevToolsAtStartup', true)) {
      log(`Opening DevTools in the browser... (press ${chalk.bold`shift-d`} to disable)`);
      openBrowser(devToolsUrl);
    } else {
      log(
        `Press ${chalk.bold`d`} to open DevTools now, or ${chalk.bold`shift-d`} to always open it automatically.`
      );
    }
  }
}
github expo / expo-cli / packages / expo-cli / src / sendTo.ts View on Github external
async function getRecipient(sendTo: string) {
  let recipient;
  if (sendTo) {
    if (typeof sendTo !== 'boolean') {
      recipient = sendTo;
    } else {
      recipient = await UserSettings.getAsync('sendTo', null);
    }

    if (!recipient) {
      recipient = await askUser.askForSendToAsync();
    }
  }

  return recipient;
}
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.`
  }
 \u203A Press ${b`p`} to toggle ${u`p`}roduction mode. (current mode: ${i(devMode)})
github expo / expo-cli / packages / expo-cli / src / commands / start / TerminalUI.js View on Github external
printHelp();
          break;
        }
        case 'i': {
          clearConsole();
          log('Trying to open the project in iOS simulator...');
          await Simulator.openProjectAsync(projectDir);
          printHelp();
          break;
        }
        case 'e': {
          stopWaitingForCommand();
          const lanAddress = await UrlUtils.constructManifestUrlAsync(projectDir, {
            hostType: 'lan',
          });
          const defaultRecipient = await UserSettings.getAsync('sendTo', null);
          const rl = readline.createInterface({
            input: process.stdin,
            output: process.stdout,
          });
          const handleKeypress = (chr, key) => {
            if (key && key.name === 'escape') {
              cleanup();
              cancel();
            }
          };
          const cleanup = () => {
            rl.close();
            process.stdin.removeListener('keypress', handleKeypress);
            startWaitingForCommand();
          };
          const cancel = async () => {