Skip to content

Massive Refactor 🤠 #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 56 additions & 26 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
{
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "module",
"ecmaFeatures": {
"impliedStrict": true
},
"allowImportExportEverywhere": false
},

"extends": [
"standard"
],

"rules": {
"semi": [2, "always"],
"no-empty": 2,
"array-callback-return": 2,
"indent": [2, 4, { "SwitchCase": 1 }],
"space-before-function-paren": [2, "never"],
"no-debugger": 0
}
}
parser: babel-eslint
env:
es6: true
parserOptions:
ecmaVersion: 6
sourceType: module
ecmaFeatures:
impliedStrict: true
allowImportExportEverywhere: false
plugins:
- babel
extends:
- semistandard
rules:
no-undef: 1
no-unreachable: 1
no-empty: error
array-callback-return: error
no-var: error
indent:
- error
- 4
-
SwitchCase: 1
space-before-function-paren:
- error
- never
no-debugger: 0
prefer-const: error
strict: error
no-template-curly-in-string: error
consistent-return: error
no-multiple-empty-lines:
- error
-
max: 1
maxBOF: 0
no-lonely-if: error
new-parens: error
eol-last: error
no-array-constructor: error
arrow-body-style:
- error
- as-needed
prefer-arrow-callback:
- error
-
allowNamedFunctions: true
prefer-destructuring:
- error
-
object: true
array: false
prefer-spread: error
prefer-rest-params: error
valid-typeof: 0
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules/
npm-debug.log
docs/_site
docs/.sass-cache
dist
bin
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
lib/
docs/
node_modules/
Gruntfile.js
gulpfile.js
.grenrc
.grenrc.*
.jsdoc.conf.json
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cache:
- node_modules

before_install:
- npm install -g grunt-cli
- npm install -g gulp-cli

script:
- grunt test
- gulp test
23 changes: 0 additions & 23 deletions Gruntfile.js

This file was deleted.

30 changes: 29 additions & 1 deletion bin/gren.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
#!/usr/bin/env node
'use strict';

require('../github-release-notes');
var _commander = require('commander');

var _commander2 = _interopRequireDefault(_commander);

var _package = require('../package.json');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var argvWithVersion = function argvWithVersion(argvs) {
var vPos = argvs.indexOf('-v');

if (vPos > -1) {
argvs[vPos] = '-V';
}

return argvs;
};

_commander2.default.version(_package.version).description(_package.description).usage('[command] [options]').command('release', 'Release into chunk').alias('r').command('changelog', 'Write a motherfucking changelog').alias('c').on('--help', function () {
// Get help from markdown or json instead.
console.log('');
console.log(' Examples:');
console.log('');
console.log(' $ gren release');
console.log('');
console.log(' $ gren help release');
console.log('');
}).parse(argvWithVersion(process.argv));
67 changes: 67 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const eslint = require('gulp-eslint');
const watch = require('gulp-watch');
const sass = require('gulp-sass');
const gulpIf = require('gulp-if');
const ghPages = require('gulp-gh-pages');
const babel = require('gulp-babel');
const chmod = require('gulp-chmod');
const nodeunit = require('gulp-nodeunit');

gulp.task('deploy', ['build'], function() {
return gulp.src('./docs/**/*')
.pipe(ghPages());
});

gulp.task('scripts', () => {
gulp.src('./lib/src/**/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'));

gulp.src('./lib/src/**/*.json')
.pipe(gulp.dest('dist'));

gulp.src('./lib/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(chmod(0o755))
.pipe(gulp.dest('bin'));

});

gulp.task('lint', () => {
const isFixed = file => file.eslint != null && file.eslint.fixed;

return gulp.src('./lib/**/*.js')
.pipe(
eslint({
fix: true,
envs: [
'node'
]
})
)
.pipe(eslint.format())
.pipe(gulpIf(isFixed, gulp.dest('./lib/')));
});

gulp.task('watch', () => {
return gulp.watch('./lib/**/*.js', ['lint', 'scripts']);
});

