How to use the @expo/xdl.Project.startAsync 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 / 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-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
github expo / expo-cli / packages / dev-tools / server / dev-server.js View on Github external
websocketConnectionParams: {
          clientAuthenticationToken: authenticationContext.clientAuthenticationToken,
        },
      })
    );
    server.get('*', app.getRequestHandler());

    const httpServer = http.createServer(server);
    await new Promise((resolve, reject) => {
      httpServer.once('error', reject);
      httpServer.once('listening', resolve);
      httpServer.listen(PORT, 'localhost');
    });
    startGraphQLServer(projectDir, httpServer, authenticationContext);
    console.log('Starting project...');
    await Project.startAsync(projectDir);
    let url = `http://localhost:${PORT}`;
    console.log(`Development server running at ${url}`);
    openBrowser(url);
  } catch (error) {
    console.error(error);
    process.exit(1);
  }
}
github expo / expo-cli / packages / expo-cli / src / commands / start / TerminalUI.js View on Github external
)}${chalk.reset(` mode.`)}
Please reload the project in the Expo app for the change to take effect.`
        );
        printHelp();
        break;
      }
      case 'r':
      case 'R': {
        clearConsole();
        const reset = key === 'R';
        if (reset) {
          log('Restarting Metro Bundler and clearing cache...');
        } else {
          log('Restarting Metro Bundler...');
        }
        Project.startAsync(projectDir, { ...options, reset });
        break;
      }
      case 's': {
        const authSession = await UserManager.getSessionAsync();
        if (authSession) {
          await UserManager.logoutAsync();
          log('Signed out.');
        } else {
          stopWaitingForCommand();
          try {
            await loginOrRegisterIfLoggedOut();
          } catch (e) {
            log.error(e);
          } finally {
            startWaitingForCommand();
          }
github expo / expo-cli / packages / expo-cli / src / commands / start / TerminalUI.js View on Github external
)}${chalk.reset(` mode.`)}
Please reload the project in the Expo app for the change to take effect.`
        );
        printHelp();
        break;
      }
      case 'r':
      case 'R': {
        clearConsole();
        const reset = key === 'R';
        if (reset) {
          log('Restarting Metro Bundler and clearing cache...');
        } else {
          log('Restarting Metro Bundler...');
        }
        Project.startAsync(projectDir, { ...options, reset });
        break;
      }
      case 's': {
        const authSession = await UserManager.getSessionAsync();
        if (authSession) {
          await UserManager.logoutAsync();
          log('Signed out.');
        } else {
          stopWaitingForCommand();
          try {
            await loginOrRegisterIfLoggedOut();
          } catch (e) {
            log.error(e);
          } finally {
            startWaitingForCommand();
          }
github expo / expo-cli / packages / expo-cli / src / commands / publish.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;
    }

    await Project.startAsync(projectDir, startOpts, !options.quiet);
    startedOurOwn = true;
  }

  let recipient = await sendTo.getRecipient(options.sendTo);
  log(`Publishing to channel '${options.releaseChannel}'...`);

  const { args: { sdkVersion } } = await Exp.getPublishInfoAsync(projectDir);

  const buildStatus = await Project.buildAsync(projectDir, {
    mode: 'status',
    platform: 'all',
    current: true,
    releaseChannel: options.releaseChannel,
    sdkVersion,
  });
github expo / expo-cli / packages / expo-cli / src / commands / start.js View on Github external
async function startWebAction(projectDir, options) {
  const { exp, rootPath } = await configureProjectAsync(projectDir, options);
  const startOpts = parseStartOptions(projectDir, options);
  await Project.startAsync(rootPath, startOpts);
  await urlOpts.handleMobileOptsAsync(projectDir, options);

  if (!options.nonInteractive && !exp.isDetached) {
    await TerminalUI.startAsync(projectDir, startOpts);
  }
}
github expo / expo-cli / packages / expo-cli / src / commands / start.js View on Github external
async function action(projectDir, options) {
  const { exp, pkg, rootPath } = await configureProjectAsync(projectDir, options);

  await validateDependenciesVersions(projectDir, exp, pkg);

  const startOpts = parseStartOptions(projectDir, options);

  await Project.startAsync(rootPath, startOpts);

  const url = await UrlUtils.constructManifestUrlAsync(projectDir);

  const recipient = await sendTo.getRecipient(options.sendTo);
  if (recipient) {
    await sendTo.sendUrlAsync(url, recipient);
  }

  await urlOpts.handleMobileOptsAsync(projectDir, options);

  if (!startOpts.nonInteractive && !exp.isDetached) {
    await TerminalUI.startAsync(projectDir, startOpts);
  } else {
    if (!exp.isDetached) {
      log.newLine();
      urlOpts.printQRCode(url);