Compare commits

...
12 Commits
Author SHA1 Message Date
Christoph Witzko 7ba1cb956f fix(pre): improved logging 2015-05-15 19:41:27 +02:00
Christoph Witzko 1f70215ffe test(pre): verification hook 2015-05-15 19:32:32 +02:00
Stephan BönnemannandChristoph Witzko 245f918201 fix(pre): exit script for failed validation 2015-05-15 19:08:27 +02:00
Christoph Witzko f0f53f207b fix(pre): correct type on initial release 2015-05-14 01:19:54 +02:00
Christoph Witzko 41c90124f6 feat(pre): pass more information to the verification hook 2015-05-12 15:52:47 +02:00
Christoph Witzko 44db677c4a chore: added cracks 2015-05-12 09:28:10 +02:00
Christoph Witzko 127cb673bd feat(pre): verification hook 2015-05-12 09:27:35 +02:00
Christoph Witzko a5dabed534 fix(pre): use raw body instead of subject 2015-05-12 08:53:38 +02:00
Christoph Witzko be9bb40dd2 refactor(pre): inline if 2015-05-12 08:53:38 +02:00
Stephan Bönnemann 4821aff69e fix(npm-info): correctly encode scoped package names
This adds support for releasing scoped packages that are public and and that have an initial version in the registry available.
More fixes needed to support yet unpublished/private scoped modules.
2015-05-12 00:06:03 +02:00
Stephan Bönnemann 773ecf693f docs(readme): document expected error closes #18 2015-05-11 23:34:35 +02:00
Stephan Bönnemann f2dd66f614 chore(travis): test on iojs-v2 2015-05-08 00:49:11 +02:00
9 changed files with 100 additions and 6 deletions
+1
View File
@@ -1,5 +1,6 @@
language: node_js
node_js:
- iojs-v2
- iojs-v1
- '0.10'
- '0.12'
+4 -1
View File
@@ -44,7 +44,7 @@ Note: The default release notes are a [changelog](https://github.com/ajoslin/con
Note: This is tied to GitHub, feel free to send PRs for other services.
Note: `semantic-release` works around a limitation in `npm`'s `prepublish` step. Once a version is published it prints an error that you can *safely ignore* [npm/npm#7118](https://github.com/npm/npm/issues/7118).
Note: `semantic-release` works around a limitation in `npm`'s `prepublish` step. Once a version is published it prints a "Could not pack" error that you can *safely ignore* [npm/npm#7118](https://github.com/npm/npm/issues/7118).
## How you can set it up
@@ -101,6 +101,9 @@ cache:
- node_modules
notifications:
email: false
# See https://github.com/boennemann/semantic-release/issues/18
before_deploy:
- npm config set spin false --global
env:
# Get your token here: https://github.com/settings/tokens/new
# Grant the token repo/public_repo scope (all others can be deselected)
+1 -1
View File
@@ -7,7 +7,7 @@ var efh = require('./error').efh
module.exports = function (from, cb) {
var range = (from ? from + '..' : '') + 'HEAD'
exec(
'git log -E --format=%H==SPLIT==%s==END== ' + range,
'git log -E --format=%H==SPLIT==%B==END== ' + range,
efh(cb)(function (stdout) {
cb(null, String(stdout).split('==END==\n')
+2 -1
View File
@@ -5,7 +5,8 @@ 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 encodedPkgName = pkgName.replace(/\//g, '%2F')
request(process.env.npm_config_registry + encodedPkgName, efh(cb)(function (response, body) {
var res = {
version: null,
gitHead: null,
+4
View File
@@ -21,6 +21,7 @@
"semver": "^4.3.3"
},
"devDependencies": {
"cracks": "^2.0.1",
"github-release-fake-server": "^1.3.0",
"lodash.defaults": "^3.0.0",
"nano-uid": "^0.2.0",
@@ -59,5 +60,8 @@
"test:style": "standard",
"test:integration": "node tests | tap-spec",
"test": "./bin/test"
},
"release": {
"verification": "cracks"
}
}
+37 -3
View File
@@ -20,10 +20,44 @@ module.exports = function (options, plugins, cb) {
var type = analyzer(commits)
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)
if (res.version) {
pkg.version = semver.inc(res.version, type)
} else {
type = 'major'
pkg.version = '1.0.0'
}
var writePkg = function () {
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n')
cb(null, pkg.version)
}
if (!plugins.verification) return writePkg()
var opts = {}
if (typeof plugins.verification === 'string') {
opts.name = plugins.verification
}
if (typeof plugins.verification === 'object') {
opts = plugins.verification
}
opts.type = type
opts.commits = commits
opts.version = res.version
opts.nextVersion = pkg.version
var verification = require(opts.name)
console.log('Running verification hook...')
verification(opts, function (error, ok) {
if (!error && ok) return writePkg()
console.log('Verification failed' + (error ? ': ' + error : ''))
process.exit(1)
})
}))
}))
}
+1
View File
@@ -5,6 +5,7 @@ var test = require('tape')
var createModule = require('./lib/create-module')
require('./scenarios/custom-analyzer')(test, createModule)
require('./scenarios/custom-verification')(test, createModule)
require('./scenarios/ignore')(test, createModule)
require('./scenarios/prepublish')(test, createModule)
require('./scenarios/postpublish')(test, createModule)
+5
View File
@@ -0,0 +1,5 @@
'use strict'
module.exports = function (opts, cb) {
cb(null, !(opts.commits.length % 2))
}
+45
View File
@@ -0,0 +1,45 @@
'use strict'
var path = require('path')
var efh = require('error-first-handler')
var nixt = require('nixt')
module.exports = function (test, createModule) {
createModule({
release: {
verification: path.join(__dirname, '../lib/custom-verification')
}
}, efh()(function (name, cwd) {
test('custom-verification', function (t) {
t.test('even commit count', function (t) {
t.plan(1)
nixt()
.cwd(cwd)
.env('CI', true)
.env('npm_config_registry', 'http://127.0.0.1:4873/')
.exec('git commit --allow-empty -m "feat: commit"')
.run('npm run prepublish')
.code(0)
.end(function (err) {
t.error(err, 'nixt')
})
})
t.test('odd commit count', function (t) {
t.plan(1)
nixt()
.cwd(cwd)
.env('CI', true)
.env('npm_config_registry', 'http://127.0.0.1:4873/')
.exec('git commit --allow-empty -m "feat: commit"')
.run('npm run prepublish')
.code(1)
.stdout(/Verification failed/)
.end(function (err) {
t.error(err, 'nixt')
})
})
})
}))
}