public async runApp()

in src/extension/exponent/exponentPlatform.ts [34:138]


    public async runApp(): Promise<void> {
        let extProps = {
            platform: {
                value: PlatformType.Exponent,
                isPii: false,
            },
        };

        extProps = TelemetryHelper.addPlatformPropertiesToTelemetryProperties(
            this.runOptions,
            this.runOptions.reactNativeVersions,
            extProps,
        );

        await TelemetryHelper.generate("ExponentPlatform.runApp", extProps, async () => {
            await this.loginToExponentOrSkip(this.runOptions.expoHostType);
            await XDL.setOptions(this.projectPath, { packagerPort: this.packager.getPort() });
            await XDL.startExponentServer(this.projectPath);

            // the purpose of this is to save the same sequence of handling 'adb reverse' command execution as in Expo
            // https://github.com/expo/expo-cli/blob/1d515d21200841e181518358fd9dc4c7b24c7cd6/packages/xdl/src/Project.ts#L2226-L2370
            // we added this to be sure that our Expo launching logic doesn't have any negative side effects

            if (this.runOptions.expoHostType === "tunnel") {
                await this.prepareExpoTunnels();
            } else {
                await XDL.stopAdbReverse(this.projectPath);
            }

            const isAdbReversed =
                this.runOptions.expoHostType !== "local"
                    ? false
                    : // we need to execute 'adb reverse' command to bind ports used by Expo and RN of local machine to ports of a connected Android device or a running emulator
                      await XDL.startAdbReverse(this.projectPath);
            let exponentUrl = "";
            switch (this.runOptions.expoHostType) {
                case "lan":
                    exponentUrl = await XDL.getUrl(this.projectPath, {
                        dev: true,
                        minify: false,
                        hostType: "lan",
                    });
                    break;
                case "local":
                    if (isAdbReversed) {
                        this.logger.info(
                            localize(
                                "ExpoStartAdbReverseSuccess",
                                "A device or an emulator was found, 'adb reverse' command successfully executed.",
                            ),
                        );
                    } else {
                        this.logger.warning(
                            localize(
                                "ExpoStartAdbReverseFailure",
                                "Adb reverse command failed. Couldn't find connected over usb device or running emulator. Also please make sure that there is only one currently connected device or running emulator.",
                            ),
                        );
                    }

                    exponentUrl = await XDL.getUrl(this.projectPath, {
                        dev: true,
                        minify: false,
                        hostType: "localhost",
                    });
                    break;
                case "tunnel":
                default:
                    exponentUrl = await XDL.getUrl(this.projectPath, { dev: true, minify: false });
            }
            exponentUrl = `exp://${String(url.parse(exponentUrl).host)}`;

            if (!exponentUrl) {
                throw ErrorHelper.getInternalError(InternalErrorCode.ExpectedExponentTunnelPath);
            }

            if (this.runOptions.openExpoQR) {
                const exponentPage = vscode.window.createWebviewPanel(
                    "Expo QR Code",
                    "Expo QR Code",
                    vscode.ViewColumn.Two,
                    {},
                );
                exponentPage.webview.html = this.qrCodeContentProvider.provideTextDocumentContent(
                    vscode.Uri.parse(exponentUrl),
                );
            }

            this.exponentTunnelPath = exponentUrl;
            const outputMessage = localize(
                "ExponentServerIsRunningOpenToSeeIt",
                "Expo server is running. Open your Expo app at {0} to see it.",
                this.exponentTunnelPath,
            );
            this.logger.info(outputMessage);

            const copyButton = localize("CopyToClipboard", "Copy to clipboard");

            void vscode.window.showInformationMessage(outputMessage, copyButton).then(selection => {
                if (selection === copyButton) {
                    void vscode.env.clipboard.writeText(exponentUrl);
                }
            });
        });
    }