Skip to content

Commit

Permalink
feat(cli/templates) add clojurescript (#185)
Browse files Browse the repository at this point in the history
* 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
just-sultanov committed Sep 22, 2022
1 parent 0a498d0 commit 6ca747e
Show file tree
Hide file tree
Showing 33 changed files with 239 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changes/clojurescript.md
@@ -0,0 +1,6 @@
---
"create-tauri-app": minor
"create-tauri-app-js": minor
---

Add `clojurescript` template.
1 change: 1 addition & 0 deletions .scripts/generate-templates-matrix.js
Expand Up @@ -16,6 +16,7 @@ const nodeJsTemplates = [
"next-ts",
"preact",
"preact-ts",
"clojurescript",
];

const matrixConfig = [
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -87,6 +87,7 @@ Currently supported template presets include:
- `preact`
- `preact-ts`
- `angular`
- `clojurescript`

You can use `.` for the project name to scaffold in the current directory.

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-angular/_cta_manifest_
Expand Up @@ -8,4 +8,5 @@ devPath = http://localhost:1420
distDir = ../dist

[files]
tauri.svg = src/assets/tauri.svg
tauri.svg = src/assets/tauri.svg
style.css = src/style.css
@@ -0,0 +1,7 @@
{
"recommendations": [
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer",
"betterthantomorrow.calva"
]
}
7 changes: 7 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/README.md
@@ -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)
7 changes: 7 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/_[pnpm]_.npmrc
@@ -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 packages/cli/fragments/fragment-clojurescript/_cta_manifest_
@@ -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
23 changes: 23 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/_gitignore
@@ -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 packages/cli/fragments/fragment-clojurescript/package.json
@@ -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 packages/cli/fragments/fragment-clojurescript/public/cljs.svg
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 packages/cli/fragments/fragment-clojurescript/public/index.html
@@ -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 packages/cli/fragments/fragment-clojurescript/shadow-cljs.edn
@@ -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}}}}}
@@ -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))
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-next-ts/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
next.svg = src/assets/next.svg
react.svg = src/assets/react.svg
tauri.svg = src/assets/tauri.svg
tauri.svg = src/assets/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-next/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
next.svg = src/assets/next.svg
react.svg = src/assets/react.svg
tauri.svg = src/assets/tauri.svg
tauri.svg = src/assets/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-preact-ts/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
preact.svg = src/assets/preact.svg
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
tauri.svg = public/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-preact/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
preact.svg = src/assets/preact.svg
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
tauri.svg = public/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-react-ts/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
react.svg = src/assets/react.svg
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
tauri.svg = public/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-react/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
react.svg = src/assets/react.svg
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
tauri.svg = public/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-solid-ts/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
solid.svg = src/assets/logo.svg
solid.svg = src/assets/logo.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-solid/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
solid.svg = src/assets/logo.svg
solid.svg = src/assets/logo.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-svelte-ts/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
svelte.svg = public/svelte.svg
svelte.svg = public/svelte.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-svelte/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
svelte.svg = public/svelte.svg
svelte.svg = public/svelte.svg
style.css = src/style.css
1 change: 1 addition & 0 deletions packages/cli/fragments/fragment-vanilla-ts/_cta_manifest_
Expand Up @@ -7,3 +7,4 @@ withGlobalTauri = true
[files]
tauri.svg = src/assets/tauri.svg
vite.svg = src/assets/vite.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-vanilla/_cta_manifest_
Expand Up @@ -3,4 +3,5 @@ distDir = ../src
withGlobalTauri = true

[files]
tauri.svg = src/assets/tauri.svg
tauri.svg = src/assets/tauri.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-vue-ts/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
vue.svg = src/assets/vue.svg
vue.svg = src/assets/vue.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-vue/_cta_manifest_
Expand Up @@ -10,4 +10,5 @@ distDir = ../dist
[files]
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
vue.svg = src/assets/vue.svg
vue.svg = src/assets/vue.svg
style.css = src/style.css
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-yew/_cta_manifest_
Expand Up @@ -9,4 +9,5 @@ distDir = ../dist
withGlobalTauri = true

[files]
tauri.svg = public/tauri.svg
tauri.svg = public/tauri.svg
style.css = src/style.css
1 change: 1 addition & 0 deletions packages/cli/node/README.md
Expand Up @@ -59,6 +59,7 @@ Currently supported template presets include:
- `preact`
- `preact-ts`
- `angular`
- `clojurescript`

You can use `.` for the project name to scaffold in the current directory.

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/package_manager.rs
Expand Up @@ -49,6 +49,7 @@ impl PackageManager {
Template::NextTs,
Template::Preact,
Template::PreactTs,
Template::ClojureScript,
],
}
}
Expand Down

0 comments on commit 6ca747e

Please sign in to comment.