diff --git a/re-natal.coffee b/re-natal.coffee index 414ab1b..fd67ba0 100644 --- a/re-natal.coffee +++ b/re-natal.coffee @@ -23,6 +23,7 @@ projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g platformRx = /\$PLATFORM\$/g devHostRx = /\$DEV_HOST\$/g +figwheelUrlRx = /ws:\/\/[0-9a-zA-Z\.]*:/g rnVersion = '0.18.1' rnPackagerPort = 8081 podMinVersion = '0.38.2' @@ -230,7 +231,7 @@ copyFigwheelBridge = (projNameUs) -> edit "figwheel-bridge.js", [[projNameUsRx, projNameUs]] updateGitIgnore = () -> - fs.appendFileSync(".gitignore", "\n# Generated by re-natal\n#\nenv/dev\nindex.android.js\nindex.ios.js") + fs.appendFileSync(".gitignore", "\n# Generated by re-natal\n#\nindex.android.js\nindex.ios.js") fs.appendFileSync(".gitignore", "\n# Figwheel\n#\nfigwheel_server.log") patchReactNativePackager = () -> @@ -433,11 +434,15 @@ generateRequireModulesCode = (modules) -> jsCode += "modules['#{m}']=require('#{m}');"; jsCode += '\n' +updateFigwheelUrlForAndroid= (devHost) -> + mainAndroidDevPath = "env/dev/env/android/main.cljs" + + edit mainAndroidDevPath, [[figwheelUrlRx, "ws://#{devHost}:"]] + generateDevScripts = (devHost) -> try config = readConfig() projName = config.name - projNameHyph = projName.replace(camelRx, '$1-$2').toLowerCase() log 'Cleaning...' exec 'lein clean' @@ -446,13 +451,15 @@ generateDevScripts = (devHost) -> modulesAndImages = config.modules.concat images; moduleMap = generateRequireModulesCode modulesAndImages - fs.writeFileSync 'index.ios.js', "#{moduleMap}require('figwheel-bridge').withModules(modules).start('#{projName}','ios','#{devHost}');" + fs.writeFileSync 'index.ios.js', "#{moduleMap}require('figwheel-bridge').withModules(modules).start('#{projName}','ios','localhost');" log 'index.ios.js was regenerated' fs.writeFileSync 'index.android.js', "#{moduleMap}require('figwheel-bridge').withModules(modules).start('#{projName}','android','#{devHost}');" log 'index.android.js was regenerated' - copyDevEnvironmentFiles(projNameHyph, projName, devHost) - log 'Dev server host: ' + devHost + updateFigwheelUrlForAndroid(devHost) + log 'Dev server host for iOS: localhost' + log 'Dev server host for Android: ' + devHost + catch {message} logErr \ if message.match /EACCES/i @@ -483,6 +490,9 @@ doUpgrade = (config) -> writeConfig(config) log 'upgraded .re-natal' + edit '.gitignore', [[/^\s*env\/dev\s*$/m, ""]] + log 'upgraded .gitignore' + useComponent = (name) -> log "Component '#{name}' is now configured for figwheel, please re-run 'use-figwheel' command to take effect" try