Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kgryte/github-create-issue
Create an issue on a GitHub repository.
https://github.com/kgryte/github-create-issue
Last synced: 25 days ago
JSON representation
Create an issue on a GitHub repository.
- Host: GitHub
- URL: https://github.com/kgryte/github-create-issue
- Owner: kgryte
- License: mit
- Created: 2016-03-21T06:45:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-09T22:31:16.000Z (almost 8 years ago)
- Last Synced: 2024-09-20T11:07:28.072Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 18
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Create Issue
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url]
> [Create][github-create-issue] an issue on a GitHub repository.
## Installation
``` bash
$ npm install github-create-issue
```## Usage
``` javascript
var createIssue = require( 'github-create-issue' );
```#### createIssue( slug, title, options, clbk )
[Creates][github-create-issue] an issue on a GitHub repository.
``` javascript
var opts = {
'token': 'tkjorjk34ek3nj4!'
};createIssue( 'kgryte/test-repo1', 'Big bug.', opts, clbk );
function clbk( error, issue, info ) {
// Check for rate limit information...
if ( info ) {
console.error( 'Limit: %d', info.limit );
console.error( 'Remaining: %d', info.remaining );
console.error( 'Reset: %s', (new Date( info.reset*1000 )).toISOString() );
}
if ( error ) {
throw new Error( error.message );
}
console.log( JSON.stringify( issue ) );
// returns
}
```The `function` accepts the following `options`:
* __token__: GitHub [access token][github-token] (*required*).
* __useragent__: [user agent][github-user-agent] `string`.
* __body__: issue content.
* __assignees__: GitHub usernames of assigned users.
* __milestone__: associated milestone `number`.
* __labels__: `array` of associated labels.To [authenticate][github-oauth2] with GitHub, set the [`token`][github-token] option.
``` javascript
var opts = {
'token': 'tkjorjk34ek3nj4!'
};createIssue( 'kgryte/test-repo1', 'Big bug.', opts, clbk );
```To specify a [user agent][github-user-agent], set the `useragent` option.
``` javascript
var opts = {
'token': 'tkjorjk34ek3nj4!',
'useragent': 'hello-github!'
};createIssue( 'kgryte/test-repo1', 'Big bug.', opts, clbk );
```## Notes
* [Rate limit][github-rate-limit] information includes the following:
- __limit__: maximum number of requests a consumer is permitted to make per hour.
- __remaining__: number of remaining requests.
- __reset__: time at which the current [rate limit][github-rate-limit] window resets in [UTC seconds][unix-time].---
## Examples
``` javascript
var opts = {
'token': 'tkjorjk34ek3nj4!',
'useragent': 'beep-boop-bop',
'body': 'Beep boop.'
};createIssue( 'kgryte/test-repo1', 'Big bug.', opts, clbk );
function clbk( error, issue, info ) {
if ( info ) {
console.error( info );
}
if ( error ) {
throw new Error( error.message );
}
console.log( issue );
}
```To run the example code from the top-level application directory,
``` bash
$ node ./examples/index.js
```__Note__: in order to run the example, you will need to obtain an access [token][github-token] with appropriate permissions and modify the `token` option accordingly.
---
## CLI
### Installation
To use the module as a general utility, install the module globally
``` bash
$ npm install -g github-create-issue
```### Usage
``` bash
Usage: ghcreateissue [options] slugOptions:
-h, --help Print this message.
-V, --version Print the package version.
--token token GitHub access token.
-ua, --useragent ua User agent.
--title title Issue title.
--body content Issue content.
--assignees user1,user2,... GitHub usernames of assigned users.
--milestone number Associated milestone number.
--labels label1,label2,... Issue labels.
```### Notes
* In addition to the [`token`][github-token] option, the [token][github-token] may also be specified by a [`GITHUB_TOKEN`][github-token] environment variable. The command-line option __always__ takes precedence.
* Issue information is written to `stdout`.
* [Rate limit][github-rate-limit] information is written to `stderr`.### Examples
Setting the access [token][github-token] using the command-line option:
``` bash
$ DEBUG=* ghcreateissue beep/boop --title 'Big bug.' --token
# => '{...}'
```Setting the access [token][github-token] using an environment variable:
``` bash
$ DEBUG=* GITHUB_TOKEN= ghcreateissue beep/boop --title 'Big bug.'
# => '{...}'
```For local installations, modify the command to point to the local installation directory; e.g.,
``` bash
$ DEBUG=* ./node_modules/.bin/ghcreateissue beep/boop --title 'Big bug.' --token
# => '{...}'
```Or, if you have cloned this repository and run `npm install`, modify the command to point to the executable; e.g.,
``` bash
$ DEBUG=* node ./bin/cli beep/boop --title 'Big bug.' --token
# => '{...}'
```---
## Tests
### Unit
This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory:
``` bash
$ make test
```All new feature development should have corresponding unit tests to validate correct functionality.
### Test Coverage
This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
``` bash
$ make test-cov
```Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,
``` bash
$ make view-cov
```### Browser Support
This repository uses [Testling][testling] for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
``` bash
$ make test-browsers
```To view the tests in a local web browser,
``` bash
$ make view-browser-tests
```---
## License
[MIT license](http://opensource.org/licenses/MIT).
## Copyright
Copyright © 2016. Athan Reines.
[npm-image]: http://img.shields.io/npm/v/github-create-issue.svg
[npm-url]: https://npmjs.org/package/github-create-issue[build-image]: http://img.shields.io/travis/kgryte/github-create-issue/master.svg
[build-url]: https://travis-ci.org/kgryte/github-create-issue[coverage-image]: https://img.shields.io/codecov/c/github/kgryte/github-create-issue/master.svg
[coverage-url]: https://codecov.io/github/kgryte/github-create-issue?branch=master[dependencies-image]: http://img.shields.io/david/kgryte/github-create-issue.svg
[dependencies-url]: https://david-dm.org/kgryte/github-create-issue[dev-dependencies-image]: http://img.shields.io/david/dev/kgryte/github-create-issue.svg
[dev-dependencies-url]: https://david-dm.org/dev/kgryte/github-create-issue[github-issues-image]: http://img.shields.io/github/issues/kgryte/github-create-issue.svg
[github-issues-url]: https://github.com/kgryte/github-create-issue/issues[tape]: https://github.com/substack/tape
[istanbul]: https://github.com/gotwarlost/istanbul
[testling]: https://ci.testling.com[unix-time]: http://en.wikipedia.org/wiki/Unix_time
[github-api]: https://developer.github.com/v3/
[github-token]: https://github.com/settings/tokens/new
[github-oauth2]: https://developer.github.com/v3/#oauth2-token-sent-in-a-header
[github-user-agent]: https://developer.github.com/v3/#user-agent-required
[github-rate-limit]: https://developer.github.com/v3/rate_limit/
[github-create-issue]: https://developer.github.com/v3/issues/#create-an-issue