Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor expo launch request using expo-cli #2260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions i18n/chs/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "React Native 应用程序的类型",
"UseHermesEnginePrompt": "使用Hermes引擎直接调试?",
"UseHermesEngineInvalid": "使用 Hermes 引擎尚未确认",
"ExpoPlatformTypeSelection": "选择要运行的平台",
"ExpoPlatformTypeSelectionPrompt": "运行的平台类型",
"ExpoHostTypeSelectionTitle": "选择Expo主机参数类型",
"ExpoHostTypeSelectionPrompt": "Expo主机参数类型",
"BrowserTypeSelectionTitle": "选择浏览器类型",
Expand Down
2 changes: 2 additions & 0 deletions i18n/cht/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "React Native 應用程式的類型",
"UseHermesEnginePrompt": "使用Hermes引擎直接調試?",
"UseHermesEngineInvalid": "使用 Hermes 引擎尚未確認",
"ExpoPlatformTypeSelection": "選擇要運行的平台",
"ExpoPlatformTypeSelectionPrompt": "運行的平台類型",
"ExpoHostTypeSelectionTitle": "選擇Expo主機參數類型",
"ExpoHostTypeSelectionPrompt": "Expo主機參數類型",
"BrowserTypeSelectionTitle": "選擇瀏覽器類型",
Expand Down
2 changes: 2 additions & 0 deletions i18n/csy/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Typ aplikace React Native",
"UseHermesEnginePrompt": "Použít Hermes engine pro přímé ladění?",
"UseHermesEngineInvalid": "Použití enginu Hermes není potvrzeno",
"ExpoPlatformTypeSelection": "Vyberte platformu, na které chcete spustit",
"ExpoPlatformTypeSelectionPrompt": "Typ platformy pro provoz",
"ExpoHostTypeSelectionTitle": "Vyberte typ parametru hostitele Expo",
"ExpoHostTypeSelectionPrompt": "Typ parametru hostitele Expo",
"BrowserTypeSelectionTitle": "Vyberte typ prohlížeče",
Expand Down
2 changes: 2 additions & 0 deletions i18n/deu/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Art der React Native-Anwendung",
"UseHermesEnginePrompt": "Hermes-Engine zum direkten Debuggen verwenden?",
"UseHermesEngineInvalid": "Die Verwendung der Hermes-Engine ist nicht bestätigt",
"ExpoPlatformTypeSelection": "Wählen Sie die Plattform zur Ausführung aus",
"ExpoPlatformTypeSelectionPrompt": "Art der Plattform, auf der ausgeführt werden soll",
"ExpoHostTypeSelectionTitle": "Wählen Sie den Typ des Expo-Host-Parameters aus",
"ExpoHostTypeSelectionPrompt": "Typ des Expo-Hostparameters",
"BrowserTypeSelectionTitle": "Wählen Sie den Browsertyp aus",
Expand Down
2 changes: 2 additions & 0 deletions i18n/esn/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Tipo de aplicación React Native",
"UseHermesEnginePrompt": "¿Utilizar el motor Hermes para la depuración directa?",
"UseHermesEngineInvalid": "El uso del motor Hermes no está confirmado.",
"ExpoPlatformTypeSelection": "Seleccione la plataforma para ejecutar",
"ExpoPlatformTypeSelectionPrompt": "Tipo de plataforma para correr",
"ExpoHostTypeSelectionTitle": "Seleccione el tipo de parámetro del anfitrión de la Expo",
"ExpoHostTypeSelectionPrompt": "Tipo de parámetro del anfitrión de la Expo",
"BrowserTypeSelectionTitle": "Seleccione tipo de navegador",
Expand Down
2 changes: 2 additions & 0 deletions i18n/fra/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Type d'application React Native",
"UseHermesEnginePrompt": "Utiliser le moteur Hermes pour le débogage direct ?",
"UseHermesEngineInvalid": "L'utilisation du moteur Hermes n'est pas confirmée",
"ExpoPlatformTypeSelection": "Sélectionnez la plate-forme sur laquelle exécuter",
"ExpoPlatformTypeSelectionPrompt": "Type de plateforme sur laquelle fonctionner",
"ExpoHostTypeSelectionTitle": "Sélectionnez le type de paramètre d'hôte Expo",
"ExpoHostTypeSelectionPrompt": "Type de paramètre d'hôte Expo",
"BrowserTypeSelectionTitle": "Sélectionnez le type de navigateur",
Expand Down
2 changes: 2 additions & 0 deletions i18n/ita/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Tipo di applicazione React Native",
"UseHermesEnginePrompt": "Utilizzare il motore Hermes per il debug diretto?",
"UseHermesEngineInvalid": "L'utilizzo del motore Hermes non è confermato",
"ExpoPlatformTypeSelection": "Seleziona la piattaforma su cui eseguire",
"ExpoPlatformTypeSelectionPrompt": "Tipo di piattaforma su cui eseguire",
"ExpoHostTypeSelectionTitle": "Seleziona il tipo di parametro host Expo",
"ExpoHostTypeSelectionPrompt": "Tipo di parametro host dell'Expo",
"BrowserTypeSelectionTitle": "Seleziona il tipo di browser",
Expand Down
2 changes: 2 additions & 0 deletions i18n/jpn/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "React Native アプリケーションの種類",
"UseHermesEnginePrompt": "直接デバッグにHermesエンジンを使用しますか?",
"UseHermesEngineInvalid": "ヘルメスエンジンの使用は未確認",
"ExpoPlatformTypeSelection": "実行するプラットフォームを選択してください",
"ExpoPlatformTypeSelectionPrompt": "実行するプラットフォームの種類",
"ExpoHostTypeSelectionTitle": "Expo ホストパラメータのタイプを選択してください",
"ExpoHostTypeSelectionPrompt": "Expo ホストパラメータのタイプ",
"BrowserTypeSelectionTitle": "ブラウザの種類を選択してください",
Expand Down
2 changes: 2 additions & 0 deletions i18n/kor/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "React Native 애플리케이션 유형",
"UseHermesEnginePrompt": "직접 디버깅을 위해 Hermes 엔진을 사용하시겠습니까?",
"UseHermesEngineInvalid": "Hermes 엔진 사용 여부는 확인되지 않았습니다.",
"ExpoPlatformTypeSelection": "실행할 플랫폼 선택",
"ExpoPlatformTypeSelectionPrompt": "실행할 플랫폼 유형",
"ExpoHostTypeSelectionTitle": "Expo 호스트 매개변수 유형 선택",
"ExpoHostTypeSelectionPrompt": "Expo 호스트 매개변수 유형",
"BrowserTypeSelectionTitle": "브라우저 유형 선택",
Expand Down
2 changes: 2 additions & 0 deletions i18n/plk/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Typ aplikacji React Native",
"UseHermesEnginePrompt": "Używać silnika Hermes do bezpośredniego debugowania?",
"UseHermesEngineInvalid": "Korzystanie z silnika Hermes nie zostało potwierdzone",
"ExpoPlatformTypeSelection": "Wybierz platformę, na której chcesz uruchomić",
"ExpoPlatformTypeSelectionPrompt": "Typ platformy, na której można uruchomić",
"ExpoHostTypeSelectionTitle": "Wybierz typ parametru gospodarza Expo",
"ExpoHostTypeSelectionPrompt": "Typ parametru gospodarza Expo",
"BrowserTypeSelectionTitle": "Wybierz typ przeglądarki",
Expand Down
2 changes: 2 additions & 0 deletions i18n/ptb/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Tipo de aplicativo React Native",
"UseHermesEnginePrompt": "Usar o mecanismo Hermes para depuração direta?",
"UseHermesEngineInvalid": "O uso do motor Hermes não está confirmado",
"ExpoPlatformTypeSelection": "Selecione a plataforma para rodar",
"ExpoPlatformTypeSelectionPrompt": "Tipo de plataforma para rodar",
"ExpoHostTypeSelectionTitle": "Selecione o tipo de parâmetro de host da Expo",
"ExpoHostTypeSelectionPrompt": "Tipo de parâmetro de host da Expo",
"BrowserTypeSelectionTitle": "Selecione o tipo de navegador",
Expand Down
2 changes: 2 additions & 0 deletions i18n/rus/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "Тип приложения React Native",
"UseHermesEnginePrompt": "Использовать движок Hermes для прямой отладки?",
"UseHermesEngineInvalid": "Использование двигателя Hermes не подтверждено",
"ExpoPlatformTypeSelection": "Выберите платформу для запуска",
"ExpoPlatformTypeSelectionPrompt": "Тип платформы для запуска",
"ExpoHostTypeSelectionTitle": "Выберите тип параметра хоста Expo",
"ExpoHostTypeSelectionPrompt": "Тип параметра хоста Expo",
"BrowserTypeSelectionTitle": "Выберите тип браузера",
Expand Down
2 changes: 2 additions & 0 deletions i18n/trk/src/common/configurationProviderHelper.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"ApplicationTypeSelectionPrompt": "React Native uygulamasının türü",
"UseHermesEnginePrompt": "Doğrudan hata ayıklama için Hermes motoru kullanılsın mı?",
"UseHermesEngineInvalid": "Hermes motorunun kullanılması onaylanmadı",
"ExpoPlatformTypeSelection": "Çalıştırılacak platformu seçin",
"ExpoPlatformTypeSelectionPrompt": "Çalıştırılacak platform türü",
"ExpoHostTypeSelectionTitle": "Expo ana bilgisayar parametresi türünü seçin",
"ExpoHostTypeSelectionPrompt": "Expo ana bilgisayar parametresi türü",
"BrowserTypeSelectionTitle": "Tarayıcı türünü seçin",
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,13 @@
],
"description": "%reactNative.launch.direct.platform.description%"
},
"expoPlatformType": {
"type": "string",
"enum": [
"Android",
"iOS"
]
},
"expoHostType": {
"type": "string",
"enum": [
Expand Down
29 changes: 28 additions & 1 deletion src/common/configurationProviderHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
IQuickPickParameters,
} from "../extension/debuggingConfiguration/multiStepInput";
import { ILaunchRequestArgs } from "../debugger/debugSessionBase";
import { ExpoHostType, PlatformType } from "../extension/launchArgs";
import { ExpoHostType, PlatformType, ExpoPlatform } from "../extension/launchArgs";
import {
DebugConfigurationState,
DebugConfigurationQuickPickItem,
appTypePickConfig,
expoPlatform,
expoHostTypePickConfig,
shouldUseHermesEngine,
DEBUG_TYPES,
Expand Down Expand Up @@ -119,6 +120,32 @@ export class ConfigurationProviderHelper {
return config;
}

public async selectExpoPlatform(
input: MultiStepInput<DebugConfigurationState>,
config: Partial<ILaunchRequestArgs>,
step: number,
totalSteps: number,
): Promise<Partial<ILaunchRequestArgs>> {
const pick = await input.showQuickPick<
DebugConfigurationQuickPickItem,
IQuickPickParameters<DebugConfigurationQuickPickItem>
>({
title: localize("ExpoPlatformTypeSelection", "Select platform to run on"),
placeholder: localize("ExpoPlatformTypeSelectionPrompt", "Type of platform to run on"),
step,
totalSteps,
items: expoPlatform,
activeItem: expoPlatform[0],
});

if (!pick) {
throw new Error("Expo platform is not selected");
}

config.expoPlatformType = pick.label as ExpoPlatform;
return config;
}

public async selectExpoHostType(
input: MultiStepInput<DebugConfigurationState>,
config: Partial<ILaunchRequestArgs>,
Expand Down
1 change: 1 addition & 0 deletions src/common/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class Packager {
this.logger,
).spawnReactPackager(args, spawnOptions);
} else if (this.runOptions?.platform == "exponent") {
args.push(`--${this.runOptions?.expoPlatformType?.toLowerCase()}`);
packagerSpawnResult = new CommandExecutor(
nodeModulesRoot,
this.projectPath,
Expand Down
5 changes: 5 additions & 0 deletions src/common/telemetryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export class TelemetryHelper {
"expoHostType",
properties,
);
properties = TelemetryHelper.addPropertyToTelemetryProperties(
args.expoPlatformType,
"expoPlatformType",
properties,
);
}

return properties;
Expand Down
5 changes: 4 additions & 1 deletion src/extension/appLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ export class AppLauncher {
"Building and running application.",
),
);
await this.mobilePlatform.runApp();
if (launchArgs.platform !== "exponent") {
await this.mobilePlatform.runApp();
}

if (mobilePlatformOptions.isDirect) {
if (launchArgs.useHermesEngine) {
Expand Down Expand Up @@ -596,6 +598,7 @@ export class AppLauncher {

if (args.platform === PlatformType.Exponent) {
mobilePlatformOptions.expoHostType = args.expoHostType || "lan";
mobilePlatformOptions.expoPlatformType = args.expoPlatformType || "Android";
mobilePlatformOptions.openExpoQR =
typeof args.openExpoQR !== "boolean" ? true : args.openExpoQR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class DebugConfigProvider extends BaseConfigProvider {
} else if (state.config.platform === PlatformType.Exponent) {
return async () => {
await this.configureApplicationType(input, state.config);
if (state.config.type === "reactnativedirect") {
await this.configureExpoPlatform(input, state.config);
}
await this.configureExpoHostType(input, state.config);
};
} else if (state.config.platform === PlatformType.ExpoWeb) {
Expand Down Expand Up @@ -92,12 +95,14 @@ export class DebugConfigProvider extends BaseConfigProvider {
input: MultiStepInput<DebugConfigurationState>,
config: Partial<ILaunchRequestArgs>,
): Promise<InputStep<DebugConfigurationState> | void> {
await this.configurationProviderHelper.selectExpoHostType(
input,
config,
2,
this.maxStepCount,
);
await this.configurationProviderHelper.selectExpoHostType(input, config, 4, 4);
}

private async configureExpoPlatform(
input: MultiStepInput<DebugConfigurationState>,
config: Partial<ILaunchRequestArgs>,
): Promise<InputStep<DebugConfigurationState> | void> {
await this.configurationProviderHelper.selectExpoPlatform(input, config, 3, 4);
}

private async configureUseHermesEngine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ export const shouldUseHermesEngine: DebugConfigurationQuickPickItem[] = [
},
];

export const expoPlatform: DebugConfigurationQuickPickItem[] = [
{
label: "Android",
type: PlatformType.Android,
},
{
label: "iOS",
type: PlatformType.iOS,
},
];

export const expoHostTypePickConfig: DebugConfigurationQuickPickItem[] = [
{
label: "Tunnel",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import { PlatformType } from "../launchArgs";
import { PlatformType, ExpoPlatform } from "../launchArgs";
import { DebugScenarioType, DEBUG_TYPES } from "./debugConfigTypesAndConstants";

interface DebugScenarioName {
Expand All @@ -10,6 +10,7 @@ interface DebugScenarioName {
platformType?: string;
postPlatformTypeDescription?: string;
experimentalDescription?: string;
expoPlatformType?: ExpoPlatform;
}

export class DebugScenarioNameGenerator {
Expand All @@ -19,10 +20,16 @@ export class DebugScenarioNameGenerator {
platformType?: PlatformType | string,
useHermesEngine: boolean = false,
isExperimental: boolean = false,
expoPlatformType?: ExpoPlatform,
): string {
const debugScenarioName: DebugScenarioName =
this.createScenarioAccordingToDebugScenarioType(debugScenarioType);
debugScenarioName.platformType = this.getPlatformTypeName(platformType);

if (platformType === PlatformType.Exponent) {
debugScenarioName.expoPlatformType = expoPlatformType;
}

if (debugType === DEBUG_TYPES.REACT_NATIVE) {
this.configureNotDirectModeScenario(
debugScenarioName,
Expand Down Expand Up @@ -131,6 +138,9 @@ export class DebugScenarioNameGenerator {
if (debugScenarioName.platformType) {
debugScenarioNameStr += ` ${debugScenarioName.platformType}`;
}
if (debugScenarioName.expoPlatformType) {
debugScenarioNameStr += ` ${debugScenarioName.expoPlatformType}`;
}
if (debugScenarioName.postPlatformTypeDescription) {
debugScenarioNameStr += ` ${debugScenarioName.postPlatformTypeDescription}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ export class ReactNativeDebugConfigProvider implements vscode.DebugConfiguration
state.config.platform,
state.config.useHermesEngine !== false,
);
} else if (state.config.platform === "exponent") {
state.config.name = DebugScenarioNameGenerator.createScenarioName(
state.scenarioType,
state.config.type,
state.config.platform,
state.config.useHermesEngine !== false,
false,
state.config.expoPlatformType,
);
} else {
state.config.name = DebugScenarioNameGenerator.createScenarioName(
state.scenarioType,
Expand Down
3 changes: 3 additions & 0 deletions src/extension/launchArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export enum PlatformType {

export type ExpoHostType = "tunnel" | "lan" | "local";

export type ExpoPlatform = "Android" | "iOS";

/**
* Defines the options needed to start debugging a project.
*/
Expand All @@ -61,6 +63,7 @@ export interface IIOSRunOptions extends ImacOSRunOptions {
export interface IExponentRunOptions extends IAndroidRunOptions, IIOSRunOptions {
expoHostType?: ExpoHostType;
openExpoQR?: boolean;
expoPlatformType?: ExpoPlatform;
}

export type IWindowsRunOptions = ILaunchArgs;
Expand Down