-
Notifications
You must be signed in to change notification settings - Fork 126
/
bb.edn
90 lines (89 loc) · 7.13 KB
/
bb.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{:paths []
:deps {org.babashka/cli {:mvn/version "0.4.39"}}
:tasks {testnet-test {:doc "Start testnet" ; To migrate here, use
:task (let [seed "easy leave proof verb wait patient fringe laptop intact opera slab shine"
host "0.0.0.0"
port "8550"
block-time "0"
args (format "npx ganache --logging.verbose --wallet.mnemonic \"%s\" --server.host %s --server.port %s --miner.blockGasLimit 20000000 --chain.allowUnlimitedContractSize true --miner.blockTime=%s --chain.vmErrorsOnRPCResponse --chain.chainId 1337" seed host port block-time)]
(println "Starting TEST testnet with args: " args)
(println "To migrate here use:")
(println " export ETHLANCE_ENV=qa")
(println " npx truffle migrate --reset --network ganache-test")
(shell args))}
testnet-dev {:doc "Start testnet"
:task (let [seed "easy leave proof verb wait patient fringe laptop intact opera slab shine"
host "0.0.0.0"
port "8549"
block-time "0" ; Seconds (could be fractional). 0 means instamine https://trufflesuite.com/docs/ganache/reference/cli-options/#miner
; Changed networkId and chainId to 1 for MetaMask to show custom tokens (ERC20) correctly
; see: https://github.com/trufflesuite/ganache/discussions/4332#discussioncomment-5492132
args (format "npx ganache --database.dbPath=./temp/ganache-db --logging.verbose --wallet.mnemonic \"%s\" --server.host %s --server.port %s --miner.blockGasLimit 20000000 --chain.allowUnlimitedContractSize true --miner.blockTime=%s --chain.vmErrorsOnRPCResponse --chain.chainId 1 --chain.networkId 1" seed host port block-time)]
(println "Starting DEV testnet with args: " args)
(shell args))}
serve-designs {:doc "Start HTTP server on 8088 to serve designs"
:task (shell {:dir "designs"} "php --server 0.0.0.0:8088 --docroot ./deploy")}
compile-css {:doc "Compile LESS -> CSS"
:task (do
(println "Compiling LESS to CSS")
(shell {:dir "ui"} "./node_modules/less/bin/lessc resources/public/less/main.less resources/public/css/main.css --verbose"))}
watch-css {:doc "Watch & recompile LESS to CSS on file changes"
:task (do
(println "Watching LESS under ui/resources/public/less")
(shell {:dir "ui"} "npx less-watch-compiler resources/public/less resources/public/css main.less"))}
watch-ui {:doc "Watch and compile ui code changes CLJS -> JS in ui/src/**"
:requires ([babashka.cli :as cli])
:task (let [aliases (or *command-line-args* [])
command-args (format "-A:dev:shadow-cljs%s watch dev-ui" (clojure.string.join "" aliases))]
(println "Starting watch-ui. args:" command-args)
(clojure {:dir "ui"} command-args))}
watch-server {:doc "Watch and compile server code changes CLJS -> JS in server/src/**"
:requires ([babashka.cli :as cli])
:task (let [aliases (or *command-line-args* [])
command-args (format "-A:dev:shadow-cljs%s watch dev-server" (clojure.string.join "" aliases))]
(println "Starting watch dev-server args:" command-args)
(clojure {:dir "server"} command-args))}
run-server {:doc "Start Node.js API server process"
:task (do
(println "Starting Ethlance API server")
(shell {:dir "server"
:extra-env {"ETHLANCE_ENV" "dev"
"UI_CONFIG_PATH" "../config/ui-config-dev.edn"
"SERVER_CONFIG_PATH" "../config/server-config-dev.edn"}}
"node out/ethlance_server.js"))}
repl {:doc "Start REPL. Usage: bb repl [ui|server|test]"
:requires ([clojure.edn :as edn])
:task (let [build-arg (or (first *command-line-args*) "ui")
runtime-id (second *command-line-args*)
_ (println ">>> type runtime-id" (type runtime-id) runtime-id)
[build-id folder] (case build-arg
"ui" [:dev-ui "ui"]
"server" [:dev-server "server"]
"test" [:test-repl "server"])
_ (println ">>> build-id folder" build-id folder)
parse-port (fn [folder] (get-in (clojure.edn/read-string (slurp (str folder "/shadow-cljs.edn"))) [:nrepl :port]))
port (parse-port folder)
; Runtime numbers increase each time the browser app is reloaded
; They can be seen at http://d0x-vm:3420/runtimes
; To switch between them, open a 2nd REPL with: 1) bb repl 2) :cljs/quit
; and then pick build-id with:
; (shadow.cljs.devtools.api/repl-runtime-select :dev-ui 51)
choose-runtime (format "(shadow.cljs.devtools.api/repl-runtime-select %s %s)" build-id runtime-id)
connect-repl (format "(shadow/repl %s)" build-id)
code-for-repl (str
(when runtime-id choose-runtime)
connect-repl)
command (format "clojure -Sdeps '{:deps {reply/reply {:mvn/version \"0.5.1\"}}}' -M -m reply.main --color --attach %s --custom-eval \"%s\""
port code-for-repl)]
(println "Connecting lein repl to" runtime-id)
(println " command: " command)
(shell command))}
; In practice
; 1. Watch server tests: shadow-cljs watch server-tests
; 2. Run tests in a namespace: node out/server-tests.js --test=tests.contract.job-test
run-server-tests {:doc "Compile & run server tests"
:task (do
(println "Compiling server tests")
(clojure {:dir "server"} "-A:dev:shadow-cljs compile server-tests")
(println "Running server tests")
(shell {:dir "server"} "node out/server-tests.js"))}}}