diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 169ae47..1601674 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -29,6 +29,6 @@ jobs: && git clone https://github.com/calcit-lang/calcit-test.git - name: "test" - run: mode=ci cr -1 + run: cr -1 --entry test - - run: mode=ci cr --emit-js -1 && yarn && yarn webpack && mode=ci node ./js-out/bundle.js + - run: cr --emit-js -1 --entry test && node ./main.mjs diff --git a/README.md b/README.md index 9076150..cc2d305 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Calcit Workflow ### Usages -Install [calcit-runner](https://github.com/calcit-lang/calcit_runner.rs) to run demo: +Install [Calcit](https://github.com/calcit-lang/calcit) to run demo: ```bash cr -1 # run once @@ -14,40 +14,17 @@ cr -1 # run once cr # run and watch ``` -run in JavaScript: - -```bash -cr --emit-js -1 # emit-js once -yarn webpack -node js-out/bundle.js # run code -``` - -watch reload js program: - -```bash -cr --emit-js - -# and watch and build with Webpack -hot=true webpack --watch - -# run with hot reload -node js-out/bundle.js -``` - run tests: ```bash -mode=ci cr -1 - -mode=ci node js-out/bundle.js +cr -1 --entry test ``` -### esbuild - -This demo provided Webpack for hot code replacement. To build, esbuild is a simpler tool: +run test in JavaScript: ```bash -esbuild main.js --bundle --outfile=js-out/bundle.js --platform=node +cr --emit-js -1 --entry test # emit-js once +node main.mjs # run code ``` ### Workflow diff --git a/calcit.cirru b/calcit.cirru index cf00fd5..86a7842 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -1,8 +1,10 @@ {} - :configs $ {} (:compact-output? true) (:extension |.cljs) (:init-fn |app.main/main!) (:local-ui? false) (:output |src) (:port 6001) (:reload-fn |app.main/reload!) + :configs $ {} (:init-fn |app.main/main!) (:port 6001) (:reload-fn |app.main/reload!) (:version |0.0.1) :modules $ [] |calcit-test/ |calcit.std/ :entries $ {} + :test $ {} (:init-fn |app.test/main!) (:reload-fn |app.test/reload!) + :modules $ [] |calcit-test/ :ir $ {} (:package |app) :files $ {} |app.main $ {} @@ -24,39 +26,21 @@ |j $ {} (:at 1606310749711) (:by |u0) (:text |main!) (:type :leaf) |r $ {} (:at 1606310749711) (:by |u0) (:type :expr) :data $ {} - |t $ {} (:at 1625340391049) (:by |u0) (:type :expr) + |t $ {} (:at 1625340406714) (:by |u0) (:type :expr) :data $ {} - |T $ {} (:at 1625340394073) (:by |u0) (:text |if) (:type :leaf) - |j $ {} (:at 1625340394798) (:by |u0) (:type :expr) - :data $ {} - |T $ {} (:at 1625340394997) (:by |u0) (:text |=) (:type :leaf) - |j $ {} (:at 1625340399668) (:by |u0) (:text "|\"ci") (:type :leaf) - |r $ {} (:at 1625340400294) (:by |u0) (:type :expr) - :data $ {} - |T $ {} (:at 1625340402301) (:by |u0) (:text |get-env) (:type :leaf) - |j $ {} (:at 1625340404943) (:by |u0) (:text "|\"mode") (:type :leaf) - |r $ {} (:at 1625340406714) (:by |u0) (:type :expr) - :data $ {} - |T $ {} (:at 1625340407993) (:by |u0) (:text |run-tests) (:type :leaf) - |v $ {} (:at 1651385433094) (:by |u0) (:type :expr) + |T $ {} (:at 1625340407993) (:by |u0) (:text |run-tests) (:type :leaf) + |u $ {} (:at 1651385435232) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1651385435232) (:by |u0) (:text |set-interval) (:type :leaf) + |b $ {} (:at 1651385435232) (:by |u0) (:text |2000) (:type :leaf) + |h $ {} (:at 1651385435232) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1651385433629) (:by |u0) (:text |do) (:type :leaf) - |T $ {} (:at 1625340412805) (:by |u0) (:type :expr) - :data $ {} - |T $ {} (:at 1625340412805) (:by |u0) (:text |echo) (:type :leaf) - |j $ {} (:at 1625340416431) (:by |u0) (:text "||Run app") (:type :leaf) + |T $ {} (:at 1651385435232) (:by |u0) (:text |fn) (:type :leaf) |b $ {} (:at 1651385435232) (:by |u0) (:type :expr) :data $ {} - |T $ {} (:at 1651385435232) (:by |u0) (:text |set-interval) (:type :leaf) - |b $ {} (:at 1651385435232) (:by |u0) (:text |2000) (:type :leaf) - |h $ {} (:at 1651385435232) (:by |u0) (:type :expr) - :data $ {} - |T $ {} (:at 1651385435232) (:by |u0) (:text |fn) (:type :leaf) - |b $ {} (:at 1651385435232) (:by |u0) (:type :expr) - :data $ {} - |h $ {} (:at 1651385435232) (:by |u0) (:type :expr) - :data $ {} - |T $ {} (:at 1651385435232) (:by |u0) (:text |calling-func) (:type :leaf) + |h $ {} (:at 1651385435232) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1651385435232) (:by |u0) (:text |calling-func) (:type :leaf) |on-error $ {} (:at 1606310757107) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1606310757107) (:by |u0) (:text |defn) (:type :leaf) @@ -105,6 +89,25 @@ |app.test $ {} :configs $ {} :defs $ {} + |main! $ {} (:at 1651385630841) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1651385630841) (:by |u0) (:text |defn) (:type :leaf) + |b $ {} (:at 1651385630841) (:by |u0) (:text |main!) (:type :leaf) + |h $ {} (:at 1651385630841) (:by |u0) (:type :expr) + :data $ {} + |l $ {} (:at 1651385633767) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1651385635804) (:by |u0) (:text |run-tests) (:type :leaf) + |reload! $ {} (:at 1651385641606) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1651385641606) (:by |u0) (:text |defn) (:type :leaf) + |b $ {} (:at 1651385641606) (:by |u0) (:text |reload!) (:type :leaf) + |h $ {} (:at 1651385641606) (:by |u0) (:type :expr) + :data $ {} + |l $ {} (:at 1651385642773) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1651385643658) (:by |u0) (:text |println) (:type :leaf) + |b $ {} (:at 1651385646578) (:by |u0) (:text "|\"TODO reload") (:type :leaf) |run-tests $ {} (:at 1625339970921) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1625339972421) (:by |u0) (:text |defn) (:type :leaf) diff --git a/compact.cirru b/compact.cirru index 647ee7d..f47f885 100644 --- a/compact.cirru +++ b/compact.cirru @@ -1,19 +1,18 @@ {} (:package |app) - :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version nil) + :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version |0.0.1) :modules $ [] |calcit-test/ |calcit.std/ :entries $ {} + :test $ {} (:init-fn |app.test/main!) (:reload-fn |app.test/reload!) + :modules $ [] |calcit-test/ :files $ {} |app.main $ {} :defs $ {} |calling-func $ quote defn calling-func () $ println "\"todo bcc" |main! $ quote - defn main! () $ if - = "\"ci" $ get-env "\"mode" - run-tests - do (echo "|Run app") - set-interval 2000 $ fn () (calling-func) + defn main! () (run-tests) + set-interval 2000 $ fn () (calling-func) |on-error $ quote defn on-error (message) (; draw-error-message message) |reload! $ quote @@ -24,6 +23,10 @@ calcit.std.time :refer $ set-interval |app.test $ {} :defs $ {} + |main! $ quote + defn main! () $ run-tests + |reload! $ quote + defn reload! () $ println "\"TODO reload" |run-tests $ quote defn run-tests () (reset! *quit-on-failure? true) (test-add) |test-add $ quote diff --git a/main.mjs b/main.mjs index 33b2a3b..3049a77 100644 --- a/main.mjs +++ b/main.mjs @@ -1,3 +1,3 @@ -import { main_$x_, reload_$x_ } from "./js-out/app.main.mjs" +import { main_$x_, reload_$x_ } from "./js-out/app.test.mjs" main_$x_()