This is a file that configures laoban
. The key variable values can be seen by laoban config
The existence of the file marks that this is the root of a ‘big project’ which is composed of one or more sub projects
It is rare to just have ‘a single laoban.json with all the stuff’. That would probably violate the principle of ‘separation of concerns’.
Instead, we have the ability to ‘merge together’ lots of parents. A typical
laoban.json
file might look like this:
{
"parents": [
"https://raw.githubusercontent.com/phil-rice/laoban/master/common/laoban.json/core.laoban.json",
"https://raw.githubusercontent.com/phil-rice/laoban/master/common/laoban.json/typescript.laoban.json",
"https://raw.githubusercontent.com/phil-rice/laoban/master/common/laoban.json/typescript.publish.laoban.json"
]
}
core
parent pulls in useful things that are language dependanttypescript
parent pulls in scripts for compiling and testing typescripttypescript.publish
parent pulls in scripts for publishing to npmjs
Note that most of these have defaults if you include the core
in parents.
templateDir
: the directory that the templates can be found inlog
: the name of the log file found in the project directories holding the log of executing the commandsstatus
: the name of the file (in each project directory) that holds the status of ‘important commands’ executedscriptDir
: A place for bash scripts that can be accessed by the laoban commands. You can put your own scripts herepackageManager
: Probably npm
or yarn
throttle
sets the maximum number of parallel activities that will be executed. The default is 0 which doesn’t limit
things</div
Let me start with some strong advice. DO NOT STORE SECRETS IN laoban.json
Here is why.
laoban.json goes into git, and it is a bad idea to have secrets in git. Instead, use environment variables.
A lot of scripts that use secrets need an environment variable, and because of the nature of (other) configuration tools will often crash if the environment variable is not set. So, we have a mechanism for setting the DEFAULT value of environment variables. i.e. the value if not set in the environment.
A good example of this is in the ‘.npmrc’ files in the typescript templates. Their content is
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
This is needed if you want to publish code. BUT it will break many npm/yarn commands if the environment variable
is not set. To solve this we add a section to laoban.json
. This stops the crash. PLEASE DO NOT USE THIS FOR SETTING
THE SECRET
{
"defaultEnv": {
"NPM_TOKEN": ""
}
}