diff --git a/bin/gen-site.js b/bin/gen-site.js index aefbe47..951fbfd 100755 --- a/bin/gen-site.js +++ b/bin/gen-site.js @@ -3,7 +3,7 @@ var cljsLoad = require("./cljs-load"); var srcFile = "outsite/public/js/main.js"; var outputDirectory = "outsite/public/js/out/"; -var moduleName = "devsetup"; +var moduleName = "reagentdemo.dev"; var beep = "\u0007"; @@ -16,7 +16,10 @@ if (typeof location === "undefined") { var gensite = function () { console.log("Loading " + srcFile); var optNone = cljsLoad.load(srcFile, outputDirectory, moduleName); - sitetools.genpages({"opt-none": optNone}); + if (typeof reagenttest != "undefined") { + reagenttest.runtests.run_tests(); + } + sitetools.core.genpages({"opt-none": optNone}); } var compileFail = function () { diff --git a/demo/demo.cljs b/demo/reagentdemo/core.cljs similarity index 95% rename from demo/demo.cljs rename to demo/reagentdemo/core.cljs index 4494986..6e117a3 100644 --- a/demo/demo.cljs +++ b/demo/reagentdemo/core.cljs @@ -1,8 +1,8 @@ -(ns demo +(ns reagentdemo.core (:require [reagent.core :as reagent :refer [atom]] [reagent.interop :as i :refer-macros [.' .!]] [clojure.string :as string] - [sitetools :as tools :refer [link]] + [sitetools.core :as tools :refer [link]] [reagentdemo.common :as common :refer [demo-component]] [reagentdemo.intro :as intro] [reagentdemo.news :as news] diff --git a/demo/reagentdemo/intro.cljs b/demo/reagentdemo/intro.cljs index 67b9799..b4c6a70 100644 --- a/demo/reagentdemo/intro.cljs +++ b/demo/reagentdemo/intro.cljs @@ -4,10 +4,10 @@ [reagent.debug :refer-macros [dbg println]] [clojure.string :as string] [reagentdemo.syntax :as s] - [sitetools :refer [link]] + [sitetools.core :refer [link]] [reagentdemo.common :as common :refer [demo-component]] - [simpleexample :as simple] - [todomvc :as todo])) + [simpleexample.core :as simple] + [todomvc.core :as todo])) (defn simple-component [] [:div @@ -307,7 +307,7 @@ [demo-component {:comp simple/simple-example :complete true - :src (s/src-of nil "simpleexample.cljs")}]]) + :src (s/src-of nil "simpleexample/core.cljs")}]]) (defn todomvc-demo [] [:div.demo-text @@ -319,7 +319,7 @@ [demo-component {:comp todo/todo-app :complete true - :src (s/src-of nil "todomvc.cljs")}]]) + :src (s/src-of nil "todomvc/core.cljs")}]]) (defn main [] (let [show-all (atom false) diff --git a/demo/reagentdemo/news/anyargs.cljs b/demo/reagentdemo/news/anyargs.cljs index 74f6196..f611766 100644 --- a/demo/reagentdemo/news/anyargs.cljs +++ b/demo/reagentdemo/news/anyargs.cljs @@ -3,7 +3,7 @@ [reagent.interop :refer-macros [.' .!]] [reagent.debug :refer-macros [dbg println]] [reagentdemo.syntax :as s] - [sitetools :as tools :refer [link]] + [sitetools.core :as tools :refer [link]] [reagentdemo.common :as common :refer [demo-component]] [geometry.core :as geometry])) diff --git a/demo/reagentdemo/news/async.cljs b/demo/reagentdemo/news/async.cljs index a366f72..67c5dac 100644 --- a/demo/reagentdemo/news/async.cljs +++ b/demo/reagentdemo/news/async.cljs @@ -3,7 +3,7 @@ [reagent.interop :refer-macros [.' .!]] [reagent.debug :refer-macros [dbg println]] [reagentdemo.syntax :as s] - [sitetools :as tools :refer [link]] + [sitetools.core :as tools :refer [link]] [reagentdemo.common :as common :refer [demo-component]])) (def url "news/reagent-is-async.html") diff --git a/demo/reagentdemo/news/clockpost.cljs b/demo/reagentdemo/news/clockpost.cljs index caa239c..e380fcf 100644 --- a/demo/reagentdemo/news/clockpost.cljs +++ b/demo/reagentdemo/news/clockpost.cljs @@ -3,7 +3,7 @@ [reagent.interop :refer-macros [.' .!]] [reagent.debug :refer-macros [dbg]] [reagentdemo.syntax :as s] - [sitetools :as tools :refer [link]] + [sitetools.core :as tools :refer [link]] [reagentdemo.common :as common :refer [demo-component]] [reagentdemo.news.binaryclock :as binaryclock])) diff --git a/demo/reagentdemo/news/news050.cljs b/demo/reagentdemo/news/news050.cljs index 0ca1913..fad1436 100644 --- a/demo/reagentdemo/news/news050.cljs +++ b/demo/reagentdemo/news/news050.cljs @@ -3,9 +3,8 @@ [reagent.interop :refer-macros [.' .!]] [reagent.debug :refer-macros [dbg println]] [reagentdemo.syntax :as s] - [sitetools :as tools :refer [link]] - [reagentdemo.common :as common :refer [demo-component]] - [todomvc :as todomvc])) + [sitetools.core :as tools :refer [link]] + [reagentdemo.common :as common :refer [demo-component]])) (def url "news/news050.html") (def title "News in 0.5.0-alpha") diff --git a/demo/reagentdemo/news/undodemo.cljs b/demo/reagentdemo/news/undodemo.cljs index bf642dd..95a9dad 100644 --- a/demo/reagentdemo/news/undodemo.cljs +++ b/demo/reagentdemo/news/undodemo.cljs @@ -3,9 +3,9 @@ [reagent.interop :refer-macros [.' .!]] [reagent.debug :refer-macros [dbg println]] [reagentdemo.syntax :as s] - [sitetools :as tools :refer [link]] + [sitetools.core :as tools :refer [link]] [reagentdemo.common :as common :refer [demo-component]] - [todomvc :as todomvc])) + [todomvc.core :as todomvc])) (def url "news/cloact-reagent-undo-demo.html") (def title "Cloact becomes Reagent: Undo is trivial") diff --git a/demo/sitetools.cljs b/demo/sitetools/core.cljs similarity index 99% rename from demo/sitetools.cljs rename to demo/sitetools/core.cljs index c1414ca..0b26535 100644 --- a/demo/sitetools.cljs +++ b/demo/sitetools/core.cljs @@ -1,4 +1,4 @@ -(ns sitetools +(ns sitetools.core (:require [clojure.string :as string] [goog.events :as evt] [goog.history.EventType :as hevt] diff --git a/env/dev/devsetup.cljs b/env/dev/reagentdemo/dev.cljs similarity index 62% rename from env/dev/devsetup.cljs rename to env/dev/reagentdemo/dev.cljs index ef288d0..f527368 100644 --- a/env/dev/devsetup.cljs +++ b/env/dev/reagentdemo/dev.cljs @@ -1,6 +1,6 @@ -(ns ^:figwheel-always devsetup - (:require [demo :as site] - [runtests] +(ns ^:figwheel-always reagentdemo.dev + (:require [reagentdemo.core :as demo] + [reagenttest.runtests :as runtests] [reagent.core :as r] [figwheel.client :as fw])) @@ -13,6 +13,7 @@ (defn start! [] (demo/start! {:test-results test-results}) - (runtests/run-tests)) + (when r/is-client + (runtests/run-tests))) (start!) diff --git a/env/prod/prodsetup.cljs b/env/prod/prodsetup.cljs deleted file mode 100644 index b23eae1..0000000 --- a/env/prod/prodsetup.cljs +++ /dev/null @@ -1,12 +0,0 @@ -(ns envsetup - (:require [demo :as site] - [reagent.core :as r])) - -(site/start! nil) - -(defn do-test [] - (when (exists? js/runtests) - (js/runtests.run-tests))) - -;; Wait for tests to be defined -(r/next-tick do-test) diff --git a/env/prod/reagentdemo/prod.cljs b/env/prod/reagentdemo/prod.cljs new file mode 100644 index 0000000..f2aa16d --- /dev/null +++ b/env/prod/reagentdemo/prod.cljs @@ -0,0 +1,13 @@ +(ns reagentdemo.prod + (:require [reagentdemo.core :as demo] + [reagent.core :as r])) + +(demo/start! nil) + +(defn do-test [] + (when (and (exists? js/reagenttest)) + (js/reagenttest.runtests.run-tests))) + +;; Wait for tests to be defined +(when r/is-client + (r/next-tick do-test)) diff --git a/examples/geometry/devsrc/devsetup.cljs b/examples/geometry/devsrc/geometry/dev.cljs similarity index 91% rename from examples/geometry/devsrc/devsetup.cljs rename to examples/geometry/devsrc/geometry/dev.cljs index a25b803..06883d1 100644 --- a/examples/geometry/devsrc/devsetup.cljs +++ b/examples/geometry/devsrc/geometry/dev.cljs @@ -1,4 +1,4 @@ -(ns devsetup +(ns geometry.dev (:require [geometry.core :as example] [figwheel.client :as fw])) diff --git a/examples/geometry/project.clj b/examples/geometry/project.clj index f6d042d..6adf2f0 100644 --- a/examples/geometry/project.clj +++ b/examples/geometry/project.clj @@ -1,6 +1,6 @@ (defproject geometry-reagent "0.5.0-alpha3" :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/clojurescript "0.0-2760"] + [org.clojure/clojurescript "0.0-2816"] [reagent "0.5.0-alpha3"] [figwheel "0.2.3-SNAPSHOT"]] @@ -12,7 +12,7 @@ :profiles {:dev {:cljsbuild {:builds {:client {:source-paths ["devsrc"] :compiler - {:main devsetup + {:main geometry.dev :optimizations :none :source-map true :source-map-timestamp true}}}}} diff --git a/examples/todomvc/devsrc/devsetup.cljs b/examples/simple/devsrc/simpleexample/dev.cljs similarity index 66% rename from examples/todomvc/devsrc/devsetup.cljs rename to examples/simple/devsrc/simpleexample/dev.cljs index adce322..543863a 100644 --- a/examples/todomvc/devsrc/devsetup.cljs +++ b/examples/simple/devsrc/simpleexample/dev.cljs @@ -1,5 +1,5 @@ -(ns devsetup - (:require [todomvc :as example] +(ns simpleexample.dev + (:require [simpleexample.core :as example] [figwheel.client :as fw])) (fw/start {:on-jsload example/run diff --git a/examples/simple/example.html b/examples/simple/example.html index 0caf43b..a9b7c39 100644 --- a/examples/simple/example.html +++ b/examples/simple/example.html @@ -11,7 +11,7 @@ diff --git a/examples/simple/project.clj b/examples/simple/project.clj index cd27bbf..fba3660 100644 --- a/examples/simple/project.clj +++ b/examples/simple/project.clj @@ -1,7 +1,7 @@ (defproject simple-reagent "0.5.0-alpha3" :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/clojurescript "0.0-2760"] + [org.clojure/clojurescript "0.0-2816"] [reagent "0.5.0-alpha3"] [figwheel "0.2.3-SNAPSHOT"]] @@ -13,7 +13,7 @@ :profiles {:dev {:cljsbuild {:builds {:client {:source-paths ["devsrc"] :compiler - {:main devsetup + {:main simpleexample.dev :optimizations :none :source-map true :source-map-timestamp true}}}}} diff --git a/examples/simple/src/simpleexample.cljs b/examples/simple/src/simpleexample/core.cljs similarity index 97% rename from examples/simple/src/simpleexample.cljs rename to examples/simple/src/simpleexample/core.cljs index 423e417..103b059 100644 --- a/examples/simple/src/simpleexample.cljs +++ b/examples/simple/src/simpleexample/core.cljs @@ -1,4 +1,4 @@ -(ns simpleexample +(ns simpleexample.core (:require [reagent.core :as reagent :refer [atom]])) (defonce timer (atom (js/Date.))) diff --git a/examples/simple/devsrc/devsetup.cljs b/examples/todomvc/devsrc/todomvc/dev.cljs similarity index 71% rename from examples/simple/devsrc/devsetup.cljs rename to examples/todomvc/devsrc/todomvc/dev.cljs index 4025d52..0fcde96 100644 --- a/examples/simple/devsrc/devsetup.cljs +++ b/examples/todomvc/devsrc/todomvc/dev.cljs @@ -1,5 +1,5 @@ -(ns devsetup - (:require [simpleexample :as example] +(ns todomvc.dev + (:require [todomvc.core :as example] [figwheel.client :as fw])) (fw/start {:on-jsload example/run diff --git a/examples/todomvc/example.html b/examples/todomvc/example.html index ff36a3e..e0aaeca 100644 --- a/examples/todomvc/example.html +++ b/examples/todomvc/example.html @@ -11,7 +11,7 @@ diff --git a/examples/todomvc/project.clj b/examples/todomvc/project.clj index 8279882..57c8749 100644 --- a/examples/todomvc/project.clj +++ b/examples/todomvc/project.clj @@ -1,6 +1,6 @@ (defproject todomvc-reagent "0.5.0-alpha3" :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/clojurescript "0.0-2760"] + [org.clojure/clojurescript "0.0-2816"] [reagent "0.5.0-alpha3"] [figwheel "0.2.3-SNAPSHOT"]] @@ -12,7 +12,7 @@ :profiles {:dev {:cljsbuild {:builds {:client {:source-paths ["devsrc"] :compiler - {:main devsetup + {:main todomvc.dev :optimizations :none :source-map true :source-map-timestamp true}}}}} diff --git a/examples/todomvc/src/todomvc.cljs b/examples/todomvc/src/todomvc/core.cljs similarity index 99% rename from examples/todomvc/src/todomvc.cljs rename to examples/todomvc/src/todomvc/core.cljs index abaa284..1e15b71 100644 --- a/examples/todomvc/src/todomvc.cljs +++ b/examples/todomvc/src/todomvc/core.cljs @@ -1,4 +1,4 @@ -(ns todomvc +(ns todomvc.core (:require [reagent.core :as reagent :refer [atom]])) (defonce todos (atom (sorted-map))) diff --git a/project.clj b/project.clj index 5b241c8..9934194 100644 --- a/project.clj +++ b/project.clj @@ -1,11 +1,10 @@ - (defproject reagent "0.5.0-SNAPSHOT" :url "http://github.com/reagent-project/reagent" :license {:name "MIT"} :description "A simple ClojureScript interface to React" :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/clojurescript "0.0-2760"] + [org.clojure/clojurescript "0.0-2816"] [cljsjs/react "0.12.2-5"]] :plugins [[lein-cljsbuild "1.0.4"]] @@ -24,7 +23,7 @@ {:builds {:client {:source-paths ["env/dev"] - :compiler {:main "devsetup" + :compiler {:main "reagentdemo.dev" :source-map true :source-map-timestamp true :optimizations :none @@ -41,7 +40,7 @@ {:cljsbuild {:builds {:client {:source-paths ["env/prod"] - :compiler {:main "prodsetup" + :compiler {:main "reagentdemo.prod" :optimizations :advanced :elide-asserts true :pretty-print false @@ -54,6 +53,7 @@ "outsite/public/js" "outsite/public/site" "outsite/public/news" + "outsite/public/css" "outsite/public/index.html" "out"] diff --git a/test/runtests.cljs b/test/reagenttest/runtests.cljs similarity index 55% rename from test/runtests.cljs rename to test/reagenttest/runtests.cljs index fdc18f4..63f0699 100644 --- a/test/runtests.cljs +++ b/test/reagenttest/runtests.cljs @@ -1,26 +1,32 @@ - -(ns runtests - (:require [testreagent] - [testcursor] - [testinterop] - [testratom] - [testwrap] +(ns reagenttest.runtests + (:require [reagenttest.testreagent] + [reagenttest.testcursor] + [reagenttest.testinterop] + [reagenttest.testratom] + [reagenttest.testwrap] [cljs.test :as test :include-macros true] [reagent.core :as reagent :refer [atom]] [reagent.interop :refer-macros [.' .!]] - [reagent.debug :refer-macros [dbg println]])) - -(defn all-tests [] - (test/run-tests 'testreagent - 'testcursor - 'testinterop - 'testratom - 'testwrap)) + [reagent.debug :refer-macros [dbg log]])) (enable-console-print!) +(defn all-tests [] + (test/run-tests 'reagenttest.testreagent + 'reagenttest.testcursor + 'reagenttest.testinterop + 'reagenttest.testratom + 'reagenttest.testwrap)) + (def test-results (atom nil)) +(defmethod test/report [::test/default :summary] [m] + ;; ClojureScript 2814 doesn't return anything from run-tests + (reset! test-results m) + (println "\nRan" (:test m) "tests containing" + (+ (:pass m) (:fail m) (:error m)) "assertions.") + (println (:fail m) "failures," (:error m) "errors.")) + (def test-box {:position 'absolute :margin-left -35 :color :#aaa}) @@ -46,14 +52,15 @@ [:div {:style test-box} "testing"]))) (defn ^:export run-all-tests [] - (println "-----------------------------------------") + (log "-----------------------------------------") (try - (reset! test-results (all-tests)) + (reset! test-results nil) + (all-tests) (catch js/Object e (do - (println "Testrun failed\n" e "\n" (.-stack e)) + (log "Testrun failed\n" e "\n" (.-stack e)) (reset! test-results {:error e})))) - (println "-----------------------------------------")) + (log "-----------------------------------------")) (defn ^:export run-tests [] (if reagent/is-client diff --git a/test/testcursor.cljs b/test/reagenttest/testcursor.cljs similarity index 99% rename from test/testcursor.cljs rename to test/reagenttest/testcursor.cljs index 59ff5f5..08e7a33 100644 --- a/test/testcursor.cljs +++ b/test/reagenttest/testcursor.cljs @@ -1,4 +1,4 @@ -(ns testcursor +(ns reagenttest.testcursor (:require [cljs.test :as t :refer-macros [is deftest testing]] [reagent.ratom :as rv :refer-macros [run! reaction]] [reagent.debug :refer-macros [dbg]] diff --git a/test/testinterop.cljs b/test/reagenttest/testinterop.cljs similarity index 97% rename from test/testinterop.cljs rename to test/reagenttest/testinterop.cljs index db9d289..441bf76 100644 --- a/test/testinterop.cljs +++ b/test/reagenttest/testinterop.cljs @@ -1,4 +1,4 @@ -(ns testinterop +(ns reagenttest.testinterop (:require [cljs.test :as t :refer-macros [is deftest]] [reagent.debug :refer-macros [dbg]] [reagent.interop :refer-macros [.' .!]])) diff --git a/test/testratom.cljs b/test/reagenttest/testratom.cljs similarity index 99% rename from test/testratom.cljs rename to test/reagenttest/testratom.cljs index 364ff70..f96a8fc 100644 --- a/test/testratom.cljs +++ b/test/reagenttest/testratom.cljs @@ -1,4 +1,4 @@ -(ns testratom +(ns reagenttest.testratom (:require [cljs.test :as t :refer-macros [is deftest testing]] [reagent.ratom :as rv :refer-macros [run! reaction]] [reagent.debug :refer-macros [dbg]] diff --git a/test/testreagent.cljs b/test/reagenttest/testreagent.cljs similarity index 99% rename from test/testreagent.cljs rename to test/reagenttest/testreagent.cljs index c6c2a2f..6c0b6f7 100644 --- a/test/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -1,4 +1,4 @@ -(ns testreagent +(ns reagenttest.testreagent (:require [cljs.test :as t :refer-macros [is deftest testing]] [reagent.ratom :as rv :refer-macros [reaction]] [reagent.debug :refer-macros [dbg println log]] diff --git a/test/testwrap.cljs b/test/reagenttest/testwrap.cljs similarity index 99% rename from test/testwrap.cljs rename to test/reagenttest/testwrap.cljs index 99ff4c9..2012746 100644 --- a/test/testwrap.cljs +++ b/test/reagenttest/testwrap.cljs @@ -1,4 +1,4 @@ -(ns testwrap +(ns reagenttest.testwrap (:require [cljs.test :as t :refer-macros [is deftest]] [reagent.debug :refer-macros [dbg println log]] [reagent.core :as r :refer [atom wrap]]))