Deps-new: How can I generate a project from a new custom template?

I’m trying to use deps-new to generate a template, then use that template to generate a new project.

clojure -Tnew template :name dfornika/mytemplate 

This creates a new directory ‘mytemplate’ with this directory structure.

mytemplate
├── build.clj
├── CHANGELOG.md
├── deps.edn
├── doc
│   └── intro.md
├── LICENSE
├── pom.xml
├── README.md
├── resources
│   └── dfornika
│       └── mytemplate
│           ├── root
│           │   ├── build.clj
│           │   ├── CHANGELOG.md
│           │   ├── deps.edn
│           │   ├── doc
│           │   │   └── intro.md
│           │   ├── LICENSE
│           │   ├── pom.xml
│           │   ├── README.md
│           │   └── resources
│           ├── src
│           │   └── main.clj
│           ├── template.edn
│           └── test
│               └── main_test.clj
├── src
│   └── dfornika
│       └── mytemplate.clj
└── test
    └── dfornika
        └── mytemplate_test.clj

Now I’d like to use that template to generate a project.

cd mytemplate
clj -Tnew create :template dfornika/mytemplate :name dfornika/newproject :target-dir ../newproject

…but I’m getting an error message:

Execution error (ExceptionInfo) at org.corfield.new/create (new.clj:41).
Unable to find template.edn for dfornika/mytemplate

Full report at:
/tmp/clojure-7825932627563344434.edn

Does anyone have advice on what I may be doing wrong?

It’s a work-in-progress for a reason…

I thought that the generated README’s instructions would just work, but they don’t.

What the clojure -Tnew template :name dfornika/mytemplate command produces is a valid template but the instructions for using it are wrong.

I’ll work on this next week and update the docs and report back here how it should work.

1 Like

How do you use the newly-created template project? · Issue #15 · seancorfield/deps-new (github.com)

1 Like

Thanks @seancorfield, I know it’s a new tool so I’m not too troubled that there might still be a few rough spots. Looking forward to giving it another try soon.

v0.3.3 is available. The only change from v.0.3.2 is an updated README in a generated template project that shows how to use the new template project – what was missing was a -Sdeps argument that adds the local project as a dependency so the new tools can find its components.

So the following command should work in your generated project:

clj -Sdeps '{:deps {dfornika/mytemplate {:local/root "."}}}' -Tnew create :template dfornika/mytemplate :name dfornika/newproject :target-dir ../newproject
1 Like

It works! Thank you.