Skip to content

Commit

Permalink
Merge pull request #146 from cutenode/bnb/libgfi-refactor
Browse files Browse the repository at this point in the history
Refactor to use libgfi
  • Loading branch information
bnb authored Aug 21, 2019
2 parents 792c833 + f52431a commit 6e09359
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 574 deletions.
51 changes: 11 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
<h3 align="center">Good First Issue</h3>
# Good First Issue

[![Shields.io badge for the latest version of good-first-issue](https://img.shields.io/npm/v/good-first-issue/latest.svg)](https://www.npmjs.com/package/good-first-issue)
![[Greenkeeper badge](https://badges.greenkeeper.io/cutenode/good-first-issue.svg)](https://greenkeeper.io/)
A CLI for finding issues labeled with Good First Issue to help lower the barrier to contributing to open source projects.

<p align="center">
A CLI for finding issues labeled with Good First Issue to help lower the barrier to contributing to open source projects.
<br>
<a href="#usage">Usage</a> •
<a href="#projects">Projects</a> •
<a href="#contributing">Contributing</a>
</p>

<p align="center">
<a href="https://www.npmjs.com/package/good-first-issue"><img src="https://img.shields.io/npm/v/good-first-issue/latest.svg"></a>
<a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/cutenode/good-first-issue.svg"></a>
</p>

</p>
## Table of Contents

## Prerequisites

Expand All @@ -29,9 +19,7 @@ To use Good First Issue, you'll need to have a few things installed:

## Usage

### As a CLI

This module can be used as an interactive CLI.
This module is an interactive CLI. If you're looking for a module to use in an application, check out [libgfi](https://www.npmjs.com/package/libgfi).

### Installation

Expand Down Expand Up @@ -60,33 +48,16 @@ good-first issue # call the CLI
- `-o, --open` - open in browser
- `-f, --first` - Return first/top issue

### As Module

```js
const goodFirstIssue = require('good-first-issue')

let log = async () => {
let issues = await goodFirstIssue('node')
issues.forEach(function (issue) {
console.log('#' + issue.pr + ': ' + issue.title)
})
}

log()
```

#### Examples

Good First Issue has an [examples/](./examples) directory, in which we try to maintain various examples of how Good First Issue can be used as a module. If you'd like to contribute to the examples, please don't hesitate to submit a PR! 🤗

## TODOs: What's coming up next

`good-first-issue` is still in an early state. I wanted to get `good-first-issue node` out the door, but have some other things I'm planning on implementing. Here's a list:

- [x] `good-first-issue node` command
- [x] Interactive selector when `good-first-issue` is run without a sub command
- [ ] Export Good First Issues for all repos that have a command
- [ ] Add tests
- [ ] Add additional useful commands
- [ ] Explore adding a secondary selector that shows paginated results from GitHub, allowing the user to select which Good First Issue to pick rather than returning a random one
- [ ] Improve `Feeling Lucky` to be better about picking a random issue
- [ ] Add more tests

If you'd like to help with any of these, feel free to submit a PR or ask how you can help 🤗

Expand Down Expand Up @@ -156,7 +127,7 @@ The table of projects which are _currently_ supported.
If you'd like to add a new project to `good-first-issue`, you're more than welcome to submit a PR! There are a few components you'll need to submit:

- Update `data/projects.json`
- Add your `<project>` as a property of `projects` with an object that includes a `name`, `description`, and a `q` (representing the GitHub search query).
- Add your `<project>` as a property of `projects` **in the correct alphabetical position** with an object that includes a `name`, `description`, and a `q` (representing the GitHub search query).

- Update `README.md` by running `npm run markdown`
- This will automatically update README.md with the new project's data.
Expand Down
30 changes: 16 additions & 14 deletions bin/good-first-issue.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env node

var cli = require('commander')
var chalk = require('chalk')
var opn = require('open')

var pJson = require('../package.json')
const cli = require('commander')
const chalk = require('chalk')
const opn = require('open')
const gfi = require('libgfi')

const packageJSON = require('../package.json')
const log = require('../lib/log')
const prompt = require('../lib/prompt')
const projects = require('../data/projects.json')
const goodFirstIssue = require('..')

const prompt = require('./prompt')
const options = { // options for libgfi
projects
}

cli
.version(pJson.version, '-v, --version')
.description(pJson.description)
.version(packageJSON.version, '-v, --version')
.description(packageJSON.description)
.arguments('[project]')
.option('-o, --open', 'Open in browser')
.option('-f, --first', 'Return first/top issue')
Expand All @@ -27,11 +29,11 @@ cli
}

try {
const issues = await goodFirstIssue(input)
const issues = await gfi(input, options)

if (issues.length === 0) {
console.log(chalk.yellow(`\nNo Good First Issues were found for the GitHub organization, repo, or project ${chalk.white(input)}.\n`))
process.exit(0)
process.exitCode = 0
return console.log(chalk.yellow(`\nNo Good First Issues were found for the GitHub organization, repo, or project ${chalk.white(input)}.\n`))
}

const key = cmd.first ? 0 : Math.floor(Math.random() * Math.floor(issues.length - 1))
Expand All @@ -44,11 +46,11 @@ cli

if (cmd.open) {
opn(issues[key].url)
process.exit(0)
process.exitCode = 0
}
} catch (err) {
console.error(err)
process.exit(1)
process.exitCode = 1
}
})
.parse(process.argv)
10 changes: 0 additions & 10 deletions data/gfiLabelAliases.json

This file was deleted.

10 changes: 0 additions & 10 deletions examples/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions examples/github.js

This file was deleted.

11 changes: 0 additions & 11 deletions examples/node.js

This file was deleted.

11 changes: 0 additions & 11 deletions index.js

This file was deleted.

File renamed without changes.
78 changes: 0 additions & 78 deletions lib/search.js

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@
"Dhruv Jain <[email protected]> (https://maddhruv.github.io)"
],
"dependencies": {
"@octokit/rest": "^16.0.1",
"boxen": "^3.0.0",
"chalk": "^2.4.1",
"commander": "^2.19.0",
"inquirer": "^6.2.0",
"libgfi": "^1.0.2",
"open": "^6.4.0"
},
"devDependencies": {
"jest": "^23.6.0",
"markdown-magic": "^0.1.25",
"nock": "^10.0.4",
"strip-ansi": "^5.0.0",
"standard": "^13.1.0"
}
Expand Down
83 changes: 0 additions & 83 deletions tests/index.spec.js

This file was deleted.

Loading

0 comments on commit 6e09359

Please sign in to comment.