diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 21f4906..44ef2e6 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -11,16 +11,19 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - - uses: calcit-lang/setup-cr@0.0.8 + - uses: calcit-lang/setup-cr@0.0.9 - - name: "prepare modules" - run: > - mkdir -p ~/.config/calcit/modules/ && cd ~/.config/calcit/modules/ - && git clone https://github.com/calcit-lang/calcit-http.git - && git clone https://github.com/calcit-lang/calcit-json.git - && git clone https://github.com/calcit-lang/lilac.git - && git clone https://github.com/calcit-lang/stir-template.git --branch 0.0.8 + - name: "install modules" + run: caps --ci - - run: cr compact.cirru ir + - name: "validate snapshot and entries" + run: | + cr calcit.cirru edit format + git diff --exit-code -- calcit.cirru + cr calcit.cirru --check-only + cr calcit.cirru --entry server --check-only + cr calcit.cirru analyze check-types --summary-only --format json + cr calcit.cirru analyze weak-types --only schema-dynamic,code-dynamic --intent unresolved --summary-only --format json + cr calcit.cirru analyze deprecated --summary-only --format json diff --git a/README.md b/README.md index 7b49909..c5d6ec5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ based on [calcit-http](https://github.com/calcit-lang/calcit-http). ### Usages ```bash -cr compact.cirru ir +cr calcit.cirru ir ``` ### Workflow diff --git a/calcit.cirru b/calcit.cirru new file mode 100644 index 0000000..a82a3c3 --- /dev/null +++ b/calcit.cirru @@ -0,0 +1,85 @@ + +{} (:about "|Machine-generated snapshot. Do not edit directly — changes will be overwritten. Use `cr query` to inspect and `cr edit`/`cr tree` to modify. Run `cr docs agents --full` first. Manual edits must follow format and schema conventions, then run `cr edit format`.") (:package |app) + :entries $ {} + :default $ {} (:description |) (:init-fn 'app.main/main!) (:mode :native) (:reload-fn 'app.main/reload!) + :feature-policy $ {} + :modules $ [] |calcit-http/ |calcit-json/ |stir-template/ |lilac/ + :type-slots $ {} + :server $ {} (:description |) (:init-fn 'http.test/demo-server!) (:mode :native) (:reload-fn 'http.test/reload!) + :feature-policy $ {} + :modules $ [] |calcit-http/ |calcit-json/ |stir-template/ |lilac/ + :type-slots $ {} + :files $ {} + |app.main $ %{} 'FileEntry + :defs $ {} + |demo-server! $ %{} 'CodeEntry (:doc |) + :code $ quote + defn demo-server! () $ serve-http! + {} $ :port 4000 + fn (req) (on-request req) + :examples $ [] + :schema $ :: 'Dynamic + |main! $ %{} 'CodeEntry (:doc |) + :code $ quote + defn main! () $ demo-server! + :examples $ [] + :schema $ :: 'Dynamic + |mid-call $ %{} 'CodeEntry (:doc |) + :code $ quote + defn mid-call () $ println "|Calling internal function" + :examples $ [] + :schema $ :: 'Dynamic + |on-request $ %{} 'CodeEntry (:doc |) + :code $ quote + defn on-request (req) + println "|Handling request:" $ get req :body + println $ get req :url + ; mid-call + case-default + option:unwrap-or (get req :path) | + {} (:status :ok) (:code 200) + :headers $ {} (:content-type |text/json) + :body $ format-cirru-edn req + |/html $ {} (:status :ok) (:code 200) + :headers $ {} (:content-type |text/html) + :body $ make-page + {} + :title $ {} (:innerHTML "|Calcit HTTP Demo") + :styles $ [] |https://cdn.tiye.me/favored-fonts/main-fonts.css + :content $ div + {} $ :style + {} $ :font-family ui/font-normal + h1 + {} $ :style + {} $ :color :red + , "|A demo page" + |/json $ {} (:status :ok) (:code 200) + :headers $ {} (:content-type |application/json) + :body $ json/stringify + {} (:message "|a piece of json") (:status false) + %some true + |/post-json $ let + body $ get req :body + data $ if (option:some? body) + json/parse $ option:unwrap body + , nil + println "|POST data:" data + {} (:status :ok) (:code 200) + :headers $ {} (:content-type |application/json) + :body $ json/stringify + {} (:message "|another piece of json") (:status false) (:sent-data data) + %some true + :examples $ [] + :schema $ :: 'Dynamic + |reload! $ %{} 'CodeEntry (:doc |) + :code $ quote + defn reload! () $ println |Reload + :examples $ [] + :schema $ :: 'Dynamic + :ns $ %{} 'NsEntry (:doc |) + :code $ quote + ns app.main $ :require + http.core :refer $ serve-http! + stir-template.alias :refer $ make-page div h1 + stir-template.ui :as ui + json.core :as json diff --git a/compact.cirru b/compact.cirru deleted file mode 100644 index dfd390d..0000000 --- a/compact.cirru +++ /dev/null @@ -1,70 +0,0 @@ - -{} (:package |app) - :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version |0.0.6) - :modules $ [] |calcit-http/ |calcit-json/ |stir-template/ |lilac/ - :entries $ {} - :server $ {} (:init-fn |http.test/demo-server!) (:reload-fn |http.test/reload!) - :modules $ [] - :files $ {} - |app.main $ %{} :FileEntry - :defs $ {} - |demo-server! $ %{} :CodeEntry (:doc |) - :code $ quote - defn demo-server! () $ serve-http! - {} $ :port 4000 - fn (req) (on-request req) - |main! $ %{} :CodeEntry (:doc |) - :code $ quote - defn main! () $ demo-server! - |mid-call $ %{} :CodeEntry (:doc |) - :code $ quote - defn mid-call () $ println "\"Calling internal function" - |on-request $ %{} :CodeEntry (:doc |) - :code $ quote - defn on-request (req) - println "\"Handling request:" $ :body req - println $ :url req - ; mid-call - case-default (:path req) - {} (:status :ok) (:code 200) - :headers $ {} (:content-type "\"text/json") - :body $ format-cirru-edn req - "\"/html" $ {} (:status :ok) (:code 200) - :headers $ {} (:content-type "\"text/html") - :body $ make-page - {} - :title $ {} (:innerHTML "\"Calcit HTTP Demo") - :styles $ [] "\"https://cdn.tiye.me/favored-fonts/main-fonts.css" - :content $ div - {} $ :style - {} $ :font-family ui/font-normal - h1 - {} $ :style - {} $ :color :red - , "\"A demo page" - "\"/json" $ {} (:status :ok) (:code 200) - :headers $ {} (:content-type "\"application/json") - :body $ json/stringify - {} (:message "\"a piece of json") (:status false) - , true - "\"/post-json" $ let - data $ if - some? $ :body req - json/parse $ :body req - , nil - println "\"POST data:" data - {} (:status :ok) (:code 200) - :headers $ {} (:content-type "\"application/json") - :body $ json/stringify - {} (:message "\"another piece of json") (:status false) (:sent-data data) - , true - |reload! $ %{} :CodeEntry (:doc |) - :code $ quote - defn reload! () $ println "\"Reload" - :ns $ %{} :CodeEntry (:doc |) - :code $ quote - ns app.main $ :require - http.core :refer $ serve-http! - stir-template.alias :refer $ make-page div h1 - stir-template.ui :as ui - json.core :as json diff --git a/deps.cirru b/deps.cirru index 17ee865..0715f65 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,2 +1,7 @@ -{} (:calcit-version |0.12.14) +{} (:calcit-version |0.13.27) + :version |0.0.6 + :dependencies $ {} (|calcit-lang/calcit-http |main) + |calcit-lang/calcit-json |main + |calcit-lang/lilac |0.5.2 + |calcit-lang/stir-template |main diff --git a/package.cirru b/package.cirru deleted file mode 100644 index f76a148..0000000 --- a/package.cirru +++ /dev/null @@ -1,6 +0,0 @@ -{} - :dependencies $ {} - |calcit-lang/calcit-http |main - |calcit-lang/calcit-json |main - |calcit-lang/lilac |main - |calcit-lang/stir-template |0.0.8