From 4a1539f99f2d680ef5afb0c3e4164277a2874ba9 Mon Sep 17 00:00:00 2001 From: Andrey Dubov Date: Fri, 14 Aug 2020 14:19:34 +0300 Subject: [PATCH] Fix json parse issue (#738) --- src/script/management-sdk.ts | 2 +- src/utils/adapter/adapter.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/script/management-sdk.ts b/src/script/management-sdk.ts index 1a563b7..d361b2e 100644 --- a/src/script/management-sdk.ts +++ b/src/script/management-sdk.ts @@ -297,7 +297,7 @@ class AccountManager { const appParams = await this._adapter.parseApiAppName(appName); const requestBody = targetRelease ? { label: targetRelease - } : null; + } : {}; await this._requestManager.post(urlEncode`/apps/${appParams.appOwner}/${appParams.appName}/deployments/${deploymentName}/rollback_release`, JSON.stringify(requestBody), /*expectResponseBody=*/ false); return null; diff --git a/src/utils/adapter/adapter.ts b/src/utils/adapter/adapter.ts index 98307ad..b5d733d 100644 --- a/src/utils/adapter/adapter.ts +++ b/src/utils/adapter/adapter.ts @@ -271,13 +271,17 @@ class Adapter { public toRestReleaseModification( legacyCodePushReleaseInfo: sdkTypes.PackageInfo ): adapterTypes.ReleaseModification { - const releaseModification: adapterTypes.ReleaseModification = { - target_binary_range: legacyCodePushReleaseInfo.appVersion, - is_disabled: legacyCodePushReleaseInfo.isDisabled, - is_mandatory: legacyCodePushReleaseInfo.isMandatory, - description: legacyCodePushReleaseInfo.description, - rollout: legacyCodePushReleaseInfo.rollout - }; + let releaseModification: adapterTypes.ReleaseModification = {} as adapterTypes.ReleaseModification ; + + if (legacyCodePushReleaseInfo.appVersion) releaseModification.target_binary_range = legacyCodePushReleaseInfo.appVersion; + + if (legacyCodePushReleaseInfo.isDisabled) releaseModification.is_disabled = legacyCodePushReleaseInfo.isDisabled; + + if (legacyCodePushReleaseInfo.isMandatory) releaseModification.is_mandatory = legacyCodePushReleaseInfo.isMandatory; + + if (legacyCodePushReleaseInfo.description) releaseModification.description = legacyCodePushReleaseInfo.description; + + if (legacyCodePushReleaseInfo.rollout) releaseModification.rollout = legacyCodePushReleaseInfo.rollout; if (legacyCodePushReleaseInfo.label) releaseModification.label = legacyCodePushReleaseInfo.label;