|
1 | | -import { prompt } from 'inquirer'; |
2 | | -import { Options, SetupConfigs, IosSetupResult } from './interfaces'; |
3 | | -import { getPlatformName, iosRealDeviceUDID, symbols } from '../../utils'; |
4 | | -import { AVAILABLE_OPTIONS, SETUP_CONFIG_QUES } from './constants'; |
| 1 | +import {prompt} from 'inquirer'; |
| 2 | +import {Options, SetupConfigs, IosSetupResult} from './interfaces'; |
| 3 | +import {getPlatformName, iosRealDeviceUDID, symbols} from '../../utils'; |
| 4 | +import {AVAILABLE_OPTIONS, SETUP_CONFIG_QUES} from './constants'; |
5 | 5 | import colors from 'ansi-colors'; |
6 | | -import { execSync } from 'child_process'; |
| 6 | +import {execSync} from 'child_process'; |
7 | 7 | import boxen from 'boxen'; |
8 | 8 | import Logger from '../../logger'; |
9 | 9 |
|
@@ -81,36 +81,37 @@ export class IosSetup { |
81 | 81 | Logger.log('\nVerifying the setup requirements for simulators ...'); |
82 | 82 |
|
83 | 83 | try { |
84 | | - execSync("/usr/bin/xcodebuild -version", { |
| 84 | + execSync('/usr/bin/xcodebuild -version', { |
85 | 85 | stdio: 'pipe' |
86 | 86 | }); |
87 | 87 | Logger.log(` ${colors.red(symbols().ok)} Xcode is installed in your machine\n`); |
88 | 88 |
|
89 | | - Logger.log(boxen(`Run the following command to get the list of simulators\n` + |
| 89 | + Logger.log(boxen('Run the following command to get the list of simulators\n' + |
90 | 90 | colors.cyan.italic('xcrun simctl list devices') + '\n' + |
91 | 91 | `\nAnd then update ${colors.cyan('safari:deviceName')} (eg: 'iphone 13') and ${colors.cyan('safari:platformVersion')} (eg: '15.0') in nightwatch configuration for ${colors.gray.italic('ios.simulator.safari')} environment accordingly.` |
92 | 92 | , {padding: 1})); |
93 | 93 | } catch (error) { |
94 | 94 | Logger.log(` ${colors.red(symbols().ok)} Xcode is not installed.`); |
95 | | - missingRequirements.push('Xcode is not installed') |
| 95 | + missingRequirements.push('Xcode is not installed'); |
96 | 96 | } |
97 | 97 | } |
98 | 98 |
|
99 | 99 | if (setupConfigs.mode === 'real' || setupConfigs.mode === 'both') { |
100 | 100 | Logger.log('\nVerifying the setup requirements for real devices...'); |
101 | 101 |
|
102 | 102 | try { |
| 103 | + // eslint-disable-next-line |
103 | 104 | const stdout = execSync("system_profiler SPUSBDataType | sed -n '/iPhone/,/Serial/p' | grep 'Serial Number:' | awk -F ': ' '{print $2}'", { |
104 | 105 | stdio: 'pipe' |
105 | 106 | }); |
106 | 107 |
|
107 | 108 | if (stdout.toString() !== '') { |
108 | 109 | Logger.log(boxen( |
109 | 110 | colors.white(`Update ${colors.cyan('UDID')} in nightwatch configuration for ${colors.gray.italic('ios.real.safari')} environment.`) + |
110 | | - "\nUDID: " + |
| 111 | + '\nUDID: ' + |
111 | 112 | colors.cyan(iosRealDeviceUDID(stdout.toString())), {padding: 1})); |
112 | 113 | } else { |
113 | | - throw "Device is not connected"; |
| 114 | + throw 'Device is not connected'; |
114 | 115 | } |
115 | 116 | } catch (error) { |
116 | 117 | Logger.log(` ${colors.red(symbols().fail)} Device is either not connected or turned off.`); |
@@ -148,36 +149,36 @@ export class IosSetup { |
148 | 149 | if (missingRequirements.includes('Xcode is not installed')) { |
149 | 150 | Logger.log('\nSetting up missing requirements for iOS simulator...'); |
150 | 151 |
|
151 | | - Logger.log(boxen(`${colors.cyan("If Xcode is already installed : ")}` + |
152 | | - `${colors.white("\n 1. Run the following after changing the Xcode app name in the command ")}` + |
153 | | - `\n ${colors.grey.italic("sudo xcode-select -switch /Applications/Xcode_x_x.app")}\n` + |
| 152 | + Logger.log(boxen(`${colors.cyan('If Xcode is already installed : ')}` + |
| 153 | + `${colors.white('\n 1. Run the following after changing the Xcode app name in the command ')}` + |
| 154 | + `\n ${colors.grey.italic('sudo xcode-select -switch /Applications/Xcode_x_x.app')}\n` + |
154 | 155 |
|
155 | | - `${colors.cyan("\nIf Xcode is not installed : ")}` + |
156 | | - `${colors.green("\n [Easiest Option] : Download via the App Store for the latest version")}` + |
157 | | - `${colors.white("\n 1. Open the App Store on your mac and Sign in with your Apple credentials")}` + |
158 | | - `${colors.white("\n 2. Search for Xcode & click install or update. That's it!!")}\n` + |
159 | | - `${colors.green("\n [Preferred Option] : Download via the Developer site for a specific version")}` + |
160 | | - `${colors.white(`\n 1. Navigate to this URL ${colors.grey.italic("https://developer.apple.com/download/more/")}`)}` + |
161 | | - `${colors.white("\n 2. Sign in with your Apple credentials")}` + |
162 | | - `${colors.white("\n 3. Type in the version that you like, and download the Xcode_x_x.xip file")}` + |
163 | | - `${colors.white("\n 4. Once the file is downloaded, click on .xip to extract it.")}` + |
164 | | - `${colors.white("\n 5. Now click on that Xcode file complete all the installation process")}` + |
165 | | - `${colors.white("\n 6. After completion drag the Xcode to Applications folder")}`, {padding: 1})); |
| 156 | + `${colors.cyan('\nIf Xcode is not installed : ')}` + |
| 157 | + `${colors.green('\n [Easiest Option] : Download via the App Store for the latest version')}` + |
| 158 | + `${colors.white('\n 1. Open the App Store on your mac and Sign in with your Apple credentials')}` + |
| 159 | + `${colors.white('\n 2. Search for Xcode & click install or update. That\'s it!!')}\n` + |
| 160 | + `${colors.green('\n [Preferred Option] : Download via the Developer site for a specific version')}` + |
| 161 | + `${colors.white(`\n 1. Navigate to this URL ${colors.grey.italic('https://developer.apple.com/download/more/')}`)}` + |
| 162 | + `${colors.white('\n 2. Sign in with your Apple credentials')}` + |
| 163 | + `${colors.white('\n 3. Type in the version that you like, and download the Xcode_x_x.xip file')}` + |
| 164 | + `${colors.white('\n 4. Once the file is downloaded, click on .xip to extract it.')}` + |
| 165 | + `${colors.white('\n 5. Now click on that Xcode file complete all the installation process')}` + |
| 166 | + `${colors.white('\n 6. After completion drag the Xcode to Applications folder')}`, {padding: 1})); |
166 | 167 |
|
167 | | - Logger.log(`\nFollow the guide for more detailed info ${colors.magenta("https://www.freecodecamp.org/news/how-to-download-and-install-xcode/")}\n`); |
| 168 | + Logger.log(`\nFollow the guide for more detailed info ${colors.magenta('https://www.freecodecamp.org/news/how-to-download-and-install-xcode/')}\n`); |
168 | 169 |
|
169 | 170 | result.simulator = false; |
170 | 171 | } |
171 | 172 | } |
172 | 173 |
|
173 | 174 | if (setupConfigs.mode === 'real' || setupConfigs.mode === 'both') { |
174 | | - Logger.log("\nSetting up missing requirements for real devices...") |
| 175 | + Logger.log('\nSetting up missing requirements for real devices...'); |
175 | 176 |
|
176 | | - let msg = colors.cyan("1. Remote Automation should be turned on your iOS device.") + |
177 | | - colors.grey.italic("\n(turn it on via Settings → Safari → Advanced → Remote Automation.)"); |
| 177 | + let msg = colors.cyan('1. Remote Automation should be turned on your iOS device.') + |
| 178 | + colors.grey.italic('\n(turn it on via Settings → Safari → Advanced → Remote Automation.)'); |
178 | 179 |
|
179 | 180 | if (missingRequirements.includes('Device is not connected')) { |
180 | | - msg += colors.cyan(`\n\n2. Device is connected via data cable and turned on properly.`); |
| 181 | + msg += colors.cyan('\n\n2. Device is connected via data cable and turned on properly.'); |
181 | 182 | result.real = false; |
182 | 183 | } |
183 | 184 | Logger.log(boxen(msg, {padding: 1})); |
|
0 commit comments