From 02216b03a53b90c626fbd69c25a8ebe1cf63524f Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 2 Sep 2019 17:20:19 +0300 Subject: [PATCH 1/2] fix: force refresh with socket when debugging the application Currently there is an issue when livesyncing the application when it is stopped on breakpoint. The problem is that the application is always restarted - most probably due to issue with "RefreshRequest" notification. However, this notification was added as we needed to support syncing on wifi devices. As debug command doesn't work with wifi devices, we'll force refresh with socket on debug command. Rel to: https://github.com/NativeScript/nativescript-cli/issues/4966 --- lib/controllers/run-controller.ts | 1 + lib/definitions/livesync.d.ts | 3 ++- .../livesync/ios-device-livesync-service.ts | 14 +++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/controllers/run-controller.ts b/lib/controllers/run-controller.ts index 8b29bdfe0d..caee785a21 100644 --- a/lib/controllers/run-controller.ts +++ b/lib/controllers/run-controller.ts @@ -166,6 +166,7 @@ export class RunController extends EventEmitter implements IRunController { const debugOptions = deviceDescriptor.debugOptions || {}; liveSyncResultInfo.waitForDebugger = !!debugOptions.debugBrk; + liveSyncResultInfo.forceRefreshWithSocket = true; const refreshInfo = await this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor, { shouldSkipEmitLiveSyncNotification: true, shouldCheckDeveloperDiscImage: true }); diff --git a/lib/definitions/livesync.d.ts b/lib/definitions/livesync.d.ts index e4ac2c0d99..f729eabfa6 100644 --- a/lib/definitions/livesync.d.ts +++ b/lib/definitions/livesync.d.ts @@ -220,7 +220,8 @@ declare global { isFullSync: boolean; waitForDebugger?: boolean; deviceAppData: Mobile.IDeviceAppData; - didRecover?: boolean + didRecover?: boolean; + forceRefreshWithSocket?: boolean; } interface IAndroidLiveSyncResultInfo extends ILiveSyncResultInfo, IAndroidLivesyncSyncOperationResult { } diff --git a/lib/services/livesync/ios-device-livesync-service.ts b/lib/services/livesync/ios-device-livesync-service.ts index b8afcb8028..f82898cf4b 100644 --- a/lib/services/livesync/ios-device-livesync-service.ts +++ b/lib/services/livesync/ios-device-livesync-service.ts @@ -23,7 +23,11 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen super(platformsDataService, device); } - private canRefreshWithNotification(projectData: IProjectData): boolean { + private canRefreshWithNotification(projectData: IProjectData, liveSyncInfo?: ILiveSyncResultInfo): boolean { + if (liveSyncInfo && liveSyncInfo.forceRefreshWithSocket) { + return false; + } + if (this.device.isEmulator) { return false; } @@ -72,7 +76,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen shouldRestart = true; } else { const canExecuteFastSync = this.canExecuteFastSyncForPaths(liveSyncInfo, localToDevicePaths, projectData, deviceAppData.platform); - const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData) || (!this.device.isOnlyWiFiConnected && await this.setupSocketIfNeeded(projectData)); + const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData, liveSyncInfo) || (!this.device.isOnlyWiFiConnected && await this.setupSocketIfNeeded(projectData)); if (!canExecuteFastSync || !isRefreshConnectionSetup) { shouldRestart = true; } @@ -93,7 +97,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen try { if (otherFiles.length) { - didRefresh = await this.refreshApplicationCore(projectData); + didRefresh = await this.refreshApplicationCore(projectData, liveSyncInfo); } } catch (e) { didRefresh = false; @@ -102,9 +106,9 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen return didRefresh; } - private async refreshApplicationCore(projectData: IProjectData) { + private async refreshApplicationCore(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo) { let didRefresh = true; - if (this.canRefreshWithNotification(projectData)) { + if (this.canRefreshWithNotification(projectData, liveSyncInfo)) { didRefresh = await this.refreshWithNotification(projectData); } else { if (await this.setupSocketIfNeeded(projectData)) { From 76cb16b261dfbf17a1683911b6b98e07b9163013 Mon Sep 17 00:00:00 2001 From: Elena Hristova Date: Mon, 2 Sep 2019 14:20:57 +0300 Subject: [PATCH 2/2] fix: update `plugin create` command description --- docs/man_pages/lib-management/plugin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/man_pages/lib-management/plugin.md b/docs/man_pages/lib-management/plugin.md index 89677429c2..f44f2e6a41 100644 --- a/docs/man_pages/lib-management/plugin.md +++ b/docs/man_pages/lib-management/plugin.md @@ -35,5 +35,5 @@ Command | Description [plugin remove](plugin-remove.html) | Uninstalls the specified plugin and its dependencies. [plugin update](plugin-update.html) | Updates the specified plugin(s) and its dependencies. [plugin build](plugin-build.html) | Builds the Android project of a NativeScript plugin, and updates the `include.gradle`. -[plugin create](plugin-create.html) | Builds the Android project of a NativeScript plugin, and updates the `include.gradle`. +[plugin create](plugin-create.html) | Creates a new project for NativeScript plugin development. <% } %>