Skip to content

Commit

Permalink
empty project change to calcit-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Nov 15, 2021
1 parent 65926a2 commit 0f44984
Show file tree
Hide file tree
Showing 11 changed files with 775 additions and 1,869 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Try to upload
on:
push:
branches:
- master
- main
pull_request: {}

jobs:
Expand All @@ -12,6 +12,18 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
name: Cache node modules of yarn
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
id: ACTIONS_ALLOW_UNSECURE_COMMANDS
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
Expand All @@ -37,10 +49,14 @@ jobs:
&& git clone https://github.com/mvc-works/ws-edn.calcit.git
&& git clone https://github.com/Respo/respo-feather.calcit.git
&& git clone https://github.com/Respo/alerts.calcit.git
&& git clone https://github.com/calcit-lang/calcit-wss.git
&& git clone https://github.com/calcit-lang/calcit.std.git --branch 0.0.14
- run: cr --entry server --emit-ir -1

- run: yarn && yarn compile-server && yarn compile-page && yarn release-page && yarn release-server
- run: yarn && yarn compile-page && yarn release-page

- run: mkdir -p dist-server && mv js-out/bundle.js dist-server && cp package.json dist-server/
- run: mkdir -p dist-server && cp compact.cirru dist-server && cp package.json dist-server/
name: Copy server scripts

- name: Upload web assets
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ dist/
out-page/

yarn-error.log

storage.cirru
backups/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TODO

### Workflow

https://github.com/Cumulo/cumulo-workflow.calcit
https://github.com/Cumulo/calcium-workflow

### License

Expand Down
1,368 changes: 500 additions & 868 deletions calcit.cirru

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import { main_$x_ } from "./out-page/app.client.js"
import { main_$x_ } from "./js-out/app.client.js"

main_$x_()

