Fork me on GitHub
#deps-new
<
2020-09-22
>
fabrao22:09:50

hello all, how does it work? I want to create a custom template to my projects base, how do I do?

fabrao23:09:04

clj -A:new -M:new template myname/myapp
?

seancorfield23:09:03

@fabrao I'm not sure what you are asking...?

fabrao23:09:01

yes, but I didn´t understand how the flow to create my own template

fabrao23:09:03

clj -m clj-new.create mytemplate myname/mynewapp first?

seancorfield23:09:24

That creates you a new project that is setup like a template, yes.

seancorfield23:09:05

If you plan to publish a template to Clojars, it must have a specific structure to its name (as explained in that link I posted above).

fabrao23:09:24

I want to use it locally

seancorfield23:09:27

Or you can publish it to GitHub or you can use it locally (as a :local/root dependency).

seancorfield23:09:47

Internally, templates have to have a very specific structure (again, explained above).

seancorfield23:09:06

Then you can create new projects based on your template.

seancorfield23:09:27

Think of a template as a library that generates projects.

fabrao23:09:41

`Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate clj_new/create__init.class, clj_new/create.clj or clj_new/create.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.` what is this for this error?

seancorfield23:09:58

What command did you run to produce that error?

fabrao23:09:11

clj -m clj-new.create mytemplate myname/mynewapp

fabrao23:09:43

and beside, I´m running it on Windows

fabrao23:09:57

is that a problem?

seancorfield23:09:04

That says you don't have clj-new on your class path.

seancorfield23:09:16

That's not the same command you posted above (nor does it match the readme).

fabrao23:09:25

template -- A minimal `clj-new` template. Can produce a new template with `clj -m clj-new.create mytemplate myname/mynewapp` (where `mytemplate` is the appropriate part of whatever project name you used when you asked `clj-new` to create the template project).

seancorfield23:09:50

(! 636)-> clj -A:new -M:new template myname/myapp
Generating a project called myapp that is a 'clj-new' template
(! 637)-> clj -Sdeps '{:deps {myname/myapp {:local/root "myapp"}}}' -A:new -M:new myapp myname/myproject
Generating fresh 'clj new' myapp project.
(! 638)-> tree myproject
|____
| |____deps.edn
| |____src
| | |____myname
| | | |____myproject
| | | | |____foo.clj

seancorfield23:09:28

The second command uses the myname/myapp project as the template for creating myname/myproject

fabrao23:09:56

ow, now I understand

seancorfield23:09:52

I am removing "Can produce a new template with clj -m clj-new.create mytemplate myname/mynewapp (where mytemplate is the appropriate part of whatever project name you used when you asked clj-new to create the template project)." -- it assumes you understand that you need both clj-new and your new template on your classpath before you can use that.

fabrao23:09:00

yes, thats I thougth

seancorfield23:09:18

I've added the above to the readme (using myname/mytemplate for the template and myname/myproject for the generated project).