Gathering detailed insights and metrics for codeowners-generator
Gathering detailed insights and metrics for codeowners-generator
Gathering detailed insights and metrics for codeowners-generator
Gathering detailed insights and metrics for codeowners-generator
npm install codeowners-generator
v2.4.1
Published on 16 Jan 2024
Action 2.0: now with preserve block position fixed!
Published on 15 Jan 2024
v2.4.0
Published on 12 Jan 2024
Remove extraneous quote from action.yml
Published on 23 Mar 2023
now with preserve block position!
Published on 23 Mar 2023
action.v1
Published on 19 Mar 2023
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
55 Stars
334 Commits
9 Forks
4 Watching
14 Branches
11 Contributors
Updated on 05 Nov 2024
TypeScript (94.38%)
JavaScript (4.19%)
HTML (1.32%)
Shell (0.11%)
Cumulative downloads
Total Downloads
Last day
54.6%
4,683
Compared to previous day
Last week
-10.9%
19,291
Compared to previous week
Last month
60.9%
77,387
Compared to previous month
Last year
3.9%
513,323
Compared to previous year
✨ use codeowners anywhere in your monorepo 🛠️
Explore the docs »
Report Bug
·
Request Feature
CODEOWNERS 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.
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.
If you wish to use codeowners-generator
as a standalone utility:
1npm -g install codeowners-generator
This will make the codeowners-generator
command available in your terminal.
1codeowners-generator --help
If instead you would like to add it to a package:
1npm install --only=dev codeowners-generator
Every command accepts several options through command line or custom configuration see configuration for more
1 codeowners-generator generate
maintainers
field from package.json
)1codeowners-generator generate --use-maintainers
1 codeowners-generator generate --includes '**/CODEOWNERS'
Now you can use codeowners-generator
to validate if the CODEOWNERS file has been updated during a Pull Request.
1name: Lint CODEOWNERS 2 3on: 4 pull_request: 5 6jobs: 7 codeowners: 8 runs-on: ubuntu-latest 9 steps: 10 - uses: actions/checkout@v2 # to checkout the code of the repo you want to check the CODEOWNERS from. 11 - name: check codeowners 12 uses: gagoar/codeowners-generator@master 13 with: 14 use-maintainers: true 15 check: true
You 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:
1name: update CODEOWNERS 2 3on: 4 pull_request: 5 6jobs: 7 build: 8 runs-on: ubuntu-latest 9 steps: 10 - uses: actions/checkout@v3 11 - uses: gagoar/codeowners-generator@master 12 with: 13 use-maintainers: true 14 - run: | 15 STATUS=$(git diff --quiet && echo clean || echo modified) 16 echo "status=$(echo $STATUS)" >> $GITHUB_OUTPUT 17 id: gitStatus 18 - run: | 19 echo ${{ steps.gitStatus.outputs.status }} 20 echo ${{ contains(steps.gitStatus.outputs.status, 'modified') }} 21 - name: Commit CODEOWNERS 22 if: contains(steps.gitStatus.outputs.status, 'modified') 23 run: | 24 set -x 25 git config --local user.email "action@github.com" 26 git config --local user.name "GitHub Action" 27 git add CODEOWNERS 28 git commit -m "update CODEOWNERS" 29 - id: auth 30 if: contains(steps.gitStatus.outputs.status, 'modified') 31 uses: jnwng/github-app-installation-token-action@v2 32 with: 33 appId: ${{ secrets.YOUR_APP_ID }} 34 installationId: ${{ secrets.YOUR_APP_INSTALLATION_ID }} 35 privateKey: ${{ secrets.YOUR_APP_PRIVATE_KEY }} 36 - name: Push changes 37 if: contains(steps.gitStatus.outputs.status, 'modified') 38 uses: ad-m/github-push-action@master 39 with: 40 github_token: ${{ steps.auth.outputs.token }} 41 branch: ${{github.head_ref}}
Remember 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.
You can configure codeowners-generator
from several places:
includes (--includes
): The glob used to find CODEOWNERS files in the repo default: ['**/CODEOWNERS', '!CODEOWNERS', '!.github/CODEOWNERS', '!docs/CODEOWNERS', '!node_modules']
output (--output
): The output path and name of the file default: CODEOWNERS
useMaintainers (--use-maintainers
): It will use maintainers
field from package.json to generate codeowners, by default it will use **/package.json
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
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.
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.
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").
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.
For more details you can invoke:
1 codeowners-generator --help
You can also define custom configuration in your package:
1{ 2 "name": "my-package", 3 "codeowners-generator": { 4 "includes": ["**/CODEOWNERS"], 5 "output": ".github/CODEOWNERS", 6 "useMaintainers": true, 7 "useRootMaintainers": true, 8 "groupSourceComments": true, 9 "customRegenerationCommand": "npm run codeowners" 10 }, 11 "scripts": { 12 "codeowners": " codeowners-generator generate" 13 }, 14 "devDependencies": { 15 "codeowners-generator": "^2.0.0" 16 } 17}
When the command is invoked it will look for the codeowners-generator
configuration block.
1(my-package)$ npm run codeowners
If you create any files matching the following patterns, codeowners-generator
will pick them up:
codeowners-generator
property in package.json.codeowners-generatorrc
file in JSON or YAML format.codeowners-generator.json
, .codeowners-generator.yaml
, .codeowners-generator.yml
, .codeowners-generator.js
, or .codeowners-generator.cjs
filecodeowners-generatorrc
, codeowners-generator.json
, codeowners-generatorrc.yaml
, codeowners-generatorrc.yml
, codeowners-generator.js
or codeowners-generator.cjs
file inside a .config subdirectorycodeowners-generator.config.js
or codeowners-generator.config.cjs
CommonJS module exporting an objectFor more insight into the custom configuration and where it can be defined check cosmiconfig
See the open issues for a list of proposed features (and known issues).
Contributions 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.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 16/20 approved changesets -- score normalized to 8
Reason
4 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More