We've been writing a number of CLI tools lately. When that happens, certain patterns start to become more obvious.
One thing is creating tables for output, which we just extracted into mfgames-cil-table into this program. There isn't any changes from that, mostly because we were extracting something we've been copy/pasting for a year.
The other change, however, is obvious. We've introduced the --config option. Previously, the configuration for mfgames-conventional-commit was hard-coded to be //.git/mfgames-conventional-commit.yaml. But, most of our other programs use --config to get rid of the hard-coding so we decided to do the same.
$ mfgames-conventional-commit --config .config/dev-mfgames-conventional-commit.json version
package_name last_version flatten_version flatten_changed detail_version detail_changed
default 0.4.0 0.4.0 false 0.4.0 false
If there is no --config, then this continues to work as normal. However, if one or more --config files are included on the path, those take priority.
Split Processing
This is one approach to handling a current limitation for this tool. At the moment, we only have one set of “update” commands in the configuration file. Those commands can be used to update versions inside assembly files or configurations. It can also be used to tag and push up releases, but there are times when one needs to update the versions before the build but do the tagging after the build.
To get around that, the --config can be used to have three files:
//.config/mfgames-conventional-commit.json//.config/mfgames-conventional-commit-prepare.json//.config/mfgames-conventional-commit-release.json
The first file contains the common rules for packages, how to find them, which ones exist. The second can be used for the actions that need to be done before the build such as updating version files.
$ mfgames-conventional-commit --config .config/mfgames-conventional-commit-prepare.json update
Then the third file can be used only in pipelines or for the release process to perform the actual tagging and uploading of binaries.
There might be a cleaner way to do this in the future, but at the moment, that's all we got.