Skip to content

Commit

Permalink
Merge pull request #3 from mvc-works/updates
Browse files Browse the repository at this point in the history
upgrade deps and scripts
  • Loading branch information
soyaine authored Aug 18, 2020
2 parents 9eb5dfe + cb88f43 commit b5ed106
Show file tree
Hide file tree
Showing 13 changed files with 511 additions and 426 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

name: Deploy package

on:
release:
types: [created]

jobs:
deploy:
name: Deploy

runs-on: ubuntu-latest

steps:
- run: curl -O https://download.clojure.org/install/linux-install-1.10.1.507.sh && chmod +x linux-install-1.10.1.507.sh && sudo ./linux-install-1.10.1.507.sh

- uses: actions/checkout@v2

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

- uses: actions/cache@v1
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: Cache Clojars
uses: actions/cache@v1
env:
cache-name: cache-clojars
with:
path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('shadow-cljs.edn') }}
restore-keys: |
${{ runner.os }}-clojars
- name: run tests
run: 'yarn && yarn shadow-cljs compile client server'

- run: echo Working on ${{ github.ref }}

- name: deploy to clojars
run: env CLOJARS_USERNAME=jiyinyiyong CLOJARS_PASSWORD=${{ secrets.CLOJARS_PASSWORD }} clojure -A:release
40 changes: 40 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

name: Test

on:
pull_request: {}
push:
branches:
- master

jobs:
upload-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker://timbru31/java-node:latest

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

