Fork me on GitHub
#deps-new
<
2021-08-06
>
seancorfield04:08:39

What would be your wish-list for the next version of clj-new? If you're writing templates, what features do you require and what aspects of today's template-writing is bothersome? If you're a user of clj-new for creating new projects, what do you like and what bothers you?

Russell Mull05:08:57

My wish may be impossible: a way to change my mind about template options after the fact. Consider Luminus: (yes, it's a lein template) There are a bunch of choices that you have to make up front, but have no way to re-visit or re-examine later. We should be able to instantiate the basic thing, and then later add the "reagent" option (or whatever). I could imagine that this would only work if you haven't changed too much of the template, already.

seancorfield05:08:06

That's interesting. clj-new has the idea of "generators" to modify an existing project but it isn't very well fleshed-out...

rickmoynihan07:08:14

I think modifying / integrating existing code whether it came from a template or not is going to be very awkward. However I do think if it’s not already supported a way of overlaying new files into the same project may be worth while. e.g. imagine you clj-new a minimal clojure project then later decide to add in your companies default circle ci template. Providing the file additions don’t intersect with code in the repo already that would be ok.

seancorfield17:08:53

@U06HHF230 That's good feedback. I currently have it written to not overwrite an existing project, unless you say :overwrite true but, right now, that deletes any existing target directory first. I'll create an issue to rethink that.

seancorfield04:08:53

The "2.0" version can run as a "tool" and can find a template on the classpath (so you can point it at a directory with :local/root or a git repo since you would just use the CLI to set up the "context" when you run clojure ... -Tnew2 ... with -Sdeps or -A:aliases in there). A template is a folder with template.edn in it and folders containing the template files that are copied in phases with substitutions.

athomasoriginal12:08:45

I built my template for front end apps a while ago (https://github.com/athomasoriginal/create-reagent-app) and haven’t revisited clj-new itself to see if the following was actually provided, but: Request: flexible approach to naming the app/lib folder/project/files/ns. Right now, clj-new does company/project and i’ve felt that how that manifests into a folder/file/ns structure is not as flexible or intuitive as I might like. Aside from the above, I will look into my template and see if there is anything I would have liked.

seancorfield17:08:48

The company/project approach is intended to encourage users to create namespaces that won't collide with other people's code. I created https://github.com/seancorfield/deps-new/issues/2 if you'd like to elaborate on what you might want? You can override substitution keys easily via the command-line, and this new version has the idea of a "top" namespace and a "main" namespace so you can do something like this:

clojure -Tdeps-new create :template app :name company/project :top ws :main cool.api
and your tree will look like this:
(! 937)-> tree project
project
|____.gitignore
|____CHANGELOG.md
|____deps.edn
|____doc
| |____intro.md
|____LICENSE
|____pom.xml
|____README.md
|____resources
| |____.keep
|____src
| |____ws
| | |____cool
| | | |____api.clj
|____test
| |____ws
| | |____cool
| | | |____api_test.clj
So the project name is used for group/artifact and for the scm stuff in pom.xml but not for the file structure:
<groupId>net.clojars.company</groupId>
  <artifactId>project</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <name>company/project</name>
...
  <scm>
    <url></url>
    <connection>scm:git:</connection>
    <developerConnection>scm:git:</developerConnection>
    <tag>v0.1.0-SNAPSHOT</tag>
  </scm>

dominicm14:08:18

An approach to testing, even just a few basic utilities to spin up a repl of some kind and run some functions, testing that they don't explode would be great.

dominicm14:08:45

Right now I have a bash script that generates a few variants of the project and then I manually check that they do sensible things (like that (dev) works, or that a server starts)

seancorfield17:08:04

@dominicm I'd be interested to hear more about that -- could you elaborate in https://github.com/seancorfield/deps-new/issues/3 for me?

dominicm19:08:07

@seancorfield Sure. Anything you're interested in particularly?

dominicm19:08:00

@seancorfield I linked my scripts and talked a little about what the difficulties I run into are. If there's more lemme know and I'll happily share.

3
seancorfield19:08:48

I posted a Q in that issue and will likely continue the discussion there as needed. Thank you!