# Gren

Class creating release notes and changelog notes

## Constructor

#### new Gren()

Source:
  - Gren.js, line 30

### Methods

#### (private) _checkChangelogFile() → {string}

Check if the changelog file exists

Since:
  - 0.8.0
Source:
  - Gren.js, line 126

##### Returns:

Type:
  `string`

#### (private) _createChangelog(body)

Create the changelog file

Since:
  - 0.8.0
Source:
  - Gren.js, line 144

##### Parameters:

Name | Type | Description
--- | --- | ---
`body` | `string` | The body of the file

#### (async, private) _createRelease(releaseOptions) → {Promise}

Create a release from a given tag (in the options)

Since:
  - 0.1.0
Source:
  - Gren.js, line 200

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseOptions` | `Object` | The options to build the release:

##### Returns:

Type:
  `Promise`

##### Example

    {
      "tag_name": "1.0.0",
      "target_commitish": "master",
      "name": "v1.0.0",
      "body": "Description of the release",
      "draft": false,
      "prerelease": false
    }

#### (private) _createReleaseRanges(releaseDates) → {Array}

Create the ranges of release dates

Since:
  - 0.5.0
Source:
  - Gren.js, line 978

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseDates` | `Array` | The release dates

##### Returns:

Type:
  `Array`

#### (async, private) _editRelease(releaseId, releaseOptions) → {Promise}

Edit a release from a given tag (in the options)

Since:
  - 0.5.0
Source:
  - Gren.js, line 173

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseId` | `number` | The id of the release to edit
`releaseOptions` | `Object` | The options to build the release:

##### Returns:

Type:
  `Promise`

##### Example

    {
      "tag_name": "v1.0.0",
      "target_commitish": "master",
      "name": "v1.0.0",
      "body": "Description of the release",
      "draft": false,
      "prerelease": false
    }

#### (private) _filterBlockIssue(range, issue) → {Boolean}

Filter the issue based on the date range, or if is in the release milestone.

Since:
  - 0.9.0
Source:
  - Gren.js, line 856

##### Parameters:

Name | Type | Description
--- | --- | ---
`range` | `Array` | The release ranges
`issue` | `Object` | GitHub issue

##### Returns:

Type:
  `Boolean`

#### (private) _filterBlockPullRequest(range, pullRequest) → {Boolean}

Filter the pull requests in case the release is milestone, or otherwise by dates range.

Source:
  - Gren.js, line 879

##### Parameters:

Name | Type | Description
--- | --- | ---
`range` | `Array` | The release ranges
`pullRequest` | `Object` | GitHub pull request

##### Returns:

Type:
  `Boolean`

#### (private) _filterCommit(commit) → {Boolean}

Filter a commit based on the includeMessages option and commit message

Since:
  - 0.10.0
Source:
  - Gren.js, line 579

##### Parameters:

Name | Type | Description
--- | --- | ---
`commit` | `Object` |

##### Returns:

Type:
  `Boolean`

#### (private) _filterIssue(issue) → {Boolean}

Filter the issue based on gren options and labels

Since:
  - 0.9.0
Source:
  - Gren.js, line 825

##### Parameters:

Name | Type | Description
--- | --- | ---
`issue` | `Object` |

##### Returns:

Type:
  `Boolean`

#### (private) _filterPullRequest(pullRequest) → {Boolean}

Filter the pull request based on gren options and labels

Source:
  - Gren.js, line 840

##### Parameters:

Name | Type | Description
--- | --- | ---
`pullRequest` | `Object` |

##### Returns:

Type:
  `Boolean`

#### (private) _generateCommitsBody(commits) → {string}

Return a commit messages generated body

Since:
  - 0.1.0
Source:
  - Gren.js, line 608

##### Parameters:

Name | Type | Description
--- | --- | ---
`commits` | `Array` |

##### Returns:

Type:
  `string`

#### (async, private) _getClosedIssues(releaseRanges) → {Promise}

Get all the closed issues from the current repo

Since:
  - 0.5.0
Source:
  - Gren.js, line 715

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseRanges` | `Array` | The array of date ranges

##### Returns:

Type:
  `Promise`

