From 01e83da7674b5488234045d59f907abda12e9255 Mon Sep 17 00:00:00 2001 From: Lucas Bento Date: Thu, 18 Apr 2019 15:31:54 +0200 Subject: [PATCH 1/4] Check `ios-deploy` installation before proceeding to build on device --- .../platform-ios/src/commands/runIOS/index.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.js b/packages/platform-ios/src/commands/runIOS/index.js index 777090cd3..fb18b023b 100644 --- a/packages/platform-ios/src/commands/runIOS/index.js +++ b/packages/platform-ios/src/commands/runIOS/index.js @@ -190,6 +190,18 @@ async function runOnSimulator(xcodeProject, scheme, args: FlagsT) { } async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { + const isIOSDeployInstalled = child_process.spawnSync( + 'ios-deploy', + ['--version'], + {encoding: 'utf8'}, + ); + + if (isIOSDeployInstalled.error) { + return logger.error( + '** INSTALLATION FAILED **\nMake sure you have ios-deploy installed globally.\n(e.g "npm install -g ios-deploy")', + ); + } + const appName = await buildProject( xcodeProject, selectedDevice.udid, @@ -214,12 +226,12 @@ async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { ); if (iosDeployOutput.error) { - logger.error( - '** INSTALLATION FAILED **\nMake sure you have ios-deploy installed globally.\n(e.g "npm install -g ios-deploy")', + return logger.error( + '** INSTALLATION FAILED **\nThere was an internal error with ios-deploy.', ); - } else { - logger.info('** INSTALLATION SUCCEEDED **'); } + + return logger.info('** INSTALLATION SUCCEEDED **'); } function buildProject(xcodeProject, udid, scheme, args: FlagsT) { From 06ae293ca21253665cff6c690ed405cb28e722de Mon Sep 17 00:00:00 2001 From: Lucas Bento Date: Fri, 19 Apr 2019 13:41:35 +0200 Subject: [PATCH 2/4] Improve info & error messages when running iOS --- packages/platform-ios/src/commands/runIOS/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.js b/packages/platform-ios/src/commands/runIOS/index.js index 9a140a762..8e1a0ceae 100644 --- a/packages/platform-ios/src/commands/runIOS/index.js +++ b/packages/platform-ios/src/commands/runIOS/index.js @@ -197,9 +197,10 @@ async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { ); if (isIOSDeployInstalled.error) { - return logger.error( - '** INSTALLATION FAILED **\nMake sure you have ios-deploy installed globally.\n(e.g "npm install -g ios-deploy")', - ); + throw new Error(`Failed to install the app on the device because we couldn't execute the "ios-deploy" command. + Please install it by running "${chalk.bold( + 'npm install -g ios-deploy', + )}" and try again.`); } const appName = await buildProject( @@ -226,12 +227,11 @@ async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { ); if (iosDeployOutput.error) { - return logger.error( - '** INSTALLATION FAILED **\nThere was an internal error with ios-deploy.', - ); + throw new Error(`Failed to install the app on the device. We've encountered an error in "ios-deploy" command. + Here are more details: ${isIOSDeployInstalled.error.message}`); } - return logger.info('** INSTALLATION SUCCEEDED **'); + return logger.info('App installed on device.'); } function buildProject(xcodeProject, udid, scheme, args: FlagsT) { From 034f4ba352558911b3fdc80c25818fb4365561ca Mon Sep 17 00:00:00 2001 From: Lucas Bento Date: Fri, 19 Apr 2019 14:13:40 +0200 Subject: [PATCH 3/4] Use `CLIError` instead of `Error` --- .../platform-ios/src/commands/runIOS/index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.js b/packages/platform-ios/src/commands/runIOS/index.js index 8e1a0ceae..5a83f1520 100644 --- a/packages/platform-ios/src/commands/runIOS/index.js +++ b/packages/platform-ios/src/commands/runIOS/index.js @@ -191,16 +191,17 @@ async function runOnSimulator(xcodeProject, scheme, args: FlagsT) { async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { const isIOSDeployInstalled = child_process.spawnSync( - 'ios-deploy', + 'ioxs-deploy', ['--version'], {encoding: 'utf8'}, ); if (isIOSDeployInstalled.error) { - throw new Error(`Failed to install the app on the device because we couldn't execute the "ios-deploy" command. - Please install it by running "${chalk.bold( + throw new CLIError( + `Failed to install the app on the device because we couldn't execute the "ios-deploy" command. Please install it by running "${chalk.bold( 'npm install -g ios-deploy', - )}" and try again.`); + )}" and try again.`, + ); } const appName = await buildProject( @@ -227,11 +228,14 @@ async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { ); if (iosDeployOutput.error) { - throw new Error(`Failed to install the app on the device. We've encountered an error in "ios-deploy" command. - Here are more details: ${isIOSDeployInstalled.error.message}`); + throw new CLIError( + `Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${ + iosDeployOutput.error.message + }`, + ); } - return logger.info('App installed on device.'); + return logger.success('Installed the app on the device.'); } function buildProject(xcodeProject, udid, scheme, args: FlagsT) { From 3668ae6ddb5422ca96d5e0a7efc8f5dfb1554ae3 Mon Sep 17 00:00:00 2001 From: Lucas Bento Date: Fri, 19 Apr 2019 14:21:42 +0200 Subject: [PATCH 4/4] Fix typo --- packages/platform-ios/src/commands/runIOS/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.js b/packages/platform-ios/src/commands/runIOS/index.js index 5a83f1520..97e0c865d 100644 --- a/packages/platform-ios/src/commands/runIOS/index.js +++ b/packages/platform-ios/src/commands/runIOS/index.js @@ -191,7 +191,7 @@ async function runOnSimulator(xcodeProject, scheme, args: FlagsT) { async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) { const isIOSDeployInstalled = child_process.spawnSync( - 'ioxs-deploy', + 'ios-deploy', ['--version'], {encoding: 'utf8'}, );