npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codeowners-flow/cli

v0.1.2

Published

A tool to script and manage the CODEOWNERS file programmatically

Downloads

4

Readme

@codeowners-flow/cli

About

@codeowners-flow/cli lets you manage your CODEOWNERS file programmatically.

Instead of directly creating and maintaining the CODEOWNERS markup file, with @codeowners-flow/cli you can define your code owners rules in JavaScript, and based on that, generate the CODEOWNERS file for you.

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

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

Prerequisite

  • Node 16 or later
  • pnpm, yarn, or npm

Usage

Usage
$ codeowners-flow generate
$ codeowners-flow generate --config /path/to/config.mjs
$ codeowners-flow init

Example
  $ codeowners-flow generate

    CODEOWNERS file generated! 🎉
    You can find it at: "/path/to/CODEOWNERS".

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, run the init command:

pnpm codeowners-flow init # or npx codeowners-flow init

This command will create a file in the folder you're named codeowners.config.mjs. This config file is where you're gonna define your code owners shape.

After that, you can run the CLI:

pnpm codeowners-flow generate # or 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 -------------------- #

Using helpers to define config

To ease the configuration, we expose some helpers to give you type inference on the fields you need to define:

import {
  defineConfig,
  defineOwner,
  defineRule,
} from '@codeowners-flow/cli/config';

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

Config API

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.