kit
kit copied to clipboard
Add support for `deps-new`
Overview
I'm working on a PR for neil
(https://github.com/babashka/neil/pull/51) which will make it possible to simplify the "Quick start" for Kit:
brew install clojure babashka/brew/neil
neil new io.github.kit-clj/kit yourname/app
Requirements
- Add a
deps-new
template to thekit
repo- Docs: https://github.com/seancorfield/deps-new
- Example: https://github.com/kit-clj/kit/compare/25b784c9a8e885bedb964dd067761545f6ce23b1...rads:kit:master
- Update the README with the new "Quick start" instructions listed above
Performance
The neil new
command is using babashka
to run org.corfield.new/create
which removes the JVM startup time. I haven't ported the lein-template
to deps-new
so I can't do a direct comparison yet. That said, with the built-in app
template, the difference is significant (3s down to 0.1s):
$ time clojure -Tnew app :name yourname/app :force true
Generating a project called app based on the 'app' template.
clojure -Tnew app :name yourname/app :force true 3.04s user 0.13s system 205% cpu 1.542 total
$ time ./neil new app yourname/app --overwrite
Creating project from org.corfield.new/app in app
./neil new app yourname/app --overwrite 0.10s user 0.03s system 88% cpu 0.147 total
This sound good to me, @nikolap thoughts?
Sounds great. Seems like a good option to migrate (simpler command, faster startup).
@nikolap @yogthos: I have an initial version of the port here: https://github.com/rads/kit/tree/master/libs/deps-template
Still needs some clean up, but it works! Here's how you can test it yourself:
- Ensure you have the latest version of
neil
:brew upgrade babashka/brew/neil
- Create a
kit
project with+xtdb
and+quartz
time neil new io.github.kit-clj/kit yourname/app --xtdb --quartz \ --git/url https://github.com/rads/kit.git \ --git/sha cb2236503c5fd5202df28bca1551bd2128a71e23 Creating project from io.github.kit-clj/kit in app ... 0.10s user 0.04s system 95% cpu 0.147 total
Edit: Updated the instructions to only two steps now that neil new
is available in the main package.
The neil new
feature is now available in version 0.1.36
: https://github.com/babashka/neil/blob/main/CHANGELOG.md#0136
Now that neil
is ready to go, all we need to do is add the support for deps-new to kit-clj.
As seen above, I've already got a prototype of this working on my branch. I'm planning to open a PR soon so we can start reviewing the code and talking about how this fits in to the existing kit-clj project.
@nikolap @yogthos: I'm planning to start working on this again to hopefully get it across the finish line. Do you folks have any specific ideas of how this would fit in with the existing lein-template
? Here is what I'm thinking so far:
-
Goal: This change is backwards compatible
- The
lein-template
lib andclj-new
templates will continue to be supported - The
deps-template
lib will be added tolibs
and referenced from the top-leveldeps.edn
- To avoid duplication, a third
base-template
lib will be added tolibs
to share things betweenlein-template
anddeps-template
- The
In my WIP PR, I didn't really have to change the template files themselves to make things work with deps-new. It's mainly the build tooling and manifest files that are different. Therefore I think it would be reasonable to share the template files across both lein-template
and deps-template
. Once I have a plan for how to reconcile with lein-template
, I can clean up the actual build code in the PR since I haven't done that yet.
What do you think about this?
Yeah that sounds pretty reasonable to me.
@yogthos: It looks like deps-new
currently only supports sourcing files from a single root template directory. If we try to break apart a single template into base-template
and deps-template
, the deps-template
will not find the files in the resources
of base-template
, even if the directory names are correct on both sides (resources/io/github/kit_clj/kit
).
In other words, it doesn't seem like it's possible to compose templates with deps-new
right now. I think the easiest path forward would be to make lein-template
depend on deps-template
, which seems to work fine since clj-new
doesn't have the same limitation.
Now that I've eliminated the duplication between the templates, I'm still working out bugs in the deps-template
version. I'm planning to add a test that will check that the output of both lein-template
and deps-template
is the same.
Yeah that sounds like the way to go since deps-new
only supports using a single root.
Just saw in your issue on deps-new that it's possible to support multiple files, but agree with Dmitri that it's cleaner to just have lein-template depend on deps-template for backwards compatibility. That way we don't duplicate the code
@nikolap @yogthos: The first PR is ready for review: https://github.com/kit-clj/kit/pull/65
This is just to set things up with the shared templates. Then the next PR will be to add the code to make deps-new work.