cleanup CLI: 'launch' command is not needed since RN 0.19.0 now has 'run-ios' command to run iOS app

- removed 're-nata launch' and related commands
This commit is contained in:
Artur Girenko 2016-02-06 14:23:55 +01:00
parent f99a05c689
commit 84f9f2bec0
1 changed files with 0 additions and 116 deletions

View File

@ -70,10 +70,6 @@ edit = (path, pairs) ->
contents.replace rx, replacement contents.replace rx, replacement
, readFile path , readFile path
pluckUuid = (line) ->
line.match(/\[(.+)\]/)[1]
mkdirSync = (path) -> mkdirSync = (path) ->
try try
fs.mkdirSync(path) fs.mkdirSync(path)
@ -81,15 +77,6 @@ mkdirSync = (path) ->
if not message.match /EEXIST/i if not message.match /EEXIST/i
throw new Error "Could not create dir #{path}: #{message}" ; throw new Error "Could not create dir #{path}: #{message}" ;
getUuidForDevice = (deviceName) ->
device = getDeviceList().find (line) -> line.match deviceName
unless device
logErr "Cannot find device `#{deviceName}`"
pluckUuid device
toUnderscored = (s) -> toUnderscored = (s) ->
s.replace(camelRx, '$1_$2').toLowerCase() s.replace(camelRx, '$1_$2').toLowerCase()
@ -109,7 +96,6 @@ checkPort = (port, cb) ->
sock.end() sock.end()
cb false cb false
ensureFreePort = (cb) -> ensureFreePort = (cb) ->
checkPort rnPackagerPort, (inUse) -> checkPort rnPackagerPort, (inUse) ->
if inUse if inUse
@ -122,10 +108,6 @@ ensureFreePort = (cb) ->
ensureXcode = (cb) -> ensureXcode = (cb) ->
try try
ensureExecutableAvailable 'xcodebuild' ensureExecutableAvailable 'xcodebuild'
config = readConfig()
unless config.device?
config.device = getUuidForDevice 'iPhone 6'
writeConfig config
cb(); cb();
catch {message} catch {message}
if message.match /type.+xcodebuild/i if message.match /type.+xcodebuild/i
@ -176,30 +158,6 @@ readConfig = (verify = true)->
else else
message message
getBundleId = (name) ->
try
if line = readFile "ios/#{name}.xcodeproj/project.pbxproj"
.match /PRODUCT_BUNDLE_IDENTIFIER = (.+);/
line[1]
else if line = readFile "ios/#{name}/Info.plist"
.match /\<key\>CFBundleIdentifier\<\/key\>\n?\s*\<string\>(.+)\<\/string\>/
rfcIdRx = /\$\(PRODUCT_NAME\:rfc1034identifier\)/
if line[1].match rfcIdRx
line[1].replace rfcIdRx, name
else
line[1]
else
throw new Error 'Cannot find bundle identifier in project.pbxproj or Info.plist'
catch {message}
logErr message
scanImageDir = (dir) -> scanImageDir = (dir) ->
fnames = fs.readdirSync(dir) fnames = fs.readdirSync(dir)
.map (fname) -> "#{dir}/#{fname}" .map (fname) -> "#{dir}/#{fname}"
@ -405,36 +363,6 @@ init = (projName) ->
else else
message message
launch = ({name, device}) ->
unless device in getDeviceUuids()
log 'Device ID not available, defaulting to iPhone 6 simulator', 'yellow'
{device} = generateConfig name
try
fs.statSync 'node_modules'
catch
logErr 'Dependencies are missing. Something went horribly wrong...'
log 'Compiling ClojureScript'
exec 'lein prod-build'
log 'Compiling Xcode project'
try
exec "
xcodebuild
-project ios/#{name}.xcodeproj
-scheme #{name}
-destination platform='iOS Simulator',OS=latest,id='#{device}'
test
"
log 'Launching simulator'
exec "xcrun simctl launch #{device} #{getBundleId name}"
catch {message}
logErr message
openXcode = (name) -> openXcode = (name) ->
try try
exec "open ios/#{name}.xcodeproj" exec "open ios/#{name}.xcodeproj"
@ -450,21 +378,6 @@ openXcode = (name) ->
else else
message message
getDeviceList = ->
try
exec 'xcrun instruments -s devices', true
.toString()
.split '\n'
.filter (line) -> /^i/.test line
catch {message}
logErr 'Device listing failed: ' + message
getDeviceUuids = ->
getDeviceList().map (line) -> line.match(/\[(.+)\]/)[1]
generateRequireModulesCode = (modules) -> generateRequireModulesCode = (modules) ->
jsCode = "var modules={'react-native': require('react-native')};" jsCode = "var modules={'react-native': require('react-native')};"
for m in modules for m in modules
@ -572,40 +485,11 @@ cli.command 'init <name>'
ensureFreePort -> init name ensureFreePort -> init name
cli.command 'launch'
.description 'compile project and run in iOS simulator'
.action ->
ensureOSX ->
ensureXcode ->
ensureFreePort -> launch readConfig()
cli.command 'upgrade' cli.command 'upgrade'
.description 'upgrades project files to current installed version of re-natal (the upgrade of re-natal itself is done via npm)' .description 'upgrades project files to current installed version of re-natal (the upgrade of re-natal itself is done via npm)'
.action -> .action ->
doUpgrade readConfig(false) doUpgrade readConfig(false)
cli.command 'listdevices'
.description 'list available simulator devices by index'
.action ->
ensureOSX ->
ensureXcode ->
console.log (getDeviceList()
.map (line, i) -> "#{i}\t#{line.replace /\[.+\]/, ''}"
.join '\n')
cli.command 'setdevice <index>'
.description 'choose simulator device by index'
.action (index) ->
ensureOSX ->
ensureXcode ->
unless device = getDeviceList()[parseInt index, 10]
logErr 'Invalid device index. Run re-natal listdevices for valid indexes.'
config = readConfig()
config.device = pluckUuid device
writeConfig config
cli.command 'xcode' cli.command 'xcode'
.description 'open Xcode project' .description 'open Xcode project'
.action -> .action ->