An open API service indexing awesome lists of open source software.

https://github.com/xarunoba/ccoco

🥥 — Change configurations on checkout
https://github.com/xarunoba/ccoco

ccoco cli config-changer developer-experience git nodejs post-checkout

Last synced: 4 months ago
JSON representation

🥥 — Change configurations on checkout

Awesome Lists containing this project

README

          

# @xarunoba/ccoco 🥥

![Static Badge](https://img.shields.io/badge/Made_with-%E2%9D%A4%EF%B8%8F-red?style=for-the-badge) [![License](https://img.shields.io/npm/l/%40xarunoba%2Fccoco?style=for-the-badge)](https://github.com/xarunoba/ccoco?tab=MIT-1-ov-file#readme)
[![NPM Version](https://img.shields.io/npm/v/%40xarunoba%2Fccoco?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@xarunoba/ccoco?activeTab=readme)

**`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.**

## 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

```bash
go install github.com/xarunoba/ccoco@latest
```

### npm/pnpm/yarn

You can install `ccoco` from the `npmjs` repository.

```bash
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`

```bash
ccoco init
# or use alias: ccoco i
```

Add file/s to `ccoco.config.json`

```bash
ccoco add file1 file2 ...
# ccoco add myconfiguration.yml another.json
# or use alias: ccoco a
```

Remove file/s from `ccoco.config.json`

```bash
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`

```bash
ccoco generate
# or use alias: ccoco gen
```

Inject `ccoco` in your `post-checkout` git hook.

```bash
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.

```bash
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`

```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.