Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function printServerInfo () {
await ProjectSettings.readPackagerInfoAsync(projectDir)
// who knows why qrcode-terminal takes a callback instead of just returning a string
const address = await UrlUtils.constructManifestUrlAsync(projectDir)
let emulatorHelp
if (process.platform === 'darwin') {
emulatorHelp = `Press ${chalk.bold('a')} (Android) or ${chalk.bold('i')} (iOS) to start an emulator.`
} else {
emulatorHelp = `Press ${chalk.bold('a')} to start an Android emulator.`
}
qr.generate(address, qrCode => {
log(`
${indent(qrCode, 2)}
Your app is now running at URL: ${chalk.underline(chalk.cyan(address))}
${chalk.bold('View your app with live reloading:')}
${chalk.underline('Android device:')}
-> Point the Expo app to the QR code above.
(You'll find the QR scanner on the Projects tab of the app.)
${chalk.underline('iOS device:')}
-> Press ${chalk.bold('s')} to email/text the app URL to your phone.
async function printServerInfo() {
const settings = await ProjectSettings.readPackagerInfoAsync(process.cwd());
// who knows why qrcode-terminal takes a callback instead of just returning a string
const address = await UrlUtils.constructManifestUrlAsync(process.cwd());
let emulatorHelp;
if (process.platform === 'darwin') {
emulatorHelp = `Press ${chalk.bold('a')} (Android) or ${chalk.bold('i')} (iOS) to start an emulator.`;
} else {
emulatorHelp = `Press ${chalk.bold('a')} to start an Android emulator.`;
}
qr.generate(address, qrCode => {
log(`
${indent(qrCode, 2)}
Your app is now running at URL: ${chalk.underline(chalk.cyan(address))}
${chalk.bold('View your app with live reloading:')}
${chalk.underline('Android device:')}
-> Point the Expo app to the QR code above.
async function startExpoProject(config, platform) {
try {
const projectRoot = path.join(path.resolve('.'), '.expo', platform);
setupExpoDir(projectRoot, platform);
await startExpoServer(projectRoot, config.devServer.port);
const address = await UrlUtils.constructManifestUrlAsync(projectRoot);
console.log(`Expo address for ${platform}:`, address);
console.log("To open this app on your phone scan this QR code in Expo Client (if it doesn't get started automatically)");
qr.generate(address, code => {
console.log(code);
});
if (platform === 'android') {
const { success, error } = await Android.openProjectAsync(projectRoot);
if (!success) {
console.error(error.message);
}
} else if (platform === 'ios') {
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(address);
if (!success) {
console.error("Failed to start Simulator: ", msg);
async function action(projectDir, options) {
await urlOpts.optsAsync(projectDir, options);
if ((await Project.currentStatus(projectDir)) !== 'running') {
throw new CommandError(
'NOT_RUNNING',
`Project is not running. Please start it with \`${options.parent.name} start\`.`
);
}
const url = await UrlUtils.constructManifestUrlAsync(projectDir);
log.newLine();
urlOpts.printQRCode(url);
log('Your URL is\n\n' + chalk.underline(url) + '\n');
log.raw(url);
await printRunInstructionsAsync();
await urlOpts.handleMobileOptsAsync(projectDir, options);
}
async function startAndroidAndPrintInfo() {
const address = await UrlUtils.constructManifestUrlAsync(process.cwd());
log.withTimestamp('Starting Android...');
const { success, error } = await Android.openProjectAsync(process.cwd());
qr.generate(address, qrCode => {
log.withTimestamp(`${chalk.green('Packager started!')}`);
log(
`
To view your app with live reloading, point the Expo app to this QR code.
You'll find the QR scanner on the Projects tab of the app.
${indent(qrCode, 2)}
Or enter this address in the Expo app's search bar:
${chalk.underline(chalk.cyan(address))}
if (await UserSettings.getAsync('openDevToolsAtStartup', true)) {
log(`Opening DevTools in the browser... (press ${chalk.bold`shift-d`} to disable)`);
opn(devToolsUrl, { wait: false });
} else {
log(
`Press ${chalk.bold`d`} to open DevTools now, or ${chalk.bold`shift-d`} to always open it automatically.`
);
}
}
const startOpts = await parseStartOptionsAsync(projectDir, options);
await Project.startAsync(rootPath, startOpts);
await Web.logURL(projectDir);
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 (!nonInteractive && !exp.isDetached) {
await TerminalUI.startAsync(projectDir, startOpts);
} else if (!options.webOnly) {
if (!exp.isDetached) {
log.newLine();
urlOpts.printQRCode(url);
}
log(`Your native app is running at ${chalk.underline(url)}`);
async _simulatorProjectUrlAsync() {
return UrlUtils.constructManifestUrlAsync(this.props.projectRoot, {
localhost: true,
dev: this.props.dev,
minify: this.props.minify,
});
}