Skip to content

Commit

Permalink
move into separate repo from thheller/shadow-cljs
Browse files Browse the repository at this point in the history
prep for adding full launcher functionality
  • Loading branch information
thheller committed Aug 8, 2018
0 parents commit 06eab91
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
target/
node_modules/
checkouts/
pom.xml
pom.xml.asc
*.iml
*.jar
*.js.map
*.class
.cpcache
.cljs-cache
.shadow-cljs
.cljs-repl
.cljs_node_repl
.idea
.lein-*
.nrepl-*
/tmp
.DS_Store
yarn.lock
package-lock.json
/package.json
*.log
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a utility used by `shadow-cljs` to resolve/download dependencies.

https://github.com/thheller/shadow-cljs
15 changes: 15 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(defproject shadow-cljs/launcher "1.2.0"
:description "CLJS development tools"
:url "https://github.com/thheller/shadow-cljs"
:dependencies
[[org.clojure/clojure "1.9.0"]
[com.cemerick/pomegranate "1.0.0"]
[org.slf4j/slf4j-nop "1.7.25"]]

:source-paths
["src/main"]

:profiles
{:uberjar
{:aot [shadow.cljs.launcher.deps]
:main shadow.cljs.launcher.deps}})
71 changes: 71 additions & 0 deletions src/main/shadow/cljs/launcher/deps.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(ns shadow.cljs.launcher.deps
"lightweight launcher that just downloads jars and builds a classpath"
(:gen-class)
(:require
[clojure.java.io :as io]
[cemerick.pomegranate.aether :as aether]))

(defn transfer-listener
[{:keys [type error resource] :as info}]
(let [{:keys [name repository]} resource]
(binding [*out* *err*]
(case type
:started (println "Retrieving" name "from" repository)
;; :progressed
;; :succeeded
:corrupted (when error (println (.getMessage error)))
nil))))

(defn -main []
(try
(let [{:keys [cache-root repositories proxy local-repo dependencies mirrors version]
:or {dependencies []
repositories {}
cache-root ".shadow-cljs"}
:as config}
(read *in*)]

(println "shadow-cljs - updating dependencies")

;; FIXME: resolve conflicts?
(let [resolve-args
(-> {:coordinates
dependencies
:repositories
(merge aether/maven-central {"clojars" "https://clojars.org/repo"} repositories)
:transfer-listener
transfer-listener}
(cond->
mirrors
(assoc :mirrors mirrors)
proxy
(assoc :proxy proxy)
local-repo
(assoc :local-repo local-repo)
))

deps
(apply aether/resolve-dependencies (into [] (mapcat identity) resolve-args))

files
(into [] (map #(.getAbsolutePath %)) (aether/dependency-files deps))

result
{:dependencies dependencies
:version version
:files files
:deps deps}

classpath-file
(io/file cache-root "classpath.edn")]

(io/make-parents classpath-file)

(spit classpath-file (pr-str result)))

(println "shadow-cljs - dependencies updated"))

(catch Exception e
(println "shadow-cljs - dependency update failed -" (.getMessage e))
(System/exit 1)
)))

0 comments on commit 06eab91

Please sign in to comment.