Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli/templates) add clojurescript #185

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/clojurescript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"create-tauri-app": patch
"create-tauri-app-js": patch
amrbashir marked this conversation as resolved.
Show resolved Hide resolved
---

Add `clojurescript` template.
3 changes: 3 additions & 0 deletions .github/workflows/templates-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jobs:
cargo install --locked trunk
if: matrix.settings.template == 'yew'

- run: sudo apt install -y clojure
if: matrix.settings.template == 'clojurescript'

- name: download cli artifact
uses: actions/download-artifact@v3

Expand Down
1 change: 1 addition & 0 deletions .scripts/generate-templates-matrix.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Currently supported template presets include:
- `preact`
- `preact-ts`
- `angular`
- `clojurescript`
just-sultanov marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/fragments/fragment-angular/_cta_manifest_
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
just-sultanov marked this conversation as resolved.
Show resolved Hide resolved
}
7 changes: 7 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/README.md
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)
just-sultanov marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 12 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/_cta_manifest_
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
23 changes: 23 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/_gitignore
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
9 changes: 9 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{:paths ["src/main/clojure"]

:deps {reagent/reagent {:mvn/version "1.1.1"
:exclusions [cljsjs/react
cljsjs/react-dom
cljsjs/react-dom-server]}}
just-sultanov marked this conversation as resolved.
Show resolved Hide resolved

:aliases {:develop {:extra-deps {thheller/shadow-cljs {:mvn/version "2.20.1"}
binaryage/devtools {:mvn/version "1.0.6"}}}}}
20 changes: 20 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/package.json
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": "npm run shadow-cljs watch app",
"build": "npm run shadow-cljs release app",
just-sultanov marked this conversation as resolved.
Show resolved Hide resolved
"shadow-cljs": "shadow-cljs",
"tauri": "tauri"
},
"devDependencies": {
"@tauri-apps/cli": "^1.0.5",
"shadow-cljs": "^2.20.1"
},
"dependencies": {
"@tauri-apps/api": "^1.0.5",
"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
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>
15 changes: 15 additions & 0 deletions packages/cli/fragments/fragment-clojurescript/shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{:deps {:aliases [:develop]}

:nrepl {:init-ns user}

:dev-http {1420 "public"}

:build-defaults {:closure-defines {goog.DEBUG true}
:compiler-options {:output-feature-set :es-next}}

:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:init-fn app.core/-main}}
:devtools {:preloads [devtools.preload]}
:dev {:external-config {:devtools/config {:features-to-install [:formatters :hints]}}}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(ns app.core
(:require
["@tauri-apps/api/tauri" :as tauri]
[goog.dom :as gdom]
[reagent.core :as r]
[reagent.dom :as dom]))

;; Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
just-sultanov marked this conversation as resolved.
Show resolved Hide resolved

(def root
(let [*name (r/atom "")
*message (r/atom "")
handle-input (fn [new-value]
(reset! *name new-value))
greet! (fn [name]
(-> (.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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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_
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl PackageManager {
Template::NextTs,
Template::Preact,
Template::PreactTs,
Template::ClojureScript,
],
}
}
Expand Down