-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
neil new
: Add support for deps-based templates
#51
Conversation
neil new
: Add support for deps-based templates
src/babashka/neil.clj
Outdated
; template deps overrides | ||
:local/root | ||
:git/url | ||
:git/sha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the deps-new docs:
:local/root
andgit
-based coordinates are supported, but Maven/Clojars coordinates are not.
Made some progress on porting Kit's existing |
neil
Outdated
:dry-run | ||
|
||
; template deps overrides | ||
:local/root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not necessary to explicitly list all the options. Babashka CLI automatically parses all command line flags. The list your using here is for converting options in order to options, using :cmds-opts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I updated the :cmds-opts
to be [:template :name :target-dir]
. These are the ones that made most sense to me as positional arguments.
For the special named arguments which are not directly supported by deps-new
(:git/url
, :git/sha
, :git/tag
, :local/root
), we'll probably want to add those to the neil help
docs in addition to the existing link to the deps-new
override options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 16 (on main) we already have a bunch of options. I'd prefer if we could align the names of options, even if they are used in different contexts. Since we already have :sha
, maybe we should re-use that one? Or should we deprecate it and rename it to :git/sha
(with :sha
being an :alias
for :git/sha
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@borkdude: Here's the solution I came up with:
neil new
will always accept namespaced keys like:git/sha
neil new
also supports the existing:sha
and:latest-sha
options:sha
is simply renamed to:git/sha
before parsing:latest-sha
provides an alternative to fetching the latest:git/tag
(which is the default behavior when neither:git/tag
,:git/sha
, nor:latest-sha
is provided)
- Any options for
neil new
that are not already inbabashka.neil/spec
should be documented specifically forneil new
. If we find someneil new
options to be useful elsewhere, we can promote them tobabashka.neil/spec
as needed.
What do you think about this?
The new-scratch-test already covers extra opts (:overwrite)
I updated the logic in |
Dev note: Not sure if there's a better way to do this, but here's what I'm currently using to auto-build the
|
neil new
: Add support for deps-based templatesneil new
: Add support for deps-based templates
@borkdude: Finished up with everything I originally planned to do so far. This is officially ready for review. 🙂 |
I realized I hadn't tested this with One caveat for
|
Classpath property must always be set manually when using babashka with deps-new
"Returns parsed deps-new template deps opts from raw CLI opts." | ||
[cli-opts] | ||
(-> cli-opts | ||
(set/rename-keys {:sha :git/sha}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This we can do via the :alias
feature of babashka.cli I think?
Usage
Let's say you want to set up a
kit-clj
project on a new macOS machine. Here's what that looks like withoutneil
:brew install clojure clojure -Ttools install com.github.seancorfield/clj-new '{:git/tag "v1.2.381"}' :as new clojure -Tnew create :template io.github.kit-clj :name yourname/app
And then with
neil
:Testing
Note: To make the above command work temporarily, you need to add the
--git/url
and--git/sha
options to use my fork of kit-clj/kit:Once Kit gets support for
deps-new
(see kit-clj/kit#52), the--git/url
and--git/sha
options can be removed.Notes
If you run into an error like this while testing, this is due to hitting the GitHub rate limit:
TODO
neil new scratch ...
neil new io.github.rads/neil-new-test-template ...
io.github.rads/neil-new-test-template
to something else?