The promise which resolves the list of the issues

#### (async, private) _getCommitBlocks(releaseRanges) → {Array.<Promise>}

Get the blocks of commits based on release dates

Since:
  - 0.5.0
Source:
  - Gren.js, line 655

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseRanges` | `Array` | The array of date ranges

##### Returns:

Type:
  `Array.<Promise>`

#### (async, private) _getCommitsBetweenTwo(since, until) → {Promise}

Gets all the commits between two dates

Since:
  - 0.1.0
Source:
  - Gren.js, line 633

##### Parameters:

Name | Type | Description
--- | --- | ---
`since` | `string` | The since date in ISO
`until` | `string` | The until date in ISO

##### Returns:

Type:
  `Promise`

The promise which resolves the [Array] commit messages

#### (async, private) _getIssueBlocks(releaseRanges) → {Array.<Promise>}

Get the blocks of issues based on release dates

Since:
  - 0.5.0
Source:
  - Gren.js, line 901

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseRanges` | `Array` | The array of date ranges

##### Returns:

Type:
  `Array.<Promise>`

#### (private) _getLastPage(link) → {boolean|number}

Get the last page from a Hypermedia link

Since:
  - 0.11.1
Source:
  - Gren.js, line 404

##### Parameters:

Name | Type | Description
--- | --- | ---
`link` | `string` |

##### Returns:

Type:
  `boolean` | `number`

#### (async, private) _getLastTags(releases, page) → {Promise}

Get all the tags of the repo

Since:
  - 0.1.0
Source:
  - Gren.js, line 299

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`releases` | `Array` |  |
`page` | `number` | 1 |

##### Returns:

Type:
  `Promise`

#### (async, private) _getListReleases() → {Promise}

Get all releases

Since:
  - 0.5.0
Source:
  - Gren.js, line 418

##### Returns:

Type:
  `Promise`

The promise which resolves an array of releases

#### (async, private) _getMergedPullRequests(page, limit) → {Array.<Promise>}

Get the merged pull requests from the repo

Source:
  - Gren.js, line 374

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`page` | `number` | 1 |
`limit` | `number` | 1000 |

##### Returns:

Type:
  `Array.<Promise>`

The promises which returns pull requests

#### (async, private) _getPullRequestsBlocks(releaseRanges) → {Array.<Promise>}

Get the blocks of pull requests based on the release dates

