Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/transitive-bullshit/puppeteer-github

GitHub automation driven by headless chrome.
https://github.com/transitive-bullshit/puppeteer-github

automation github headless-chrome puppeteer

Last synced: 12 days ago
JSON representation

GitHub automation driven by headless chrome.

Awesome Lists containing this project

README

        

# puppeteer-github

> [GitHub](https://github.com) automation driven by headless chrome.

[![NPM](https://img.shields.io/npm/v/puppeteer-github.svg)](https://www.npmjs.com/package/puppeteer-github) [![Build Status](https://travis-ci.com/transitive-bullshit/puppeteer-github.svg?branch=master)](https://travis-ci.com/transitive-bullshit/puppeteer-github) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

This module also has a [CLI](https://github.com/transitive-bullshit/puppeteer-github-cli).

## Install

```bash
npm install --save puppeteer-github
```

## Usage

This example signs into a [GitHub](https://github.com) account.

```js
const PuppeteerGitHub = require('puppeteer-github')

const github = new PuppeteerGitHub()

await github.signin({ username: 'xxx', password: 'xxx' })
await github.starRepo('facebook/react')

await github.close()
```

## API

#### Table of Contents

- [PuppeteerGitHub](#puppeteergithub)
- [isAuthenticated](#isauthenticated)
- [user](#user)
- [browser](#browser)
- [signup](#signup)
- [signin](#signin)
- [signout](#signout)
- [verifyEmail](#verifyemail)
- [starPackage](#starpackage)
- [unstarPackage](#unstarpackage)
- [starRepo](#starrepo)
- [unstarRepo](#unstarrepo)
- [close](#close)

### [PuppeteerGitHub](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L20-L199)

[GitHub](https://github.com) automation driven by headless chrome.

Type: `function (opts)`

- `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options (optional, default `{}`)
- `opts.browser` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Puppeteer browser instance to use
- `opts.puppeteer` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Puppeteer [launch options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions)

* * *

#### [isAuthenticated](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L32-L32)

Whether or not this instance is authenticated with GitHub.

Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)

* * *

#### [user](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L39-L39)

Authenticated user if authenticated with GitHub.

Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

* * *

#### [browser](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L46-L52)

Puppeteer Browser instance to use.

Type: `function ()`

* * *

#### [signup](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L66-L77)

Automates the creation of a new GitHub account.

Type: `function (user, opts): Promise`

- `user` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** User details for new account
- `user.username` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Username
- `user.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Email
- `user.password` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Password
- `opts` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options (optional, default `{}`)
- `opts.verifyEmail` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not to verify email
- `opts.emailPassword` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Email password for verification

* * *

#### [signin](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L91-L98)

Signs into an existing GitHub account.

Note: either username or email is required.

Type: `function (user, opts): Promise`

- `user` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** User details for new account
- `user.username` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Username
- `user.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Email
- `user.password` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Password
- `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options (optional, default `{}`)

* * *

#### [signout](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L104-L111)

Signs out of the currently authenticated GitHub account.

Type: `function (): Promise`

* * *

#### [verifyEmail](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L121-L131)

Verifies the authenticated GitHub account's email via pupeteer-email.

Type: `function (opts): Promise`

- `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options
- `opts.emailPassword` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Email password for verification
- `opts.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Email verification (defaults to user's GitHub email)

* * *

#### [starPackage](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L145-L148)

Stars an npm package's github repository.

Type: `function (pkgName): Promise`

- `pkgName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** NPM package name

Example:

```javascript
const gh = new PuppeteerGitHub()
await gh.signin(...)
await gh.starPackage('react')
await gh.close()
```

* * *

#### [unstarPackage](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L156-L159)

Unstars an npm package's github repository.

Type: `function (pkgName): Promise`

- `pkgName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** NPM package name

* * *

#### [starRepo](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L174-L177)

Stars a github repository.

Type: `function (repo): Promise`

- `repo` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** GitHub repository identifier

Example:

```javascript
const gh = new PuppeteerGitHub()
await gh.signin(...)
await gh.starRepo('avajs/ava')
await gh.starRepo('https://github.com/facebook/react')
await gh.close()
```

* * *

#### [unstarRepo](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L185-L188)

Unstars a github repository.

Type: `function (repo): Promise`

- `repo` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** GitHub repository identifier

* * *

#### [close](https://github.com/transitive-bullshit/puppeteer-github/blob/26f3f7d2bf8f52fecd0024135c17fffd5251afe9/index.js#L195-L198)

Closes the underlying browser instance, effectively ending this session.

Type: `function (): Promise`

* * *

## Related

- [puppeteer-github-cli](https://github.com/transitive-bullshit/puppeteer-github-cli) - CLI for this module.
- [puppeteer-email](https://github.com/transitive-bullshit/puppeteer-email) - Email automation driven by headless chrome.
- [puppeteer](https://github.com/GoogleChrome/puppeteer) - Headless Chrome Node API.
- [awesome-puppeteer](https://github.com/transitive-bullshit/awesome-puppeteer) - Curated list of awesome puppeteer resources.

## License

MIT © [Travis Fischer](https://github.com/transitive-bullshit)

Support my OSS work by following me on twitter twitter