ccoco
— change config on checkout
Change your configurations on checkout for easy config environment change. Integrate with git hooks.
Warning
ccoco
is currently in experimental mode. Every release might have breaking changes before v1.0.0
. Make sure to specify the version you'd like to use.
My team didn't want to populate the package.json
too much with scripts so I created a tool that can easily replace the main config files whenever a branch changed.
ccoco
initially started as a tool specifically used for the Node.js ecosystem but has been rewritten to Go for platform independence. You can use ccoco
for any kinds of projects as long as it is within a Git repository.
Download from the Release page, add it to your PATH, and then initialize ccoco
in your project directory.
go install github.com/xarunoba/ccoco@latest
You can install ccoco
from the npmjs
repository.
npm install -D @xarunoba/ccoco
pnpm add -D @xarunoba/ccoco
yarn add -D @xarunoba/ccoco
npx ccoco
pnpm ccoco
yarn ccoco
There's also an extra alias for ccoco
for npm/pnpm/yarn
where instead of npx ccoco
you can simply do npx cc
.
Please add .ccoco
in your .gitignore
file.
Initialize ccoco
ccoco init
# or use alias: ccoco i
Add file/s to ccoco.config.json
ccoco add file1 file2 ...
# ccoco add myconfiguration.yml another.json
# or use alias: ccoco a
Remove file/s from ccoco.config.json
ccoco remove file1 file2 ...
# ccoco remove myconfiguration.yml another.json
# or use alias: ccoco rm
Generate per-branch config files based on your current repository's list of branches and the files mentioned in ccoco.config.json
ccoco generate
# or use alias: ccoco gen
Inject ccoco
in your post-checkout
git hook.
ccoco githook
# or use alias: ccoco gh
Manually run ccoco when not using the git hook injection OR when you want to integrate it with a git hook manager.
ccoco run
# or use alias: ccoco r
# or use alias: ccoco start
ccoco
will recursively check if a sub-branch has a config file until it reaches the "root" of the sub-branch.
- Branch
nested/one/two
does not have a config file created. ccoco
will recursively check for the config file existing innested/one
up until the rootnested
and will fail if it cannot find one.
ccoco
can be configured via ccoco.config.json
{
"files": [".env"] // the file that will be generated by ccoco generate
}
You can set your preflight scripts in the .ccoco/preflights
directory. These scripts will execute before ccoco
.
This will only run when you have injected
ccoco
via theccoco githook
command.