Skip to content
This repository was archived by the owner on Mar 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions example/build.boot
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
[org.clojure/clojurescript "1.7.170"]
[reagent "0.5.1"]
;; [react-native-externs "0.0.1-SNAPSHOT"]
]
)
])

(require
'[adzerk.boot-cljs :refer [cljs]]
Expand Down Expand Up @@ -74,5 +73,5 @@
[]
(comp
(cljs :ids #{"dist"})
(rn/bundle :files {"dist.js" "main.jsbundle"})
(rn/bundle :app-dir "app" :files {"dist.js" "main.jsbundle"})
(target :dir ["app/dist"])))
12 changes: 9 additions & 3 deletions src/mattsum/boot_react_native.clj
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,18 @@ require('" boot-main "');

(deftask bundle
"Bundle the files specified"
[f files ORIGIN:TARGET {str str} "{origin target} pair of files to bundle"]
(let [tmp (c/tmp-dir!)]
[a app-dir OUT str "The (relative) path to the React Native application"
p platform PLATFORM str "The platform to bundle"
f files ORIGIN:TARGET {str str} "{origin target} pair of files to bundle"]
(let [tmp (c/tmp-dir!)]
(c/with-pre-wrap fileset
(doseq [[origin target] files]
(let [in (bh/file-by-path origin fileset)
out (clojure.java.io/file tmp target)]
(clojure.java.io/make-parents out)
(bh/bundle* in out tmp)))
(bh/bundle* {:app-dir app-dir
:platform platform
:input-file in
:output-file out
:output-dir tmp})))
(-> fileset (c/add-resource tmp) c/commit!))))
29 changes: 15 additions & 14 deletions src/mattsum/impl/boot_helpers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
(spit out-content))
(-> fileset
(c/add-resource tmp)
))))
)
)))))

(defn append-to-file
[fileset path content replacements]
Expand Down Expand Up @@ -203,29 +202,31 @@
(defn copy-file [source-path dest-path]
(clojure.java.io/copy (clojure.java.io/file source-path) (clojure.java.io/file dest-path)))

(defn bundle* [in outf outd]
(let [tempfname (str "nested/temp/" (java.util.UUID/randomUUID) ".js")
temppath (str "app/" tempfname)
(defn bundle* [{:keys [app-dir platform input-file output-file output-dir]}]
(let [app-dir (or app-dir "app")
tempfname (str "nested/temp/" (java.util.UUID/randomUUID) ".js")
temppath (str app-dir "/" tempfname)
tempdirf (->> temppath clojure.java.io/as-file .getParentFile)
cli (-> "app/node_modules/react-native/local-cli/cli.js"
cli (-> (str app-dir "/node_modules/react-native/local-cli/cli.js")
java.io.File.
.getAbsolutePath)
dir (-> in .getAbsoluteFile .getParent)
fname (-> in .getAbsolutePath)]
dir (-> input-file .getAbsoluteFile .getParent)
fname (-> input-file .getAbsolutePath)]
(util/info "Bundling %s...\n" fname)
;; create nested temp directory
;; we need this in order to keep the react packager happy
(util/info "Creating temp dir: %s\n" (.getAbsolutePath tempdirf))
(.mkdirs tempdirf)
(copy-file fname temppath)
(binding [util/*sh-dir* "app"]
(binding [util/*sh-dir* app-dir]
(try
(util/dosh "node" cli
"bundle" "--platform" "ios"
"--dev" "true"
"--entry-file" tempfname
"--bundle-output" (.getAbsolutePath outf)
"--assets-dest" (.getAbsolutePath outd))
"bundle"
"--platform" platform
"--dev" "true"
"--entry-file" tempfname
"--bundle-output" (.getAbsolutePath output-file)
"--assets-dest" (.getAbsolutePath output-dir))
(finally
(util/dosh "rm" "-f" tempfname))))))

Expand Down