mirror of https://github.com/status-im/reagent.git
Fix demo site build script, stop usinn lein profile merging
This commit is contained in:
parent
03ff2ffe87
commit
52b0b2eba4
|
@ -4,21 +4,14 @@ pom.xml
|
|||
pom.xml.asc
|
||||
.nrepl-port
|
||||
demo/empty.cljs
|
||||
outsite/public/index.html
|
||||
outsite/public/js
|
||||
outsite/public/news
|
||||
outsite/public/css
|
||||
out
|
||||
tmp
|
||||
figwheel_server.log
|
||||
|
||||
reagent.iml
|
||||
.idea
|
||||
.lein-failures
|
||||
|
||||
outsite/bundle.js
|
||||
outsite/bundle.min.js
|
||||
node_modules
|
||||
pre-render
|
||||
|
||||
test-environments/*/outsite
|
||||
test-environments/*/junit
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
SHA=$(git rev-parse HEAD)
|
||||
|
||||
# sanity check
|
||||
rm -fr tmp
|
||||
git clone git@github.com:reagent-project/reagent-project.github.io.git tmp
|
||||
rm -fr tmp/*
|
||||
|
||||
# Prerendering seems to work best on React 16
|
||||
cd test-environments/browser-node-react-16
|
||||
|
||||
lein do clean, cljsbuild once prod
|
||||
|
||||
cp -r target/cljsbuild/prod/public/* ../../tmp/
|
||||
|
||||
lein cljsbuild once prerender
|
||||
node target/cljsbuild/prerender/main.js
|
||||
cp -r target/prerender/public/* ../../tmp/
|
||||
|
||||
cd ../..
|
||||
|
||||
test -f tmp/index.html
|
||||
test -f tmp/js/main.js
|
||||
test ! -e tmp/js/out
|
||||
|
||||
lein codox
|
||||
|
||||
mkdir -p tmp/docs/master/
|
||||
cp -r target/doc/* tmp/docs/master/
|
||||
|
||||
cd tmp
|
||||
git checkout -- README.md
|
||||
git add .
|
||||
git commit -m "Built site from $SHA"
|
||||
# git push
|
||||
# rm -rf tmp
|
|
@ -14,3 +14,9 @@ dependencies:
|
|||
test:
|
||||
override:
|
||||
- ./run-tests.sh
|
||||
deployment:
|
||||
master:
|
||||
# branch: master
|
||||
branch: new-test-runner
|
||||
commands:
|
||||
- ./build-example-site.sh
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
[reagentdemo.common :as common :refer [demo-component]]
|
||||
[reagentdemo.intro :as intro]
|
||||
[reagentdemo.news :as news]
|
||||
[reagenttest.runtests :as tests]
|
||||
[reagent.debug :refer-macros [dbg println]]
|
||||
[doo.runner :as doo]))
|
||||
[reagent.debug :refer-macros [dbg println]]))
|
||||
|
||||
(def github {:href "https://github.com/reagent-project/reagent"})
|
||||
|
||||
|
@ -23,8 +21,7 @@
|
|||
|
||||
(tools/register-page index-page [#'intro/main] title)
|
||||
|
||||
|
||||
(defn demo []
|
||||
(defn demo [& [test-component]]
|
||||
[:div
|
||||
[:div.nav>ul.nav
|
||||
[:li.brand [link {:href index-page} "Reagent:"]]
|
||||
|
@ -32,16 +29,12 @@
|
|||
[:li [link {:href news/url} "News"]]
|
||||
[:li>a github "GitHub"]
|
||||
[:li [:a {:href "http://reagent-project.github.io/docs/master/"} "API"]]]
|
||||
[:div @tests/test-results-component]
|
||||
[:div test-component]
|
||||
[tools/main-content]
|
||||
[github-badge]])
|
||||
|
||||
(defn init! []
|
||||
(doo/set-exit-point! (fn [success?] nil))
|
||||
(tests/init!)
|
||||
(tools/start! {:body [#'demo]
|
||||
(defn init! [& [test-component]]
|
||||
(tools/start! {:body [#'demo test-component]
|
||||
:title-prefix "Reagent: "
|
||||
:css-infiles ["site/public/css/examples.css"
|
||||
"site/public/css/main.css"]}))
|
||||
|
||||
(init!)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
(ns reagentdemo.dev
|
||||
"Initializes the demo app, and runs the tests."
|
||||
(:require [reagentdemo.core :as core]
|
||||
[reagenttest.runtests :as tests]))
|
||||
|
||||
(defn init! []
|
||||
(core/init! (tests/init!)))
|
||||
|
||||
(init!)
|
|
@ -16,7 +16,7 @@
|
|||
(defonce config (r/atom {:body [#'main-content]
|
||||
:pages {"/index.html" {:content [:div]
|
||||
:title ""}}
|
||||
:site-dir "outsite/public"
|
||||
:site-dir "target/prerender/public/"
|
||||
:css-infiles ["site/public/css/main.css"]
|
||||
:css-file "css/built.css"
|
||||
:js-file "js/main.js"
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
(:require [reagent.debug :refer-macros [log]]
|
||||
[sitetools.core :as tools]
|
||||
[sitetools.server :as server]
|
||||
reagentdemo.core))
|
||||
[reagentdemo.core :as demo]))
|
||||
|
||||
(defn -main [& args]
|
||||
(log "Generating site")
|
||||
(demo/init!)
|
||||
(let [conf @tools/config
|
||||
conf (assoc conf :timestamp (str "?" (js/Date.now)))
|
||||
{:keys [site-dir pages]} conf]
|
||||
|
@ -13,6 +14,7 @@
|
|||
(server/write-file (->> f tools/to-relative (server/path-join site-dir))
|
||||
(server/gen-page f conf)))
|
||||
(server/write-resources site-dir conf))
|
||||
(log "Wrote site"))
|
||||
(log "Wrote site")
|
||||
(js/process.exit 0))
|
||||
|
||||
(set! *main-cli-fn* -main)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"karma": "^1.7.1",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
|
|
146
project.clj
146
project.clj
|
@ -15,7 +15,8 @@
|
|||
|
||||
:plugins [[lein-cljsbuild "1.1.7"]
|
||||
[lein-doo "0.1.8"]
|
||||
[lein-codox "0.10.3"]]
|
||||
[lein-codox "0.10.3"]
|
||||
[lein-figwheel "0.5.14"]]
|
||||
|
||||
:source-paths ["src"]
|
||||
|
||||
|
@ -23,79 +24,86 @@
|
|||
:exclude clojure.string
|
||||
:source-paths ["src"]}
|
||||
|
||||
:profiles {:node-test [:test {:cljsbuild
|
||||
{:builds {:client {:compiler {:target :nodejs
|
||||
:process-shim false}}}}}]
|
||||
|
||||
:test {:cljsbuild
|
||||
{:builds {:client {:compiler {:main "reagenttest.runtests"}}}}}
|
||||
|
||||
:react-16 {:dependencies [[cljsjs/react "16.0.0-0"]
|
||||
:profiles {:react-16 {:dependencies [[cljsjs/react "16.0.0-0"]
|
||||
[cljsjs/react-dom "16.0.0-0"]
|
||||
[cljsjs/react-dom-server "16.0.0-0"]]}
|
||||
|
||||
:site {:resource-paths ^:replace ["outsite"]
|
||||
:figwheel {:css-dirs ^:replace ["outsite/public/css"]}}
|
||||
|
||||
:prod [:site
|
||||
{:cljsbuild
|
||||
{:builds {:client
|
||||
{:compiler {:optimizations :advanced
|
||||
:elide-asserts true
|
||||
:pretty-print false
|
||||
;; :pseudo-names true
|
||||
:output-dir "target/client"}}}}}]
|
||||
|
||||
:prerender [:prod
|
||||
{:cljsbuild
|
||||
{:builds {:client
|
||||
{:compiler {:main "sitetools.prerender"
|
||||
:target :nodejs
|
||||
;; Undefine module and exports so React UMD modules work on Node
|
||||
:output-to "pre-render/main.js"
|
||||
:output-dir "pre-render/out"}}}}}]
|
||||
|
||||
:prod-test [:prod :test]
|
||||
|
||||
:dev {:dependencies [[figwheel "0.5.14"]
|
||||
[doo "0.1.8"]]
|
||||
:plugins [[lein-figwheel "0.5.14"]]
|
||||
:source-paths ["demo"] ;; for lighttable
|
||||
:resource-paths ["site" "outsite"]
|
||||
:figwheel {:css-dirs ["site/public/css"]}
|
||||
:cljsbuild
|
||||
{:builds
|
||||
{:client
|
||||
{:figwheel true
|
||||
:compiler {:source-map true
|
||||
:optimizations :none
|
||||
;; :recompile-dependents false
|
||||
:output-dir "outsite/public/js/out"
|
||||
:asset-path "js/out"}}}}}}
|
||||
:source-paths ["demo" "examples/todomvc/src" "examples/simple/src" "examples/geometry/src"]
|
||||
:resource-paths ["site" "target/cljsbuild/client"]}}
|
||||
|
||||
:clean-targets ^{:protect false} [:target-path :compile-path
|
||||
"outsite/public/js"
|
||||
"outsite/public/site"
|
||||
"outsite/public/news"
|
||||
"outsite/public/css"
|
||||
"outsite/public/index.html"
|
||||
"out"
|
||||
"pre-render"]
|
||||
|
||||
:cljsbuild {:builds {:client
|
||||
{:source-paths ["src"
|
||||
"demo"
|
||||
"test"
|
||||
"examples/todomvc/src"
|
||||
"examples/simple/src"
|
||||
"examples/geometry/src"]
|
||||
:compiler {:parallel-build true
|
||||
:main "reagentdemo.core"
|
||||
:output-to "outsite/public/js/main.js"
|
||||
:language-in :ecmascript6
|
||||
:language-out :ecmascript3
|
||||
;; Add process.env.NODE_ENV preload
|
||||
:process-shim true}}}}
|
||||
:clean-targets ^{:protect false} [:target-path :compile-path "out"]
|
||||
|
||||
:figwheel {:http-server-root "public" ;; assumes "resources"
|
||||
:repl false})
|
||||
:css-dirs ["site/public/css"]
|
||||
:repl false}
|
||||
|
||||
;; No profiles and merging - just manual configuration for each build type
|
||||
:cljsbuild
|
||||
{:builds
|
||||
{:client
|
||||
{:source-paths ["demo" "test"]
|
||||
:figwheel true
|
||||
:compiler {:parallel-build true
|
||||
:source-map true
|
||||
:optimizations :none
|
||||
; :main "reagentdemo.core"
|
||||
:main "reagentdemo.dev"
|
||||
:output-dir "target/cljsbuild/client/public/js/out"
|
||||
:output-to "target/cljsbuild/client/public/js/main.js"
|
||||
:asset-path "js/out"
|
||||
;; add process.env.node_env preload
|
||||
:process-shim true}}
|
||||
|
||||
:test
|
||||
{:source-paths ["test"]
|
||||
:compiler {:parallel-build true
|
||||
:source-map true
|
||||
:optimizations :none
|
||||
:main "reagenttest.runtests"
|
||||
:asset-path "js/out"
|
||||
:output-dir "target/cljsbuild/test/out"
|
||||
:output-to "target/cljsbuild/test/main.js"
|
||||
;; add process.env.node_env preload
|
||||
:process-shim true}}
|
||||
|
||||
:prerender
|
||||
{:source-paths ["demo"]
|
||||
:compiler {:main "sitetools.prerender"
|
||||
:target :nodejs
|
||||
:process-shim false
|
||||
:output-dir "target/cljsbuild/prerender/out"
|
||||
:output-to "target/cljsbuild/prerender/main.js"}}
|
||||
|
||||
:node-test
|
||||
{:source-paths ["test"]
|
||||
:compiler {:main "reagenttest.runtests"
|
||||
:target :nodejs
|
||||
:parallel-build true
|
||||
:source-map true
|
||||
:optimizations :none
|
||||
:output-dir "target/cljsbuild/node-test/out"
|
||||
:output-to "target/cljsbuild/node-test/main.js"}}
|
||||
|
||||
:prod
|
||||
{:source-paths ["demo"]
|
||||
:compiler {:main "reagentdemo.core"
|
||||
:optimizations :advanced
|
||||
:elide-asserts true
|
||||
:pretty-print false
|
||||
;; :pseudo-names true
|
||||
:output-to "target/cljsbuild/prod/public/js/main.js"
|
||||
:output-dir "target/cljsbuild/prod/out" ;; Outside of public, not published
|
||||
:closure-warnings {:global-this :off}}}
|
||||
|
||||
:prod-test
|
||||
{:source-paths ["demo"]
|
||||
:compiler {:main "reagenttest.runtests"
|
||||
:optimizations :advanced
|
||||
:elide-asserts true
|
||||
:pretty-print false
|
||||
;; :pseudo-names true
|
||||
:output-to "target/cljsbuild/prod-test/main.js"
|
||||
:output-dir "target/cljsbuild/prod-test/out"
|
||||
:closure-warnings {:global-this :off}}}}})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
lein with-profile test do clean, doo chrome-headless client once
|
||||
test -f out/node_modules/react/index.js
|
||||
lein do clean, doo chrome-headless test once
|
||||
test -f target/cljsbuild/test/out/node_modules/react/index.js
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
lein with-profile test do clean, doo chrome-headless client once
|
||||
test -f out/node_modules/react/react.js
|
||||
lein do clean, doo chrome-headless test once
|
||||
test -f target/cljsbuild/test/out/node_modules/react/react.js
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
lein with-profile prod-test do clean, doo chrome-headless client once
|
||||
set -x
|
||||
lein do clean, doo chrome-headless prod-test once
|
||||
test -f target/cljsbuild/prod-test/main.js
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
set -x
|
||||
lein with-profile dev,react-16 figwheel
|
||||
lein with-profile react-16 figwheel
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
lein with-profile react-16,test do clean, doo chrome-headless client once
|
||||
test -f out/cljsjs/react/development/react.inc.js
|
||||
lein with-profile dev,react-16 do clean, doo chrome-headless test once
|
||||
test -f target/cljsbuild/test/out/cljsjs/react/development/react.inc.js
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
lein with-profile test do clean, doo chrome-headless client once
|
||||
test -f out/cljsjs/react/development/react.inc.js
|
||||
lein do clean, doo chrome-headless test once
|
||||
test -f target/cljsbuild/test/out/cljsjs/react/development/react.inc.js
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
lein with-profile node-test do clean, doo node client once
|
||||
test ! -f out/node_modules/react/index.js
|
||||
grep "reagent.impl.template.node\$module\$react = require('react')" out/reagent/impl/template.js
|
||||
lein do clean, doo node node-test once
|
||||
test ! -f target/cljsbuild/node-test/out/node_modules/react/index.js
|
||||
grep "reagent.impl.template.node\$module\$react = require('react')" target/cljsbuild/node-test/out/reagent/impl/template.js
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
[reagenttest.testwithlet]
|
||||
[reagenttest.testwrap]
|
||||
[cljs.test :as test :include-macros true]
|
||||
[doo.runner :refer-macros [doo-tests]]
|
||||
[doo.runner :as doo :refer-macros [doo-tests]]
|
||||
[reagent.core :as r]
|
||||
[reagent.debug :refer-macros [dbg log]]
|
||||
[sitetools.server]))
|
||||
|
@ -49,13 +49,13 @@
|
|||
(:fail res) " failures, " (:error res) " errors."])
|
||||
"testing")]))
|
||||
|
||||
(def test-results-component (r/atom nil))
|
||||
|
||||
(defn init! []
|
||||
;; This function is only used when running tests from the demo app.
|
||||
;; Which is why exit-point is set manually.
|
||||
(when (some? (test/deftest empty-test))
|
||||
;; Only run with :load-tests true
|
||||
(reset! test-results-component [#'test-output-mini])
|
||||
(run-tests)))
|
||||
(doo/set-exit-point! (fn [success?] nil))
|
||||
(run-tests)
|
||||
[#'test-output-mini]))
|
||||
|
||||
(doo-tests 'reagenttest.testreagent
|
||||
'reagenttest.testcursor
|
||||
|
|
Loading…
Reference in New Issue