- uses: actions/cache@v1
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: Cache Clojars
uses: actions/cache@v1
env:
cache-name: cache-clojars
with:
path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('shadow-cljs.edn') }}
restore-keys: |
${{ runner.os }}-clojars
- run: yarn && yarn shadow-cljs compile client server
name: Build web assets
24 changes: 5 additions & 19 deletions calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544545993084) (:text |[]) (:id |LcIqjrx7al)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544545995583) (:text |read-string) (:id |-BYMBorJ0B)
|r $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544549161483) (:id |rjAREJXCG1)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549161848) (:text |[]) (:id |rjAREJXCG1leaf)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549162402) (:text |cljs.spec.alpha) (:id |jtmDiSHWNf)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549165178) (:text |:as) (:id |qYChXUmRs)
|v $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549165475) (:text |s) (:id |gGaSmDq1GC)
:defs $ {}
|*global-ws $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464574710) (:id |ZREWPsO0LG)
:data $ {}
Expand Down Expand Up @@ -244,8 +238,7 @@
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549830171) (:text |data) (:id |j2bsnBFP4T)
|v $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464559588) (:id |9TgREcwZqw7)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544464559588) (:text |.warn) (:id |bz08nvO27_G)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544464559588) (:text |js/console) (:id |ZTItCkkW52H)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1597742375758) (:text |js/console.warn) (:id |ZTItCkkW52H)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544464559588) (:text "||WebSocket at close state!") (:id |XVWpYxfxEWr)
:proc $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464133674) (:id |lx2L_hrVBk) (:data $ {})
|ws-edn.main $ {}
Expand Down Expand Up @@ -388,6 +381,7 @@
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544546036182) (:text |println) (:id |4RtgpUNPwQleaf)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544546038619) (:text "|\"reload!") (:id |fxhsgwBN1R)
|b $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1597742132109) (:text |^:dev/after-load) (:id |cieEc4tyh)
:proc $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464151788) (:id |2Ec0FZ11l9) (:data $ {})
|ws-edn.page $ {}
:ns $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464189777) (:id |Yxvyyx3ATA)
Expand Down Expand Up @@ -498,6 +492,7 @@
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544546058025) (:text |println) (:id |lEN2AHZRioleaf)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544546060744) (:text "|\"reload") (:id |xqccINhKO1)
|b $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1597742139381) (:text |^:dev/after-load) (:id |5oVaaeYg8)
:proc $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464189777) (:id |R8-slnikeQ) (:data $ {})
|ws-edn.server $ {}
:ns $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464128346) (:id |yz7pQZa7Qq)
Expand Down Expand Up @@ -528,12 +523,6 @@
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548031856) (:text "|\"shortid") (:id |JvMwOvkjDh)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548032303) (:text |:as) (:id |X1qdmcQ2F7)
|v $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548033200) (:text |shortid) (:id |uvbJpku6dk)
|x $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544549345253) (:id |5xJNPFodRv)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549345253) (:text |[]) (:id |W99AmLh_vb)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549345253) (:text |cljs.spec.alpha) (:id |i-vhKbBNxK)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549345253) (:text |:as) (:id |SBAfopTuab)
|v $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544549345253) (:text |s) (:id |QJQLe8tphq)
:defs $ {}
|*global-connections $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464593464) (:id |D_v6VI7TxD)
:data $ {}
Expand All @@ -553,6 +542,7 @@
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724084862) (:text |socket) (:id |uec22rqOmA)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724097962) (:text |options) (:id |H5lxCz1im8)
|D $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1597742269436) (:text |^js) (:id |H8Drun13H)
|x $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544724084862) (:id |gr95ZvwV8-)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724084862) (:text |let) (:id |Z4QOBd89-1)
Expand All @@ -563,8 +553,7 @@
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724084862) (:text |sid) (:id |lu1cUcucOm)
|j $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544724084862) (:id |0OGv2ib1J_O)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724084862) (:text |.generate) (:id |mfxDM6G5wEQ)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724084862) (:text |shortid) (:id |22uKv3IfGR4)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1597742328904) (:text |shortid/generate) (:id |22uKv3IfGR4)
|v $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544724084862) (:id |qv2ODArK6EJ)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544724084862) (:text |swap!) (:id |2LbpSSaiDmV)
Expand Down Expand Up @@ -807,7 +796,6 @@
|r $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544464609226) (:id |xabG3zTY_q5)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544464609226) (:text |.on) (:id |UZbIDsqp0cP)
|b $ {} (:type :leaf) (:by |VDPjyAOgV) (:at 1546484723073) (:text |^js) (:id |dOoMLjt03)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544464609226) (:text |wss) (:id |BonJfhc9VFV)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544464672410) (:text "|\"connection") (:id |uyocwopRBfV)
|v $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544724102470) (:id |7b1M3vwNa)
Expand All @@ -824,7 +812,6 @@
|v $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544548299847) (:id |R2gtAZYA6)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548300457) (:text |.on) (:id |R2gtAZYA6leaf)
|b $ {} (:type :leaf) (:by |VDPjyAOgV) (:at 1546484724804) (:text |^js) (:id |2oO2-PCmV)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548302607) (:text |wss) (:id |95g5BEqqK)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548303823) (:text "|\"listening") (:id |Ib04k_6k1E)
|v $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544548304487) (:id |Nxfww3C3M_)
Expand All @@ -849,7 +836,6 @@
|x $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544548343602) (:id |eUA3PAzaU)
:data $ {}
|T $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548345392) (:text |.on) (:id |eUA3PAzaUleaf)
|b $ {} (:type :leaf) (:by |VDPjyAOgV) (:at 1546484726500) (:text |^js) (:id |iedJXJkcKe)
|j $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548346030) (:text |wss) (:id |ErqxRJ7q0)
|r $ {} (:type :leaf) (:by |aQJLUBr_Hp) (:at 1544548351169) (:text "|\"error") (:id |HuRPhuxlKk)
|v $ {} (:type :expr) (:by |aQJLUBr_Hp) (:at 1544548351624) (:id |c3IfKjpSs)
Expand Down
12 changes: 12 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

{
:paths ["src"]
:aliases {
:release {
:extra-deps {
applied-science/deps-library {:mvn/version "0.4.0"}
}
:main-opts ["-m" "applied-science.deps-library"]
}
}
}
9 changes: 0 additions & 9 deletions meyvn.edn

This file was deleted.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cumulo-workflow",
"name": "ws-edn",
"version": "0.1.0",
"description": "Cumulo Workflow",
"main": "index.js",
Expand All @@ -16,12 +16,12 @@
"author": "jiyinyiyong",
"license": "MIT",
"dependencies": {
"shortid": "^2.2.14",
"ws": "^6.1.2"
"shortid": "^2.2.15",
"ws": "^7.3.1"
},
"devDependencies": {
"http-server": "^0.11.1",
"shadow-cljs": "^2.7.9",
"source-map-support": "^0.5.9"
"http-server": "^0.12.3",
"shadow-cljs": "^2.10.21",
"source-map-support": "^0.5.19"
}
}
6 changes: 6 additions & 0 deletions release.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{:version "0.1.4-a1"
:group-id "mvc-works"
:artifact-id "ws-edn"
:skip-tag true
:description "WebSocket wrapper in ClojureScript"
:scm-url "https://github.com/mvc-works/ws-edn"}
46 changes: 25 additions & 21 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@