if (import.meta.hot) {
import.meta.hot.accept('./out-page/app.client.js', (main) => {
import.meta.hot.accept('./js-out/app.client.js', (main) => {
main.reload_$x_()
})
}
114 changes: 65 additions & 49 deletions compact.cirru
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

{} (:package |app)
:configs $ {} (:init-fn |app.server/main!) (:reload-fn |app.server/reload!)
:configs $ {} (:init-fn |app.client/main!) (:reload-fn |app.client/reload!)
:modules $ [] |respo.calcit/ |lilac/ |recollect/ |memof/ |respo-ui.calcit/ |ws-edn.calcit/ |cumulo-util.calcit/ |respo-message.calcit/ |cumulo-reel.calcit/
:version nil
:entries $ {}
:server $ {} (:reload-fn |app.server/reload!) (:port 6001) (:storage-key |calcit.cirru)
:modules $ [] |lilac/ |recollect/ |memof/ |cumulo-util.calcit/ |cumulo-reel.calcit/ |calcit.std/ |calcit-wss/
:init-fn |app.server/main!
:files $ {}
|app.comp.container $ {}
:ns $ quote
Expand Down Expand Up @@ -103,33 +107,35 @@
:ns $ quote
ns app.server $ :require (app.schema :as schema)
app.updater :refer $ updater
cljs.reader :refer $ read-string
cumulo-reel.core :refer $ reel-reducer refresh-reel reel-schema
"\"fs" :as fs
"\"path" :as path
app.config :as config
cumulo-util.file :refer $ write-mildly! get-backup-path! merge-local-edn!
cumulo-util.core :refer $ id! repeat! unix-time! delay!
app.twig.container :refer $ twig-container
recollect.diff :refer $ diff-twig
ws-edn.server :refer $ wss-serve! wss-send! wss-each!
wss.core :refer $ wss-serve! wss-send! wss-each!
recollect.twig :refer $ new-twig-loop! clear-twig-caches!
app.$meta :refer $ calcit-dirname
calcit.std.fs :refer $ path-exists? check-write-file!
calcit.std.time :refer $ set-interval
calcit.std.date :refer $ Date get-time!
calcit.std.path :refer $ join-path
:defs $ {}
|*initial-db $ quote
defatom *initial-db $ merge-local-edn! schema/database storage-file
fn (found?)
if found? (println "\"Found local EDN data") (println "\"Found no data")
defatom *initial-db $ if
path-exists? $ w-log storage-file
do (println "\"Found local EDN data")
merge schema/database $ parse-cirru-edn (read-file storage-file)
do (println "\"Found no data") schema/database
|persist-db! $ quote
defn persist-db! () $ let
file-content $ format-cirru-edn
assoc (:db @*reel) :sessions $ {}
storage-path storage-file
backup-path $ get-backup-path!
write-mildly! storage-path file-content
write-mildly! backup-path file-content
check-write-file! storage-path file-content
check-write-file! backup-path file-content
|sync-clients! $ quote
defn sync-clients! (reel)
wss-each! $ fn (sid socket)
wss-each! $ fn (sid)
let
db $ :db reel
records $ :records reel
Expand All @@ -138,73 +144,83 @@
new-store $ twig-container db session records
changes $ diff-twig old-store new-store
{} $ :key :id
when config/dev? $ println "\"Changes for" sid "\":" changes (count records)
; when config/dev? $ println "\"Changes for" sid "\":" changes (count records)
if
not= changes $ []
do
wss-send! sid $ {} (:kind :patch) (:data changes)
wss-send! sid $ format-cirru-edn
{} (:kind :patch) (:data changes)
swap! *client-caches assoc sid new-store
new-twig-loop!
|storage-file $ quote
def storage-file $ path/join js/__dirname (:storage-file config/site)
def storage-file $ if (empty? calcit-dirname)
str calcit-dirname $ :storage-file config/site
str calcit-dirname "\"/" $ :storage-file config/site
|*reader-reel $ quote (defatom *reader-reel @*reel)
|*reel $ quote
defatom *reel $ merge reel-schema
{} (:base @*initial-db) (:db @*initial-db)
|*proxied-dispatch! $ quote (defatom *proxied-dispatch! dispatch!)
|main! $ quote
defn main! ()
println "\"Running mode:" $ if config/dev? "\"dev" "\"release"
let
port $ if (some? js/process.env.port) (js/parseInt js/process.env.port) (:port config/site)
p? $ get-env "\"port"
port $ if (some? p?) (parse-float p?) (:port config/site)
run-server! port
println $ str "\"Server started on port:" port
render-loop! *loop-trigger
js/process.on "\"SIGINT" on-exit!
repeat! 600 $ fn () (persist-db!)
|*loop-trigger $ quote (defatom *loop-trigger 0)
do (; "\"init it before doing multi-threading") (identity @*reader-reel)
set-interval 200 $ fn () (render-loop!)
set-interval 600000 $ fn () (persist-db!)
on-control-c on-exit!
|get-backup-path! $ quote
defn get-backup-path! () $ let
now $ .extract (get-time!)
join-path calcit-dirname "\"backups"
str $ :month now
str (:day now) "\"-snapshot.cirru"
|on-exit! $ quote
defn on-exit! (code _) (persist-db!)
; println "\"exit code is:" $ pr-str code
js/process.exit
defn on-exit! () (persist-db!) (; println "\"exit code is...") (quit! 0)
|dispatch! $ quote
defn dispatch! (op op-data sid)
let
op-id $ id!
op-time $ unix-time!
op-id $ generate-id!
op-time $ -> (get-time!) (.timestamp)
if config/dev? $ println "\"Dispatch!" (str op) op-data sid
if (= op :effect/persist) (persist-db!)
reset! *reel $ reel-reducer @*reel updater op op-data sid op-id op-time config/dev?
|run-server! $ quote
defn run-server! (port)
wss-serve! port $ {}
:on-open $ fn (sid socket) (@*proxied-dispatch! :session/connect nil sid) (println "\"New client.")
:on-data $ fn (sid action)
case-default (:kind action) (println "\"unknown action:" action)
:op $ @*proxied-dispatch! (:op action) (:data action) sid
:on-close $ fn (sid event) (println "\"Client closed!") (@*proxied-dispatch! :session/disconnect nil sid)
:on-error $ fn (error) (js/console.error error)
wss-serve! (&{} :port port)
fn (data)
key-match data
:connect sid
do (dispatch! :session/connect nil sid) (println "\"New client.")
(:message sid msg)
let
action $ parse-cirru-edn msg
case-default (:kind action) (println "\"unknown action:" action)
:op $ dispatch! (:op action) (:data action) sid
(:disconnect sid)
do (println "\"Client closed!") (dispatch! :session/disconnect nil sid)
_ $ println "\"unknown data:" data
|render-loop! $ quote
defn render-loop! (*loop)
when
not $ identical? @*reader-reel @*reel
reset! *reader-reel @*reel
sync-clients! @*reader-reel
reset! *loop $ delay! 0.2
fn () $ render-loop! *loop
defn render-loop! () $ when
not $ identical? @*reader-reel @*reel
reset! *reader-reel @*reel
sync-clients! @*reader-reel
|*client-caches $ quote
defatom *client-caches $ {}
|reload! $ quote
defn reload! () (println "\"Code updated.") (clear-twig-caches!) (reset! *proxied-dispatch! dispatch!)
defn reload! () (println "\"Code updated..")
if (not config/dev?) (raise "\"reloading only happens in dev mode")
clear-twig-caches!
reset! *reel $ refresh-reel @*reel @*initial-db updater
js/clearTimeout @*loop-trigger
render-loop! *loop-trigger
sync-clients! @*reader-reel
|app.twig.container $ {}
:ns $ quote
ns app.twig.container $ :require
app.twig.user :refer $ twig-user
"\"randomcolor" :as color
calcit.std.rand :refer $ rand-hex-color!
memof.alias :refer $ memof-call
:defs $ {}
|twig-container $ quote
Expand All @@ -224,8 +240,8 @@
:profile $ memof-call twig-members (:sessions db) (:users db)
(:name router) ({})
:count $ count (:sessions db)
:color $ color/randomColor
, nil
:color $ rand-hex-color!
{}
|twig-members $ quote
defn twig-members (sessions users)
-> sessions (.to-list)
Expand Down Expand Up @@ -264,7 +280,7 @@
:ns $ quote
ns app.updater.user $ :require
cumulo-util.core :refer $ find-first
"\"md5" :default md5
calcit.std.hash :refer $ md5
:defs $ {}
|sign-up $ quote
defn sign-up (db op-data sid op-id op-time)
Expand Down Expand Up @@ -549,4 +565,4 @@
|dev? $ quote
def dev? $ = "\"dev" (get-env "\"mode")
|site $ quote
def site $ {} (:port 5021) (:title "\"Cumulo") (:icon "\"http://cdn.tiye.me/logo/cumulo.png") (:theme "\"#eeeeff") (:storage-key "\"workflow-storage-calcit") (:storage-file "\"storage.edn")
def site $ {} (:port 5021) (:title "\"Cumulo") (:icon "\"http://cdn.tiye.me/logo/cumulo.png") (:theme "\"#eeeeff") (:storage-key "\"workflow-storage-calcit") (:storage-file "\"storage.cirru")
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<title>Workflow</title>
<title>Doctalk</title>
<link href="https://cdn.tiye.me/logo/cumulo.png" rel="icon" type="image/png" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
Expand Down
20 changes: 5 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
{
"dependencies": {
"@calcit/procs": "^0.4.32",
"md5": "^2.3.0",
"randomcolor": "^0.6.2",
"shortid": "^2.2.16",
"ws": "^8.2.2"
"@calcit/procs": "^0.5.7",
"shortid": "^2.2.16"
},
"scripts": {
"watch-server": "cr --emit-js",
"build-server": "yarn webpack && node js-out/bundle.js",
"dev-server": "hot=true webpack --watch",
"compile-server": "cr --emit-js --once",
"compile-page": "cr --emit-js --once --init-fn app.client/main! --reload-fn app.client/reload! --emit-path out-page",
"compile-page": "cr --emit-js --once",
"release-page": "vite build --base=./",
"release-server": "webpack",
"watch-page": "cr --emit-js --emit-path out-page/ --init-fn app.client/main! --reload-fn app.client/reload!"
"watch-page": "cr --emit-js/"
},
"devDependencies": {
"bottom-tip": "^0.1.2",
"url-parse": "^1.5.3",
"vite": "^2.5.8",
"webpack": "^5.53.0",
"webpack-cli": "^4.8.0"
"vite": "^2.6.14"
},
"version": "0.0.1"
}
11 changes: 0 additions & 11 deletions server.js

This file was deleted.

34 changes: 0 additions & 34 deletions webpack.config.js

This file was deleted.

Loading

0 comments on commit 0f44984

Please sign in to comment.