From 96e5120e1f8cc32026049349ff3a491cf3c2e212 Mon Sep 17 00:00:00 2001 From: Alexander Chernyatiev Date: Mon, 2 Nov 2020 14:33:29 +0300 Subject: [PATCH 1/2] Added getting owner name if app already exists --- Examples/create-app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/create-app.js b/Examples/create-app.js index 64203f9dd..d449ca27f 100644 --- a/Examples/create-app.js +++ b/Examples/create-app.js @@ -90,6 +90,9 @@ function createCodePushApp(name, os) { execCommand(`appcenter codepush deployment add -a ${owner}/${name} Staging`); } catch (e) { console.log(`App "${name}" already exists \n`); + const ownerResult = execCommand(`appcenter profile list --output json`); + const ownerInfo = JSON.parse(ownerResult); + owner = ownerInfo.name; } const deploymentKeysResult = execCommand(`appcenter codepush deployment list -a ${owner}/${name} -k --output json`); const deploymentKeys = JSON.parse(deploymentKeysResult); From 257d2f3e01a68f11863ce7e68d7f01cb6d0c5005 Mon Sep 17 00:00:00 2001 From: Alexander Chernyatiev Date: Thu, 5 Nov 2020 10:05:33 +0300 Subject: [PATCH 2/2] Added catch and logs --- Examples/create-app.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Examples/create-app.js b/Examples/create-app.js index d449ca27f..0f1355b55 100644 --- a/Examples/create-app.js +++ b/Examples/create-app.js @@ -83,16 +83,18 @@ linkCodePush(androidStagingDeploymentKey, iosStagingDeploymentKey); function createCodePushApp(name, os) { try { console.log(`Creating CodePush app "${name}" to release updates for ${os}...`); - const appResult = execCommand(`appcenter apps create -d ${name} -n ${name} -o ${os} -p React-Native --output json`); - const app = JSON.parse(appResult); - owner = app.owner.name; - console.log(`App "${name}" has been created \n`); + try { + const appResult = execCommand(`appcenter apps create -d ${name} -n ${name} -o ${os} -p React-Native --output json`); + const app = JSON.parse(appResult); + owner = app.owner.name; + console.log(`App "${name}" has been created \n`); + } catch(e) { + console.log("Error: ", e); + console.log(`Please check that you haven't application with "${name}" name on portal`); + } execCommand(`appcenter codepush deployment add -a ${owner}/${name} Staging`); } catch (e) { - console.log(`App "${name}" already exists \n`); - const ownerResult = execCommand(`appcenter profile list --output json`); - const ownerInfo = JSON.parse(ownerResult); - owner = ownerInfo.name; + console.log("Error", e); } const deploymentKeysResult = execCommand(`appcenter codepush deployment list -a ${owner}/${name} -k --output json`); const deploymentKeys = JSON.parse(deploymentKeysResult);