mirror of
https://github.com/status-im/re-natal.git
synced 2025-01-12 21:54:14 +00:00
Run in android command is implemented
This commit is contained in:
parent
b87ad2b6a3
commit
fc75fe2013
19
README.md
19
README.md
@ -62,7 +62,7 @@ To manually choose which device it connects to, you can run `natal repl --choose
|
||||
At the prompt, try loading your app's namespace:
|
||||
|
||||
```clojure
|
||||
(in-ns 'future-app.core)
|
||||
(in-ns 'future-app.ios.core)
|
||||
```
|
||||
|
||||
Changes you make via the REPL or by changing your `.cljs` files should appear live
|
||||
@ -71,7 +71,7 @@ in the simulator.
|
||||
Try this command as an example:
|
||||
|
||||
```clojure
|
||||
(swap! app-state assoc :text "Hello Native World")
|
||||
(re-frame.core/dispatch [:set-greeting "Hello Native World!"])
|
||||
```
|
||||
|
||||
When the REPL connects to the simulator it will print the location of its
|
||||
@ -83,15 +83,17 @@ $ tail -f /Volumes/Ambly-81C53995/watch.log
|
||||
|
||||
## Running in Android
|
||||
|
||||
Connect your device or start a simulator
|
||||
Connect start Android simulator or connect your device.
|
||||
Close React packager window of iOS app, if running.
|
||||
|
||||
```
|
||||
$ cd future-app
|
||||
$ re-natal run-android
|
||||
```
|
||||
This will build and run app in Android.
|
||||
This will build and run app in Android
|
||||
using[React Native](https://facebook.github.io/react-native/docs/getting-started.html#content)CLI.
|
||||
|
||||
To enable live coding
|
||||
To enable "live coding"
|
||||
bring up the menu in Android app, go to "Dev Settings" and enable
|
||||
"Auto reload on JS change"
|
||||
|
||||
@ -101,6 +103,11 @@ $ lein cljsbuild auto android
|
||||
```
|
||||
Changes in .cljs files should be reflected in running application.
|
||||
|
||||
Current limitation that this will reload whole application meaning the app-db
|
||||
will be restored to initial state
|
||||
|
||||
The REPL in android is not available... Contributions are welcome.
|
||||
|
||||
## Tips
|
||||
- Having `rlwrap` installed is optional but highly recommended since it makes
|
||||
the REPL a much nicer experience with arrow keys.
|
||||
@ -150,7 +157,7 @@ tools.
|
||||
- [ ] Automatically tail cljs build log and report compile errors
|
||||
- [ ] Working dev tools
|
||||
- [ ] Automatic bundling for offline device usage and App Store distribution
|
||||
- [ ] Android support
|
||||
- [x] Android support
|
||||
|
||||
|
||||
Contributions are welcome.
|
||||
|
@ -23,16 +23,7 @@ projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
|
||||
rnPackagerPort = 8081
|
||||
podMinVersion = '0.38.2'
|
||||
process.title = 're-natal'
|
||||
reactInterfaces =
|
||||
om: 'org.omcljs/om "0.9.0"'
|
||||
'om-next': 'org.omcljs/om "1.0.0-alpha14"'
|
||||
|
||||
interfaceNames = Object.keys reactInterfaces
|
||||
defaultInterface = 'om'
|
||||
sampleCommands =
|
||||
om: '(swap! app-state assoc :text "Hello Native World")'
|
||||
'om-next': '(swap! app-state assoc :app/msg "Hello Native World")'
|
||||
|
||||
sampleCommand = '(re-frame.core/dispatch [:set-greeting "Hello Native World!"])'
|
||||
|
||||
log = (s, color = 'green') ->
|
||||
console.log chalk[color] s
|
||||
@ -163,7 +154,7 @@ getBundleId = (name) ->
|
||||
logErr message
|
||||
|
||||
|
||||
init = (projName, interfaceName) ->
|
||||
init = (projName) ->
|
||||
if projName.toLowerCase() is 'react' or !projName.match validNameRx
|
||||
logErr 'Invalid project name. Use an alphanumeric CamelCase name.'
|
||||
|
||||
@ -327,12 +318,12 @@ init = (projName, interfaceName) ->
|
||||
log 're-natal repl', 'inverse'
|
||||
log ''
|
||||
log 'At the REPL prompt type this:', 'yellow'
|
||||
log "(in-ns '#{projNameHyph}.core)", 'inverse'
|
||||
log "(in-ns '#{projNameHyph}.ios.core)", 'inverse'
|
||||
log ''
|
||||
log 'Changes you make via the REPL or by changing your .cljs files should appear live.', 'yellow'
|
||||
log ''
|
||||
log 'Try this command as an example:', 'yellow'
|
||||
log sampleCommands[interfaceName], 'inverse'
|
||||
log sampleCommand, 'inverse'
|
||||
log ''
|
||||
log '✔ Done', 'bgMagenta'
|
||||
log ''
|
||||
@ -383,6 +374,12 @@ launch = ({name, device}) ->
|
||||
catch {message}
|
||||
logErr message
|
||||
|
||||
runAndroid = ->
|
||||
log 'Compiling ClojureScript'
|
||||
exec 'lein cljsbuild once android'
|
||||
process.chdir 'native'
|
||||
log 'Running application in running Android simulator or connected device'
|
||||
exec 'react-native run-android'
|
||||
|
||||
openXcode = (name) ->
|
||||
try
|
||||
@ -456,16 +453,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'
|
||||
.action (name, cmd) ->
|
||||
if cmd
|
||||
interfaceName = cmd['interface'] or defaultInterface
|
||||
else
|
||||
interfaceName = defaultInterface
|
||||
|
||||
unless reactInterfaces[interfaceName]
|
||||
logErr "Unsupported React interface: #{interfaceName}"
|
||||
|
||||
.action (name) ->
|
||||
if typeof name isnt 'string'
|
||||
logErr '''
|
||||
re-natal init requires a project name as the first argument.
|
||||
@ -473,14 +461,19 @@ cli.command 'init <name>'
|
||||
re-natal init HelloWorld
|
||||
'''
|
||||
|
||||
ensureFreePort -> init name, interfaceName
|
||||
ensureFreePort -> init name
|
||||
|
||||
|
||||
cli.command 'launch'
|
||||
.description 'compile project and run in simulator'
|
||||
.description 'compile project and run in iOS simulator'
|
||||
.action ->
|
||||
ensureFreePort -> launch readConfig()
|
||||
|
||||
cli.command 'run-android'
|
||||
.description 'compile project and run in Android simulator or connected device'
|
||||
.action ->
|
||||
|
||||
runAndroid()
|
||||
|
||||
cli.command 'repl'
|
||||
.description 'launch a ClojureScript REPL with background compilation'
|
||||
|
Loading…
x
Reference in New Issue
Block a user