conventional-github-releaser
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -36,6 +36,5 @@ { | ||
"scripts": { | ||
"dev": "docker run --rm --user node -v \"$(pwd)\":/app -w /app -it node:4 sh -c \"yarn install; yarn test; bash\"", | ||
"test": "eslint src/ && nyc --all --cache --include=src/ --exclude=src/cli.js --exclude=src/**/*.spec.js --exclude=src/**/*.mocks.js --reporter=lcov --reporter=text mocha --check-leaks --full-trace --globals __core-js_shared__,__coverage__,YamlEscaper --inline-diffs --no-exit --recursive --reporter=progress --retries 1 src/**/*.spec.js" | ||
"test": "eslint --fix src/ && nyc --all --cache --include=src/ --exclude=src/cli.js --exclude=src/**/*.spec.js --exclude=src/**/*.mocks.js --reporter=lcov --reporter=text mocha --check-leaks --full-trace --globals __core-js_shared__,__coverage__,YamlEscaper --inline-diffs --no-exit --recursive --reporter=progress --retries 1 src/**/*.spec.js" | ||
}, | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"dependencies": { | ||
@@ -47,3 +46,3 @@ "conventional-changelog": "^1.1.0", | ||
"lodash.merge": "^4.0.2", | ||
"meow": "^3.3.0", | ||
"meow": "^4.0.0", | ||
"object-assign": "^4.0.1", | ||
@@ -54,12 +53,3 @@ "q": "^1.4.1", | ||
"through2": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"codecov": "^3.0.0", | ||
"eslint": "^4.10.0", | ||
"eslint-config-xo-space": "^0.17.0", | ||
"mocha": "^4.0.1", | ||
"npm-publish-git-tag": "^1.1.14", | ||
"nyc": "^11.2.1" | ||
} | ||
} |
# conventional-github-releaser | ||
[![Build Status](https://travis-ci.org/conventional-changelog/conventional-github-releaser.svg?branch=master)](https://travis-ci.org/conventional-changelog/conventional-github-releaser) | ||
[![codecov.io](https://codecov.io/github/conventional-changelog/conventional-github-releaser/coverage.svg?branch=master)](https://codecov.io/github/conventional-changelog/conventional-github-releaser?branch=master) | ||
[![Join the chat at https://gitter.im/conventional-changelog/conventional-github-releaser](https://badges.gitter.im/conventional-changelog/conventional-github-releaser.svg)](https://gitter.im/conventional-changelog/conventional-github-releaser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![CircleCI](https://circleci.com/gh/conventional-changelog/releaser-tools.svg?style=svg)](https://circleci.com/gh/conventional-changelog/releaser-tools) | ||
[![codecov.io](https://codecov.io/gh/conventional-changelog/releaser-tools/coverage.svg?branch=master)](https://codecov.io/gh/conventional-changelog/releaser-tools?branch=master) | ||
[![Join the chat at https://gitter.im/conventional-changelog/conventional-github-releaser](https://badges.gitter.im/conventional-changelog/conventional-github-releaser.svg)](https://gitter.im/conventional-changelog/conventional-github-releaser) | ||
> Make a new GitHub release from git metadata. | ||
**Note** You don't have to use the angular commit convention. For the best result of the tool to tokenize you commit and produce flexible output, it's recommended to use a commit convention. | ||
**Note** You don't have to use the angular commit convention. For the best result of the tool to tokenize your commit and produce flexible output, it's recommended to use a commit convention. | ||
@@ -98,3 +98,3 @@ ## Quick start | ||
```json | ||
```javascript | ||
{ | ||
@@ -195,3 +195,2 @@ token: '0126af95c0e2d9b0a7c78738c4c00a860b04acc8', | ||
- [github-remove-all-releases](https://github.com/stevemao/github-remove-all-releases) - Remove all releases of your GitHub repo | ||
- [conventional-gitlab-releaser](https://gitlab.com/hutson/conventional-gitlab-releaser) - Similar to `conventional-github-releaser`, but makes a GitLab release. | ||
@@ -218,2 +217,2 @@ ## License | ||
Please read our [contributing guide](https://gitlab.com/hyper-expanse/conventional-gitlab-releaser/blob/master/CONTRIBUTING.md) to see how you may contribute to this project. | ||
Please read our [contributing guide](https://github.com/conventional-changelog/releaser-tools/blob/master/CONTRIBUTING.md) to see how you may contribute to this project. |
124
src/cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
'use strict' | ||
const meow = require('meow'); | ||
const conventionalGithubReleaser = require('./index'); | ||
const resolve = require('path').resolve; | ||
const meow = require('meow') | ||
const conventionalGithubReleaser = require('./index') | ||
const resolve = require('path').resolve | ||
const cli = meow({ | ||
help: [ | ||
'Usage', | ||
' conventional-github-releaser', | ||
'', | ||
'Example', | ||
' conventional-github-releaser -p angular', | ||
'', | ||
'Options', | ||
' -u, --url URL of your GitHub provider. Defaults to `https://api.github.com`', | ||
' -t, --token Your GitHub auth token', | ||
'', | ||
' -p, --preset Name of the preset you want to use. Must be one of the following:', | ||
' angular, atom, codemirror, ember, eslint, express, jquery, jscs or jshint', | ||
'', | ||
' -k, --pkg A filepath of where your package.json is located', | ||
' Default is the closest package.json from cwd', | ||
'', | ||
' -r, --release-count How many releases to be generated from the latest', | ||
' If 0, the whole changelog will be regenerated and the outfile will be overwritten', | ||
' Default: 1', | ||
'', | ||
' -v, --verbose Verbose output. Use this for debugging', | ||
' Default: false', | ||
'', | ||
' -n, --config A filepath of your config script', | ||
' Example of a config script: https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/index.js', | ||
'', | ||
' -c, --context A filepath of a javascript that is used to define template variables', | ||
'', | ||
' -d, --draft Publishes a draft instead of a real release', | ||
' Default: false', | ||
], | ||
help: ` | ||
Usage | ||
conventional-github-releaser | ||
Example | ||
conventional-github-releaser -p angular | ||
Options | ||
-u, --url URL of your GitHub provider. Defaults to 'https://api.github.com' | ||
-t, --token Your GitHub auth token | ||
-p, --preset Name of the preset you want to use. Must be one of the following: | ||
angular, atom, codemirror, ember, eslint, express, jquery, jscs or jshint | ||
-k, --pkg A filepath of where your package.json is located | ||
Default is the closest package.json from cwd | ||
-r, --release-count How many releases to be generated from the latest | ||
If 0, the whole changelog will be regenerated and the outfile will be overwritten | ||
Default: 1 | ||
-v, --verbose Verbose output. Use this for debugging | ||
Default: false | ||
-n, --config A filepath of your config script | ||
Example of a config script: https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/index.js | ||
-c, --context A filepath of a javascript that is used to define template variables | ||
-d, --draft Publishes a draft instead of a real release | ||
Default: false | ||
` | ||
}, { | ||
@@ -52,37 +52,37 @@ alias: { | ||
c: 'context', | ||
d: 'draft', | ||
}, | ||
}); | ||
d: 'draft' | ||
} | ||
}) | ||
let config = {}; | ||
const flags = cli.flags; | ||
let config = {} | ||
const flags = cli.flags | ||
let templateContext; | ||
let gitRawCommitsOpts; | ||
let parserOpts; | ||
let writerOpts; | ||
let templateContext | ||
let gitRawCommitsOpts | ||
let parserOpts | ||
let writerOpts | ||
try { | ||
if (flags.context) { | ||
templateContext = require(resolve(process.cwd(), flags.context)); | ||
templateContext = require(resolve(process.cwd(), flags.context)) | ||
} | ||
if (flags.config) { | ||
config = require(resolve(process.cwd(), flags.config)); | ||
config = require(resolve(process.cwd(), flags.config)) | ||
} | ||
if (config.gitRawCommitsOpts) { | ||
gitRawCommitsOpts = config.gitRawCommitsOpts; | ||
gitRawCommitsOpts = config.gitRawCommitsOpts | ||
} | ||
if (config.parserOpts) { | ||
parserOpts = config.parserOpts; | ||
parserOpts = config.parserOpts | ||
} | ||
if (config.writerOpts) { | ||
writerOpts = config.writerOpts; | ||
writerOpts = config.writerOpts | ||
} | ||
} catch (err) { | ||
console.error('Failed to get file. ' + err); | ||
process.exit(1); | ||
console.error('Failed to get file. ' + err) | ||
process.exit(1) | ||
} | ||
@@ -93,11 +93,11 @@ | ||
pkg: { | ||
path: flags.pkg, | ||
path: flags.pkg | ||
}, | ||
releaseCount: flags.releaseCount, | ||
draft: flags.draft, | ||
}; | ||
draft: flags.draft | ||
} | ||
if (flags.verbose) { | ||
changelogOpts.debug = console.info.bind(console); | ||
changelogOpts.warn = console.warn.bind(console); | ||
changelogOpts.debug = console.info.bind(console) | ||
changelogOpts.warn = console.warn.bind(console) | ||
} | ||
@@ -107,12 +107,12 @@ | ||
url: flags.url || process.env.CONVENTIONAL_GITHUB_URL, | ||
token: flags.token || process.env.CONVENTIONAL_GITHUB_RELEASER_TOKEN, | ||
token: flags.token || process.env.CONVENTIONAL_GITHUB_RELEASER_TOKEN | ||
}, changelogOpts, templateContext, gitRawCommitsOpts, parserOpts, writerOpts, function (err, data) { | ||
if (err) { | ||
console.error(err.toString()); | ||
process.exit(1); | ||
console.error(err.toString()) | ||
process.exit(1) | ||
} | ||
if (flags.verbose) { | ||
console.log(data); | ||
console.log(data) | ||
} | ||
}); | ||
}) |
108
src/index.js
@@ -1,48 +0,48 @@ | ||
'use strict'; | ||
'use strict' | ||
const assign = require('object-assign'); | ||
const conventionalChangelog = require('conventional-changelog'); | ||
const gitSemverTags = require('git-semver-tags'); | ||
const ghGot = require('gh-got'); | ||
const merge = require('lodash.merge'); | ||
const Q = require('q'); | ||
const semver = require('semver'); | ||
const through = require('through2'); | ||
const transform = require('./transform'); | ||
const assign = require('object-assign') | ||
const conventionalChangelog = require('conventional-changelog') | ||
const gitSemverTags = require('git-semver-tags') | ||
const ghGot = require('gh-got') | ||
const merge = require('lodash.merge') | ||
const Q = require('q') | ||
const semver = require('semver') | ||
const through = require('through2') | ||
const transform = require('./transform') | ||
/* eslint max-params: ["error", 7] */ | ||
function conventionalGithubReleaser(auth, changelogOpts, context, gitRawCommitsOpts, parserOpts, writerOpts, userCb) { | ||
function conventionalGithubReleaser (auth, changelogOpts, context, gitRawCommitsOpts, parserOpts, writerOpts, userCb) { | ||
if (!auth) { | ||
throw new Error('Expected an auth object'); | ||
throw new Error('Expected an auth object') | ||
} | ||
const promises = []; | ||
const promises = [] | ||
const changelogArgs = [changelogOpts, context, gitRawCommitsOpts, parserOpts, writerOpts].map(function (arg) { | ||
if (typeof arg === 'function') { | ||
userCb = arg; | ||
return {}; | ||
userCb = arg | ||
return {} | ||
} | ||
return arg || {}; | ||
}); | ||
return arg || {} | ||
}) | ||
if (!userCb) { | ||
throw new Error('Expected an callback'); | ||
throw new Error('Expected an callback') | ||
} | ||
changelogOpts = changelogArgs[0]; | ||
context = changelogArgs[1]; | ||
gitRawCommitsOpts = changelogArgs[2]; | ||
parserOpts = changelogArgs[3]; | ||
writerOpts = changelogArgs[4]; | ||
changelogOpts = changelogArgs[0] | ||
context = changelogArgs[1] | ||
gitRawCommitsOpts = changelogArgs[2] | ||
parserOpts = changelogArgs[3] | ||
writerOpts = changelogArgs[4] | ||
changelogOpts = merge({ | ||
transform: transform, | ||
releaseCount: 1, | ||
}, changelogOpts); | ||
releaseCount: 1 | ||
}, changelogOpts) | ||
writerOpts.includeDetails = true; | ||
writerOpts.includeDetails = true | ||
// ignore the default header partial | ||
writerOpts.headerPartial = writerOpts.headerPartial || ''; | ||
writerOpts.headerPartial = writerOpts.headerPartial || '' | ||
@@ -52,28 +52,28 @@ Q.nfcall(gitSemverTags) | ||
if (!tags || !tags.length) { | ||
setImmediate(userCb, new Error('No semver tags found')); | ||
return; | ||
setImmediate(userCb, new Error('No semver tags found')) | ||
return | ||
} | ||
const releaseCount = changelogOpts.releaseCount; | ||
const releaseCount = changelogOpts.releaseCount | ||
if (releaseCount !== 0) { | ||
gitRawCommitsOpts = assign({ | ||
from: tags[releaseCount], | ||
}, gitRawCommitsOpts); | ||
from: tags[releaseCount] | ||
}, gitRawCommitsOpts) | ||
} | ||
gitRawCommitsOpts.to = gitRawCommitsOpts.to || tags[0]; | ||
gitRawCommitsOpts.to = gitRawCommitsOpts.to || tags[0] | ||
conventionalChangelog(changelogOpts, context, gitRawCommitsOpts, parserOpts, writerOpts) | ||
.on('error', function (err) { | ||
userCb(err); | ||
userCb(err) | ||
}) | ||
.pipe(through.obj(function (chunk, enc, cb) { | ||
if (!chunk.keyCommit || !chunk.keyCommit.version) { | ||
cb(); | ||
return; | ||
cb() | ||
return | ||
} | ||
const version = chunk.keyCommit.version; | ||
const prerelease = semver.parse(version).prerelease.length > 0; | ||
const draft = changelogOpts.draft || false; | ||
const version = chunk.keyCommit.version | ||
const prerelease = semver.parse(version).prerelease.length > 0 | ||
const draft = changelogOpts.draft || false | ||
@@ -87,34 +87,34 @@ const options = { | ||
tag_name: version, | ||
target_commitish: changelogOpts.targetCommitish, | ||
}, | ||
}; | ||
target_commitish: changelogOpts.targetCommitish | ||
} | ||
} | ||
if (auth.token) { | ||
options.token = auth.token; | ||
options.token = auth.token | ||
} | ||
if (auth.url) { | ||
options.endpoint = auth.url; | ||
options.endpoint = auth.url | ||
} | ||
const promise = ghGot('repos/' + context.owner + '/' + context.repository + '/releases', options); | ||
const promise = ghGot('repos/' + context.owner + '/' + context.repository + '/releases', options) | ||
promises.push(promise); | ||
promises.push(promise) | ||
cb(); | ||
cb() | ||
}, function () { | ||
Q.all(promises) | ||
.then(function (responses) { | ||
userCb(null, responses); | ||
userCb(null, responses) | ||
}) | ||
.catch(function (err) { | ||
userCb(err); | ||
}); | ||
})); | ||
userCb(err) | ||
}) | ||
})) | ||
}) | ||
.catch(function (err) { | ||
userCb(err); | ||
}); | ||
userCb(err) | ||
}) | ||
} | ||
module.exports = conventionalGithubReleaser; | ||
module.exports = conventionalGithubReleaser |
@@ -1,18 +0,18 @@ | ||
'use strict'; | ||
'use strict' | ||
var dateFormat = require('dateformat'); | ||
var semverRegex = require('semver-regex'); | ||
var dateFormat = require('dateformat') | ||
var semverRegex = require('semver-regex') | ||
function transform(chunk, cb) { | ||
function transform (chunk, cb) { | ||
if (typeof chunk.gitTags === 'string') { | ||
chunk.version = (chunk.gitTags.match(semverRegex()) || [])[0]; | ||
chunk.version = (chunk.gitTags.match(semverRegex()) || [])[0] | ||
} | ||
if (chunk.committerDate) { | ||
chunk.committerDate = dateFormat(chunk.committerDate, 'yyyy-mm-dd', true); | ||
chunk.committerDate = dateFormat(chunk.committerDate, 'yyyy-mm-dd', true) | ||
} | ||
cb(null, chunk); | ||
cb(null, chunk) | ||
} | ||
module.exports = transform; | ||
module.exports = transform |
@@ -1,14 +0,14 @@ | ||
'use strict'; | ||
'use strict' | ||
/* eslint-disable no-unused-expressions */ | ||
const chai = require('chai'); | ||
const mocha = require(`mocha`); | ||
const transform = require('./transform'); | ||
const chai = require('chai') | ||
const mocha = require(`mocha`) | ||
const transform = require('./transform') | ||
const expect = chai.expect; | ||
const expect = chai.expect | ||
const beforeEach = mocha.beforeEach; | ||
const describe = mocha.describe; | ||
const it = mocha.it; | ||
const beforeEach = mocha.beforeEach | ||
const describe = mocha.describe | ||
const it = mocha.it | ||
@@ -37,17 +37,17 @@ /* | ||
committerDate: 'June 8, 2012', | ||
gitTags: '', | ||
}; | ||
}); | ||
gitTags: '' | ||
} | ||
}) | ||
it('should skip semantic version matching when gitTags isn\'t a string', function (done) { | ||
this.chunk.gitTags = undefined; | ||
this.chunk.gitTags = undefined | ||
transform(this.chunk, function (err, chunk) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.be.undefined; | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.be.undefined | ||
done() | ||
}) | ||
}) | ||
@@ -57,68 +57,68 @@ it('should have no version when there are no tags', function (done) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.be.undefined; | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.be.undefined | ||
done() | ||
}) | ||
}) | ||
it('should not match invalid semantic version tag', function (done) { | ||
this.chunk.gitTags = ' (tag: release-18)'; | ||
this.chunk.gitTags = ' (tag: release-18)' | ||
transform(this.chunk, function (err, chunk) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.be.undefined; | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.be.undefined | ||
done() | ||
}) | ||
}) | ||
it('should match valid semantic version tag', function (done) { | ||
this.chunk.gitTags = ' (tag: 1.1.20)'; | ||
this.chunk.gitTags = ' (tag: 1.1.20)' | ||
transform(this.chunk, function (err, chunk) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.equal('1.1.20'); | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.equal('1.1.20') | ||
done() | ||
}) | ||
}) | ||
it('should match valid semantic version tag containing a leading `v`', function (done) { | ||
this.chunk.gitTags = ' (tag: v1.1.20)'; | ||
this.chunk.gitTags = ' (tag: v1.1.20)' | ||
transform(this.chunk, function (err, chunk) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.equal('v1.1.20'); | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.equal('v1.1.20') | ||
done() | ||
}) | ||
}) | ||
it('should find valid semantic version tag out of many tags', function (done) { | ||
this.chunk.gitTags = ' (HEAD -> master, tag: something, tag: 1.1.20, origin/master, origin/HEAD)'; | ||
this.chunk.gitTags = ' (HEAD -> master, tag: something, tag: 1.1.20, origin/master, origin/HEAD)' | ||
transform(this.chunk, function (err, chunk) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.equal('1.1.20'); | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.equal('1.1.20') | ||
done() | ||
}) | ||
}) | ||
it('should match first semantic version tag when there are multiple valid tags', function (done) { | ||
this.chunk.gitTags = ' (tag: 1.1.19, tag: 1.1.20)'; | ||
this.chunk.gitTags = ' (tag: 1.1.19, tag: 1.1.20)' | ||
transform(this.chunk, function (err, chunk) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.version).to.equal('1.1.19'); | ||
done(); | ||
}); | ||
}); | ||
expect(chunk.version).to.equal('1.1.19') | ||
done() | ||
}) | ||
}) | ||
@@ -128,8 +128,8 @@ it('should format date', function (done) { | ||
if (err) { | ||
return done(err); | ||
return done(err) | ||
} | ||
expect(chunk.committerDate).to.equal('2012-06-08'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
expect(chunk.committerDate).to.equal('2012-06-08') | ||
done() | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22209
0
7
310
216
1
Updatedmeow@^4.0.0