{:source-paths ["src"]
:dependencies [[org.clojure/core.incubator "0.1.4"]]
:repositories {"central" {:url "https://maven.aliyun.com/nexus/content/groups/public/"}
"clojars" {:url "https://mirrors.ustc.edu.cn/clojars/"}}
:open-file-command ["subl" ["%s:%s:%s" :file :line :column]]
:builds {:client {:output-dir "target/"
:asset-path "./"
:target :browser
:modules {:client {:init-fn ws-edn.page/main!}}
:devtools {:after-load ws-edn.page/reload!
:http-root "target"
:http-port 7000}
:release {:output-dir "dist/"}
:module-hash-names 8
:build-options {:manifest-name "assets.edn"}}
:server {:target :node-script
:output-to "target/server.js"
:main ws-edn.main/main!
:devtools {:after-load ws-edn.main/reload!}
:release {:output-to "dist/server.js"}}}}
{
:source-paths ["src"]
:dependencies [
[org.clojure/core.incubator "0.1.4"]
]
:open-file-command [
"subl"
["%s:%s:%s" :file :line :column]
]
:dev-http {7000 "target"}
:builds {
:client {
:output-dir "target/", :asset-path "./", :target :browser, :module-hash-names 8
:modules {
:client {:init-fn ws-edn.page/main!}
}
:release {:output-dir "dist/"}
:build-options {:manifest-name "assets.edn"}
}
:server {
:target :node-script, :output-to "target/server.js", :main ws-edn.main/main!
:release {:output-to "dist/server.js"}
}
}
}
4 changes: 2 additions & 2 deletions src/ws_edn/client.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

(ns ws-edn.client (:require [cljs.reader :refer [read-string]] [cljs.spec.alpha :as s]))
(ns ws-edn.client (:require [cljs.reader :refer [read-string]]))

(defonce *global-ws (atom nil))

Expand Down Expand Up @@ -29,4 +29,4 @@

(defn ws-send! [data]
(let [ws @*global-ws]
(if (some? ws) (.send ws (pr-str data)) (.warn js/console "WebSocket at close state!"))))
(if (some? ws) (.send ws (pr-str data)) (js/console.warn "WebSocket at close state!"))))
2 changes: 1 addition & 1 deletion src/ws_edn/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
(fn [] (println "heartbeat") (wss-each! (fn [sid socket] (println sid socket))))
2000))

(defn reload! [] (println "reload!"))
(defn ^:dev/after-load reload! [] (println "reload!"))
2 changes: 1 addition & 1 deletion src/ws_edn/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
:on-close (fn [event] (println "close"))})
(js/setInterval (fn [] (println (ws-connected?))) 2000))

(defn reload! [] (println "reload"))
(defn ^:dev/after-load reload! [] (println "reload"))
13 changes: 4 additions & 9 deletions src/ws_edn/server.cljs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@

(ns ws-edn.server
(:require [cljs.reader :refer [read-string]]
["ws" :as ws]
["shortid" :as shortid]
[cljs.spec.alpha :as s]))
(:require [cljs.reader :refer [read-string]] ["ws" :as ws] ["shortid" :as shortid]))

(defonce *global-connections (atom {}))

(defn maintain-socket! [socket options]
(let [sid (.generate shortid)]
(defn maintain-socket! [^js socket options]
(let [sid (shortid/generate)]
(swap! *global-connections assoc sid socket)
(when-let [on-open (:on-open options)] (on-open sid socket))
(.on
Expand Down Expand Up @@ -41,14 +38,12 @@
(defn wss-serve! [port options]
(assert (number? port) "first argument is port")
(let [WebSocketServer (.-Server ws), wss (new WebSocketServer (js-obj "port" port))]
(.on ^js wss "connection" (fn [socket] (maintain-socket! socket options)))
(.on wss "connection" (fn [socket] (maintain-socket! socket options)))
(.on
^js
wss
"listening"
(fn [] (when-let [on-listening (:on-listening options)] (on-listening))))
(.on
^js
wss
"error"
(fn [error]
Expand Down
Loading

0 comments on commit b5ed106

Please sign in to comment.