-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli/templates) add clojurescript (#185)
* feat(cli/templates): add clojurescript * fix(cli/fragments/clojurescript): code review improvements - add a post init note about installing `java` and `clojure` - add an example using the `greet` command - move some resources to the `clojurescript` template - change ports for `shadow-cljs` and `tauri` - update ci pipeline - fix code formatting * fix(cli/fragments/clojurescript): remove test stuff * refactor(cli/templates): move `base/src/style.css` to the `_assets_` directory We can't import styles into cljs. * fix(cli/fragments/clojurescript): code review improvements - added the recommended `calva` plugin for `vscode` - updated deps - removed exclusions for the `reagent` dependency * refactor(cli/fragments/clojurescript): switch from `deps.edn` to `shadow-cljs` directly * fix(cli/fragments/clojurescript): fix issue with the `pnpm` These settings allow us to use `pnpm` as a package manager. Without these settings, we will receive several errors from the compiler: `object-assign`, `scheduler`, `scheduler/tracing` is not available. * Update .changes/clojurescript.md
- Loading branch information
1 parent
0a498d0
commit 6ca747e
Showing
33 changed files
with
239 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"create-tauri-app": minor | ||
"create-tauri-app-js": minor | ||
--- | ||
|
||
Add `clojurescript` template. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/cli/fragments/fragment-clojurescript/.vscode/extensions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"tauri-apps.tauri-vscode", | ||
"rust-lang.rust-analyzer", | ||
"betterthantomorrow.calva" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Tauri + ClojureScript | ||
|
||
This template should help get you started developing with Tauri and ClojureScript + shadow-cljs. | ||
|
||
## Recommended IDE Setup | ||
|
||
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) + [calva](https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# You can remove these settings if you use `yarn` or `npm`. | ||
# These settings allow us to use `pnpm` as a package manager. | ||
# Without these settings, we will receive several errors from the compiler: | ||
# `object-assign`, `scheduler`, `scheduler/tracing` is not available. | ||
|
||
public-hoist-pattern[]='object-assign' | ||
public-hoist-pattern[]='scheduler' |
12 changes: 12 additions & 0 deletions
12
packages/cli/fragments/fragment-clojurescript/_cta_manifest_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-License-Identifier: MIT | ||
|
||
beforeDevCommand = {{pkg_manager_run_command}} dev | ||
beforeBuildCommand = {{pkg_manager_run_command}} build | ||
devPath = http://localhost:1420 | ||
distDir = ../public | ||
|
||
[files] | ||
tauri.svg = public/tauri.svg | ||
style.css = public/style.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
.cpcache | ||
.clj-kondo/.cache | ||
.shadow-cljs | ||
target |
20 changes: 20 additions & 0 deletions
20
packages/cli/fragments/fragment-clojurescript/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "{{package_name}}", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "shadow-cljs watch app", | ||
"build": "shadow-cljs release app", | ||
"shadow-cljs": "shadow-cljs", | ||
"tauri": "tauri" | ||
}, | ||
"devDependencies": { | ||
"@tauri-apps/cli": "^1.1.1", | ||
"shadow-cljs": "^2.20.2" | ||
}, | ||
"dependencies": { | ||
"@tauri-apps/api": "^1.1.0", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/cli/fragments/fragment-clojurescript/public/cljs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
packages/cli/fragments/fragment-clojurescript/public/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/cljs.svg" /> | ||
<link rel="stylesheet" href="/style.css" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Tauri + ClojureScript</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script src="/js/main.js"></script> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/cli/fragments/fragment-clojurescript/shadow-cljs.edn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{:source-paths ["src/main/clojure"] | ||
|
||
:dependencies [[reagent/reagent "1.1.1"]] | ||
|
||
:dev-http {1420 "public"} | ||
|
||
:builds {:app {:target :browser | ||
:output-dir "public/js" | ||
:asset-path "/js" | ||
:modules {:main {:init-fn app.core/main}}}}} |
53 changes: 53 additions & 0 deletions
53
packages/cli/fragments/fragment-clojurescript/src/main/clojure/app/core.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
(ns app.core | ||
(:require | ||
["@tauri-apps/api/tauri" :as tauri] | ||
[goog.dom :as gdom] | ||
[reagent.core :as r] | ||
[reagent.dom :as dom])) | ||
|
||
(def root | ||
(let [*name (r/atom "") | ||
*message (r/atom "") | ||
handle-input (fn [new-value] | ||
(reset! *name new-value)) | ||
greet! (fn [name] | ||
;; Learn more about Tauri commands at https://tauri.app/v1/guides/features/command | ||
(-> (.invoke tauri "greet" #js {:name name}) | ||
(.then (fn [res] | ||
(reset! *message res)))))] | ||
(fn [] | ||
[:div.container | ||
[:h1 "Welcome to Tauri!"] | ||
|
||
[:div.row | ||
[:a {:href "https://tauri.app" :target "_blank"} | ||
[:img {:src "/tauri.svg" :class "logo tauri" :alt "Tauri logo"}]] | ||
[:a {:href "https://clojurescript.org" :target "_blank"} | ||
[:img {:src "/cljs.svg" :class "logo tauri" :alt "ClojureScript logo"}]]] | ||
|
||
[:p "Click on the Tauri, ClojureScript logos to learn more."] | ||
|
||
[:div.row | ||
[:input {:type "text" | ||
:id "greet-input" | ||
:on-change #(handle-input (.. % -target -value)) | ||
:placeholder "Enter a name..."}] | ||
[:button {:type "button" :on-click #(greet! @*name)} "Greet"]] | ||
|
||
[:p @*message]]))) | ||
|
||
|
||
(defn mount-root | ||
"Mount root component." | ||
{:dev/after-load true} | ||
[] | ||
(some->> | ||
(gdom/getElement "root") | ||
(dom/render [root]))) | ||
|
||
|
||
(defn main | ||
"Application entry point." | ||
{:export true} | ||
[& _args] | ||
(mount-root)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.