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:
new
: Used to generate a new projectdev
: Development stackbuild
: Build your project for productionprod
: 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:
frontendServer
: The frontend server from the@coffeekraken/s-frontend-server
package to serve views likeblade.php
,twig
, etc...vite
: The ViteJs development server to serve assets likejs/ts
andcss
.
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.