From d80f17332ff2403310829b6dabb39351d6bba3ba Mon Sep 17 00:00:00 2001 From: Ezio Li Date: Wed, 27 Sep 2023 12:12:05 +0800 Subject: [PATCH] Fix app launcher create issue in subfolder project (#2048) --- src/common/reactNativeProjectHelper.ts | 13 ++++++++++++- src/debugger/direct/directDebugSession.ts | 2 +- src/debugger/rnDebugSession.ts | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/common/reactNativeProjectHelper.ts b/src/common/reactNativeProjectHelper.ts index 99236b89b..f32ccc93a 100644 --- a/src/common/reactNativeProjectHelper.ts +++ b/src/common/reactNativeProjectHelper.ts @@ -115,7 +115,18 @@ export class ReactNativeProjectHelper { public static async verifyMetroConfigFile(projectRoot: string) { const logger = OutputChannelLogger.getChannel(OutputChannelLogger.MAIN_CHANNEL_NAME, true); - const version = await ProjectVersionHelper.getReactNativeVersions(projectRoot); + + let version; + try { + version = await ProjectVersionHelper.getReactNativeVersions(projectRoot); + } catch { + version = await ProjectVersionHelper.getReactNativeVersions( + projectRoot, + undefined, + projectRoot, + ); + } + const metroConfigPath = path.join(projectRoot, "metro.config.js"); const content = fs.readFileSync(metroConfigPath, "utf-8"); const isNewMetroConfig = content.includes("getDefaultConfig"); diff --git a/src/debugger/direct/directDebugSession.ts b/src/debugger/direct/directDebugSession.ts index 39a6e67e3..fb3b9f8ab 100644 --- a/src/debugger/direct/directDebugSession.ts +++ b/src/debugger/direct/directDebugSession.ts @@ -25,8 +25,8 @@ import { TipNotificationService } from "../../extension/services/tipsNotificatio import { RNSession } from "../debugSessionWrapper"; import { SettingsHelper } from "../../extension/settingsHelper"; import { ReactNativeProjectHelper } from "../../common/reactNativeProjectHelper"; -import { IWDPHelper } from "./IWDPHelper"; import { ExponentHelper } from "../../extension/exponent/exponentHelper"; +import { IWDPHelper } from "./IWDPHelper"; nls.config({ messageFormat: nls.MessageFormat.bundle, diff --git a/src/debugger/rnDebugSession.ts b/src/debugger/rnDebugSession.ts index 63ecf02f2..6a319dcc0 100644 --- a/src/debugger/rnDebugSession.ts +++ b/src/debugger/rnDebugSession.ts @@ -13,6 +13,7 @@ import { RnCDPMessageHandler } from "../cdp-proxy/CDPMessageHandlers/rnCDPMessag import { ErrorHelper } from "../common/error/errorHelper"; import { InternalErrorCode } from "../common/error/internalErrorCode"; import { ReactNativeProjectHelper } from "../common/reactNativeProjectHelper"; +import { ExponentHelper } from "../extension/exponent/exponentHelper"; import { MultipleLifetimesAppWorker } from "./appWorker"; import { DebugSessionBase, @@ -22,7 +23,6 @@ import { } from "./debugSessionBase"; import { JsDebugConfigAdapter } from "./jsDebugConfigAdapter"; import { RNSession } from "./debugSessionWrapper"; -import { ExponentHelper } from "../extension/exponent/exponentHelper"; nls.config({ messageFormat: nls.MessageFormat.bundle,