DEV Community

Cover image for A whole new developer ecosystem: CakeCutter 🍰
Dhravya
Dhravya

Posted on

A whole new developer ecosystem: CakeCutter 🍰

A couple months ago, I wrote a blog Introducing Cakecutter, which was, essentially, a modular version for create-python-project. Both of these projects were very easy, because they were just simple projects for me to practice the Rust programming language. I made them and forgot about it. But little did I know, small projects go a long way.

But then, a couple days ago, Yash (who is a fellow admin of the Coding Horizon community and an amazing developer), texted me, saying that he sees a lot of potential in my little pet project.

“Cakecutter is cool, let’s make it better”

And that’s exactly what we did.

We discussed new things we can implement, and decided to rewrite the entire thing in Golang

Ok, but what exactly is Cakecutter?

In a nutshell, Cakes are templates, which contain everything you need to set up a project. This includes:

  • The file structure of a project (for eg. some boilerplate files, README, src/ folder) [DOCS]
  • File content (for eg. Pre-generated licenses, or boilerplate code) [DOCS]
  • Commands to set up a project (for eg. Downloading dependencies, creating virtual environment) [DOCS]

Additionally, questions can be asked when setting up a project. Questions can be a selection between multiple things, or an input. Then, the answers to the questions can be used to fill in a template. [DOCS]

An example use case for this would be, asking the name of a user to auto-generate license, or you can even generate an entire README file with it!!

You can create files based on answer to a question, for example, creating a file only if the project is a typescript project.

And, you can even run commands based on answers. Example use case would be asking host OS to run setup commands!

This is a hell lot of power and functionality in just ONE CakeFile! (Just like real cakes 😆)

Have a look at the Basic example cake and you can also try out the Python cake

Sold yet? Install cakecutter.

Head over to https://docs.cakes.run/1-install/, or use with NPX:

npx cc
Enter fullscreen mode Exit fullscreen mode

These are not even the biggest updates.

Like create-react-app , most people don’t like to make cakes. They like to eat them. We knew this, and a way to share cakes had to be made.

So, we created a publish command, so you can publish your cakes for others to use!

Try out this command to instantly generate a very simple python project template. Now you don’t need to create cakes!

npx cc cut python
Enter fullscreen mode Exit fullscreen mode

Also, we created the website Cakes.run where you can find the documentation, installation guidelines, and also browse the cakes created by others.

To learn more about how to create cakes, Read the docs, and go through the examples repository

Your support is appreciated. Here’s how you can help

The entire stack - from the API, website, CLI, Docs - Everything is open source. You can find them on the Cake-cutter github organisation.

⭐ Star all repositories to spread the word. Especially this one, the main CLI 👇🏻

GitHub logo cake-cutter / cc

Create projects from pre-built cakes (templates) Supports files, packages, content, running commands, sharing cakes and more!

Cakecutter

License: MIT
Create projects from pre-built cakes (templates) in seconds

Contributor Covenant Read the full Documentation

👀 What is Cakecutter?

Sometimes, the most difficult thing is to just get started with a project. Cakecutter is a tool that helps you to cut the cake and start your amazing project instantly.

What Cakecutter does:

  • Users can publish, create or use a cake from Cakes.run. Cakes are basically TOML files which contain all the information needed to create a project.
  • According to the information in the Cakefile, Cakecutter will create all the files and (you can also fill them with content) in the correct location.
  • Setup commands (installing dependencies, etc) can be defined in the Cakefile. These commands are run after the files are generated.
  • Cakecutter can ask questions to the user and take input. The input can then be used as variables for the project template. Read the docs here

Follow Yash, the major contributor of this project, on DEV community and Github - https://github.com/kekda-py

Follow me, Dhravya Shah on Github - https://github.com/dhravya

Discussion (15)

Collapse
kekdadabest profile image
Yash • Edited on

sorry its not npx cc
its

npx cakecutter
Enter fullscreen mode Exit fullscreen mode

and for mac -

npx cc-for-mac
Enter fullscreen mode Exit fullscreen mode

and linux

npx cc-for-linux
Enter fullscreen mode Exit fullscreen mode

but its preferred to install it first

npm install -g cakecutter/cc-for-mac/cc-for-linux
Enter fullscreen mode Exit fullscreen mode

then

cc cut ...
Enter fullscreen mode Exit fullscreen mode

sorry for the inconvenience caused

Collapse
bovermyer profile image
Ben Overmyer

If it’s written in Go, what are the npx/m commands for?

Collapse
kekdadabest profile image
Yash • Edited on

We published the package as a binary executable to npm.

Not everyone has go installed, and almost everyone has npm

Thread Thread
bovermyer profile image
Ben Overmyer

Fair enough. Have you considered maintaining a Homebrew package for it? I'll try it out by installing with Go myself, but Homebrew would be easier, and less icky than npm.

Thread Thread
kekdadabest profile image
Yash

Yes.. We were gonna publish it on homebrew, scoop and conda-forge

but once we found out that you can publish binary executables on npm. We published it there are thought it should be enough.

And we also did tried publishing it on scoop but the request got rejected because the project was very nee

Collapse
kekdadabest profile image
Yash

Here are some features that we currently have in mind. feel free to share your own and give feedback about these

Extensions

Extensions will be a list of other published cakes or maybe even local cakes.

[metadata]
name = "..."
description = "..."
exts = ["readme","license"]
Enter fullscreen mode Exit fullscreen mode

these exts will be run before the actual cake. So you don't have to write extra code. and ask the questions.

Data Gatherers

Data gatherers are kinda like questions but they are not asked. They are commands which runs to gather data. like suppose you wanted to get the user's git username you can run git config --get user.name :-

[gatherers]
id-of-gatherer = "git config --get user.name"
Enter fullscreen mode Exit fullscreen mode

Before creating the template these commands will be run and there output will be saved. and u can use them just like questions

Collapse
fjones profile image
FJones

How are you sandboxing the commands? Seeing as how we've had a variety of install-script-based attacks on the npm platform lately.

Collapse
kekdadabest profile image
Yash • Edited on

if u have an idea please suggest!

Collapse
kekdadabest profile image
Yash • Edited on

aahh you u can run anything rn

maybe if we list the commands that will be ran, in the cake page...

Collapse
pandademic profile image
Pandademic

Hey! I'd like to help and to contribute , now that it's in go. I don't really know rust , but go is my bread and butter. You seem not to have contributing guidelines on github , so is their anyway I can help?

Thanks!

Collapse
dhravya profile image
Dhravya Author

You can! We're working on creating issues, setting up future plans and also setting up contribution guidelines for everyone.

Thanks for showing interest in our project! till then, if you find any bugs, or can think of any features to implement or, in general, think that anything can be better, kindly create an issue

Collapse
abhinav1217 profile image
Abhinav Kulshreshtha

Great to see it come alive.

Collapse
allanchain profile image
Allan Chain

It looks pretty much like cookiecutter. Could you tell us more about the difference?

Collapse
dhravya profile image
Dhravya Author

It's like our own implementation of Cookiecutter, but instead of the templates being stored in git repositories, they are stored as single files in our own database, with a central platform to find and use the "cakes"

Also, our implementation is faster

Collapse
nexxeln profile image
Shoubhit Dash

exciting stuff!