Skip to content

Commit

Permalink
fixed upgrade command to default the interface in .re-natal to 'reage…
Browse files Browse the repository at this point in the history
…nt' if absent
  • Loading branch information
drapanjanas committed Feb 11, 2016
1 parent f9317c7 commit e4bd064
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions re-natal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ interfaceConf =
shims: ["cljsjs.react", "cljsjs.react.dom"]
sampleCommandNs: '(in-ns \'$PROJECT_NAME_HYPHENATED$.state)'
sampleCommand: '(swap! app-state assoc :app/msg "Hello Native World!")'
interfaceNames = Object.keys interfaceConf
interfaceNames = Object.keys interfaceConf
defaultInterface = 'reagent'

log = (s, color = 'green') ->
console.log chalk[color] s
Expand Down Expand Up @@ -157,7 +158,7 @@ writeConfig = (config) ->
message

verifyConfig = (config) ->
if !config.androidHost? || !config.modules? || !config.imageDirs?
if !config.androidHost? || !config.modules? || !config.imageDirs? || !config.interface?
throw new Error 're-natal project needs to be upgraded, please run: re-natal upgrade'
config

Expand Down Expand Up @@ -450,30 +451,34 @@ generateDevScripts = () ->
message

doUpgrade = (config) ->
interfaceName = config.interface;
projName = config.name;
projNameHyph = projName.replace(camelRx, '$1-$2').toLowerCase()
projNameUs = toUnderscored projName

copyDevEnvironmentFiles(interfaceName, projNameHyph, projName, "localhost")
copyProdEnvironmentFiles(interfaceName, projNameHyph, projName)
log 'upgraded files in env/'

copyFigwheelBridge(projNameUs)
log 'upgraded figwheel-bridge.js'
unless config.interface
config.interface = defaultInterface

if (!config.modules)
unless config.modules
config.modules = []

if (!config.imageDirs)
unless config.imageDirs
config.imageDirs = ["images"]

if (!config.androidHost)
unless config.androidHost
config.androidHost = "localhost"

writeConfig(config)
log 'upgraded .re-natal'

interfaceName = config.interface;

copyDevEnvironmentFiles(interfaceName, projNameHyph, projName, "localhost")
copyProdEnvironmentFiles(interfaceName, projNameHyph, projName)
log 'upgraded files in env/'

copyFigwheelBridge(projNameUs)
log 'upgraded figwheel-bridge.js'

edit "src/#{projNameUs}/ios/core.cljs", [[/\^:figwheel-load\s/g, ""]]
edit "src/#{projNameUs}/android/core.cljs", [[/\^:figwheel-load\s/g, ""]]
log 'upgraded core.cljs'
Expand All @@ -498,7 +503,7 @@ cli.version pkgJson.version

cli.command 'init <name>'
.description 'create a new ClojureScript React Native project'
.option "-i, --interface [#{interfaceNames.join ' '}]", 'specify React interface', 'reagent'
.option "-i, --interface [#{interfaceNames.join ' '}]", 'specify React interface', defaultInterface
.action (name, cmd) ->
if typeof name isnt 'string'
logErr '''
Expand Down

0 comments on commit e4bd064

Please sign in to comment.