Recipes
Recipes
Maze generators can use a recipe to generate your application, and scaffold your application with controllers, models and views. Using a recipe you can get started with an maze application that extends or modifies the standard built in generator or provides additional features. For example you might want an API application that only renders JSON or use React or AngularJS for views.
Maze New Command with a recipe
Add a recipe name command line argument to create a new maze application from the recipe. The recipe name that you use to generate the application is saved so that when you generate controllers, models and views with the scaffold generator the same recipe is used - you don't have to specify the recipe each time.
maze new
maze new
Example Usage
Using maze new microsecond-blog -r damianham/mazebase
will generate a skeleton Maze application in ./microsecond-blog
using the mazebase recipe that was provided by the github user damianham.
You can have a running web application in a matter of minutes:
maze new microsecond-blog -r damianham/mazebase --deps
cd microsecond-blog
maze watch
Now open a web browser for your new maze app at http://localhost:3000.
Full example in terminal:
Recipe sources
Maze can use a recipe from the following sources;
The Maze framework recipe repository
A github repository
A local file system folder
A URL
Recipe repository
Visit the recipe repository to discover what recipes are available. The available recipes are listed in the Contributions.md file. Each recipe contributor provides additional information in their own Readme.
Github repository
Specify a Github username and repository as the recipe source as in the example above. E.g maze new microsecond-blog -r damianham/mazebase
will generate a skeleton Maze application in ./microsecond-blog
from the github repository https://github.com/damianham/mazebase
Local file system folder
Specify a local file system folder as the recipe source. Use the absolute path to the recipe folder. E.g. maze new microsecond-blog -r /home/damian/recipes/myrecipe
will generate a skeleton Maze application in ./microsecond-blog
from the recipe located in the folder /home/damian/recipes/myrecipe.
From a URL
Specify a URL to a zip file as the recipe source. The zip file must contain the standard conttents of a recipe. E.g. maze new microsecond-blog -r https://github.com/mazeframework/recipes/blob/master/dist/react/preact_redux.zip
will generate a skeleton Maze application in ./microsecond-blog
from the recipe located in the zip file at the URL https://github.com/mazeframework/recipes/blob/master/dist/react/preact_redux.zip.
Maze Generate Command
The generators in maze are a great way to get an application up and running quickly. In addition, they help keep code consistent and following convention. See the Generate option of the Command Line Tool for details about the generate command.
Once an application is generated with a recipe, it will be used by future generate or scaffold commands to maintain consistency with the recipe. For example, an application generated with a "json-api" recipe will continue to generate controllers and views according to the "json-api" recipe.
Custom Recipe
When a recipe doesn't quite suite your requirements, it's easy to modify. Recipes are application stubs written in Liquid. Modified recipes can be stored and sourced locally or contributed back to the community repository.
Download a recipe that you want to modify, extract it, and use the extracted recipe on the command line. For example:
wget https://git.io/vpdcz # zip file
mkdir ~/mymodular
unzip -d ~/mymodular modular.zip
# modify the recipe in ~/mymodular some way
maze new microsecond-blog -r ~/mymodular
cd microsecond-blog
shards install
maze watch
Now open a web browser at http://localhost:3000.
It is important to give the absolute path to the recipe folder as the recipe command line argument to ensure that the recipe can be found when generating subsequent artifacts.
Custom Repository
You can specify the location of a recipe repository in the .maze.yml
file so that you can use recipes from an independent source. Add the recipe_source item to the '.maze.yml' file with the URL of the website or website folder that contains the recipe zip files to use the recipes from the given URL. E.g
The scaffold generator would then use a recipe located at http://my.example.org/recipes/myrecipe.zip
Clear Recipe Cache
If you set a recipe source URL you should also change the name of the recipe and/or you should clear the recipe cache otherwise a recipe with the same name in the recipe cache will be used rather than a recipe from the given recipe source.
The recipe cache is located in the current working directory and is created any time you specify a recipe name that is downloaded from the repository. Since you would usually specify a recipe when creating a new application the recipe cache will be located in the parent folder of the new application in a folder called .maze_recipe_cache
.
Last updated