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

coscribe

v1.0.0

Published

Git code owners file generator and updater

Downloads

10

Readme

Coscribe

About

This package provides commands to generate and update CODEOWNERS file entries. Currently, this is done by invoking shell commands with shelljs.

Each git-tracked file (that does not have preset pattern in the configuration file) will be examined for authors via the git blame --porcelain shell command (We define the author-mail field output by the git blame --porcelain command as an author here). All authors will added as owners for that file in CODEOWNERS. Note that if no authors are resolved for a file or pattern, it will be omitted as a CODEOWNERS entry.

Configuration (coscribe.yml | coscribe.yaml)

A configuration file can be optionally provided (coscribe.yaml or coscribe.yml) to override some behavior. Commands will, by default, look for this file in the directory where they were invoked. See Usage

# The relative path to the CODEOWNERS file.
# If not defined, default to the current directory where the command is invoked
codeOwnersFile: <relativePathtoCodeOwnersFile>

# During examination of a file, if an author is in the set of keys
# in this configuration, the command will remap it to the value.
authorRemap:
    '[email protected]': '[email protected]'
    '[email protected]': '[email protected]'
    # ...

# During examination of a file, if an author is in this set,
# the author will be omitted from any set of authors.
omittedAuthors:
    - '[email protected]'
    - '[email protected]'
    # ...

# These items will be converted into entries and added to the CODEOWNERS file first.
# Any file that matches any of these patterns will be omitted.
# Patterns need to be well-formed relative to the CODEOWNER rules.
presetDirectories:
    # Will convert to in CODEOWNERS file: `pattern1 author1`
    'pattern1':
        - 'author1'
    # Will convert to in CODEOWNERS file: `pattern2 author1 author2`
    'pattern2':
        - 'author1'
        - 'author2'
    # Will convert to in CODEOWNERS file: `pattern3  author2`
    'pattern3':
        - 'author2'
    # ...

# These items will be converted into entries and added to the CODEOWNERS file
# instead the entries that would have resolved from the examination process.
# These items are not patterns, just relative-path'ed files
presetFiles:
    'file1.txt':
        - 'author1'
        - 'author2'
        - 'author3'
    'a/b/c.json':
        - 'author1'
        - 'author5'
        - 'author6'
    # ...

# These pattern items will be used to filter out entries.
omittedPatterns:
    - file1.json
    - a/d/e.cpp
    # ...

Installation

Install it globally on your system.

> yarn add global coscribe

Install locally in a project

> yarn add coscribe

Usage

Run this command in the root directory of a git project. Once installed, there are two commands that can be invoked, Generate, and Update. Both commands use the currently checked out git branch.

When installed globally, you can invoke the help command with:

> coscribe -h

Or, when installed locally:

> ./node_modules/.bin/coscribe -h

Both should provide the following output

Usage: coscribe [options] [command]

Options:
  -h, --help                      display help for command

Commands:
  generate [options]              Generate code owners file
  update [options] <base-branch>  Update code owners file
  help [command]                  display help for command

Generate

When installed globally, you can invoke the help command with:

> coscribe generate -h

Or, when installed locally:

> ./node_modules/.bin/coscribe generate -h

Both should provide the following output

Usage: coscribe generate [options]

Generate code owners file

Options:
  --coscribe-file <coscribeFile>  Provide another (relative path from command execution dir) location for the config file (default: "coscribe")
  -h, --help                    display help for command

To invoke the command when installed globally:

> coscribe generate

Or, locally:

> ./node_modules/.bin/coscribe generate

Update

When installed globally, you can invoke the help command with:

> coscribe update -h

Or, when installed locally:

> ./node_modules/.bin/coscribe update -h

Both should provide the following output

Usage: coscribe update [options] <base-branch>

Update code owners file

Arguments:
  base-branch                   The base branch used for the comparison of changes

Options:
  [target-branch]               The target branch used for comparison of changes
  --coscribe-file <coscribeFile>  Provide another (relative path from command execution dir) location for the config file (default: "coscribe")
  -h, --help                    display help for command

If you want to use the currently checked out branch to derive the entry changes, relative to a base branch, Invoke the command in the following manner when the package was installed globally:

> coscribe update base-branch-name

Or when it was installed locally

> ./node_modules/.bin/coscribe update base-branch-name

If you don't want to use the currently checked out branch to derive the entry changes, relative to a base branch, Invoke the command in the following manner when the package was installed globally:

> coscribe update base-branch-name target-branch

Or when it was installed locally

> ./node_modules/.bin/coscribe update base-branch-name target-branch

Dependencies

The following OS command line programs are required to run the commands:

  • git
  • tr
  • sort
  • grep
  • sed
  • awk

Environments

This package has been tested on the following software versions

| OS | node | git | sort | grep | sed | awk | tr | | --------------------- | ------- | ---------------------------------- | --------------- | --------------------------------------------- | --------------------- | -------------------- | --------------------- | | Mac OS Version 13.3.1 | v19.9.0 | git version 2.39.2 (Apple Git-143) | 2.3-Apple (154) | grep (BSD grep, GNU compatible) 2.6.0-FreeBSD | PROJECT:text_cmds-154 | awk version 20200816 | PROJECT:text_cmds-154 |

TODO

  • better validation throughout the process
  • Adapter for nodegit
  • More strategies to create file entries
  • testing