Skip to content

Commit

Permalink
feat: Add CHANGELOG handling by default via conventional-changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
misteroneill committed May 16, 2017
1 parent 678aca9 commit c53b6cb
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Folder/Filename | Optional? | Generated? | Description
`.editorconfig` | | ✓ |
`.gitignore` | | ✓ |
`.npmignore` | | ✓ |
`CHANGELOG.md` | ✓ | ? |
`CHANGELOG.md` | ✓ | |
`CONTRIBUTING.md` | ✓ | ✓ | Documents how developers can work on the plugin.
`index.html` | ✓ | ✓ | An example of usage of the plugin. This can be used with GitHub pages as well.
`LICENSE` | ✓ | ? | Defaults to `MIT`.
Expand Down
1 change: 0 additions & 1 deletion generators/app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports = {
LICENSE_DEFAULT,

PROMPT_DEFAULTS: {
changelog: true,
docs: false,
husky: 'lint',
lang: false,
Expand Down
9 changes: 0 additions & 9 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ module.exports = yeoman.generators.Base.extend({
message: 'Choose a license for your project',
default: defaults.license,
choices: constants.LICENSE_CHOICES
}, {
type: 'confirm',
name: 'changelog',
message: 'Do you want to include CHANGELOG tool?',
default: defaults.changelog
}, {
type: 'confirm',
name: 'sass',
Expand Down Expand Up @@ -307,10 +302,6 @@ module.exports = yeoman.generators.Base.extend({
* @function changelog
*/
changelog() {
if (!this.context.changelog) {
return;
}

try {
fs.statSync(this._dest('CHANGELOG.md'));
} catch (x) {
Expand Down
4 changes: 4 additions & 0 deletions generators/app/package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const DEFAULTS = {
'babel-plugin-transform-object-assign': '^6.8.0',
'babel-preset-es2015': '^6.14.0',
'bannerize': '^1.0.2',
'conventional-changelog-cli': '^1.3.1',
'conventional-changelog-videojs': '^3.0.0',
'karma': '^1.7.0',
'karma-chrome-launcher': '^2.1.1',
'karma-detect-browsers': '^2.2.5',
Expand All @@ -33,6 +35,7 @@ const DEFAULTS = {
'rollup-plugin-node-resolve': '^3.0.0',
'rollup-plugin-replace': '^1.1.1',
'rollup-watch': '^3.2.2',
'semver': '^5.3.0',
'sinon': '^2.2.0',
'uglify-js': '^3.0.7',
'videojs-standard': '^6.0.0'
Expand Down Expand Up @@ -177,6 +180,7 @@ const packageJSON = (current, context) => {
'pretest': 'npm-run-all lint build',
'test': 'karma start test/karma.conf.js',
'preversion': 'npm test',
'version': 'node scripts/version.js',
'watch': 'npm-run-all -p watch:*',
'watch:js': 'rollup -c scripts/build.rollup.config.js -w',
'watch:test': 'rollup -c scripts/test.rollup.config.js -w'
Expand Down
10 changes: 10 additions & 0 deletions generators/app/templates/scripts/_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const execSync = require('child_process').execSync;
const path = require('path');
const semver = require('semver');
const pkg = require('../package.json');

if (!semver.prerelease(pkg.version)) {
process.chdir(path.resolve(__dirname, '..'));
execSync('conventional-changelog -p videojs -i CHANGELOG.md -s');
execSync('git add CHANGELOG.md');
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "generator-videojs-plugin",
"version": "2.3.0",
"description": "A Yeoman generator for VideoJS plugins",
"description": "A Yeoman generator for Video.js plugins",
"license": "Apache-2.0",
"main": "generators/app/index.js",
"engine": {
"node": ">=4.4.0"
"node": ">=4.8.0"
},
"bin": {
"vjsgenclean": "bin/videojs-generator-cleanup.js"
Expand All @@ -29,7 +29,7 @@
"prepush": "npm run lint -- --errors",
"pretest": "npm run lint",
"test": "mocha test/*.test.js",
"version": "conventional-changelog -p videojs -i CHANGELOG.md -s && git add CHANGELOG.md"
"version": "node scripts/version.js"
},
"keywords": [
"yeoman-generator",
Expand Down
10 changes: 10 additions & 0 deletions scripts/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const execSync = require('child_process').execSync;
const path = require('path');
const semver = require('semver');
const pkg = require('../package.json');

if (!semver.prerelease(pkg.version)) {
process.chdir(path.resolve(__dirname, '..'));
execSync('conventional-changelog -p videojs -i CHANGELOG.md -s');
execSync('git add CHANGELOG.md');
}
4 changes: 3 additions & 1 deletion test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ describe('videojs-plugin:app', function() {
'lint',
'start',
'test',
'preversion'
'preversion',
'version',
'watch'
];

describe('defaults', function() {
Expand Down

0 comments on commit c53b6cb

Please sign in to comment.