{"id":15007950,"url":"https://github.com/amir-ben-shimol/cnb","last_synced_at":"2025-10-30T12:31:23.753Z","repository":{"id":257792729,"uuid":"861627988","full_name":"amir-ben-shimol/cnb","owner":"amir-ben-shimol","description":"CLI tool for enforcing consistent Git branch naming conventions across teams and projects","archived":false,"fork":false,"pushed_at":"2025-02-14T23:17:52.000Z","size":927,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T00:23:53.978Z","etag":null,"topics":["branch","cli","devtools","git"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amir-ben-shimol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-23T08:47:22.000Z","updated_at":"2024-09-30T13:14:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"8096c559-9a75-47ce-a150-9257f597960c","html_url":"https://github.com/amir-ben-shimol/cnb","commit_stats":null,"previous_names":["amir-ben-shimol/cnb"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-ben-shimol%2Fcnb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-ben-shimol%2Fcnb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-ben-shimol%2Fcnb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-ben-shimol%2Fcnb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amir-ben-shimol","download_url":"https://codeload.github.com/amir-ben-shimol/cnb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238968234,"owners_count":19560585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["branch","cli","devtools","git"],"created_at":"2024-09-24T19:14:36.090Z","updated_at":"2025-10-30T12:31:18.318Z","avatar_url":"https://github.com/amir-ben-shimol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/amir-ben-shimol/cnb/blob/main/assets/brand.png\" width=\"350\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/amir-ben-shimol/cnb\"\u003e\n    \t\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/amir-ben-shimol/cnb/integrate.yaml?label=CI\u0026logo=GitHub\" alt=\"CI status\"\u003e\n  \t\u003c/a\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/cnb\"\u003e\n    \t\u003cimg src=\"https://img.shields.io/npm/dm/cnb?logo=NPM\" alt=\"npm downloads\"\u003e\n  \t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/amir-ben-shimol/cnb\"\u003e\n    \t\u003cimg src=\"https://img.shields.io/npm/l/cnb\" alt=\"npm license\"\u003e\n  \t\u003c/a\u003e\n\t\u003ca href=\"https://github.com/amir-ben-shimol/cnb\"\u003e\n    \t\u003cimg src=\"https://img.shields.io/npm/v/cnb?label=version\" alt=\"version\"\u003e\n  \t\u003c/a\u003e\n\u003c/p\u003e\n\n\u003chr /\u003e\n\n# 🚀 Create New Branch\n\n✨ **cnb** is a simple and customizable CLI tool that helps you create Git branches following naming conventions, and validates (lints) branch names to ensure they follow the configured conventions.\n\n## 🎬 Demo\n\n![cnb](assets/demo.gif)\n\n## 📦 Installation\n\nInstall the package as a dev dependency:\n\n```bash\nnpm i -D cnb\n```\n\n## 🛠️ Usage\n\n### Creating a New Branch\n\n1. Add the following alias to your `.gitconfig`:\n\n```shell\n[alias]\ncnb = \"!npx cnb\"\n```\n\n2. Add the following script to your `package.json`:\n\n```json\n\"scripts\": {\n\t\"prepare\": \"git config --local include.path ../.gitconfig\",\n}\n```\n\n3. Make sure the prepare script runs before trying the new git alias. You can do this by running (only once):\n\n```bash\nnpm i\n```\n\nOr explicitly run the script:\n\n```bash\nnpm run prepare\n```\n\n4. Run the following command to create a new branch with naming conventions:\n\n```bash\ngit cnb\n```\n\nThis will prompt you with a set of options to choose from (e.g., `feat`, `fix`, `chore`, etc.). You'll also provide a short description that will be formatted into kebab-case.\n\nExample:\n\n-   Selected type: `feat`\n-   Description: `configure notifications`\n\nThe branch created will be: `feat/configure-notifications`.\n\nIf your configuration requires a ticket ID (based on your config file), the flow will prompt you to enter that first.\n\n### Linting a Branch Name\n\nYou can also use **cnb** to lint and validate if the current branch name follows your configured conventions.\n\n1. Add the following script to your `package.json`:\n\n```json\n\"scripts\": {\n\t\"cnb:check\": \"cnb --check\"\n}\n```\n\n2. Run the script to lint the current branch name:\n\n```bash\nnpm run cnb:check\n```\n\n## 📁 Configuration\n\nYou can customize the behavior of **cnb** by creating a configuration file in your project root called `cnb.config.ts` (for ES6 environments) or `cnb.config.cjs` (for CommonJS environments).\n\n### Configuration Options\n\n| Option                 | Type       | Description                                                                                     | Default                             |\n| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------- | ----------------------------------- |\n| `branchTypes`          | `string[]` | The types of branches you can select (e.g., `feat`, `fix`, `chore`, `style`)                    | `['feat', 'fix', 'chore', 'style']` |\n| `maxDescriptionLength` | `number`   | The maximum length allowed for the branch description.                                          | `20`                                |\n| `skipTicketId`         | `boolean`  | Whether to skip the ticket ID prompt.                                                           | `false`                             |\n| `ticketIdPrefix`       | `string`   | The prefix to add to the ticket ID (e.g., `JIRA-`).                                             | `T-`                                |\n| `separator`            | `string`   | The character(s) used to separate the ticket ID, branch type, and branch name (e.g., `/`, `_`). | `/`                                 |\n\n### Example `cnb.config.ts` (ES6)\n\n```ts\nimport type { CnbConfig } from 'cnb';\n\nconst config: CnbConfig = {\n\tbranchTypes: ['feat', 'fix', 'chore', 'style'],\n\tmaxDescriptionLength: 20,\n\tskipTicketId: false,\n\tticketIdPrefix: 'JIRA-',\n};\n\nexport default config;\n```\n\n### Example `cnb.config.cjs` (CommonJS)\n\n```js\nmodule.exports = {\n\tbranchTypes: ['feat', 'fix', 'chore', 'style'],\n\tmaxDescriptionLength: 20,\n\tskipTicketId: false,\n\tticketIdPrefix: 'JIRA-',\n};\n```\n\n## 🛠️ Note for ES6 vs. CommonJS Users\n\n-   **For ES6 users**: Create your configuration file as `cnb.config.ts` and use `export default`.\n-   **For CommonJS users**: Create your configuration file as `cnb.config.cjs` and use `module.exports`.\n\n## 👥 Authors\n\n\u003ca href=\"https://github.com/amir-ben-shimol\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/105565954?s=400\u0026u=01efa537bf4368251ffa05954d13aa1861073b39\u0026v=4\" height=\"50\" /\u003e\n\u003c/a\u003e\n\n## 📄 License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famir-ben-shimol%2Fcnb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famir-ben-shimol%2Fcnb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famir-ben-shimol%2Fcnb/lists"}