Skip to content

Commit

Permalink
rebuild as lein generator; fixes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
metasoarous committed May 2, 2017
1 parent 4d51d50 commit 603f4c4
Show file tree
Hide file tree
Showing 54 changed files with 484 additions and 284 deletions.
30 changes: 3 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
/logs
/target
/classes
/checkouts
target
.lein-env
*.swo
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
/resources/public/js/*.js
/resources/public/js/
profiles.clj
config/local/
data
# So you can install datomic here
datomic/
# You can run a local checkout of datsync here
libs/datsync
libs/
Session.vim
*.ini
.idea
*.iml
.idea/
checkouts/
figwheel_server.log
dev-resources
Empty file.
Empty file.
Empty file.
Empty file.
167 changes: 2 additions & 165 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,169 +1,6 @@
(defproject datsys "0.0.1-alpha3"
:description "(+ clj cljs datomic datascript frp) web development framework" ;;should this be "an" or "un"?
:description "(+ clj cljs datomic datascript frp) web development framework generator"
:url "https://github.com/metasoarous/datsys"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.9.0-alpha15"]
[org.clojure/tools.reader "1.0.0-beta3"]
[org.clojure/clojurescript "1.9.518"]
[org.clojure/core.async "0.3.442"]
[org.clojure/core.match "0.3.0-alpha4"]
;[org.clojure/core.typed "0.3.28"] ;; WARNING: 0.3.28 breaks piggieback(!); 0.3.23 known-safe
;; Datsys things
[datsync "0.0.1-alpha3"]
[datview "0.0.1-alpha3"]
[datspec "0.0.1-alpha3"]
[datreactor "0.0.1-alpha3"]
;; Other stuff (should try to clean things up once in main project)
[com.stuartsierra/component "0.3.2"]
[environ "1.1.0"]
[slingshot "0.12.2"]
[ring/ring-core "1.5.0" :exclusions [commons-codec]]
[ring/ring-defaults "0.2.1"]
[compojure "1.5.1"]
[http-kit "2.2.0"]
[bidi "2.0.16"]
[com.cognitect/transit-clj "0.8.297"]
[com.cognitect/transit-cljs "0.8.239"]
[com.lucasbradstreet/cljs-uuid-utils "1.0.2"]
[testdouble/clojurescript.csv "0.2.0"]
[datascript "0.15.5"]
[posh "0.5.5"]
[data-frisk-reagent "0.3.5"]
[reagent "0.6.0"]
[org.webjars/bootstrap "3.3.5"]
[re-com "0.8.3"]
[prismatic/schema "1.1.3"]
[io.rkn/conformity "0.4.0"]
[ch.qos.logback/logback-classic "1.1.8"]
[com.taoensso/timbre "4.8.0"]
[com.taoensso/encore "2.88.2"]
[com.taoensso/sente "1.11.0" :exclusions [org.clojure/tools.reader]]
;;For the free version of Datomic
[com.datomic/datomic-free "0.9.5544" :exclusions [joda-time org.slf4j/slf4j-nop com.google.guava/guava commons-codec]]

;; libraries to suppress warnings until upstream libraries get sorted with clojure 1.9 alpha
[org.clojure/tools.analyzer "0.6.9"]
[medley "0.8.4"]]

:plugins [[lein-cljsbuild "1.1.5" :exclusions [org.clojure/clojure]]]
;; For Datomic Pro uncomment the following and set the DATOMIC_USERNAME and DATAOMIC_PASSWORD environment
;; variables of the process in which you run this program to those matching your Datomic Pro account. You'll
;; have to start your own transactor separately from this process as well. More instructions on how to do
;; that in the Wiki (I think... bug us if you can't find them).
;; TODO Add `+datomic-pro` toggle for this
;:repositories {"my.datomic.com" {:url
; "https://my.datomic.com/repo"
; :username
; [:env/datomic_username]
; :password
; [:env/datomic_password]}}
:source-paths ["src/cljc"
"src/clj"
;; TODO Uncomment if you would like checkouts; This should be +edge for everything on
;"checkouts/datview/src/clj"
;"checkouts/datview/src/cljc"
;"checkouts/datsync/src/clj"
;"checkouts/datsync/src/cljc"
;"checkouts/datreactor/src/clj"
;"checkouts/datreactor/src/cljc"
;"checkouts/datspec/src/clj"
;"checkouts/datspec/src/cljc"
#_:end]

:resource-paths ["resources"]
:target-path "target/%s"

;; Should be doing https://github.com/cemerick/clojurescript.test/issues/97 instead, but I can't figure it out so we turn off clean protection instead
:clean-targets ^{:protect false} [:target-path :compile-path "resources/public/js/compiled"]

:main ^:skip-aot dat.sys.run
:cljsbuild {:builds
{:client
{:source-paths ["src/cljc" "src/cljs"]
:compiler {:main dat.sys.app
:asset-path "js/compiled/out"
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:optimizations :none
:source-map true
:source-map-timestamp true}}}} ;; helps prevent browser caching from interferring with interactive dev


;; The figwheel config is adapted from https://github.com/plexus/chestnut

;; nREPL by default starts in the :main namespace, we want to start in `user`
;; because that's where our development helper functions like (run) and
;; (browser-repl) live.
:repl-options {:init-ns user
;should have this auto-gen
:port 11233}

;; When running figwheel from nREPL, figwheel will read this configuration
;; stanza, but it will read it without passing through leiningen's profile
;; merging. So don't put a :figwheel section under the :dev profile, it will
;; not be picked up, instead configure figwheel here on the top level.
:figwheel {:server-port 11234 ;; default. overwritten by datsys config anyways
;; :server-ip "127.0.0.1" ;; default
:css-dirs ["resources/public/css"] ;; watch and update CSS
:server-logfile "logs/figwheel.log"}


:profiles {:dev-config {}
:dev [:dev-config
{:dependencies [[alembic "0.3.2"]
[figwheel "0.5.8"]
[figwheel-sidecar "0.5.8"] ;;:exclusions [org.clojure/clojure org.clojure/clojurescript fipp.visit/boolean?]
[com.cemerick/pomegranate "0.3.1"]
[com.cemerick/piggieback "0.2.1"]
[org.clojure/tools.nrepl "0.2.12"]
[devcards "0.2.2" :exclusions [cljsjs/react-dom]]]
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:cljsbuild {:builds {:client {:source-paths ["dev/cljs" "dev/cljc"]
:figwheel {:on-jsload "dat.sys.start/on-js-reload"}}}}
:plugins [[lein-figwheel "0.5.8"] ;;:exclusions [org.clojure/clojure org.clojure/clojurescript org.codehaus.plexus/plexus-utils]
;[com.palletops/lein-shorthand "0.4.0"]
[lein-environ "1.0.1"]]
;; The lein-shorthand plugin gives us access to the following shortcuts as `./*` (e.g. `./pprint`)
:shorthand {. [clojure.pprint/pprint
alembic.still/distill
alembic.still/lein
taoensso.timbre/trace
taoensso.timbre/spy]}
:source-paths ["dev/clj"
"dev/cljc"
;; TODO Uncomment if you would like checkouts; This should be +edge opton or some such
;"checkouts/datview/src/cljs"
;"checkouts/datview/src/cljc"
;"checkouts/datsync/src/cljs"
;"checkouts/datsync/src/cljc"
;"checkouts/datreactor/src/cljs"
;"checkouts/datreactor/src/cljc"
;"checkouts/datspec/src/cljs"
;"checkouts/datspec/src/cljc"
#_:end]
;; libs/datsync/resources is important here; It's lib code need access to it's resources
;; dir in dev
:resource-paths ^:replace ["resources" "libs/datsync/resources"]}]
:prod {:cljsbuild
{:builds
{:client {:figwheel false
:compiler {:output-dir "resources/public/js/compiled"
:output-to "resources/public/js/compiled/app.js"
:source-map "resources/public/js/compiled/app.js.map"
;:pseudo-names true
:optimizations :advanced
:pretty-print false}}}}}

:uberjar [:prod
{:omit-source true
:aot :all}]}

:aliases {"package"
["with-profile" "prod" "do"
"clean" ["cljsbuild" "once"]]
"run-prod"
["with-profile" "prod" "do"
"package" "run"]})

:eval-in-leiningen true)
13 changes: 0 additions & 13 deletions src/clj/dat/sys/run.clj

This file was deleted.

14 changes: 0 additions & 14 deletions src/dat/sys/client/start_prod.cljs

This file was deleted.

21 changes: 21 additions & 0 deletions src/leiningen/datsys.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(ns leiningen.datsys
(:require [leiningen.new.options.helpers :as helpers]))


(defmulti handle-checkout-command
(fn [command args]
command))

(defn checkouts
[command & args]
(handle-checkout-command command args))

(defmethod handle-checkout-command "init"
[command args]
(println "Recieving checkout init message:" args))

(defmethod handle-checkout-command :default
[command args]
(println "Recieving random command:" command "; args:" args))


60 changes: 60 additions & 0 deletions src/leiningen/new/datsys.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
(ns leiningen.new.datsys
(:require
[leiningen.new.templates :refer [name-to-path sanitize-ns ->files]]
[leiningen.new.options.base :as base]
[leiningen.new.options.views :as views]
[leiningen.new.options.helpers :as helpers]
[leiningen.new.options.re-com :as re-com]
[leiningen.core.main :as main]))


;; Just realized; datspec should be about having a static project.clj like specification of what your datsys options
;; are in the sense of this namespace, what has been created so far, etc, and shows you changes to the template on a per
;; file basis, taking into account your changes.
;; So your datspec.clj file would compile or recompile things from the template.

;; Random port blocks
;; Set up checkouts
;; Datomic pro
;; P2P?
;; Component vs mount


(defn app-files [data options]
(concat
(base/files data)
(views/view-cljs options data)
(when (helpers/option? re-com/option options) (re-com/assets data))))


(defn generate-ports []
(let [server-port (+ 3000 (rand-int 10000))]
{:server-port server-port
:figwheel-port (inc server-port)
:nrepl-port (+ server-port 2)
:figwheel-nrepl-port (+ server-port 3)}))


(defn template-data [name options]
(merge
(generate-ports)
{:name name
:ns-name (sanitize-ns name)
:sanitized (name-to-path name)
:re-com? (helpers/invoke-option "+re-com" options)
:checkouts? (helpers/invoke-option "+checkouts" options)

;;prep-tasks
:init-checkouts (when (helpers/option? "+checkouts" options)
["datsys" "checkouts" "init"])}))


;; Think about generating base port

(defn datsys [name & options]
(let [data (template-data name options)]
;(check-options options)
(main/info "Generating datsys project:" name)
(apply ->files data (app-files data options))))


24 changes: 24 additions & 0 deletions src/leiningen/new/datsys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/logs
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
/resources/public/js/*.js
/resources/public/js/
profiles.clj
config/local/
data
# So you can install datomic here
datomic/
Session.vim
*.ini
.idea
*.iml
.idea/
figwheel_server.log
dev-resources
4 changes: 4 additions & 0 deletions src/leiningen/new/datsys/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

This generated code is public domain, and you can do whatever the hell you want with it.
However, do keep in mind that the leiningen template/generator is open source.

16 changes: 16 additions & 0 deletions src/leiningen/new/datsys/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# {{name}}

Welcome to your new Datsys application!

## Usage

Execute `lein repl` and when that finishes booting execute `(run)` from the REPL.
You should get some data loading on the client when you hit <localhost:{{server-port}}>.

From here:
* go to `checkouts/schema.edn` and `checkouts/test-data.edn` to start tinkering around with the data
* go to `cljs/{{ns-name}}/views.cljs` to modify the views
* go to `dev/user.clj` for a clj REPL scratch pad
* have fun!

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns dat.sys.figwheel-server
(ns {{ns-name}}.figwheel-server
(:require [com.stuartsierra.component :as component]
[figwheel-sidecar.system :as figwheel]
[dat.sys.utils :refer [deep-merge]]
[{{ns-name}}.utils :refer [deep-merge]]
[taoensso.timbre :as log :include-macros true]))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[clojure.repl :refer [apropos dir doc find-doc pst source]]
[com.stuartsierra.component :as component]
[clojure.tools.namespace.repl :refer [refresh refresh-all]]
[dat.sys.system :as system]
[{{ns-name}}.system :as system]
[taoensso.timbre :as log :include-macros true]
[dat.sys.figwheel-server :as fserver]))
[{{ns-name}}.figwheel-server :as fserver]))

(def system nil)

Expand Down Expand Up @@ -59,4 +59,4 @@
`(do (~'require '[cemerick.pomegranate])
(~'cemerick.pomegranate/add-dependencies :coordinates '[~dependency]
:repositories (~'merge cemerick.pomegranate.aether/maven-central
{"clojars" "http://clojars.org/repo"}))))
{"clojars" "http://clojars.org/repo"}))))
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns dat.sys.start
(:require [dat.sys.app :as app]
(ns {{ns-name}}.start
(:require [{{ns-name}}.app :as app]
[dat.view :as view]
[taoensso.timbre :as log :include-macros true]))

Expand Down
File renamed without changes.
Loading

0 comments on commit 603f4c4

Please sign in to comment.