Skip to content
/ ccoco Public

🥥 — Change configurations on checkout

License

Notifications You must be signed in to change notification settings

xarunoba/ccoco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@xarunoba/ccoco 🥥

Static Badge License NPM Version

ccoco — change config on checkout

Change your configurations on checkout for easy config environment change. Integrate with git hooks.

Why

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.

Installation

Download Binary

Download from the Release page, add it to your PATH, and then initialize ccoco in your project directory.

Go Install

go install github.com/xarunoba/ccoco@latest

npm/pnpm/yarn

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.

.gitignore

Please add .ccoco in your .gitignore file.

Usage

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

Using sub-branches

ccoco will recursively check if a sub-branch has a config file until it reaches the "root" of the sub-branch.

Example

  1. Branch nested/one/two does not have a config file created.
  2. ccoco will recursively check for the config file existing in nested/one up until the root nested and will fail if it cannot find one.

Configuring ccoco

ccoco can be configured via ccoco.config.json

{
  "files": [".env"] // the file that will be generated by ccoco generate
}

Preflights

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 the ccoco githook command.