Compare commits

...
16 Commits
Author SHA1 Message Date
Stephan Bönnemann f74f764a80 fix(npm-info): registry unexpectedly returned no json formatted error
This only affected publishing of yet unreleased packages.
2015-04-03 19:37:39 +02:00
Stephan Bönnemann d5a8cb1935 style: adhere to standard style 2015-03-22 10:44:19 +01:00
Stephan Bönnemann f32a8e7d03 chore(package): update standard 2015-03-22 10:44:06 +01:00
Stephan Bönnemann 30fd1c19eb Merge pull request #16 from tlvince/15-oauth-scope
docs(readme): add GitHub token scope notes
2015-03-22 10:33:50 +01:00
Tom Vincent f192acc1ff docs(readme): add GitHub token scope notes
Closes #15.
2015-03-22 00:15:43 +00:00
Stephan Bönnemann 4ccda66a39 docs(readme): fix language and formatting 2015-03-01 17:18:37 +01:00
Stephan Bönnemann c2d963be70 Merge pull request #12 from davidpfahler/master
docs(readme): fix ignore scripts flag
2015-02-22 00:08:59 +01:00
David Pfahler f8c4e495fd docs(readme): fix ignore scripts flag 2015-02-22 00:07:53 +01:00
Stephan Bönnemann c3b59d6a06 Merge pull request #10 from boennemann/githead-registry
refactor(pre): use `gitHead` information from registry
2015-02-13 09:13:13 +01:00
Christoph Witzko 53c0adb365 refactor(pre): use gitHead information from registry 2015-02-12 22:07:04 +01:00
Christoph Witzko 045c913342 chore(pretest): automatically clean up 2015-02-11 15:28:46 +01:00
Stephan Bönnemann 5c12e718cb docs(readme): clarify npm abbrevs 2015-02-10 12:31:48 +01:00
Christoph Witzko 4e32c7dde0 chore: updated git-head 2015-02-09 14:32:46 +01:00
Stephan Bönnemann 6f891ed781 Merge pull request #6 from boennemann/fix-git-node
refactor(post): use git-head instead of exec
2015-02-09 00:11:50 +01:00
Christoph Witzko e43ff5573b refactor(post): use git-head instead of exec 2015-02-09 00:08:52 +01:00
Christoph Witzko 19af8b7ef2 test(postpublish): get commit hash in detached HEAD mode 2015-02-09 00:07:11 +01:00
17 changed files with 85 additions and 59 deletions
+10 -5
View File
@@ -11,13 +11,15 @@
This is fully integrated with the `npm` lifecycle, so all you have to do is to setup your CI to `npm publish`.
The goal of this package is to remove humans from version numbers and releases. The [SemVer](http://semver.org/) spec clearly and unambiguously defines when to increase the major, minor or patch part and still we tend to think we're clever when we ignore this, because marketing or something.
The goal of this package is to remove humans from version numbers and releases. The [SemVer](http://semver.org/) spec clearly and unambiguously defines when to increase the major, minor or patch part. Still we tend to ignore the rules, because we are emotionally attached to version numbers.
![https://twitter.com/trodrigues/status/509301317467373571](https://cloud.githubusercontent.com/assets/908178/6091690/cc86f58c-aeb8-11e4-94cb-15f15f486cde.png)
## How does this work?
Conventions, conventions, conventions. Instead of dumping [funny lols](http://whatthecommit.com/) into our commit messages, we can take some time to think about what we changed in the codebase and write it down. Following formalized conventions it this then possible to not only generate a meaningful changelog, but to determine the next semantic version to release. Currently the only supported style is the [AngularJS Commit Message Convention](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) style, but feel free to formalize your own style, write a parser for it, and send a PR to this package.
Conventions, conventions, conventions. Instead of dumping [lols](http://whatthecommit.com/) into our commit messages, we can take some time to think about what we changed in the codebase and write it down. Following formalized conventions it this then possible to not only generate a meaningful changelog, but to determine the next semantic version to release.
Note: Currently the only supported style is the [AngularJS Commit Message Convention](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) style, but feel free to formalize your own style, write a parser for it, and send a PR to this package.
```
<type>(<scope>): <subject>
@@ -82,11 +84,13 @@ Note: `semantic-release` works around a limitation in `npm`'s `prepublish` step.
## How do I set this up?
First of all you need to install `semantic-release` and save it as a `devDependency`.
### Installation
First of all you need to install `semantic-release` and save it as a `devDependency`.
```bash
npm install --save-dev semantic-release
# Btw, if you're feeling lazy you can just type this it's the same thing.
npm i -D semantic-release
```
@@ -135,6 +139,7 @@ notifications:
email: false
env:
# Get your token here: https://github.com/settings/tokens/new
# Grant the token repo/public_repo scope (all others can be deselected)
# You should encrypt this:
# `travis encrypt GH_TOKEN=<token> --add`
global: GH_TOKEN=<github-access-token-with-acceess-to-your-repo>
@@ -191,7 +196,7 @@ Note: pre-release flags are kind of an exeption here and a solution for them is
### How do I get back to good ol' `npm publish`?
`npm` offers the `--no-scripts` flag. Doing `npm publish --no-scripts` doesn't execute the `prepublish` and `postpublish` scripts.
`npm` offers the `--ignore-scripts` flag. Doing `npm publish --ignore-scripts` doesn't execute the `prepublish` and `postpublish` scripts.
### Is it _really_ a good idea to release on every push?
+2
View File
@@ -2,6 +2,8 @@
set -e
[ -d ".tmp" ] && ./bin/post-test
mkdir -p .tmp/modules
export DEBUG=ghrs:cli
+1 -1
View File
@@ -4,7 +4,7 @@ var efh = require('error-first-handler')
module.exports = {
efh: efh,
standard: efh(function(err) {
standard: efh(function (err) {
console.log('Something went wrong:')
if (typeof err === 'string') return console.log(err)
if (err instanceof Error) return console.log(err.message)
+27
View File
@@ -0,0 +1,27 @@
'use strict'
var request = require('request')
var efh = require('./error').efh
module.exports = function (pkgName, cb) {
request(process.env.npm_config_registry + pkgName, efh(cb)(function (response, body) {
var res = {
version: null,
gitHead: null,
pkg: null
}
if (response.statusCode === 404 || !body) return cb(null, res)
var pkg = JSON.parse(body)
if (pkg.error && response.statusCode !== 404) return cb(pkg.error)
res.version = pkg['dist-tags'].latest
res.gitHead = pkg.versions[res.version].gitHead
res.pkg = pkg
cb(null, res)
}))
}
+3 -5
View File
@@ -4,10 +4,8 @@ var git = require('conventional-changelog/lib/git')
var efh = require('../error').efh
module.exports = function (cb) {
git.latestTag(efh(cb)(function (from) {
git.getCommits({from: from}, efh(cb)(function (commits) {
cb(null, commits)
}))
module.exports = function (from, cb) {
git.getCommits({from: from}, efh(cb)(function (commits) {
cb(null, commits)
}))
}
+2 -2
View File
@@ -4,8 +4,8 @@ var analyze = require('./analyze')
var commits = require('./commits')
var efh = require('../error').efh
module.exports = function (cb) {
commits(efh(cb)(function (commits) {
module.exports = function (gitHead, cb) {
commits(gitHead, efh(cb)(function (commits) {
cb(null, analyze(commits))
}))
}
-17
View File
@@ -1,17 +0,0 @@
'use strict'
var request = require('request')
var efh = require('./error').efh
module.exports = function (pkg, cb) {
if (!pkg.name) return cb(new Error('Package must have a name'))
request(process.env.npm_config_registry + pkg.name, efh(cb)(function (response, body) {
var pkg = JSON.parse(body)
if (response.statusCode === 404 || pkg.error) return cb(null, null, true)
cb(null, pkg['dist-tags'].latest)
}))
}
+2 -1
View File
@@ -11,6 +11,7 @@
"abbrev": "^1.0.5",
"conventional-changelog": "0.0.11",
"error-first-handler": "^1.0.1",
"git-head": "^1.2.1",
"github": "^0.2.3",
"github-url-from-git": "^1.4.0",
"ini": "^1.3.2",
@@ -25,7 +26,7 @@
"nano-uid": "^0.2.0",
"nixt": "^0.4.1",
"sinopia": "^1.0.0",
"standard": "^2.3.1",
"standard": "^3.2.1",
"tap-spec": "^2.2.0",
"tape": "^3.5.0"
},
+2 -2
View File
@@ -1,10 +1,10 @@
'use strict'
var exec = require('child_process').exec
var readFile = require('fs').readFileSync
var url = require('url')
var changelog = require('conventional-changelog')
var gitHead = require('git-head')
var GitHubApi = require('github')
var parseSlug = require('parse-github-repo-url')
var parseUrl = require('github-url-from-git')
@@ -31,7 +31,7 @@ module.exports = function (options, cb) {
repository: parseUrl(repository),
file: false
}, efh(cb)(function (log) {
exec('git rev-parse HEAD', efh(cb)(function (hash) {
gitHead(efh(cb)(function (hash) {
var ghRepo = parseSlug(repository)
var release = {
owner: ghRepo[0],
+8 -8
View File
@@ -5,17 +5,17 @@ var fs = require('fs')
var semver = require('semver')
var type = require('../lib/type')
var version = require('../lib/version')
var npmInfo = require('../lib/npm-info')
var efh = require('../lib/error').efh
module.exports = function (options, cb) {
type(efh(cb)(function (type) {
if (!type) return cb(null, null)
var path = './package.json'
var pkg = JSON.parse(fs.readFileSync(path))
version(pkg, efh(cb)(function (version, unpublished) {
pkg.version = unpublished ? '1.0.0' : semver.inc(version, type)
var path = './package.json'
var pkg = JSON.parse(fs.readFileSync(path))
if (!pkg.name) return cb(new Error('Package must have a name'))
npmInfo(pkg.name, efh(cb)(function (res) {
type(res.gitHead, efh(cb)(function (type) {
if (!type) return cb(null, null)
pkg.version = !res.version ? '1.0.0' : semver.inc(res.version, type)
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2))
cb(null, pkg.version)
+1 -4
View File
@@ -28,10 +28,7 @@ module.exports = function () {
var config = ini.decode(fs.readFileSync('./.git/config') + '')
var repo = config['remote "origin"'].url
if (repo) pkg.repository = {
type: 'git',
url: ghUrl(repo)
}
if (repo) pkg.repository = { type: 'git', url: ghUrl(repo) }
}
// set up devDependency
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = function (test, createModule) {
.run(command)
.code(0)
.stdout(/> semantic-release pre\n$/m)
.end(function(err) {
.end(function (err) {
t.is(pkg + '', fs.readFileSync(cwd + '/package.json') + '', 'package')
t.error(err, 'nixt')
})
+20 -7
View File
@@ -25,19 +25,32 @@ module.exports = function (test, createModule) {
}
}, efh()(function (name, cwd) {
test('postpublish', function (t) {
t.test('publish new version to github releases', function (t) {
t.plan(1)
nixt()
var base = nixt()
.cwd(cwd)
.env('CI', true)
.env('GH_URL', 'http://127.0.0.1:4343/')
.env('GH_TOKEN', '***')
.exec('git commit --allow-empty -m "feat(cool): the next big thing"')
.run('npm run postpublish')
.code(0)
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
.end(function(err) {
t.test('publish new version to github releases', function (t) {
t.plan(1)
base.clone()
.run('npm run postpublish')
.end(function (err) {
t.error(err, 'nixt')
})
})
t.test('publish new version (with detached HEAD) to github releases', function (t) {
t.plan(1)
base.clone()
.exec('git checkout `git rev-parse HEAD`')
.run('npm run postpublish')
.end(function (err) {
t.error(err, 'nixt')
})
})
@@ -49,7 +62,7 @@ module.exports = function (test, createModule) {
t.error(err, 'github')
t.is(res.tag_name, 'v2.0.0', 'version')
t.is(res.author.login, 'user', 'user')
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\* the next big thing/.test(res.body), 'body')
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\*\n.*the next big thing/.test(res.body), 'body')
})
})
})
+3 -3
View File
@@ -28,7 +28,7 @@ module.exports = function (test, createModule) {
.run('npm run prepublish')
.code(code)
.stdout(/> semantic-release pre\n\nDetermining new version\n/m)
.end(function(err) {
.end(function (err) {
t.error(err, 'nixt')
var pkg = JSON.parse(fs.readFileSync(cwd + '/package.json'))
@@ -38,8 +38,8 @@ module.exports = function (test, createModule) {
return t.error(null, 'no publish')
}
exec('npm publish --ignore-scripts', {cwd: cwd}, function(err) {
setTimeout(function() {
exec('npm publish --ignore-scripts', {cwd: cwd}, function (err) {
setTimeout(function () {
t.error(err, 'publish')
}, 300)
})
+1 -1
View File
@@ -27,7 +27,7 @@ module.exports = function (test, createModule) {
.run(command)
.code(1)
.stdout(/Everything is alright/)
.end(function(err) {
.end(function (err) {
t.error(err, 'nixt')
})
})
+1 -1
View File
@@ -22,7 +22,7 @@ module.exports = function (test, createModule) {
.exec('git remote add origin git@github.com:user/repo.git')
.run('./node_modules/.bin/semantic-release setup')
.code(0)
.end(function(err) {
.end(function (err) {
t.error(err, 'nixt')
var pkg = JSON.parse(readFile(join(cwd, 'package.json')))
+1 -1
View File
@@ -25,7 +25,7 @@ module.exports = function (test, createModule) {
, 'm'
))
.code(1)
.end(function(err) {
.end(function (err) {
t.error(err, 'nixt')
})
})