This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-28
Channels
- # bangalore-clj (1)
- # beginners (67)
- # braveandtrue (179)
- # cider (28)
- # cljdoc (1)
- # clojure (132)
- # clojure-conj (3)
- # clojure-dev (1)
- # clojure-finland (6)
- # clojure-nl (2)
- # clojure-russia (6)
- # clojure-spec (19)
- # clojure-uk (62)
- # clojurescript (90)
- # clojutre (5)
- # component (2)
- # cursive (30)
- # data-science (1)
- # datomic (42)
- # duct (9)
- # emacs (1)
- # figwheel-main (158)
- # fulcro (57)
- # funcool (3)
- # hoplon (1)
- # jobs (17)
- # mount (38)
- # off-topic (15)
- # re-frame (53)
- # remote-jobs (2)
- # schema (11)
- # shadow-cljs (299)
- # spacemacs (25)
- # specter (2)
- # tools-deps (54)
- # vim (11)
- # yada (6)
@seancorfield question about clj-new
's generators - how do I handle the case where I want to modify a file in the project root, like a deps.edn
?
(and is it common/good practice?)
@richiardiandrea That sounds like a nice enhancement -- to expose the prefix
argument somehow. Feel free to open an issue.
@seancorfield oh I think this is similar to https://github.com/seancorfield/clj-new/issues/8
Looks like it's been implemented here: https://github.com/juxt/pack.alpha/blob/master/src/mach/pack/alpha/inject.clj
The main obstacle right now is that you can't specify the prefix
(or any other parameters to generate-code
under the hood), mostly because the command line processing isn't very sophisticated. Hence the open issue about looking at tools.cli
for some of this.
@seancorfield sorry other question, can I build a template that accepts a single path in clj-new
?
I'm not quite sure what you're asking there?
If your template function accepts [name & args]
instead of the default [name]
, then any additional arguments you provides on the command-line are passed in...
it seems like I always receive an error directly from clj-new
if I pass the project name as my-template-test
for instance
$ clj -Sdeps '{:deps {clj-new {:git/url "" :sha "108f27159501f8ce12564b398b0ea50def3892b1"}}}' -m clj-new.create template myt/thing
...
$ vi thing/src/clj/new/thing.clj # add & args and print them out
$ clj -Sdeps '{:deps {clj-new {:git/url "" :sha "108f27159501f8ce12564b398b0ea50def3892b1"} my/thing {:local/root "./thing"}}}' -m clj-new.create thing another.generated.thing with args
Generating fresh 'clj new' thing project.
args= (with args)
$
clj-new
does not accept a single-segment name
oh ok that's what I feared
It must either be a multi.segment.name or a qualified/name
Phil always regretted allowing that bad practice for lein new
🙂
oh ok got it
You can always say my-template-test.core
to get the Leiningen behavior.
too bad because it feels natural for JS devs (which are my audience now)
have to explain that 😄
The docs say: > The project name should be a qualified Clojure symbol, where the first part is typically your GitHub account name or your organization's domain reversed, e.g., com.acme, and the second part is the "local" name for your project (and is used as the name of the folder in which the project is created). An alternative is to use a multi-segment project name, such as foo.bar (the folder created will be called foo.bar and will contain src/foo/bar.clj).
BTW, note above how I generated a template and then used it via :local/root
🙂 Gotta love the whole clj
/ deps.edn
thing!
yeah I am using the :local/root
thing, it is a nice thing
the thing is, JS users do not care/are used to the Java wait of packaging - therefore they consider it an additional burden..
some people here at least 😄
so the naming now for them feels Java-y
JS people should learn the benefits of globally unique names 🙂
I have zero sympathy! :rolling_on_the_floor_laughing:
well, they have a group as well but very few people use it
I will admit that when generating a new template, the qualified/multi-segment thing doesn't work as expected. If you use a qualified/name then the qualified part is ignored. If you use a multi.segment.name you get an illegal project (src/clj/new/multi.segment.name.clj). That's a bug that I haven't opened an issue for yet because there are restrictions on how template functions are named, including their namespace, so I'm not sure how best to resolve that conflict.
The simplest solution would be to allow simple names for templates but... ¯\(ツ)/¯
also I don't see any util to get only the myproj
from something like my.long.group/myproj
If you generate an actual project for my.long.group/myproj
the qualifier part goes into the namespaces:
(! 978)-> clj -Sdeps '{:deps {clj-new {:git/url "" :sha "108f27159501f8ce12564b398b0ea50def3892b1"}}}' -m clj-new.create app my.long.group/myproj
Generating a project called myproj based on the 'app' template.
Tue Aug 28 13:13:34
(sean)-(jobs:0)-(~/clojure)
(! 979)-> tree myproj
myproj
|____.gitignore
|____.hgignore
|____CHANGELOG.md
|____deps.edn
|____doc
| |____intro.md
|____LICENSE
|____README.md
|____resources
| |____.keep
|____src
| |____my
| | |____long
| | | |____group
| | | | |____myproj.clj
|____test
| |____my
| | |____long
| | | |____group
| | | | |____myproj_test.clj
uhm this does not seem to work in my template...I always get: Could not create directory /home/arichiardi/tmp/my.long.group/myproj. Maybe it already exists? Use -f / --force to overwrite it.
.
Super weird I am doing the same thing that your app
is doing
oh found the problem, :name
is actually used by ->files
! didn't expect that 😄
That's how Leiningen and Boot work.
yes that works but I would like to have {:project-name ...}
in my data
working on a patch
{:project-name ...}
in what data?
the template data
together with {:year ... :name ...}
Ah, yes, the template generator could do with a lot of enhancements.
this is something I really need, so patch will be coming
The app
generator has :name
for (project-name name)
You might consider sending a similar patch to boot-new
since it's pretty much the same code, as I recall?
The template already has :raw-name
by the way -- which is the whole name.
https://github.com/seancorfield/clj-new/blob/master/src/clj/new/template.clj#L9-L14
(but the template template does not have all that -- and it probably should https://github.com/seancorfield/clj-new/blob/master/src/clj/new/template/temp.clj )
kk will see what I can do
maybe I can just roll my own template