gulp.task('test', () => {
gulp.src('test/**/*.js')
.pipe(nodeunit({
reporter: 'junit',
reporterOptions: {
output: 'test'
}
}));
});

gulp.task('build', ['lint', 'scripts', 'test']);
gulp.task('default', ['build', 'watch']);
102 changes: 102 additions & 0 deletions lib/_release-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// TODO: write test to check whether there are any duplicates (short or name)
export const options = [
{
short: '-u',
name: 'username',
valueType: '<repo owner>',
description: 'The username of the repo e.g. github-tools'
},
{
short: '-r',
name: 'repo',
valueType: '<repository name>',
description: 'The repository name e.g. github-release-notes'
},
{
short: '-T',
name: 'token',
valueType: '<github token>',
description: 'The token generated with repo access'
},
{
short: '-au',
name: 'api-url',
valueType: '<url>',
description: 'Override the GitHub API URL, allows gren to connect to a private GHE installation'
},
{
short: '-o',
name: 'override',
description: 'Override the release notes if exist.'
},
{
short: '-t',
name: 'tags',
valueType: '<old-tag>..<new-tag>',
description: 'Write release notes for a range of tags, a specific tag or all. e.g. 0.2.0..0.1.0 or 0.2.0.. or ..0.1.0 or 0.2.0 or *', // needs to be documented better,
action: value => value.split('..')
},
{
short: '-D',
name: 'data-source',
valueType: '<source>',
description: 'The informations you want to use to build release notes.',
action: /^(issues|commits|milestones)$/i,
defaultValue: 'issues'
},
{
short: '-im',
name: 'include-messages',
valueType: '<merge|commits|all>',
description: 'Filter the messages added to the release notes. Only used when --data-source used is commits',
action: /^(merge|commits|all)$/i,
defaultValue: 'commits'
},
{
short: '-p',
name: 'prefix',
valueType: '<name prefix>',
description: 'Add a prefix to the tag version. e.g. \'v\''
},
{
short: '-d',
name: 'draft',
description: 'Set the release as a draft.'
},
{
short: '-pr',
name: 'prerelease',
description: 'Set the release as a prerelease.'
},
{
short: '-g',
name: 'group-by',
valueType: '<"label"|Object>',
description: 'Group the issues using the labels as group headings. You can set custom headings for groups of labels from a configuration file.'
},
{
short: '-L',
name: 'ignore-labels',
valueType: '<label1>,<label2>,<label3>',
description: 'Ignore the specified labels.',
action: value => value.split(',')
},
{
short: '-I',
name: 'ignore-issues-with',
valueType: '<label1>,<label2>,<label3>',
description: 'Ignore issues that contains one of the specified labels.',
action: value => value.split(',')
},
{
short: '-mm',
name: 'milestone-match',
valueType: '<prefix>',
description: 'The title that the script needs to match to link the release to the milestone. e.g. v will match v0.1.0'
},
{
short: '-M',
name: 'only-milestones',
description: 'Add to the release bodies only the issues that have a milestone'
}
];
3 changes: 3 additions & 0 deletions lib/gren-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

console.log('changelog');
35 changes: 35 additions & 0 deletions lib/gren-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

import Program from '../dist/Program';
import GitHubInfo from '../dist/GitHubInfo';
import Release from '../dist/Release';
import { options } from './_release-options';

const githubInfo = new GitHubInfo();

githubInfo.options.then(githubOptions => Promise.resolve(new Program({
name: 'gren release',
description: 'Generate release notes and attach them to a tag',
argv: process.argv,
cwd: process.cwd(),
bashOptions: Object.assign({}, ...githubOptions),
options,
events: {
'--help': () => {
console.log('');
console.log(' Basic Examples:');
console.log('');
console.log(' $ gren release');
console.log('');
console.log(' $ gren release --tags 2.1.3..4.0.0');
console.log('');
}
}
})))
.then(({ options }) => {
const releaseAction = new Release(options);
return releaseAction.release();
})
.catch(error => {
console.error(error);
});
Loading