do not regenerate env/dev* files in use-figwheel command #13
- No need to change host for iOS it is always localhost - For android simulators, update only the host in figwheel URL instead of overwriting whole file - env/dev can be removed from .gitignore
This commit is contained in:
parent
ca7deb20e9
commit
b601f62a4f
|
@ -23,6 +23,7 @@ projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
|
||||||
projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g
|
projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g
|
||||||
platformRx = /\$PLATFORM\$/g
|
platformRx = /\$PLATFORM\$/g
|
||||||
devHostRx = /\$DEV_HOST\$/g
|
devHostRx = /\$DEV_HOST\$/g
|
||||||
|
figwheelUrlRx = /ws:\/\/[0-9a-zA-Z\.]*:/g
|
||||||
rnVersion = '0.18.1'
|
rnVersion = '0.18.1'
|
||||||
rnPackagerPort = 8081
|
rnPackagerPort = 8081
|
||||||
podMinVersion = '0.38.2'
|
podMinVersion = '0.38.2'
|
||||||
|
@ -230,7 +231,7 @@ copyFigwheelBridge = (projNameUs) ->
|
||||||
edit "figwheel-bridge.js", [[projNameUsRx, projNameUs]]
|
edit "figwheel-bridge.js", [[projNameUsRx, projNameUs]]
|
||||||
|
|
||||||
updateGitIgnore = () ->
|
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")
|
fs.appendFileSync(".gitignore", "\n# Figwheel\n#\nfigwheel_server.log")
|
||||||
|
|
||||||
patchReactNativePackager = () ->
|
patchReactNativePackager = () ->
|
||||||
|
@ -433,11 +434,15 @@ generateRequireModulesCode = (modules) ->
|
||||||
jsCode += "modules['#{m}']=require('#{m}');";
|
jsCode += "modules['#{m}']=require('#{m}');";
|
||||||
jsCode += '\n'
|
jsCode += '\n'
|
||||||
|
|
||||||
|
updateFigwheelUrlForAndroid= (devHost) ->
|
||||||
|
mainAndroidDevPath = "env/dev/env/android/main.cljs"
|
||||||
|
|
||||||
|
edit mainAndroidDevPath, [[figwheelUrlRx, "ws://#{devHost}:"]]
|
||||||
|
|
||||||
generateDevScripts = (devHost) ->
|
generateDevScripts = (devHost) ->
|
||||||
try
|
try
|
||||||
config = readConfig()
|
config = readConfig()
|
||||||
projName = config.name
|
projName = config.name
|
||||||
projNameHyph = projName.replace(camelRx, '$1-$2').toLowerCase()
|
|
||||||
|
|
||||||
log 'Cleaning...'
|
log 'Cleaning...'
|
||||||
exec 'lein clean'
|
exec 'lein clean'
|
||||||
|
@ -446,13 +451,15 @@ generateDevScripts = (devHost) ->
|
||||||
modulesAndImages = config.modules.concat images;
|
modulesAndImages = config.modules.concat images;
|
||||||
moduleMap = generateRequireModulesCode modulesAndImages
|
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'
|
log 'index.ios.js was regenerated'
|
||||||
fs.writeFileSync 'index.android.js', "#{moduleMap}require('figwheel-bridge').withModules(modules).start('#{projName}','android','#{devHost}');"
|
fs.writeFileSync 'index.android.js', "#{moduleMap}require('figwheel-bridge').withModules(modules).start('#{projName}','android','#{devHost}');"
|
||||||
log 'index.android.js was regenerated'
|
log 'index.android.js was regenerated'
|
||||||
|
|
||||||
copyDevEnvironmentFiles(projNameHyph, projName, devHost)
|
updateFigwheelUrlForAndroid(devHost)
|
||||||
log 'Dev server host: ' + devHost
|
log 'Dev server host for iOS: localhost'
|
||||||
|
log 'Dev server host for Android: ' + devHost
|
||||||
|
|
||||||
catch {message}
|
catch {message}
|
||||||
logErr \
|
logErr \
|
||||||
if message.match /EACCES/i
|
if message.match /EACCES/i
|
||||||
|
@ -483,6 +490,9 @@ doUpgrade = (config) ->
|
||||||
writeConfig(config)
|
writeConfig(config)
|
||||||
log 'upgraded .re-natal'
|
log 'upgraded .re-natal'
|
||||||
|
|
||||||
|
edit '.gitignore', [[/^\s*env\/dev\s*$/m, ""]]
|
||||||
|
log 'upgraded .gitignore'
|
||||||
|
|
||||||
useComponent = (name) ->
|
useComponent = (name) ->
|
||||||
log "Component '#{name}' is now configured for figwheel, please re-run 'use-figwheel' command to take effect"
|
log "Component '#{name}' is now configured for figwheel, please re-run 'use-figwheel' command to take effect"
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue