From 9fc8ed73accc77408702f2a3c58fdc8deeca910c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A2=98=E5=8F=B6?= Date: Sun, 1 May 2022 14:22:11 +0800 Subject: [PATCH] Initialize updates --- .gitattributes | 3 + .github/workflows/tests.yaml | 34 ++++++++ .gitignore | 8 ++ README.md | 36 ++++++++ calcit.cirru | 165 +++++++++++++++++++++++++++++++++++ compact.cirru | 37 ++++++++ main.mjs | 3 + package.json | 8 ++ yarn.lock | 27 ++++++ 9 files changed, 321 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/tests.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 calcit.cirru create mode 100644 compact.cirru create mode 100644 main.mjs create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f865be5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ + +calcit.cirru -diff linguist-generated +yarn.lock -diff linguist-generated diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..eba25c9 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: {} + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: ACTIONS_ALLOW_UNSECURE_COMMANDS + id: ACTIONS_ALLOW_UNSECURE_COMMANDS + run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV + + - name: add cr + run: | + mkdir -p $GITHUB_WORKSPACE/bin + wget -O $GITHUB_WORKSPACE/bin/cr http://repo.calcit-lang.org/binaries/linux/cr + chmod +x $GITHUB_WORKSPACE/bin/cr + echo "::add-path::$GITHUB_WORKSPACE/bin" + + - name: "prepare modules" + run: > + mkdir -p ~/.config/calcit/modules/ && cd ~/.config/calcit/modules/ + && git clone https://github.com/calcit-lang/calcit-test.git + + - name: "test" + run: cr -1 --entry test + + - run: cr --emit-js -1 --entry test && yarn && node ./main.mjs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ce1b95 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ + +.compact-inc.cirru +.calcit-error.cirru + +js-out/ +node_modules + +example/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc2d305 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ + +Calcit Workflow +---- + +> running in both Calcit and Calcit-js, with hot code reload. + +### Usages + +Install [Calcit](https://github.com/calcit-lang/calcit) to run demo: + +```bash +cr -1 # run once + +cr # run and watch +``` + +run tests: + +```bash +cr -1 --entry test +``` + +run test in JavaScript: + +```bash +cr --emit-js -1 --entry test # emit-js once +node main.mjs # run code +``` + +### Workflow + +https://github.com/calcit-lang/calcit-workflow + +### License + +MIT diff --git a/calcit.cirru b/calcit.cirru new file mode 100644 index 0000000..86a7842 --- /dev/null +++ b/calcit.cirru @@ -0,0 +1,165 @@ + +{} + :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 $ {} + :configs $ {} (:extension nil) + :defs $ {} + |calling-func $ {} (:at 1635438145038) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1635438146706) (:by |u0) (:text |defn) (:type :leaf) + |j $ {} (:at 1635438145038) (:by |u0) (:text |calling-func) (:type :leaf) + |r $ {} (:at 1635438145038) (:by |u0) (:type :expr) + :data $ {} + |v $ {} (:at 1635438147671) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1635440602999) (:by |u0) (:text |println) (:type :leaf) + |j $ {} (:at 1635438316806) (:by |u0) (:text "|\"todo bcc") (:type :leaf) + |main! $ {} (:at 1606310749711) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1606310749711) (:by |u0) (:text |defn) (:type :leaf) + |j $ {} (:at 1606310749711) (:by |u0) (:text |main!) (:type :leaf) + |r $ {} (:at 1606310749711) (:by |u0) (:type :expr) + :data $ {} + |t $ {} (:at 1625340406714) (:by |u0) (:type :expr) + :data $ {} + |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 $ {} + |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) + |on-error $ {} (:at 1606310757107) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1606310757107) (:by |u0) (:text |defn) (:type :leaf) + |j $ {} (:at 1606310757107) (:by |u0) (:text |on-error) (:type :leaf) + |r $ {} (:at 1606310757107) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1606310780908) (:by |u0) (:text |message) (:type :leaf) + |v $ {} (:at 1606311673317) (:by |u0) (:type :expr) + :data $ {} + |D $ {} (:at 1606370713438) (:by |u0) (:text |;) (:type :leaf) + |T $ {} (:at 1606311684125) (:by |u0) (:text |draw-error-message) (:type :leaf) + |j $ {} (:at 1606311685136) (:by |u0) (:text |message) (:type :leaf) + |reload! $ {} (:at 1606310753106) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1606310753106) (:by |u0) (:text |defn) (:type :leaf) + |j $ {} (:at 1606310753106) (:by |u0) (:text |reload!) (:type :leaf) + |r $ {} (:at 1606310753106) (:by |u0) (:type :expr) + :data $ {} + |v $ {} (:at 1606310801441) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1606310803027) (:by |u0) (:text |echo) (:type :leaf) + |j $ {} (:at 1625293407488) (:by |u0) (:text "|\"Reloaded.") (:type :leaf) + :ns $ {} (:at 1606310745262) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1606310745262) (:by |u0) (:text |ns) (:type :leaf) + |j $ {} (:at 1606310745262) (:by |u0) (:text |app.main) (:type :leaf) + |r $ {} (:at 1625340359278) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340360591) (:by |u0) (:text |:require) (:type :leaf) + |j $ {} (:at 1625340360867) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340363084) (:by |u0) (:text |app.test) (:type :leaf) + |j $ {} (:at 1625340363810) (:by |u0) (:text |:refer) (:type :leaf) + |r $ {} (:at 1625340366421) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340368206) (:by |u0) (:text |run-tests) (:type :leaf) + |r $ {} (:at 1635438174394) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1635438179295) (:by |u0) (:text |calcit.std.time) (:type :leaf) + |j $ {} (:at 1635438177953) (:by |u0) (:text |:refer) (:type :leaf) + |r $ {} (:at 1635438180356) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1635438182183) (:by |u0) (:text |set-interval) (:type :leaf) + :proc $ {} (:at 1606310745262) (:by |u0) (:type :expr) + :data $ {} + |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) + |j $ {} (:at 1625339970921) (:by |u0) (:text |run-tests) (:type :leaf) + |r $ {} (:at 1625339970921) (:by |u0) (:type :expr) + :data $ {} + |t $ {} (:at 1625340033281) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340034982) (:by |u0) (:text |reset!) (:type :leaf) + |j $ {} (:at 1625340036265) (:by |u0) (:text |*quit-on-failure?) (:type :leaf) + |r $ {} (:at 1625340037959) (:by |u0) (:text |true) (:type :leaf) + |v $ {} (:at 1625339973401) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625339982550) (:by |u0) (:text |test-add) (:type :leaf) + |test-add $ {} (:at 1625339983101) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625339986557) (:by |u0) (:text |deftest) (:type :leaf) + |j $ {} (:at 1625339983101) (:by |u0) (:text |test-add) (:type :leaf) + |r $ {} (:at 1625340048519) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340049484) (:by |u0) (:text |testing) (:type :leaf) + |j $ {} (:at 1625340052314) (:by |u0) (:text ||add) (:type :leaf) + |r $ {} (:at 1625340054484) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340055860) (:by |u0) (:text |is) (:type :leaf) + |j $ {} (:at 1625340056137) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340056311) (:by |u0) (:text |=) (:type :leaf) + |j $ {} (:at 1625340057399) (:by |u0) (:text |2) (:type :leaf) + |r $ {} (:at 1625340057796) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340058161) (:by |u0) (:text |+) (:type :leaf) + |j $ {} (:at 1625340058562) (:by |u0) (:text |1) (:type :leaf) + |r $ {} (:at 1625340138662) (:by |u0) (:text |1) (:type :leaf) + :ns $ {} (:at 1625339956346) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625339956346) (:by |u0) (:text |ns) (:type :leaf) + |j $ {} (:at 1625339956346) (:by |u0) (:text |app.test) (:type :leaf) + |r $ {} (:at 1625340009385) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340010270) (:by |u0) (:text |:require) (:type :leaf) + |j $ {} (:at 1625340010573) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340015655) (:by |u0) (:text |calcit-test.core) (:type :leaf) + |j $ {} (:at 1625340016422) (:by |u0) (:text |:refer) (:type :leaf) + |r $ {} (:at 1625340016945) (:by |u0) (:type :expr) + :data $ {} + |T $ {} (:at 1625340018567) (:by |u0) (:text |deftest) (:type :leaf) + |j $ {} (:at 1625340020648) (:by |u0) (:text |testing) (:type :leaf) + |r $ {} (:at 1625340021012) (:by |u0) (:text |is) (:type :leaf) + |v $ {} (:at 1625340040078) (:by |u0) (:text |*quit-on-failure?) (:type :leaf) + :proc $ {} (:at 1625339956346) (:by |u0) (:type :expr) + :data $ {} + :users $ {} + |u0 $ {} (:avatar nil) (:id |u0) (:name |chen) (:nickname |chen) (:password |d41d8cd98f00b204e9800998ecf8427e) (:theme :star-trail) diff --git a/compact.cirru b/compact.cirru new file mode 100644 index 0000000..f47f885 --- /dev/null +++ b/compact.cirru @@ -0,0 +1,37 @@ + +{} (:package |app) + :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! () (run-tests) + set-interval 2000 $ fn () (calling-func) + |on-error $ quote + defn on-error (message) (; draw-error-message message) + |reload! $ quote + defn reload! () $ echo "\"Reloaded." + :ns $ quote + ns app.main $ :require + app.test :refer $ run-tests + 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 + deftest test-add $ testing |add + is $ = 2 (+ 1 1) + :ns $ quote + ns app.test $ :require + calcit-test.core :refer $ deftest testing is *quit-on-failure? diff --git a/main.mjs b/main.mjs new file mode 100644 index 0000000..3049a77 --- /dev/null +++ b/main.mjs @@ -0,0 +1,3 @@ +import { main_$x_, reload_$x_ } from "./js-out/app.test.mjs" + +main_$x_() diff --git a/package.json b/package.json new file mode 100644 index 0000000..afcdca0 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "version": "0.0.7", + "dependencies": { + "@calcit/procs": "^0.5.41" + }, + "scripts": {}, + "devDependencies": {} +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..42ff035 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,27 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@calcit/procs@^0.5.41": + version "0.5.41" + resolved "https://registry.yarnpkg.com/@calcit/procs/-/procs-0.5.41.tgz#2d31d8912e4049050faf4b0ab357cd0afeac4e50" + integrity sha512-xhzLUzQvU+lMzcfARUYiQv0xjkliOng1PJtGV5eXpofj/aKI+KndUYdfdc18vpCogBaZwaL02fGAHsJ77qBH1w== + dependencies: + "@calcit/ternary-tree" "0.0.19" + "@cirru/parser.ts" "^0.0.5" + "@cirru/writer.ts" "^0.1.3" + +"@calcit/ternary-tree@0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@calcit/ternary-tree/-/ternary-tree-0.0.19.tgz#b5b33a3d07a9e603feeef7cd642958c83628122f" + integrity sha512-dn2kNlcOQOPtCAeE68MHcRgrZzRP+jNKBmDW2wO0S8HTUA2SeAbpzZoK0HfcTHFmlGl6yKpjZ95rICQ319AjcA== + +"@cirru/parser.ts@^0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@cirru/parser.ts/-/parser.ts-0.0.5.tgz#12325a69561b95e219e049790c53d5479dc2c1e5" + integrity sha512-jmucRW6fQX+HhFZKeN37TDO8ejBxgxLDX9RvU7WKSDM/7peGtfyu9+b6G8NMi4a8wqpDACTvnzbgZId7Xi5bHw== + +"@cirru/writer.ts@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@cirru/writer.ts/-/writer.ts-0.1.3.tgz#5f54bdecaa20ba3dab16cbe6da711854138a9c0a" + integrity sha512-vJnhmhm7we5UfQIwmZfQpF3bAFbVybzT6LbmkbQHxgijaQg3gPfNVsnSIa3g3KpmWVtvkzEx+nUy5aMwsJiV1A==