b5 provides some common modules to allow for easy usage of generic tasks, helper functions and more. All modules are defined inside the config.yml. Each module may be used multiple times using different parameters, so you may for example use one virtualenv for your build/ and one for your web/ path.
Inside your config.yml you may just put the desired modules inside the "modules" key. Example:
modules:
examplemodule:
modulewithparams:
param1: value1
param2: value2
Example module: "example"
# The functions provided by the modules will be prefixed by it's name
examplemodule:function() {
echo "Did something"
}
This is important when calling module functions and for understanding how to write your own modules.
All parameters passed to the module will be available in the bash environment using the following schema:
{MODULE_NAME}_{variable_key}
The example above will generate the following environment for modulewithparams
:
MODULEWITHPARAMS_param1="value1"
MODULEWITHPARAMS_param2="value2"
Please note, that the provided environment will represent the internal values of the module. This means that in most cases some preprocessing/cleanup of values might have happened. For paths like this in the example, it means that paths are converted to absolute paths. Example:
modules:
example:
some_path: ../web
Will most certainly become:
EXAMPLE_some_path="/absolute/path/to/project/web"
Some generic tasks may need to call the used modules. This is currently used for the following tasks:
- install
- update
- clean
Your install task may look like:
task:install() {
virtualenv:install
npm:install
}
If you need to use the same module twice or more (for example when needing multiple virtualenv directories) you may need to instantiate the same module twice. This may be done using the "class" key inside the module parameters:
modules:
virtualenv_build:
class: virtualenv
base_path: .
virtualenv_web:
class: virtualenv
base_path: ../web
The Taskfile will then look like this:
task:install() {
virtualenv_build:install
virtualenv_web:install
}
The following environment will be provided in this case:
VIRTUALENV_BUILD_base_path="/path/to/project/build"
VIRTUALENV_BUILD_...="more variables of virtualenv module"
VIRTUALENV_WEB_base_path="/path/to/project/web"
VIRTUALENV_WEB_...="more variables of virtualenv module"
modules:
npm:
virtualenv_build:
class: virtualenv
base_path: .
virtualenv_web:
class: virtualenv
base_path: ../web
#!/usr/bin/env bash
# b5 Taskfile, see https://git.team23.de/build/b5 for details
task:install() {
npm:install
virtualenv_build:install
virtualenv_web:install
}
task:update() {
npm:update
virtualenv_build:update
virtualenv_web:update
}
task:example() {
echo "This is a minimal example task"
}
You may now use b5 install
to install your npm and python packages, b5 update
for updating the installed
packages.
Note: See source of module for details, beyond documentation.
Reenables legacy module loading using b5:module_load
. Do not use.
Use npm to install JS dependencies. See documentation.
Use comlipy to lint your commit messages by adding a git commit-msg hook. See documentation.
Use composer to install PHP dependencies. See documentation.
Allow simple usage of docker. See documentation.
Handling of your virtualenv's using pipenv. See documentation.
Handling of your virtualenv's. See documentation.
Allows for easy template rendering using Jinja2. See documentation.