Skip to content

Commit

Permalink
Migrate from figwheel-main to shadow-cljs
Browse files Browse the repository at this point in the history
  • Loading branch information
MrEbbinghaus committed Nov 15, 2021
1 parent 7337b4f commit 56d43a3
Show file tree
Hide file tree
Showing 15 changed files with 750 additions and 64 deletions.
42 changes: 29 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI/CD
name: Deploy to GitHub Pages

on:
push:
Expand All @@ -9,19 +9,35 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install dependencies
run: lein deps
- name: Build JS
run: lein do clean, fig:publish
- name: Copy Files
run: mv target/public/cljs-out resources/public/
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v1.3.0

- name: Prepare java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@3.5
with:
cli: 1.10.3.1029

- name: Install yarn
run: npm install -g yarn




- name: Install and Build
run: |
yarn install
clojure -M:cljs:dev release :main
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
build_dir: resources/public
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: resources/public
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ figwheel_server.log
.rebel_readline_history
*.iml

/resources/public/cljs-out/
/resources/public/js/
/.clj-kondo/.cache/
/.cpcache
/.shadow-cljs
/node_modules
yarn-error.log
10 changes: 10 additions & 0 deletions .idea/clojure-deps.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions .idea/runConfigurations/Start__w_REPL.xml

This file was deleted.

1 change: 0 additions & 1 deletion biosphere.cljs.edn

This file was deleted.

17 changes: 17 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{:paths ["src"]

:deps
{org.clojure/clojure {:mvn/version "1.10.3"}
quil/quil {:mvn/version "3.1.0"}}

:aliases
{:cljs
{:extra-deps
{org.clojure/clojurescript {:mvn/version "1.10.891"}
thheller/shadow-cljsjs {:mvn/version "0.0.22"}}}

:dev
{:extra-paths ["dev"]
:extra-deps
{thheller/shadow-cljs {:mvn/version "2.16.4"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
11 changes: 9 additions & 2 deletions dev/user.clj
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
(require '[figwheel.main.api :as fig])
(fig/start "biosphere")
(ns user
(:require
[shadow.cljs.devtools.server :as server]
[shadow.cljs.devtools.api :as shadow]))

(defn start-repl []
(server/start!)
(shadow/watch :main)
(shadow/repl :main))
2 changes: 0 additions & 2 deletions figwheel-main.edn

This file was deleted.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "biosphere",
"author": "Björn Ebbinghaus (https://github.com/MrEbbinghaus)",
"homepage": "https://mrebbinghaus.github.io/Biosphere/",
"repository": "github:MrEbbinghaus/Biosphere",
"dependencies": {
"p5": "^1.4.0"
},
"devDependencies": {
"shadow-cljs": "^2.16.4"
}
}
18 changes: 0 additions & 18 deletions project.clj

This file was deleted.

2 changes: 1 addition & 1 deletion resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1>Biosphere</h1>
<button onClick="biosphere.core.restart()">Restart</button>
</div>
<div id="biosphere"></div>
<script src="cljs-out/biosphere-main.js"></script>
<script src="js/app.js"></script>
<script>
biosphere.core.run_sketch("biosphere", [1536, 864])
</script>
Expand Down
11 changes: 11 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{:deps {:alias [:cljs :dev]}
:builds {:main
{:target :browser
:output-dir "resources/public/js"
:modules {:app {:entries [biosphere.core]}}

:devtools
{:repl-init-ns user
:repl-pprint true
:http-port 9500
:http-root "resources/public"}}}}
6 changes: 4 additions & 2 deletions src/biosphere/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
(defn *d [state x]
(* (:delta-time state) x))

(defn ^Number radians [^Number degree]
(def ^:constant deg->rad (/ Math/PI 180))

(defn radians [degree]
#?(:clj (Math/toRadians degree)
:cljs (/ (* degree Math/PI) 180)))
:cljs (* degree deg->rad)))
Loading

0 comments on commit 56d43a3

Please sign in to comment.