Skip to content
Permalink
Browse files

Migrate to deps.edn and figwheel-main

  • Loading branch information...
tonsky committed Apr 29, 2019
1 parent f85fbdd commit 0b50ae3073d5dfdcd7bb79965a5142a53493049a
@@ -2,32 +2,29 @@ version: 2
jobs:
build:
docker:
- image: circleci/clojure:lein-2.7.1
- image: circleci/clojure:tools-deps-1.10.0.442

working_directory: ~/repo

environment:
LEIN_ROOT: "true"
JVM_OPTS: -Xmx3200m


steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "project.clj" }}
- v2-dependencies-{{ checksum "deps.edn" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: lein deps
- v2-dependencies-
- run: ./scripts/package.sh

- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}

- run: lein package
- .cpcache
key: v2-dependencies-{{ checksum "deps.edn" }}

- add_ssh_keys:
fingerprints:
@@ -13,4 +13,7 @@ grumpy_data
resources/static/editor*
figwheel_server.log
backup.sh
*.sublime-workspace
*.sublime-workspace
*.sublime-project
.cpcache
.DS_Store
@@ -8,6 +8,6 @@ https://grumpy.website
mkdir grumpy_data
echo "nikitonsky" >> grumpy_data/FORCED_USER
echo "http://localhost:8080" >> grumpy_data/HOSTNAME
lein figwheel
./scripts/repl.sh
open http://localhost:8080
```
@@ -0,0 +1,25 @@
{:deps
{org.clojure/clojure {:mvn/version "1.10.1-beta2"}
com.stuartsierra/component {:mvn/version "0.4.0"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
ring/ring-core {:mvn/version "1.6.3"}
org.immutant/web {:mvn/version "2.1.10"}
compojure {:mvn/version "1.6.1"}
rum {:mvn/version "0.11.3"}
com.cognitect/transit-clj {:mvn/version "0.8.313"}
clj-http {:mvn/version "3.9.1"}
cheshire {:mvn/version "5.8.1"} ; for clj-http :as :json
cljs-drag-n-drop {:mvn/version "0.1.0"}
com.cognitect/transit-cljs {:mvn/version "0.8.256"}}
:paths ["src" "resources"]
:aliases
{:dev {:jvm-opts ["-ea" "--add-opens" "java.base/sun.nio.ch=ALL-UNNAMED"]
:extra-paths ["dev" "target/resources"]
:extra-deps {org.clojure/tools.namespace {:mvn/version "0.2.11"}
com.bhauman/figwheel-main {:mvn/version "0.2.0"}
org.clojure/clojurescript {:mvn/version "1.10.520"}}}
:uberjar {:extra-paths ["target/uberjar"]}
:package {:extra-paths ["package"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
uberdeps {:mvn/version "0.1.0"}}}
}}
@@ -0,0 +1,6 @@
^{:watch-dirs ["src"]
:css-dirs ["resources/static"]}
{:main grumpy.editor
:output-to "target/resources/static/editor.js"
:output-dir "target/resources/static/editor"
:asset-path "/static/editor"}
@@ -0,0 +1,21 @@
(ns grumpy.figwheel
(:require
[com.stuartsierra.component :as component]
[cljs.stacktrace]
[figwheel.main.api :as fig]))

(defrecord Figwheel [opts]
component/Lifecycle
(start [this]
(println "[Figwheel] Starting figwheel build" (:build opts))
(fig/start {:mode :serve
:rebel-readline false
:cljs-devtools false
:helpful-classpaths false
:open-url false}
(:build opts))
this)
(stop [this]
(println "[Figwheel] Stopping figwheel build" (:build opts))
(fig/stop (:build opts))
this))
@@ -0,0 +1,58 @@
(ns user
(:require
[clojure.tools.namespace.repl :as namespace]
[com.stuartsierra.component :as component]
[figwheel.main.api]
[grumpy.figwheel :as figwheel]))


(namespace/disable-reload!)
(namespace/set-refresh-dirs "src" "dev")


(defonce *system (atom nil))
(defonce *figwheel (atom nil))


(defn stop []
(some-> @*system (component/stop))
(reset! *system nil))


(defn refresh []
(let [res (namespace/refresh)]
(when (not= res :ok)
(throw res))
:ok))


(defn start
([] (start {}))
([opts]
(let [opts' (merge-with merge {:server {:host "0.0.0.0"}} opts)]
(when-some [f (resolve 'grumpy.system/system)]
(when-some [system (f opts')]
(when-some [system' (component/start system)]
(reset! *system system')))))))


(defn reset []
(stop)
(refresh)
(start))


(defn cljs-repl []
(figwheel.main.api/cljs-repl "dev"))


(reset! *figwheel
(component/start (figwheel/map->Figwheel {:opts {:build "dev"}})))


(reset)


(println "[user] Run (reset) for full system reload")
(println "[user] Run (cljs-repl) for upgrading REPL to CLJS")
(println "[user] Open http://localhost:8080/")
@@ -0,0 +1,38 @@
(ns grumpy.package
(:require
[clojure.edn :as edn]
[clojure.string :as str]
[clojure.java.io :as io]
[cljs.build.api :as cljs]
[uberdeps.api :as uberdeps]))


(defn compile-cljs []
(let [t0 (System/currentTimeMillis)]
(println "[package] Compiling target/uberjar/static/editor.js...")
(cljs/build (io/file "src")
{:main 'grumpy.editor
:output-to "target/uberjar/static/editor.js"
:output-dir "target/resources/static/editor"
:asset-path "/static/editor"
:optimizations :advanced
:elide-asserts true
:closure-defines {"goog.DEBUG" false}
:parallel-build true})
(println "[package] Compiled target/uberjar/static/editor.js in" (- (System/currentTimeMillis) t0) "ms")))


(defn package []
(binding [uberdeps/exclusions (into uberdeps/exclusions
[#"\.DS_Store"
#".*\.cljs"
#"cljsjs/.*"
#"META-INF/maven/cljsjs/.*"])
uberdeps/level :info]
(uberdeps/package (edn/read-string (slurp "deps.edn")) "target/grumpy.jar")))


(defn -main [& args]
(compile-cljs)
(package)
(shutdown-agents))

This file was deleted.

@@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36}: %msg%n</pattern>
</encoder>
</appender>

<root level="warn">
<appender-ref ref="STDOUT" />
</root>
</configuration>
@@ -0,0 +1,3 @@
#!/bin/bash -e

clojure -A:package -m grumpy.package
@@ -0,0 +1,3 @@
#!/bin/bash -e

clj -A:dev
@@ -0,0 +1,3 @@
#!/bin/bash -e

java --add-opens java.base/sun.nio.ch=ALL-UNNAMED -cp target/grumpy.jar clojure.main -m grumpy.system
@@ -52,4 +52,4 @@

(when (not= db-version expected-db-version)
(spit "grumpy_data/DB_VERSION" (str expected-db-version))
(alter-var-root #'db-version (constantly expected-db-version)))
(alter-var-root #'db-version (constantly expected-db-version)))

0 comments on commit 0b50ae3

Please sign in to comment.
You can’t perform that action at this time.