{"id":13532942,"url":"https://github.com/gagoar/codeowners-generator","last_synced_at":"2025-03-17T14:12:14.928Z","repository":{"id":38018472,"uuid":"283064170","full_name":"gagoar/codeowners-generator","owner":"gagoar","description":"CODEOWNERS solution for mono repos","archived":false,"fork":false,"pushed_at":"2024-04-09T08:07:32.000Z","size":1318,"stargazers_count":48,"open_issues_count":20,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-09T09:28:04.899Z","etag":null,"topics":["cli","codeowners","codeowners-files","codeowners-generator","monorepo"],"latest_commit_sha":null,"homepage":"https://gagoar.github.io/codeowners-generator/","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/gagoar.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-07-28T01:33:31.000Z","updated_at":"2024-04-09T09:28:06.645Z","dependencies_parsed_at":"2023-09-23T11:13:58.919Z","dependency_job_id":"81978f77-148e-4bc4-8807-2014bd26217a","html_url":"https://github.com/gagoar/codeowners-generator","commit_stats":{"total_commits":311,"total_committers":9,"mean_commits":34.55555555555556,"dds":"0.26688102893890675","last_synced_commit":"085dceade0fd936192bfcf55a72b2ea54a1d3d89"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagoar%2Fcodeowners-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagoar%2Fcodeowners-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagoar%2Fcodeowners-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagoar%2Fcodeowners-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gagoar","download_url":"https://codeload.github.com/gagoar/codeowners-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240637764,"owners_count":19833189,"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":["cli","codeowners","codeowners-files","codeowners-generator","monorepo"],"created_at":"2024-08-01T07:01:15.210Z","updated_at":"2025-02-26T00:08:28.166Z","avatar_url":"https://github.com/gagoar.png","language":"TypeScript","funding_links":[],"categories":["开发流程工具","cli"],"sub_categories":["Code ownership"],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/codeowners-generator\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/v/codeowners-generator/latest.svg?style=flat-square\" alt=\"NPM Version\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/gagoar/codeowners-generator/actions\"\u003e\n      \u003cimg src=\"https://github.com/gagoar/codeowners-generator/workflows/codeowners-generator/badge.svg\" alt=\"Workflow\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/gagoar/codeowners-generator\"\u003e\n      \u003cimg src=\"https://codecov.io/gh/gagoar/codeowners-generator/branch/master/graph/badge.svg?token=48gHuQl8zV\" alt=\"codecov\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/gagoar/codeowners-generator/blob/master/LICENSE\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/l/codeowners-generator.svg?style=flat-square\" alt=\"MIT license\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\n  \u003ch3 align=\"center\"\u003ecodeowners-generator\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\n     \u003ca href=\"https://gagoar.github.io/codeowners-generator/\"\u003e\n        \u003cimg src=\"images/logo.png\" alt=\"Logo\" width=\"128\" height=\"128\"\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\n  \u003cp align=\"center\"\u003e\n    this project is sponsored by: \u003cbr\u003e\n    \u003ca href=\"https://sourcegraph.com/\"\u003e\n       \u003cimg src=\"https://sourcegraph.com/.assets/img/sourcegraph-logo-light.svg\" alt=\"SourceGraph\" width=\"20%\"\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n   \n  \u003cp align=\"center\"\u003e\n    ✨ use codeowners anywhere in your monorepo 🛠️\n    \u003cbr /\u003e\n    \u003ca href=\"https://gagoar.github.io/codeowners-generator/\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/gagoar/codeowners-generator/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/gagoar/codeowners-generator/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n## Table of Contents\n\n- [About the Project](#about-the-project)\n- [Built With](#built-with)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n- [Action](#action)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n\n## About The Project\n\n[CODEOWNERS](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners) are automatically requested for review when someone opens a pull request that modifies code that they own. This is a great feature, but when working on monorepos ownership is shared between teams and it becomes difficult to maintain.\n\n`codeowners-generator` allows you to position CODEOWNERS files anywhere in your project tree and it will take care of compiling all the files into a single generated file, that Github can understand. It also can read the maintainers fields (`contributors`, `author` and alternatively `maintainers`) in `package.json` (`--use-maintainers` option in the cli ) making easy to keep CODEOWNERS and package.json in sync. Make sure the `author`/`contributors` syntax matches with `package.json` expected syntax from the [documentation](https://docs.npmjs.com/files/package.json#people-fields-author-contributors).\n\n### Built With\n\n- [ora](https://github.com/sindresorhus/ora)\n- [commander](https://github.com/tj/commander.js/)\n- [cosmiconfig](https://github.com/davidtheclark/cosmiconfig)\n\n\u003c!-- GETTING STARTED --\u003e\n\n### Installation\n\nIf you wish to use `codeowners-generator` as a standalone utility:\n\n```sh\nnpm -g install codeowners-generator\n```\n\nThis will make the `codeowners-generator` command available in your terminal.\n\n```sh\ncodeowners-generator --help\n```\n\nIf instead you would like to add it to a package:\n\n```sh\nnpm install --only=dev codeowners-generator\n```\n\n\u003c!-- USAGE EXAMPLES --\u003e\n\n## Usage\n\nEvery command accepts several options through command line or custom configuration [see configuration for more](#configuration)\n\n### Generate CODEOWNERS file\n\n```sh\n  codeowners-generator generate\n```\n\n### Generate CODEOWNERS file (using `maintainers` field from `package.json`)\n\n```sh\ncodeowners-generator generate --use-maintainers\n```\n\n### Specify CODEOWNERS (in case the CODEOWNERS files are named differently)\n\n```sh\n  codeowners-generator generate --includes '**/CODEOWNERS'\n```\n\n## Action\n\nNow you can use `codeowners-generator` to validate if the CODEOWNERS file has been updated during a Pull Request.\n\n```yml\nname: Lint CODEOWNERS\n\non:\n  pull_request:\n\njobs:\n  codeowners:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2 # to checkout the code of the repo you want to check the CODEOWNERS from.\n      - name: check codeowners\n        uses: gagoar/codeowners-generator@master\n        with:\n          use-maintainers: true\n          check: true\n```\n\nYou can also use it to update the Pull Request. For that, you will need a GitHub App or Personal Token with the necessary permissions (code content). The code for that will look roughly like this:\n\n```yml\nname: update CODEOWNERS\n\non:\n  pull_request:\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - uses: gagoar/codeowners-generator@master\n        with:\n          use-maintainers: true\n      - run: |\n          STATUS=$(git diff --quiet \u0026\u0026 echo clean || echo modified)\n          echo \"status=$(echo $STATUS)\" \u003e\u003e $GITHUB_OUTPUT\n        id: gitStatus\n      - run: |\n          echo ${{ steps.gitStatus.outputs.status }}\n          echo ${{ contains(steps.gitStatus.outputs.status, 'modified') }}\n      - name: Commit CODEOWNERS\n        if: contains(steps.gitStatus.outputs.status, 'modified')\n        run: |\n          set -x\n          git config --local user.email \"action@github.com\"\n          git config --local user.name \"GitHub Action\"\n          git add CODEOWNERS\n          git commit -m \"update CODEOWNERS\"\n      - id: auth\n        if: contains(steps.gitStatus.outputs.status, 'modified')\n        uses: jnwng/github-app-installation-token-action@v2\n        with:\n          appId: ${{ secrets.YOUR_APP_ID }}\n          installationId: ${{ secrets.YOUR_APP_INSTALLATION_ID }}\n          privateKey: ${{ secrets.YOUR_APP_PRIVATE_KEY }}\n      - name: Push changes\n        if: contains(steps.gitStatus.outputs.status, 'modified')\n        uses: ad-m/github-push-action@master\n        with:\n          github_token: ${{ steps.auth.outputs.token }}\n          branch: ${{github.head_ref}}\n```\n\n\u003c!-- CONFIGURATION --\u003e\n\nRemember that you can always create a configuration file in your project that will be picked up by the tool running on the action. For examples in how to configure take a look at the [configuration section below](#configuration).\n\n## Configuration\n\nYou can configure `codeowners-generator` from several places:\n\n### CLI options\n\n- **includes** (`--includes`): The glob used to find CODEOWNERS files in the repo `default: ['**/CODEOWNERS', '!CODEOWNERS', '!.github/CODEOWNERS', '!docs/CODEOWNERS', '!node_modules']`\n\n- **output** (`--output`): The output path and name of the file `default: CODEOWNERS`\n\n- **useMaintainers** (`--use-maintainers`): It will use `maintainers` field from package.json to generate codeowners, by default it will use `**/package.json`\n\n- **useRootMaintainers** (`--use-root-maintainers`): It will use `maintainers` field from the package.json in the root to generate default codeowners. Works only in conjunction with `useMaintainers`. `default: false`\n\n- **groupSourceComments** (`--group-source-comments`): Instead of generating one comment per rule, enabling this flag will group them, reducing comments to one per source file. Useful if your codeowners file gets too noisy.\n\n- **preserveBlockPosition** (`--preserve-block-position`): It will keep the generated block in the same position it was found in the CODEOWNERS file (if present). Useful for when you make manual additions.\n\n- **customRegenerationCommand** (`--custom-regeneration-command`): Specify a custom regeneration command to be printed in the generated CODEOWNERS file, it should be mapped to run codeowners-generator (e.g. \"npm run codeowners\").\n\n- **check** (`--check`): It will fail if the CODEOWNERS generated doesn't match the current (or missing) CODEOWNERS . Useful for validating that the CODEOWNERS file is not out of date during CI.\n\n- **hidden-directories** (`--hidden-directories`): Also include searching in hidden (dot) directories.\n\nFor more details you can invoke:\n\n```sh\n  codeowners-generator --help\n```\n\n### Custom Configuration\n\nYou can also define custom configuration in your package:\n\n```json\n{\n  \"name\": \"my-package\",\n  \"codeowners-generator\": {\n    \"includes\": [\"**/CODEOWNERS\"],\n    \"output\": \".github/CODEOWNERS\",\n    \"useMaintainers\": true,\n    \"useRootMaintainers\": true,\n    \"groupSourceComments\": true,\n    \"customRegenerationCommand\": \"npm run codeowners\"\n  },\n  \"scripts\": {\n    \"codeowners\": \" codeowners-generator generate\"\n  },\n  \"devDependencies\": {\n    \"codeowners-generator\": \"^2.0.0\"\n  }\n}\n```\n\nWhen the command is invoked it will look for the `codeowners-generator` configuration block.\n\n```bash\n(my-package)$ npm run codeowners\n```\n\nIf you create any files matching the following patterns, `codeowners-generator` will pick them up:\n\n- a `codeowners-generator` property in package.json\n- a `.codeowners-generatorrc` file in JSON or YAML format\n- a `.codeowners-generator.json`, `.codeowners-generator.yaml`, `.codeowners-generator.yml`, `.codeowners-generator.js`, or `.codeowners-generator.cjs` file\n- a `codeowners-generatorrc`, `codeowners-generator.json`, `codeowners-generatorrc.yaml`, `codeowners-generatorrc.yml`, `codeowners-generator.js` or `codeowners-generator.cjs` file inside a .config subdirectory\n- a `codeowners-generator.config.js` or `codeowners-generator.config.cjs` CommonJS module exporting an object\n\nFor more insight into the custom configuration and where it can be defined check [cosmiconfig](https://github.com/davidtheclark/cosmiconfig)\n\n\u003c!-- ROADMAP --\u003e\n\n## Roadmap\n\nSee the [open issues](https://github.com/gagoar/codeowners-generator/issues) for a list of proposed features (and known issues).\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\nContributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003c!-- LICENSE --\u003e\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n\u003c!-- CONTACT --\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://linkedin.com/in/gagoar\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square\u0026logo=linkedin\u0026colorB=555\" alt=\"follow on Twitter\"\u003e\n  \u003c/a\u003e\n    \u003ca href=\"https://twitter.com/intent/follow?screen_name=gagoar\"\u003e\n      \u003cimg src=\"https://img.shields.io/twitter/follow/gagoar?style=social\u0026logo=twitter\" alt=\"follow on Twitter\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgagoar%2Fcodeowners-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgagoar%2Fcodeowners-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgagoar%2Fcodeowners-generator/lists"}