Source:
  - Gren.js, line 929

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseRanges` | `Array` | The array of date ranges

##### Returns:

Type:
  `Array.<Promise>`

#### (async) _getReleaseBlocks() → {Promise}

Generate release blocks based on issues or commit messages depending on the option.

Source:
  - Gren.js, line 1003

##### Returns:

Type:
  `Promise`

Resolving the release blocks

#### (private) _getSelectedTags(allTags, tags) → {Boolean|Array}

Get the tags information from the given ones, and adds the next one in case only one is given

Since:
  - 0.5.0
Source:
  - Gren.js, line 253

##### Parameters:

Name | Type | Description
--- | --- | ---
`allTags` | `Array` | `string` |
`tags` | `Array.<Object>` |

##### Returns:

Type:
  `Boolean` | `Array`

#### (private) _getTagDates(tags) → {Array.<Promise>}

Get the dates of the last two tags

Since:
  - 0.1.0
Source:
  - Gren.js, line 340

##### Parameters:

Name | Type | Description
--- | --- | ---
`tags` | `Array.<Object>` | List of all the tags in the repo

##### Returns:

Type:
  `Array.<Promise>`

The promises which returns the dates

#### (private) _groupBy(issues) → {Array}

Create groups of issues based on labels

Since:
  - 0.8.0
Source:
  - Gren.js, line 775

##### Parameters:

Name | Type | Description
--- | --- | ---
`issues` | `Array` | The array of all the issues.

##### Returns:

Type:
  `Array`

#### (private) _groupByLabel(issues) → {string}

Group the issues based on their first label

Since:
  - 0.8.0
Source:
  - Gren.js, line 741

##### Parameters:

Name | Type | Description
--- | --- | ---
`issues` | `Array` |

##### Returns:

Type:
  `string`

#### (private) _hasNetwork() → {Promise}

Check if there is connectivity

Since:
  - 0.5.0
Source:
  - Gren.js, line 1055

##### Returns:

Type:
  `Promise`

#### (private) _lablesAreIgnored(labels) → {boolean}

Compare the ignored labels with the passed ones

Since:
  - 0.10.0
Source:
  - Gren.js, line 695

##### Parameters:

Name | Type | Description
--- | --- | ---
`labels` | `Array` | The labels to check

##### Returns:

Type:
  `boolean`

If the labels array contains any of the ignore ones

##### Example

    [{
        name: 'bug'
    }]

#### _listReleases(options) → {Promise}

Temporary function for this.repo.listReleases to accept options

Source:
  - Gren.js, line 360
See:
  - https://github.com/github-tools/github/pull/485

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | `Object` |

##### Returns:

Type:
  `Promise`

#### _listTags(options) → {Promise}

Temporary function for this.repo.listReleases to accept options

Source:
  - Gren.js, line 284
See:
  - https://github.com/github-tools/github/pull/485

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | `Object` |

##### Returns:

Type:
  `Promise`

#### _outputOptions(options)

Output the options in the terminal in a formatted way

Source:
  - Gren.js, line 1072

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | `Object` |

#### (private) _prepareRelease(tags) → {Promise}

Creates the options to make the release

Since:
  - 0.2.0
Source:
  - Gren.js, line 219

##### Parameters:

Name | Type | Description
--- | --- | ---
`tags` | `Array.<Object>` | The collection of tags

##### Returns:

Type:
  `Promise`

#### (private) _sortReleasesByDate(releaseDates) → {Array}

Sort releases by dates

Since:
  - 0.5.0
Source:
  - Gren.js, line 964

##### Parameters:

Name | Type | Description
--- | --- | ---
`releaseDates` | `Array` |

##### Returns:

Type:
  `Array`

#### (private) _templateBody(blocks) → {string}

Generate the Changelog issues body template

Since:
  - 0.5.0
Source:
  - Gren.js, line 533

##### Parameters:

Name | Type | Description
--- | --- | ---
`blocks` | `Array.<Object>` |

##### Returns:

Type:
  `string`

#### (private) _templateCommits(commit) → {string}

Return the templated commit message

Since:
  - 0.1.0
Source:
  - Gren.js, line 468

##### Parameters:

Name | Type | Description
--- | --- | ---
`commit` | `Object` |

##### Returns:

Type:
  `string`

#### (private) _templateGroups(groups) → {string}

Generates the template for the groups

Since:
  - 0.8.0
Source:
  - Gren.js, line 558

##### Parameters:

Name | Type | Description
--- | --- | ---
`groups` | `Object` | The groups to template e.g. { 'bugs': [{...}, {...}, {...}] }

##### Returns:

Type:
  `string`

#### (private) _templateIssue(issue) → {string}

Generate the MD template for each issue

Since:
  - 0.5.0
Source:
  - Gren.js, line 511

##### Parameters:

Name | Type | Description
--- | --- | ---
`issue` | `Object` |

##### Returns:

Type:
  `string`

#### (private) _templateLabels(issue) → {string}

Generate the MD template from all the labels of a specific issue

Since:
  - 0.5.0
Source:
  - Gren.js, line 487

##### Parameters:

Name | Type | Description
--- | --- | ---
`issue` | `Object` |

##### Returns:

Type:
  `string`

#### _validateRequiredTagsExists(tags, requireTags)

Check that the require tags are exists in tags

Source:
  - Gren.js, line 1034

##### Parameters:

Name | Type | Description
--- | --- | ---
`tags` | `Array` |
`requireTags` | `Array` |

#### (async) changelog() → {Promise}

Generate changelog file based on the release notes or generate new one

Since:
  - 0.10.0
Source:
  - Gren.js, line 103

##### Returns:

Type:
  `Promise`

#### (async) release() → {Promise}

Generate release notes and draft a new release

Since:
  - 0.10.0
Source:
  - Gren.js, line 86

##### Returns:

Type:
  `Promise`