This project is a ClojureScript starter project, complete with:
- A bare-bones
index.html
web page which loads a compiled React component (which originated as ClojureScript). - A bare-bones suite of Speclj specs/tests! Once cloned, the repo is ready for you to write the next test.
The Speclj specs/tests are:
- Written in Clojure(Script)
- Compiled (alongside the production code they exercise) to Javascript
- Executed via PhantomJS from the command-line (or the web-browser console).
Much of the value of this repository is in the 'glue' code that stitches all the moving parts and concepts together. There just didn't seem to be any other up-to-date and working example of this combination of utilities, so we built it. You're very welcome.
- Step 1: Fork/clone the repo and run the commands below to make sure everything is working.
- Step 2: Write tests and make changes until your project is complete.
- Step 3: There is no step 3.
(Remember to cd
into the cloned project!)
lein cljs once development
- Runs testslein cljs auto development
- Runs tests continuously on detection of changeslein cljs once production
- Compiles ClojureScript to javascriptlein cljs auto production
- Compiles ClojureScript to javascript continuously on detection of changeslein clean
- Deletes all compiled artifacts.
/README.md
- You're looking at it.
/LICENSE.md
- The open-source license file.
/.gitignore
- Listing of files that git should ignore (like project files and compiled artifacts).
/project.clj
- The project file interpreted by the Leiningen build tool.
- Declares project metadata, dependencies, plugins, and entrypoints.
- The
"cljs"
key within the:aliases
structure is what provides thelein
commands above.
/resources/config/cljs.edn
- configuration profiles for compiling ClojureScript
- The
:development
and:production
keys correspond to thelein
command arguments above.
/resources/public/cljs
- Will be created and populated with compiled artifacts upon running the
lein
commands above.
- Will be created and populated with compiled artifacts upon running the
/resources/public/specs/speclj.js
- This script is what enables the 'auto' test command above. It detects code that has been updated and runs only the associated specs.
/resources/public/specs/specs.html
- references test (development) code compiled to javascript, a page from which to run the tests in the browser's console. Load this file in a web browser after running one of the
development
commands above.
- references test (development) code compiled to javascript, a page from which to run the tests in the browser's console. Load this file in a web browser after running one of the
/resources/public/index.html
- references production code compiled javascript, the page on which the sample-project is hosted. Load this file in a web browser after running one of the
production
commands above.
- references production code compiled javascript, the page on which the sample-project is hosted. Load this file in a web browser after running one of the
/spec/cljs/runner/cljs.clj
- The entry point for all
lein cljs
commands above. - Parses command line flags that come after
lein cljs
. - Reads configuration structure provided by
/resources/config/cljs.edn
. - Invokes the ClojureScript compiler library functions (from
cljs.build.api
namespace).
- The entry point for all
/spec/cljs/sample_project/core_spec.cljs
- Actual test code!
- Notice the use of
:require-macros
within the(ns ...)
form, which is required when using speclj from ClojureScript (.cljs
).
/src/cljs/sample_project/components.cljs
- A sample (and simple) reagent component
/src/cljs/sample_project/core.cljs
- The main entrypoint providing reagent/react components for the rendered web page.
If the plan is to turn it into a Leiningen template, we could probably simplify it a bit more... maybe get rid of the the speclj.html and speclj.js, or at least make it so that you don’t have to edit them, and maybe use c3kit.scafold.cljs instead of the copied cljs.clj...