Skip to content

Commit

Permalink
feat: Initial commit 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Aug 15, 2017
0 parents commit 02b8b1e
Show file tree
Hide file tree
Showing 11 changed files with 10,219 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
extends: [
'@metahub/eslint-config/es6-config',
'@metahub/eslint-config/node-config',
'@metahub/eslint-config/promise-config',
'@metahub/eslint-config/ava-config',
'@metahub/eslint-config/prettier-config',
],
parserOptions: {sourceType: 'module'},
};
128 changes: 128 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@

# Created by https://www.gitignore.io/api/macos,windows,linux,node

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/macos,windows,linux,node
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: node_js
node_js:
- 8
cache:
directories:
- node_modules
branches:
only:
- master
- /^greenkeeper.*$/
git:
depth: 3
before_install:
- npm install -g greenkeeper-lockfile@1
before_script:
- npm prune
- greenkeeper-lockfile-update
script:
- npm run test
after_script:
- greenkeeper-lockfile-upload
after_success:
- if [ -n "${CODECOV_TOKEN:-}" ]; then npm run codecov; fi
- npm run semantic-release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Pierre-Denis Vanduynslager

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# **sr-release-notes-generator**

Customizable release-notes-generator plugin for [semantic-release](https://github.com/semantic-release/semantic-release) based on [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog)

[![npm](https://img.shields.io/npm/v/sr-release-notes-generator.svg)](https://www.npmjs.com/package/sr-release-notes-generator)
[![npm](https://img.shields.io/npm/dt/sr-release-notes-generator.svg)](https://www.npmjs.com/package/sr-release-notes-generator)
[![Greenkeeper badge](https://badges.greenkeeper.io/vanduynslagerp/sr-release-notes-generator.svg)](https://greenkeeper.io/)
[![license](https://img.shields.io/github/license/vanduynslagerp/sr-release-notes-generator.svg)](https://github.com/vanduynslagerp/sr-release-notes-generator/blob/master/LICENSE)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

[![Travis](https://img.shields.io/travis/vanduynslagerp/sr-release-notes-generator.svg)](https://travis-ci.org/vanduynslagerp/sr-release-notes-generator)
[![Codecov](https://img.shields.io/codecov/c/github/vanduynslagerp/sr-release-notes-generator.svg)](https://codecov.io/gh/vanduynslagerp/sr-release-notes-generator)

## Install
```bash
npm install --save-dev semantic-release sr-release-notes-generator
```

Set the `generateNotes` plugin for `semantic-release` in `package.json`. See [semantic-release plugins](https://github.com/semantic-release/semantic-release#plugins).
```json
{
"release": {
"generateNotes": {
"path": "sr-release-notes-generator",
"preset": "angular"
}
}
}
```

## Options

| Option | Description | Default |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `preset` | [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset (Possible values: `angular`, `atom`, `codemirror`, `ember`, `eslint`, `express`, `jquery`, `jscs`, `jshint`) | `angular` |
| `config` | NPM package name of a custom [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset | - |

**NOTE:** `options.config` will be overwritten by the values of preset. You should use either `preset` or `config`, but not both.
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-angular']};
50 changes: 50 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const SemanticReleaseError = require('@semantic-release/error');
const conventionalChangelog = require('conventional-changelog-core');
const conventionalChangelogAngular = require('conventional-changelog-angular');

/**
* @callback releaseNotesGeneratorCallback
* @param {Error} error error object
* @param {string} changelog changelog generated by the plugin
*/

/**
* Generate the changelog for all the commits since the last release.
*
* @param {Object} pluginConfig semantic-release configuration
* @param {Object} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint')
* @param {Object} pluginConfig.config requierable npm package with a custom conventional-changelog preset
* @param {Object} options semantic-release options
* @param {releaseNotesGeneratorCallback} callback The callback that handles the release note generation.
*/
module.exports = (pluginConfig, options, callback) => {
const cb = typeof options === 'function' ? options : callback;
let content = '';

if (pluginConfig.preset) {
try {
pluginConfig.config = require(`conventional-changelog-${pluginConfig.preset.toLowerCase()}`);
} catch (err) {
cb(new SemanticReleaseError(`Preset: "${pluginConfig.preset}" does not exist: ${err.message}`, err.code));
}
} else if (pluginConfig.config) {
try {
pluginConfig.config = require(pluginConfig.config);
} catch (err) {
cb(new SemanticReleaseError(`Config: "${pluginConfig.config}" does not exist: ${err.message}`, err.code));
}
} else {
pluginConfig.config = conventionalChangelogAngular;
}

conventionalChangelog(pluginConfig)
.on('error', err => {
cb(new SemanticReleaseError(`Error in conventional-changelog: ${err.message}`, err.code));
})
.on('data', buffer => {
content += buffer.toString();
})
.on('end', () => {
cb(null, content.trim());
});
};
Loading

0 comments on commit 02b8b1e

Please sign in to comment.