# Project Templates

**URL:** https://clojureverse.org/t/project-templates/2694
**Category:** shadow-cljs
**Created:** [August 21, 2018, 9:25am UTC](https://clojureverse.org/t/project-templates/2694 "2018-08-21T09:25:38Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [August 21, 2018, 9:25am UTC](https://clojureverse.org/t/project-templates/2694/1 "2018-08-21T09:25:38Z")

</div>

One objective of my [Clojurists Together](https://www.clojuriststogether.org/) funding is creating a proper template solution for `shadow-cljs` to easily and quickly create baseline project scaffolds without too much work.

While there are already a few community templates available they all require `lein` (or `clojure`) which the typical JS developer won’t have installed and I don’t want to force them to install either. So one of the base requirements is that it doesn’t rely on anything besides `node+npm` and `java` installed.

So my current plan is this:

1. create a `npm` package that can be invoked directly and does the basic project generation
2. generate some demo content + configuration on demand

Part #1 I have more or less figured out and you can try it today by just running

```bash
$ npx create-cljs-project foo-bar
$ cd foo-bar
$ npx shadow-cljs browser-repl

```

This will create a `foo-bar` directory and create the `package.json` + `shadow-cljs.edn` configs. It will also install the latest `shadow-cljs` version into the project.

Part #2 is much more tricky. My role model currently is the [vue cli](https://cli.vuejs.org/) which does all this exceptionally well. Only problem is that the `vue` cli is for `vue` the framework. I don’t want to create something that is tied to a specific framework and making something more generic quickly gets way more complex too. Replicating what the usual `lein-template`s do is not that hard but I’m curious about other options. One other really cool onboarding experience I saw was [metabase](https://www.metabase.com/start/jar.html).

Basically at this point I’m looking for ideas around project templates.

What are your favorite project templates?  
What are the best setup processes you have seen to date?

---

<div class="post-metadata">

### Author: ![jdhorwitz](https://clojureverse.org/user_avatar/clojureverse.org/jdhorwitz/32/1167_2.png) [@jdhorwitz](https://clojureverse.org/u/jdhorwitz)
#### Post date: [August 21, 2018, 2:10pm UTC](https://clojureverse.org/t/project-templates/2694/2 "2018-08-21T14:10:28Z")

</div>

I’ve always enjoyed create-react-app. It may be a lot, but when starting projects in the React world, in my experience everyone uses it and appreciates it.

---

<div class="post-metadata">

### Author: ![arichiardi](https://clojureverse.org/user_avatar/clojureverse.org/arichiardi/32/192_2.png) [@arichiardi](https://clojureverse.org/u/arichiardi)
#### Post date: [August 21, 2018, 2:44pm UTC](https://clojureverse.org/t/project-templates/2694/3 "2018-08-21T14:44:23Z")

</div>

I have used in the past a classic copy and fill the holes approach with [mustache](https://mustache.github.io/mustache.5.html) the templating language. Tht is a simple JS lib so you could just use ClojureScript for everything.

---

<div class="post-metadata">

### Author: ![arichiardi](https://clojureverse.org/user_avatar/clojureverse.org/arichiardi/32/192_2.png) [@arichiardi](https://clojureverse.org/u/arichiardi)
#### Post date: [August 21, 2018, 2:45pm UTC](https://clojureverse.org/t/project-templates/2694/4 "2018-08-21T14:45:30Z")

</div>

I think that is what lein uses as well.

---

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [August 21, 2018, 2:51pm UTC](https://clojureverse.org/t/project-templates/2694/5 "2018-08-21T14:51:38Z")

</div>

Yes, it is using `mustache` templates.

But I’m not so much looking for info on _how_ to build templates. That part is easy. I’m looking for inspiration on _what_ template to build.

`create-react-app` is another good example but its also exactly only for building react web apps. I encourage anyone to try the `vue` cli (especially `vue ui`) to get an idea about what I’m after. It might be overkill to build this kind of UI but who knows.

---

<div class="post-metadata">

### Author: ![arichiardi](https://clojureverse.org/user_avatar/clojureverse.org/arichiardi/32/192_2.png) [@arichiardi](https://clojureverse.org/u/arichiardi)
#### Post date: [August 21, 2018, 3:05pm UTC](https://clojureverse.org/t/project-templates/2694/6 "2018-08-21T15:05:22Z")

</div>

Ah! Oh sorry didn’t read it right 🙂

From a `node` point of view an example of all the node targets + azure target would be cool (can contribute that one) especially to see how to do testing. Or mixed JS-Cljs examples.

---

<div class="post-metadata">

### Author: ![biscuitpants](https://clojureverse.org/user_avatar/clojureverse.org/biscuitpants/32/1114_2.png) [@biscuitpants](https://clojureverse.org/u/biscuitpants)
#### Post date: [August 21, 2018, 6:04pm UTC](https://clojureverse.org/t/project-templates/2694/7 "2018-08-21T18:04:01Z")

</div>

`yeoman` is also something to look at. i found the generator abstraction quite useful 🙂  
[http://yeoman.io/](http://yeoman.io/)

---

<div class="post-metadata">

### Author: ![jmlsf](https://clojureverse.org/user_avatar/clojureverse.org/jmlsf/32/1271_2.png) [@jmlsf](https://clojureverse.org/u/jmlsf)
#### Post date: [August 21, 2018, 8:16pm UTC](https://clojureverse.org/t/project-templates/2694/8 "2018-08-21T20:16:07Z")

</div>

One under-appreciated aspect of create-react-app is that it upgradable, unlike standard templates. All you have to do is update the `react-scripts` version in `package.json` (instead of updating 10 different packages and their configuration files). The typical templating solutions you’ll find in the cljs ecosystem copy a bunch of stuff to your disk, and then you never interact with the template again. There isn’t a lot of user pressure to keep the template up to date because users go away after that first interaction.

I’m not even sure if it is technically possible to get the same effect with cljs, as so much of create-react-app is done with webpack & babel, but it is certainly something to think about.

---

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [August 21, 2018, 8:39pm UTC](https://clojureverse.org/t/project-templates/2694/9 "2018-08-21T20:39:23Z")

</div>

Agreed that most templates generate way too much boilerplate code that gets out of sync easily.

Problem however with `create-react-app` or `react-scripts` is that its not very customizable. You do it their way or eject which leaves you with a whole mess of things that you can’t upgrade anymore. Overall something like `create-react-app` is way out of scope for `shadow-cljs` since I don’t want something framework specific.

There could totally be a `create-reagent-app` that could use `shadow-cljs` but thats not what I’m going to build since I’m not a `reagent` user myself and wouldn’t know where to begin.

---

<div class="post-metadata">

### Author: ![lilactown](https://clojureverse.org/user_avatar/clojureverse.org/lilactown/32/1221_2.png) [@lilactown](https://clojureverse.org/u/lilactown)
#### Post date: [August 21, 2018, 8:47pm UTC](https://clojureverse.org/t/project-templates/2694/10 "2018-08-21T20:47:13Z")

</div>

I guess the question then (what I’m still unclear on, anyway) is: what is the scope?

Is the idea that it would just create a simple shadow-cljs.edn + core.cljs that would implement a simple “hello world”?

Is the idea that it would have additional plugins/generators, similar to how lein allows you to add additional parameters to a template like `+reagent +reframe +macchiato`?

It sounds like we’re talking a lot about _how_ when it’s not clear _what_ the goal is yet. Simple demo content, or a full-fledged plugin / feature generation service a la vue-cli?

---

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [August 21, 2018, 9:58pm UTC](https://clojureverse.org/t/project-templates/2694/11 "2018-08-21T21:58:57Z")

</div>

Well the scope is that I want something usable in 2.5 months

I’m unsure on how extensible this should be. I definitely cannot maintain a template for every single framework myself. I could maybe copy some popular lein templates and translate them to shadow-cljs configs but thats not exactly ideal. I’m also quite opinionated on how a project should be structured which may not suit everyone.

I really like the `vue-cli` stuff though. `yo` looks nice too. I wonder however how much value there really is in such things for the Clojure world since we usually write much much less boilerplate code than typical OOP-ish frameworks/languages.

I haven’t used a single template beyond basic `lein new project` since starting with Clojure and there is definitely value in knowing how your project is structured by building it yourself. There is also value in starting out with a single namespace and figuring out _why_ you split things into multiple namespaces. Lots of that is lost when you just start out with a pre-generated set of namespaces. Which then begs the question of who the templates should target: the expert users that already know all the details or “beginners” that just want to get started doing something?

I really wonder how many people actually understand their generated `project.clj` (or `deps.edn`). I have trouble grasping some of the stuff generated by `lein` templates.

I may drop the template idea entirely and instead focus on a “config wizard” style UI that lets you edit your build config by clicking through some basic options. Configs in shadow-cljs are already reduced to the bare minimum but a UI could still help by providing smart auto-complete or just inline documentation for each option.

Still just interested in how other people view/use templates (and which).

---

<div class="post-metadata">

### Author: ![arichiardi](https://clojureverse.org/user_avatar/clojureverse.org/arichiardi/32/192_2.png) [@arichiardi](https://clojureverse.org/u/arichiardi)
#### Post date: [August 22, 2018, 2:24am UTC](https://clojureverse.org/t/project-templates/2694/12 "2018-08-22T02:24:34Z")

</div>

I like this last idea. Maybe REPL based first, just to grasp the post of it.

It would basically be a way to build a user-friendly dsl on top of the configuration files (both deps/project.clj and shadow) and receive useful feed back in case of error or REPL restarts (say you add a dep in the REPL, dynamic load is not yet there, you receive “please restart the REPL for this to take effect”).

This could improve usability a lot. It can be further extended to a UI definitely.

👍

EDIT: if thought of a separate library it could even be used only with lein or only with deps actually. It would be super cool. Kind of like `rebel` but for configurations. Nice.

---

<div class="post-metadata">

### Author: ![dpsutton](https://clojureverse.org/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@dpsutton](https://clojureverse.org/u/dpsutton)
#### Post date: [August 22, 2018, 3:58am UTC](https://clojureverse.org/t/project-templates/2694/13 "2018-08-22T03:58:27Z")

</div>

just as a data point, I recently did

`lein new re-frame upvote +garden +10x +cider +test +handler +routes`

and it was amazing to get up with a templated and wired up re-frame app. There were samples to follow along and get the basics working and then i knew where to look to modify these parts. It was quite nice.

---

<div class="post-metadata">

### Author: ![jiyinyiyong](https://clojureverse.org/user_avatar/clojureverse.org/jiyinyiyong/32/85_2.png) [@jiyinyiyong](https://clojureverse.org/u/jiyinyiyong)
#### Post date: [August 23, 2018, 3:03am UTC](https://clojureverse.org/t/project-templates/2694/14 "2018-08-23T03:03:16Z")

</div>

> What are your favorite project templates?

I don’t use project templates like Vue CLI or react-create-app. Instead, I’m maintaining myself two repos. When I need to start a new project, I just clone them, regenerate `.git/` folder, modify configs, and new project is ready.

- [calcit-workflow](https://github.com/mvc-works/calcit-workflow), for webpages only site
- [cumulo-workflow](https://github.com/Cumulo/cumulo-workflow), for webpages with a simple WebSocket server, no database though.

There are [some other workflows](https://github.com/mvc-works/?utf8=%E2%9C%93&q=workflow&type=&language=) deprecated or still drafting. I have been creating projects in this way for really long time.

> What are the best setup processes you have seen to date?

Not sure. I think I’m satisfied with my current solution.

Besides these questions, I think another question need to be answered is “who is going to use your templates”?

---

<div class="post-metadata">

### Author: ![den](https://clojureverse.org/user_avatar/clojureverse.org/den/32/322_2.png) [@den](https://clojureverse.org/u/den)
#### Post date: [August 25, 2018, 6:23pm UTC](https://clojureverse.org/t/project-templates/2694/15 "2018-08-25T18:23:22Z")

</div>

> `create-react-app` is another good example but its also exactly only for building react web apps. I encourage anyone to try the `vue` cli (especially `vue ui` ) to get an idea about what I’m after. It might be overkill to build this kind of UI but who knows.

IMO one should avoid templates. Templates break versioning since a change in the template generator lib / cli usually doesn’t provide a git-like upgrade path to all projects that have been made with it. `create-react-app` has a solution to this, packaging default files into its source and allowing developers to run commands to _copy_ them incrementally into their own apps as they need to be changed. The fewer files get generated, the less there is to maintain.

---

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [February 24, 2019, 6:23am UTC](https://clojureverse.org/t/project-templates/2694/16 "2019-02-24T06:23:23Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
