-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: generate initial skeleton app for figwheel-main example
`clj -A:new figwheel-main dirac-figmain.core -- --react`
- Loading branch information
Showing
12 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pom.xml | ||
*jar | ||
/lib/ | ||
/classes/ | ||
/out/ | ||
/target/ | ||
.lein-deps-sum | ||
.lein-repl-history | ||
.lein-plugins/ | ||
.repl | ||
.nrepl-port | ||
.cpcache/ | ||
.rebel_readline_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# dirac-figmain.core | ||
|
||
FIXME: Write a one-line description of your library/project. | ||
|
||
## Overview | ||
|
||
FIXME: Write a paragraph about the library/project and highlight its goals. | ||
|
||
## Development | ||
|
||
To get an interactive development environment run: | ||
|
||
clojure -A:fig:build | ||
|
||
This will auto compile and send all changes to the browser without the | ||
need to reload. After the compilation process is complete, you will | ||
get a Browser Connected REPL. An easy way to try it is: | ||
|
||
(js/alert "Am I connected?") | ||
|
||
and you should see an alert in the browser window. | ||
|
||
To clean all compiled files: | ||
|
||
rm -rf target/public | ||
|
||
To create a production build run: | ||
|
||
rm -rf target/public | ||
clojure -A:fig:min | ||
|
||
|
||
## License | ||
|
||
Copyright © 2018 FIXME | ||
|
||
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{:deps {org.clojure/clojure {:mvn/version "1.9.0"} | ||
org.clojure/clojurescript {:mvn/version "1.10.339"} | ||
cljsjs/react {:mvn/version "16.4.1-0"} | ||
cljsjs/react-dom {:mvn/version "16.4.1-0"} | ||
cljsjs/create-react-class {:mvn/version "15.6.3-1"} | ||
sablono {:mvn/version "0.8.4"}} | ||
:paths ["src" "resources"] | ||
:aliases {:fig {:extra-deps | ||
{com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"} | ||
com.bhauman/figwheel-main {:mvn/version "0.1.9"}} | ||
:extra-paths ["target" "test"]} | ||
:build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]} | ||
:min {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]} | ||
:test {:main-opts ["-m" "figwheel.main" "-co" "test.cljs.edn" "-m" dirac-figmain.test-runner]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^{:watch-dirs ["test" "src"] | ||
:css-dirs ["resources/public/css"] | ||
:auto-testing true} | ||
{:main dirac-figmain.core} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
;; Figwheel-main configuration options see: https://figwheel.org/config-options | ||
;; these will be overriden by the metadata config options in dev.cljs.edn build file | ||
{ | ||
;; Set the server port https://figwheel.org/config-options#ring-server-options | ||
;; :ring-server-options {:port 9500} | ||
|
||
;; Target directory https://figwheel.org/config-options#target-dir | ||
;; you may want to set this to resources if you are using Leiningen | ||
;; :target-dir "resources" | ||
|
||
;; Server Ring Handler (optional) https://figwheel.org/docs/ring-handler.html | ||
;; If you want to embed a ring handler into the figwheel server, this | ||
;; is for simple ring servers | ||
;; :ring-handler hello_world.server/handler | ||
|
||
;; To be able to open files in your editor from the heads up display | ||
;; you will need to put a script on your path. This script will have | ||
;; to take a file path and a line number ie. | ||
;; in ~/bin/myfile-opener: | ||
;; | ||
;; #! /bin/sh | ||
;; emacsclient -n +$2:$3 $1 | ||
;; | ||
;; :open-file-command "myfile-opener" | ||
|
||
;; if you are using emacsclient you can just use | ||
;; :open-file-command "emacsclient" | ||
|
||
;; Logging output gets printed to the REPL, if you want to redirect it to a file: | ||
;; :log-file "figwheel-main.log" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* some style */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="css/style.css" rel="stylesheet" type="text/css"> | ||
<link rel="icon" href="https://clojurescript.org/images/cljs-logo-icon-32.png"> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
</div> <!-- end of app div --> | ||
<script src="cljs-out/dev-main.js" type="text/javascript"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<h1>Test host page</h1> | ||
<script src="cljs-out/test-main.js" type="text/javascript"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(ns ^:figwheel-hooks dirac-figmain.core | ||
(:require | ||
[goog.dom :as gdom] | ||
[react :as react] | ||
[react-dom :as react-dom] | ||
[sablono.core :as sab :include-macros true])) | ||
|
||
(println "This text is printed from src/dirac_figmain/core.cljs. Go ahead and edit it and see reloading in action.") | ||
|
||
(defn multiply [a b] (* a b)) | ||
|
||
|
||
;; define your app data so that it doesn't get over-written on reload | ||
(defonce app-state (atom {:text "Hello world!"})) | ||
|
||
(defn get-app-element [] | ||
(gdom/getElement "app")) | ||
(defn hello-world [state] | ||
(sab/html [:div | ||
[:h1 (:text @state)] | ||
[:h3 "Edit this in src/dirac_figmain/core.cljs and watch it change!"]])) | ||
|
||
(defn mount [el] | ||
(js/ReactDOM.render (hello-world app-state) el)) | ||
|
||
(defn mount-app-element [] | ||
(when-let [el (get-app-element)] | ||
(mount el))) | ||
|
||
;; conditionally start your application based on the presence of an "app" element | ||
;; this is particularly helpful for testing this ns without launching the app | ||
(mount-app-element) | ||
|
||
;; specify reload hook with ^;after-load metadata | ||
(defn ^:after-load on-reload [] | ||
(mount-app-element) | ||
;; optionally touch your app-state to force rerendering depending on | ||
;; your application | ||
;; (swap! app-state update-in [:__figwheel_counter] inc) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
^{ | ||
;; use an alternative landing page for the tests so that we don't | ||
;; launch the application | ||
:open-url "http://[[server-hostname]]:[[server-port]]/test.html" | ||
|
||
;; uncomment to launch tests in a headless environment | ||
;; you will have to figure out the path to chrome on your system | ||
;; :launch-js ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "--headless" "--disable-gpu" "--repl" :open-url] | ||
} | ||
{:main dirac-figmain.test-runner} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(ns dirac-figmain.core-test | ||
(:require | ||
[cljs.test :refer-macros [deftest is testing]] | ||
[dirac-figmain.core :refer [multiply]])) | ||
|
||
(deftest multiply-test | ||
(is (= (* 1 2) (multiply 1 2)))) | ||
|
||
(deftest multiply-test-2 | ||
(is (= (* 75 10) (multiply 10 75)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
;; This test runner is intended to be run from the command line | ||
(ns dirac-figmain.test-runner | ||
(:require | ||
;; require all the namespaces that you want to test | ||
[dirac-figmain.core-test] | ||
[figwheel.main.testing :refer [run-tests-async]])) | ||
|
||
(defn -main [& args] | ||
(run-tests-async 5000)) |