open-index/open-npm huggingface dataset:
npm package: @github-automations/bot-config-utils
Description: Utilities for github bot config
Author: Takashi Matsuo
Latest version: 1.0.0

# bot-config-utils

This is a small library for handling bot config file.

## Install

```bash
npm i @github-automations/bot-config-utils
```

## Get the config

This library supports yaml config file. You provide an config
interface. The code assumes we're in the probot handler.

```typescript
import {
  getConfig,
} from '@github-automations/bot-config-utils';

interface Config {
  myConfig: string;
}
const CONFIG_FILENAME = 'mybot.yaml';
const {owner, repo} = context.repo();
const config = await getConfig<Config>(
  context.octokit,
  owner,
  repo,
  CONFIG_FILENAME);
// config can be null.
```

## Provide the default value

You can use a similar method that supports default value.

```typescript
import {
  getConfigWithDefault,
} from '@github-automations/bot-config-utils';

interface Config {
  myConfig: string;
}

const defaultConfig: Config = {'myConfig': 'myValue'};

const CONFIG_FILENAME = 'mybot.yaml';
const {owner, repo} = context.repo();
const config = await getConfigWithDefault<Config>(
  context.octokit,
  owner,
  repo,
  CONFIG_FILENAME,
  defaultConfig);
// config is always a Config object.
```

## Check config schema on PRs

To use this feature, the bot needs to have some permissions.

You have to add the following permissions:
- Pull Request Read/Write
- Checks Read/Write

You also have to subscribe to Pull Request events.

You also need to provide a schema definition. Here is an example definition:

```json
// config-schema.json
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "flakybot config",
    "description": "Schema for flakybot configuration",
    "additionalProperties": false,
    "properties": {
	    "issuePriority": {
	        "description": "The default priority for flakybot issues",
	        "type": "string",
	    }
    }
}
```

Here is a sample handler(this assumes you're developping a Probot app):
```typescript
import {ConfigChecker} from '@github-automations/bot-config-utils';
import schema from './config-schema.json';

// ...

  app.on(
    [
      'pull_request.opened',
      'pull_request.reopened',
      'pull_request.edited',
      'pull_request.synchronize',
    ],
    async context => {
      const configChecker = new ConfigChecker<Config>(schema, CONFIG_FILENAME);
      const {owner, repo} = context.repo();
      await configChecker.validateConfigChanges(
        context.octokit,
        owner,
        repo,
        context.payload.pull_request.head.sha,
        context.payload.pull_request.number
      );
    }
  );
```

`validateConfigChanges` will check the config file format against the
schema you provided. It will submit a failing status check if:

- You are trying to add a wrong config file (currently it only checks
  `yaml` vs `yml`).
- You are trying to add a broken config file, or the config file
  doesn't match the schema.
npm package: @github-automations/datastore-lock
Description: Distributed lock backed by Google Cloud Datastore
Author: Takashi Matsuo
Latest version: 1.0.0

# A distributed lock

This is a simple lock library backed by Google Cloud Datastore.

Github bots can have multiple instances and sometimes those instances
are modifying the same target (issue, pull request, etc). This simple
library allows the bot to acquire a lock on sth.

## Usage

### Install

```bash
npm i @github-automations/datastore-lock
```

### Usage

```typescript
import {DatastoreLock} from '@github-automations/datastore-lock';

// Most of the cases, you can just pass `lockId` and `target`.
// `lockId` is usually the bot name.
// `target` is the target for the lock.

const lockId = 'blunderbuss';
const target = context.payload.pull_request.url;

const lock = new DatastoreLock(lockId, target);
const result = await lock.acquire();
if (!result) {
	// failure
}
// Do your stuff, and release the lock after you've done.
result = await lock.release();
// The lock will become stale after 20 seconds.
// You can pass the 3rd argument for longer expiry, up to 60 seconds.
const lock2 = new DatastoreLock(lockId, target, 60 * 1000);
```
npm package: @github-did/cli
Description: GitHub DID
Author: Orie Steele
Latest version: 0.0.5

# @github-did/cli

A command line interface for working with Github DIDs.

## Getting Started

- Go to [Github.com](https://github.com/new) and create a new public repo called `did`.
- When complete, you should end on a page like https://github.com/USERNAME/ghdid.

Next, you will need to install the cli to complete creating your GitHub DID.

```
npm i -g @github-did/cli
ghdid init "my-password" https://github.com/USERNAME/ghdid
```

If you mess up, you can overwrite everything with:

```
ghdid init "my-password" https://github.com/USERNAME/ghdid --force
```

Don't worry about this, its all experimental for now (which means be careful!).

This will clone the repo into `~/.github-did/${repo}`. Your wallet will be created, encrypted and stored:

`~/.github-did/wallet.enc` and `~/.github-did/web.wallet.enc`

Your DID Document will be:

`~/.github-did/${repo}/index.jsonld`;

It will be commited and push automatically by `init`.

Now that your `DID Document` is on Github in the correct repo, you can use the `github` did method resolver, and linked data signature verification libraries.

```
ghdid resolve did:github:OR13
```

This will resolve the DID to a DID Document by using Github and https.

The signature for the DID Document will be checked.