From 05d5efafd1bb85d8fde47ad747e772709248f4d6 Mon Sep 17 00:00:00 2001 From: Artur Girenko Date: Sun, 22 Nov 2015 10:57:51 +0100 Subject: [PATCH] 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 --- README.md | 9 ++------- package.json | 2 +- re-natal.coffee | 41 ++++++++++++++++++++++++++--------------- resources/project.clj | 4 ++-- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7fad14d..e626559 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index a13724b..8a481a9 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/re-natal.coffee b/re-natal.coffee index ada24cb..559af5e 100644 --- a/re-natal.coffee +++ b/re-natal.coffee @@ -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() diff --git a/resources/project.clj b/resources/project.clj index 5b4a2b8..b7f0d15 100644 --- a/resources/project.clj +++ b/resources/project.clj @@ -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}}}}) \ No newline at end of file