Create your own recipe

Recipes are what we use to drive a project. It is used to generate a new project, to launch the development environment, build your project, etc...

Register a new recipe

To register a new recipe, you have to create a new file called kitchen.config.ts inside of the .sugar folder at your project root. Here's the content of this file:

By doing this, we just registered a new recipe called myCoolRecipe.

We just need to tell the @coffeekraken/cli CLI that our project make use of our new myCoolRecipe. To do so, simply create a sugar.json file at your project root with this content:

We need to understand a little bit more what a recipe is made of...

What is a recipe exactly?

Recipes are made of stack(s) and action(s).

A stack is mainly like a "group" of actions that you will be able to execute separatly from each others.

If we take the default recipe, it expose 4 stacks which are:

  1. new: Used to generate a new project
  2. dev: Development stack
  3. build: Build your project for production
  4. prod: Display locally your project with production assets

Actions are processes that will be executed just like a command-line for example. They can be a node script as we will see bellow.

To stick with our default recipe as an example, the dev stack is made of 2 actions which are:

  1. frontendServer: The frontend server from the @coffeekraken/s-frontend-server package to serve views like blade.php, twig, etc...
  2. vite: The ViteJs development server to serve assets like js/ts and css.

Register a new stack

Back to our recipe. Here's how to register a new dev stack into our recipe:

Register a new action

Actions are the smaller piece of our recipe. Actions can be things like:

  • Command line
  • Nodejs process represented by a .js file that exports a function to execute

Back to our recipe. We will integrate 2 actions which will be a simple command line one, and a node process one which will be detailed bellow.

Testing your stack

To test our new recipe dev stack, simply type in your cmd

Make sure you have create the sugar.json file as described above before testing your recipe...

At this point, your recipe dev stack has to run and throw an error because we don't have created our node process action file...

Node process file

When you set the process property on one of your action, it MUST be an absolute path to a process file.

A node process file is a simply nodejs file that exports a function that will be called when our action is runned.

This function MUST return a Promise. Inside it, you can do whatever you need.

Bugs
are not our friends...

Don't hesitate to declare an issue if something does not works as expected.

Declare my issue on Github Talk about it on Discord

The more we are,
the stronger we become.

Don't hesitate to tell some words to you friends about us. The goal is to became more and more each days to help each others...

Support us on Patreon! Share on Facebook! Make a tweet!

The more we are,
the stronger we become.

Don't be afraid to join us on Discord.

Join us on discord!

We love,
Open source!

All of our codebase can be found on Github. We hope that you may contribute to help us make our tools even better!

Discover our codebase!

Welcome on