Fix broken live coding support in iOS

- Revert to react-native 0.13.0 for now
- Use single source root, this seems required for repl
This commit is contained in:
Artur Girenko 2015-11-22 10:57:51 +01:00
parent e290ec33cb
commit 05d5efafd1
4 changed files with 31 additions and 25 deletions

View File

@ -25,11 +25,6 @@ Generated project works in iOS and Android devices.
Before getting started, make sure you have the
[required dependencies](#dependencies) installed.
Install [React Native](https://facebook.github.io/react-native/docs/getting-started.html#content) CLI:
```
npm install -g react-native-cli
```
Then, install the CLI using npm:
```
@ -71,7 +66,7 @@ in the simulator.
Try this command as an example:
```clojure
(re-frame.core/dispatch [:set-greeting "Hello Native World!"])
(dispatch [:set-greeting "Hello Native World!"])
```
When the REPL connects to the simulator it will print the location of its
@ -104,7 +99,7 @@ $ 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
will be restored to initial state.
The REPL in android is not available... Contributions are welcome.

View File

@ -1,6 +1,6 @@
{
"name": "re-natal",
"version": "0.1.8",
"version": "0.1.9",
"description": "Bootstrap ClojureScript React Native apps with reagent and re-frame for iOS and Android",
"main": "index.js",
"author": "Artur Girenko <a.girenko@gmail.com>",

View File

@ -20,10 +20,11 @@ validNameRx = /^[A-Z][0-9A-Z]*$/i
camelRx = /([a-z])([A-Z])/g
projNameRx = /\$PROJECT_NAME\$/g
projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
rnVersion = '0.13.0'
rnPackagerPort = 8081
podMinVersion = '0.38.2'
process.title = 're-natal'
sampleCommand = '(re-frame.core/dispatch [:set-greeting "Hello Native World!"])'
sampleCommand = '(dispatch [:set-greeting "Hello Native World!"])'
log = (s, color = 'green') ->
console.log chalk[color] s
@ -206,15 +207,11 @@ init = (projName) ->
fs.mkdirSync 'src/cljsjs'
exec "echo '(ns cljsjs.react)' > src/cljsjs/react.cljs"
fs.mkdirSync 'src-android'
fs.mkdirSync "src-android/#{projNameUs}"
fs.mkdirSync "src-android/#{projNameUs}/android"
fs.mkdirSync 'src-ios'
fs.mkdirSync "src-ios/#{projNameUs}"
fs.mkdirSync "src-ios/#{projNameUs}/ios"
fs.mkdirSync "src/#{projNameUs}/android"
fs.mkdirSync "src/#{projNameUs}/ios"
coreAndroidPath = "src-android/#{projNameUs}/android/core.cljs"
coreIosPath = "src-ios/#{projNameUs}/ios/core.cljs"
coreAndroidPath = "src/#{projNameUs}/android/core.cljs"
coreIosPath = "src/#{projNameUs}/ios/core.cljs"
exec "cp #{resources}core-android.cljs #{coreAndroidPath}"
edit coreAndroidPath, [[projNameHyphRx, projNameHyph], [projNameRx, projName]]
@ -223,12 +220,26 @@ init = (projName) ->
edit coreIosPath, [[projNameHyphRx, projNameHyph], [projNameRx, projName]]
log 'Creating React Native skeleton'
exec "react-native init #{projName}"
exec "mv #{projName} native"
fs.mkdirSync 'native'
process.chdir 'native'
fs.writeFileSync 'package.json', JSON.stringify
name: projName
version: '0.0.1'
private: true
scripts:
start: 'node_modules/react-native/packager/packager.sh'
dependencies:
'react-native': rnVersion
, null, 2
exec 'npm i'
exec "
node -e
\"process.argv[3]='#{projName}';
require('react-native/local-cli/init')('.', '#{projName}')\"
"
fs.unlinkSync 'index.android.js'
log 'Installing Pod dependencies'
@ -437,7 +448,7 @@ startRepl = (name, autoChoose) ->
:watch-fn
(fn []
(cljs.repl/load-file repl-env
\"src/#{toUnderscored name}/core.cljs\"))
\"src/#{toUnderscored name}/ios/core.cljs\"))
:analyze-path \"src\"))
"""),
cwd: process.cwd()

View File

@ -9,11 +9,11 @@
[org.omcljs/ambly "0.6.0"]
[re-frame "0.5.0"]]
:plugins [[lein-cljsbuild "1.1.0"]]
:cljsbuild {:builds {:dev {:source-paths ["src" "src-ios"]
:cljsbuild {:builds {:dev {:source-paths ["src"]
:compiler {:output-to "target/out/main.js"
:output-dir "target/out"
:optimizations :none}}
:android {:source-paths ["src" "src-android"]
:android {:source-paths ["src"]
:compiler {:output-to "native/index.android.js"
:output-dir "target/android"
:optimizations :simple}}}})