JSPM

@codeowners-flow/cli

0.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 4
    • Score
      100M100P100Q45640F
    • License MIT

    A tool to script and manage the CODEOWNERS file programmatically

    Package Exports

    • @codeowners-flow/cli
    • @codeowners-flow/cli/config

    Readme

    codeowners-flow

    About

    codeowners-flow lets you manage your CODEOWNERS file programmatically.

    Instead of directly creating and maintaining the CODEOWNERS markup file, with codeowners-flow you can define your code owners rules in JavaScript.

    To understand the motivations behind this project, refer to the root repository README.

    Note To learn more about CODEOWNERS, please refer to the Github official documentation.

    Getting started

    The first step is to install codeowners-flow in your project:

    Important If you're using a monorepo, every step should be executed at the root level.

    # or npm/yarn
    pnpm add codeowners-flow

    Next, create a file named codeowners.config.mjs:

    export default {
      outDir: '.github',
      rules: [
        {
          patterns: ['*'],
          owners: [
            {
              name: '@company/team',
            },
          ],
        },
      ],
    };

    After that, you can run the CLI:

    npx codeowners-flow generate

    The CLI will read your configuration and generate a CODEOWNERS file in the specified `outDir``:

    .github/CODEOWNERS

    # This file was generated automatically by codeowners-flow. Do not edit it manually.
    # Instead, modify the `codeowners.config.mjs` file located at the root of your project.
    
    # -------------------- START -------------------- #
    ## Matching patterns...
    * @company/team
    # -------------------- END -------------------- #
    

    Config

    outDir

    Type: string

    The relative path where the CODEOWNERS file should be generated.

    rules

    Type: Rule[]

    A list of code owner rules.

    Rule

    Type: object

    owners

    Type: Owner[]

    Owner

    Type: object

    name

    Type: string

    The name of an owner (e.g., @company/some-team).

    patterns

    Type: string[]

    An array of code owner patterns. See the official syntax for more details.

    excludePatterns

    Type: string[] | undefined
    Default: undefined

    A list of patterns to exclude.

    # In this example, @octocat owns any file in the `/apps`
    # directory in the root of your repository except for the `/apps/github`
    # subdirectory, as its owners are left empty.
    /apps/ @octocat
    /apps/github # <- exclude pattern

    comments

    Type: string[] | undefined
    Default: undefined

    Comments that will be placed above the matching rule. These can be useful to add descriptive information for each rule.