Merge pull request #39 from boennemann/refactor-babelify
refactor: use babel and add coverage reports
This commit is contained in:
commit
995fc07617
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,3 +1,10 @@
|
|||||||
|
# common
|
||||||
|
coverage
|
||||||
node_modules
|
node_modules
|
||||||
*.log
|
*.log
|
||||||
|
.nyc_output
|
||||||
|
.tests
|
||||||
.tmp
|
.tmp
|
||||||
|
|
||||||
|
# build-artifacts
|
||||||
|
dist
|
||||||
|
12
.npmignore
Normal file
12
.npmignore
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# common
|
||||||
|
coverage
|
||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
.nyc_output
|
||||||
|
.tests
|
||||||
|
.tmp
|
||||||
|
|
||||||
|
# source/config
|
||||||
|
src
|
||||||
|
*.yml
|
||||||
|
.gitignore
|
13
.travis.yml
13
.travis.yml
@ -1,15 +1,15 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- iojs-v2
|
|
||||||
- iojs-v1
|
|
||||||
- '0.10'
|
|
||||||
- '0.12'
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
language: node_js
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
node_js:
|
||||||
|
- iojs-v2
|
||||||
|
- iojs-v1
|
||||||
|
- '0.12'
|
||||||
|
- '0.10'
|
||||||
before_install:
|
before_install:
|
||||||
- npm i -g npm@^2.0.0
|
- npm i -g npm@^2.0.0
|
||||||
before_script:
|
before_script:
|
||||||
@ -18,6 +18,7 @@ before_script:
|
|||||||
after_success:
|
after_success:
|
||||||
- python travis_after_all.py
|
- python travis_after_all.py
|
||||||
- export $(cat .to_export_back)
|
- export $(cat .to_export_back)
|
||||||
|
- if [[ $BUILD_LEADER = YES ]]; then npm run coveralls; fi
|
||||||
after_failure:
|
after_failure:
|
||||||
- python travis_after_all.py
|
- python travis_after_all.py
|
||||||
- export $(cat .to_export_back)
|
- export $(cat .to_export_back)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# semantic-release
|
# semantic-release
|
||||||
[](https://travis-ci.org/boennemann/semantic-release)
|
[](https://travis-ci.org/boennemann/semantic-release)
|
||||||
|
[](https://coveralls.io/r/boennemann/semantic-release)
|
||||||
[](https://david-dm.org/boennemann/semantic-release)
|
[](https://david-dm.org/boennemann/semantic-release)
|
||||||
[](https://david-dm.org/boennemann/semantic-release#info=devDependencies)
|
[](https://david-dm.org/boennemann/semantic-release#info=devDependencies)
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
'use strict'
|
|
||||||
|
|
||||||
var readFile = require('fs').readFileSync
|
var readFile = require('fs').readFileSync
|
||||||
|
|
||||||
var abbrev = require('abbrev')
|
|
||||||
var minimist = require('minimist')
|
var minimist = require('minimist')
|
||||||
|
|
||||||
var efh = require('../lib/error').standard
|
|
||||||
|
|
||||||
var argv = minimist(process.argv.slice(2), {
|
var argv = minimist(process.argv.slice(2), {
|
||||||
alias: {
|
alias: {
|
||||||
d: 'debug',
|
d: 'debug',
|
||||||
@ -23,72 +19,26 @@ var argv = minimist(process.argv.slice(2), {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var plugins = JSON.parse(readFile('./package.json')).release || {}
|
|
||||||
|
|
||||||
var npmArgv = process.env.npm_config_argv ?
|
var npmArgv = process.env.npm_config_argv ?
|
||||||
minimist(JSON.parse(process.env.npm_config_argv).cooked) :
|
minimist(JSON.parse(process.env.npm_config_argv).cooked) :
|
||||||
{_: []}
|
{_: []}
|
||||||
|
|
||||||
|
var plugins = JSON.parse(readFile('./package.json')).release || {}
|
||||||
|
|
||||||
|
var main
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
try {
|
||||||
|
main = require('../dist/main')
|
||||||
|
} catch (e) {
|
||||||
|
require('babel/register')
|
||||||
|
main = require('../src/main')
|
||||||
|
}
|
||||||
|
|
||||||
if (~argv._.indexOf('pre')) {
|
if (~argv._.indexOf('pre')) {
|
||||||
// see src/restart.js
|
main.pre(argv, npmArgv, plugins)
|
||||||
if (npmArgv['semantic-release-rerun']) {
|
} else if (~argv._.indexOf('post')) {
|
||||||
if (!/semantically-released/.test(process.env.npm_package_version)) process.exit(0)
|
main.post(argv, npmArgv, plugins)
|
||||||
|
} else if (~argv._.indexOf('setup')) {
|
||||||
console.log('There is something wrong with your setup, as a placeholder version is about to be released.')
|
main.setup(argv, npmArgv, plugins)
|
||||||
console.log('Please verify that your setup is correct.')
|
|
||||||
console.log('If you think this is a problem with semantic-release please open an issue.')
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
// the `prepublish` hook is also executed when the package is installed
|
|
||||||
// in this case we abort the command and do nothing.
|
|
||||||
if (
|
|
||||||
isAbbrev(npmArgv, 'install') ||
|
|
||||||
isAbbrev(npmArgv, 'link') ||
|
|
||||||
isAbbrev(npmArgv, 'pack')
|
|
||||||
) process.exit(0)
|
|
||||||
|
|
||||||
if (argv.debug) console.log('This is a dry run')
|
|
||||||
|
|
||||||
console.log('Determining new version')
|
|
||||||
|
|
||||||
var publish = false
|
|
||||||
if (isAbbrev(npmArgv, 'publish')) publish = true
|
|
||||||
|
|
||||||
// require a correct setup during publish
|
|
||||||
if (publish && !argv.debug && !require('../src/verify')(argv)) process.exit(1)
|
|
||||||
|
|
||||||
require('../src/pre')(argv, plugins, efh(function (result) {
|
|
||||||
if (!result) {
|
|
||||||
console.log('Nothing changed. Not publishing.')
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Publishing v' + result)
|
|
||||||
if (!publish) process.exit(0)
|
|
||||||
|
|
||||||
if (argv.debug) process.exit(1)
|
|
||||||
|
|
||||||
require('../src/restart')(efh(function () {
|
|
||||||
process.exit(1)
|
|
||||||
}))
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (~argv._.indexOf('post')) {
|
|
||||||
require('../src/post')(argv, plugins, efh(function () {
|
|
||||||
// see src/restart.js
|
|
||||||
if (npmArgv['semantic-release-rerun']) {
|
|
||||||
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (~argv._.indexOf('setup')) {
|
|
||||||
require('../src/setup')()
|
|
||||||
console.log('"package.json" is set up properly. Now configure your CI server.')
|
|
||||||
console.log('https://github.com/boennemann/semantic-release#ci-server')
|
|
||||||
}
|
|
||||||
|
|
||||||
function isAbbrev (argv, command) {
|
|
||||||
return argv._.some(Object.prototype.hasOwnProperty.bind(abbrev(command)))
|
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
var parseRawCommit = require('conventional-changelog/lib/git').parseRawCommit
|
|
||||||
|
|
||||||
module.exports = function (commits) {
|
|
||||||
var type = null
|
|
||||||
|
|
||||||
commits
|
|
||||||
|
|
||||||
.map(function (commit) {
|
|
||||||
return parseRawCommit(commit.hash + '\n' + commit.message)
|
|
||||||
})
|
|
||||||
|
|
||||||
.filter(function (commit) {
|
|
||||||
return !!commit
|
|
||||||
})
|
|
||||||
|
|
||||||
.every(function (commit) {
|
|
||||||
if (commit.breaks.length) {
|
|
||||||
type = 'major'
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commit.type === 'feat') type = 'minor'
|
|
||||||
|
|
||||||
if (!type && commit.type === 'fix') type = 'patch'
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
return type
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
var exec = require('child_process').exec
|
|
||||||
|
|
||||||
var efh = require('./error').efh
|
|
||||||
|
|
||||||
module.exports = function (from, cb) {
|
|
||||||
var range = (from ? from + '..' : '') + 'HEAD'
|
|
||||||
exec(
|
|
||||||
'git log -E --format=%H==SPLIT==%B==END== ' + range,
|
|
||||||
efh(cb)(function (stdout) {
|
|
||||||
cb(null, String(stdout).split('==END==\n')
|
|
||||||
|
|
||||||
.filter(function (raw) {
|
|
||||||
return !!raw.trim()
|
|
||||||
})
|
|
||||||
|
|
||||||
.map(function (raw) {
|
|
||||||
var data = raw.split('==SPLIT==')
|
|
||||||
return {
|
|
||||||
hash: data[0],
|
|
||||||
message: data[1]
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
14
lib/error.js
14
lib/error.js
@ -1,14 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
efh: efh,
|
|
||||||
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, err.stack)
|
|
||||||
if (err.message) return console.log(err.message)
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
var readFile = require('fs').readFileSync
|
|
||||||
|
|
||||||
var changelog = require('conventional-changelog')
|
|
||||||
var parseUrl = require('github-url-from-git')
|
|
||||||
|
|
||||||
module.exports = function (cb) {
|
|
||||||
var pkg = JSON.parse(readFile('./package.json'))
|
|
||||||
var repository = pkg.repository ? parseUrl(pkg.repository.url) : null
|
|
||||||
|
|
||||||
changelog({
|
|
||||||
version: pkg.version,
|
|
||||||
repository: repository,
|
|
||||||
file: false
|
|
||||||
}, cb)
|
|
||||||
}
|
|
47
package.json
47
package.json
@ -7,6 +7,14 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/boennemann/semantic-release/issues"
|
"url": "https://github.com/boennemann/semantic-release/issues"
|
||||||
},
|
},
|
||||||
|
"config": {
|
||||||
|
"nyc": {
|
||||||
|
"exclude": [
|
||||||
|
".tests",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"abbrev": "^1.0.5",
|
"abbrev": "^1.0.5",
|
||||||
"async": "^1.0.0",
|
"async": "^1.0.0",
|
||||||
@ -23,16 +31,17 @@
|
|||||||
"semver": "^4.3.3"
|
"semver": "^4.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"coveralls": "^2.11.2",
|
||||||
"cracks": "^2.0.1",
|
"cracks": "^2.0.1",
|
||||||
"github-release-fake-server": "^1.3.0",
|
"github-release-fake-server": "^1.3.0",
|
||||||
"lodash.defaults": "^3.0.0",
|
"lodash.defaults": "^3.0.0",
|
||||||
"nano-uid": "^0.2.0",
|
"nano-uid": "^0.2.0",
|
||||||
"nixt": "^0.4.1",
|
"nixt": "^0.4.1",
|
||||||
"nock": "^2.2.0",
|
"nock": "^2.2.0",
|
||||||
|
"nyc": "^2.3.0",
|
||||||
"sinopia": "^1.0.0",
|
"sinopia": "^1.0.0",
|
||||||
"standard": "^3.11.1",
|
"standard": "^4.0.1",
|
||||||
"tap-spec": "^3.0.0",
|
"tap": "^1.2.0"
|
||||||
"tape": "^4.0.0"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"iojs": "^1",
|
"iojs": "^1",
|
||||||
@ -43,28 +52,36 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"author",
|
"author",
|
||||||
"automation",
|
"automation",
|
||||||
"release",
|
"changelog",
|
||||||
"publish",
|
|
||||||
"module",
|
"module",
|
||||||
"package",
|
"package",
|
||||||
|
"publish",
|
||||||
|
"release",
|
||||||
"semver",
|
"semver",
|
||||||
"version",
|
"version"
|
||||||
"changelog"
|
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"main": "dist/main.js",
|
||||||
|
"optionalDependencies": {
|
||||||
|
"babel": "^5.5.6"
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"verification": "cracks"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/boennemann/semantic-release.git"
|
"url": "https://github.com/boennemann/semantic-release.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build": "rm -rf dist && mkdir -p dist && babel src --out-dir dist",
|
||||||
|
"build:tests": "rm -rf .tests && mkdir -p .tests && babel tests --out-dir .tests",
|
||||||
|
"coverage": "nyc report",
|
||||||
|
"coveralls": "npm run coverage -- --reporter=lcovonly && cat coverage/lcov.info | coveralls",
|
||||||
"postpublish": "./bin/semantic-release.js post",
|
"postpublish": "./bin/semantic-release.js post",
|
||||||
"prepublish": "./bin/semantic-release.js pre",
|
"prepublish": "npm run build && ./bin/semantic-release.js pre",
|
||||||
"test:style": "standard",
|
"pretest:integration": "npm run build && npm run build:tests",
|
||||||
"test:integration": "node tests | tap-spec",
|
"test": "./bin/test",
|
||||||
"test": "./bin/test"
|
"test:integration": "nyc tap --no-cov .tests/{scenarios,tap}/*.js",
|
||||||
},
|
"test:style": "standard"
|
||||||
"release": {
|
|
||||||
"verification": "cracks"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
src/lib/analyzer.js
Normal file
26
src/lib/analyzer.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const { parseRawCommit } = require('conventional-changelog/lib/git')
|
||||||
|
|
||||||
|
module.exports = function (commits) {
|
||||||
|
let type = null
|
||||||
|
|
||||||
|
commits
|
||||||
|
|
||||||
|
.map((commit) => parseRawCommit(`${commit.hash}\n${commit.message}`))
|
||||||
|
|
||||||
|
.filter((commit) => !!commit)
|
||||||
|
|
||||||
|
.every((commit) => {
|
||||||
|
if (commit.breaks.length) {
|
||||||
|
type = 'major'
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commit.type === 'feat') type = 'minor'
|
||||||
|
|
||||||
|
if (!type && commit.type === 'fix') type = 'patch'
|
||||||
|
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
return type
|
||||||
|
}
|
23
src/lib/commits.js
Normal file
23
src/lib/commits.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const { exec } = require('child_process')
|
||||||
|
|
||||||
|
const { efh } = require('./error')
|
||||||
|
|
||||||
|
module.exports = function (from, cb) {
|
||||||
|
const range = (from ? from + '..' : '') + 'HEAD'
|
||||||
|
exec(
|
||||||
|
`git log -E --format=%H==SPLIT==%B==END== ${range}`,
|
||||||
|
efh(cb)((stdout) => {
|
||||||
|
cb(null, String(stdout).split('==END==\n')
|
||||||
|
|
||||||
|
.filter((raw) => !!raw.trim())
|
||||||
|
|
||||||
|
.map((raw) => {
|
||||||
|
const data = raw.split('==SPLIT==')
|
||||||
|
return {
|
||||||
|
hash: data[0],
|
||||||
|
message: data[1]
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
8
src/lib/error.js
Normal file
8
src/lib/error.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
exports.efh = require('error-first-handler')
|
||||||
|
exports.standard = exports.efh((err) => {
|
||||||
|
console.log('Something went wrong:')
|
||||||
|
if (typeof err === 'string') return console.log(err)
|
||||||
|
if (err instanceof Error) return console.log(err.message, err.stack)
|
||||||
|
if (err.message) return console.log(err.message)
|
||||||
|
console.log(err)
|
||||||
|
})
|
@ -1,29 +1,30 @@
|
|||||||
'use strict'
|
const async = require('async')
|
||||||
|
const npmconf = require('npmconf')
|
||||||
var async = require('async')
|
const request = require('request')
|
||||||
var npmconf = require('npmconf')
|
|
||||||
var request = require('request')
|
|
||||||
|
|
||||||
module.exports = function (pkgName, cb) {
|
module.exports = function (pkgName, cb) {
|
||||||
var registry = process.env.npm_config_registry
|
const registry = process.env.npm_config_registry
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
npmconf.load,
|
npmconf.load,
|
||||||
function (conf, callback) {
|
(conf, callback) => {
|
||||||
var cred = conf.getCredentialsByURI(registry)
|
const cred = conf.getCredentialsByURI(registry)
|
||||||
var reqopts = {
|
const reqopts = {
|
||||||
url: registry + pkgName.replace(/\//g, '%2F'),
|
url: registry + pkgName.replace(/\//g, '%2F'),
|
||||||
headers: {}
|
headers: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cred.token) {
|
if (cred.token) {
|
||||||
reqopts.headers.Authorization = 'Bearer ' + cred.token
|
reqopts.headers.Authorization = `Bearer ${cred.token}`
|
||||||
} else if (cred.auth) {
|
} else if (cred.auth) {
|
||||||
reqopts.headers.Authorization = 'Basic ' + cred.auth
|
reqopts.headers.Authorization = `Basic ${cred.auth}`
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, reqopts)
|
callback(null, reqopts)
|
||||||
},
|
},
|
||||||
request,
|
request,
|
||||||
function (response, body, callback) {
|
(response, body, callback) => {
|
||||||
var res = {
|
let res = {
|
||||||
version: null,
|
version: null,
|
||||||
gitHead: null,
|
gitHead: null,
|
||||||
pkg: null
|
pkg: null
|
||||||
@ -31,7 +32,7 @@ module.exports = function (pkgName, cb) {
|
|||||||
|
|
||||||
if (response.statusCode === 404 || !body) return callback(null, res)
|
if (response.statusCode === 404 || !body) return callback(null, res)
|
||||||
|
|
||||||
var pkg = JSON.parse(body)
|
const pkg = JSON.parse(body)
|
||||||
|
|
||||||
if (pkg.error) return callback(pkg.error)
|
if (pkg.error) return callback(pkg.error)
|
||||||
|
|
15
src/lib/release-notes.js
Normal file
15
src/lib/release-notes.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const { readFileSync } = require('fs')
|
||||||
|
|
||||||
|
const changelog = require('conventional-changelog')
|
||||||
|
const parseUrl = require('github-url-from-git')
|
||||||
|
|
||||||
|
module.exports = function (cb) {
|
||||||
|
const pkg = JSON.parse(readFileSync('./package.json'))
|
||||||
|
const repository = pkg.repository ? parseUrl(pkg.repository.url) : null
|
||||||
|
|
||||||
|
changelog({
|
||||||
|
version: pkg.version,
|
||||||
|
repository: repository,
|
||||||
|
file: false
|
||||||
|
}, cb)
|
||||||
|
}
|
65
src/main.js
Normal file
65
src/main.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
const abbrev = require('abbrev')
|
||||||
|
const efh = require('./lib/error').standard
|
||||||
|
|
||||||
|
exports.pre = function (argv, npmArgv, plugins) {
|
||||||
|
// see src/restart.js
|
||||||
|
if (npmArgv['semantic-release-rerun']) {
|
||||||
|
if (!/semantically-released/.test(process.env.npm_package_version)) process.exit(0)
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`There is something wrong with your setup, as a placeholder version is about to be released.
|
||||||
|
Please verify that your setup is correct.
|
||||||
|
If you think this is a problem with semantic-release please open an issue.`
|
||||||
|
)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
// the `prepublish` hook is also executed when the package is installed
|
||||||
|
// in this case we abort the command and do nothing.
|
||||||
|
if (
|
||||||
|
isAbbrev(npmArgv, 'install') ||
|
||||||
|
isAbbrev(npmArgv, 'link') ||
|
||||||
|
isAbbrev(npmArgv, 'pack')
|
||||||
|
) process.exit(0)
|
||||||
|
|
||||||
|
if (argv.debug) console.log('This is a dry run')
|
||||||
|
|
||||||
|
console.log('Determining new version')
|
||||||
|
|
||||||
|
const publish = isAbbrev(npmArgv, 'publish')
|
||||||
|
|
||||||
|
// require a correct setup during publish
|
||||||
|
if (publish && !argv.debug && !require('./verify')(argv)) process.exit(1)
|
||||||
|
|
||||||
|
require('./pre')(argv, plugins, efh((result) => {
|
||||||
|
if (!result) {
|
||||||
|
console.log('Nothing changed. Not publishing.')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Publishing v' + result)
|
||||||
|
if (!publish) process.exit(0)
|
||||||
|
|
||||||
|
if (argv.debug) process.exit(1)
|
||||||
|
|
||||||
|
require('./restart')(efh(() => process.exit(1)))
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.post = function (argv, npmArgv, plugins) {
|
||||||
|
require('./post')(argv, plugins, efh(function () {
|
||||||
|
// see src/restart.js
|
||||||
|
if (npmArgv['semantic-release-rerun']) {
|
||||||
|
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.setup = function () {
|
||||||
|
require('./setup')()
|
||||||
|
console.log('"package.json" is set up properly. Now configure your CI server.')
|
||||||
|
console.log('https://github.com/boennemann/semantic-release#ci-server')
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAbbrev (argv, command) {
|
||||||
|
return argv._.some(Object.prototype.hasOwnProperty.bind(abbrev(command)))
|
||||||
|
}
|
38
src/post.js
38
src/post.js
@ -1,38 +1,36 @@
|
|||||||
'use strict'
|
const { readFileSync } = require('fs')
|
||||||
|
const url = require('url')
|
||||||
|
|
||||||
var readFile = require('fs').readFileSync
|
const gitHead = require('git-head')
|
||||||
var url = require('url')
|
const GitHubApi = require('github')
|
||||||
|
const parseSlug = require('parse-github-repo-url')
|
||||||
|
|
||||||
var gitHead = require('git-head')
|
const efh = require('./lib/error').efh
|
||||||
var GitHubApi = require('github')
|
|
||||||
var parseSlug = require('parse-github-repo-url')
|
|
||||||
|
|
||||||
var efh = require('../lib/error').efh
|
|
||||||
|
|
||||||
module.exports = function (options, plugins, cb) {
|
module.exports = function (options, plugins, cb) {
|
||||||
var pkg = JSON.parse(readFile('./package.json'))
|
const pkg = JSON.parse(readFileSync('./package.json'))
|
||||||
var repository = pkg.repository ? pkg.repository.url : null
|
const repository = pkg.repository ? pkg.repository.url : null
|
||||||
|
|
||||||
if (!repository) return cb(new Error('Package must have a repository'))
|
if (!repository) return cb(new Error('Package must have a repository'))
|
||||||
|
|
||||||
var notesGenerator = require(plugins.notes || '../lib/release-notes')
|
const notesGenerator = require(plugins.notes || './lib/release-notes')
|
||||||
|
|
||||||
var config = options['github-url'] ? url.parse(options['github-url']) : {}
|
const config = options['github-url'] ? url.parse(options['github-url']) : {}
|
||||||
|
|
||||||
var github = new GitHubApi({
|
const github = new GitHubApi({
|
||||||
version: '3.0.0',
|
version: '3.0.0',
|
||||||
port: config.port,
|
port: config.port,
|
||||||
protocol: (config.protocol || '').split(':')[0] || null,
|
protocol: (config.protocol || '').split(':')[0] || null,
|
||||||
host: config.hostname
|
host: config.hostname
|
||||||
})
|
})
|
||||||
|
|
||||||
notesGenerator(efh(cb)(function (log) {
|
notesGenerator(efh(cb)((log) => {
|
||||||
gitHead(efh(cb)(function (hash) {
|
gitHead(efh(cb)((hash) => {
|
||||||
var ghRepo = parseSlug(repository)
|
const ghRepo = parseSlug(repository)
|
||||||
var release = {
|
const release = {
|
||||||
owner: ghRepo[0],
|
owner: ghRepo[0],
|
||||||
repo: ghRepo[1],
|
repo: ghRepo[1],
|
||||||
tag_name: 'v' + pkg.version,
|
tag_name: `v${pkg.version}`,
|
||||||
target_commitish: hash,
|
target_commitish: hash,
|
||||||
draft: options.debug,
|
draft: options.debug,
|
||||||
body: log
|
body: log
|
||||||
@ -43,9 +41,7 @@ module.exports = function (options, plugins, cb) {
|
|||||||
token: options.token
|
token: options.token
|
||||||
})
|
})
|
||||||
|
|
||||||
github.releases.createRelease(release, efh(cb)(function () {
|
github.releases.createRelease(release, efh(cb)(() => cb(null, true)))
|
||||||
cb(null, true)
|
|
||||||
}))
|
|
||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
34
src/pre.js
34
src/pre.js
@ -1,23 +1,21 @@
|
|||||||
'use strict'
|
const fs = require('fs')
|
||||||
|
|
||||||
var fs = require('fs')
|
const semver = require('semver')
|
||||||
|
|
||||||
var semver = require('semver')
|
const getCommits = require('./lib/commits')
|
||||||
|
const npmInfo = require('./lib/npm-info')
|
||||||
var getCommits = require('../lib/commits')
|
const { efh } = require('./lib/error')
|
||||||
var npmInfo = require('../lib/npm-info')
|
|
||||||
var efh = require('../lib/error').efh
|
|
||||||
|
|
||||||
module.exports = function (options, plugins, cb) {
|
module.exports = function (options, plugins, cb) {
|
||||||
var path = './package.json'
|
const path = './package.json'
|
||||||
var pkg = JSON.parse(fs.readFileSync(path))
|
let pkg = JSON.parse(fs.readFileSync(path))
|
||||||
|
|
||||||
if (!pkg.name) return cb(new Error('Package must have a name'))
|
if (!pkg.name) return cb(new Error('Package must have a name'))
|
||||||
|
|
||||||
npmInfo(pkg.name, efh(cb)(function (res) {
|
npmInfo(pkg.name, efh(cb)((res) => {
|
||||||
getCommits(res.gitHead, efh(cb)(function (commits) {
|
getCommits(res.gitHead, efh(cb)((commits) => {
|
||||||
var analyzer = require(plugins.analyzer || '../lib/analyzer')
|
const analyzer = require(plugins.analyzer || './lib/analyzer')
|
||||||
var type = analyzer(commits)
|
let type = analyzer(commits)
|
||||||
|
|
||||||
if (!type) return cb(null, null)
|
if (!type) return cb(null, null)
|
||||||
|
|
||||||
@ -28,14 +26,14 @@ module.exports = function (options, plugins, cb) {
|
|||||||
pkg.version = '1.0.0'
|
pkg.version = '1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
var writePkg = function () {
|
function writePkg () {
|
||||||
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n')
|
if (!options.debug) fs.writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\n`)
|
||||||
cb(null, pkg.version)
|
cb(null, pkg.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugins.verification) return writePkg()
|
if (!plugins.verification) return writePkg()
|
||||||
|
|
||||||
var opts = {}
|
let opts = {}
|
||||||
|
|
||||||
if (typeof plugins.verification === 'string') {
|
if (typeof plugins.verification === 'string') {
|
||||||
opts.path = plugins.verification
|
opts.path = plugins.verification
|
||||||
@ -50,11 +48,11 @@ module.exports = function (options, plugins, cb) {
|
|||||||
opts.version = res.version
|
opts.version = res.version
|
||||||
opts.nextVersion = pkg.version
|
opts.nextVersion = pkg.version
|
||||||
|
|
||||||
var verification = require(opts.path)
|
const verification = require(opts.path)
|
||||||
|
|
||||||
console.log('Running verification hook...')
|
console.log('Running verification hook...')
|
||||||
|
|
||||||
verification(opts, function (error, ok) {
|
verification(opts, (error, ok) => {
|
||||||
if (!error && ok) return writePkg()
|
if (!error && ok) return writePkg()
|
||||||
console.log('Verification failed' + (error ? ': ' + error : ''))
|
console.log('Verification failed' + (error ? ': ' + error : ''))
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
'use strict'
|
const { spawn } = require('child_process')
|
||||||
|
|
||||||
var spawn = require('child_process').spawn
|
let exports = module.exports = function (cb) {
|
||||||
|
|
||||||
var exports = module.exports = function (cb) {
|
|
||||||
// npm loads package.json data before running the `prepublish` hook
|
// npm loads package.json data before running the `prepublish` hook
|
||||||
// changing the version on `prepublish` has no effect
|
// changing the version on `prepublish` has no effect
|
||||||
// see https://github.com/npm/npm/issues/7118
|
// see https://github.com/npm/npm/issues/7118
|
||||||
// to circumvent this behavior we are calling `npm publish` inside `prepublish`
|
// to circumvent this behavior we are calling `npm publish` inside `prepublish`
|
||||||
// the package.json is then loaded again and the correct version will be published
|
// the package.json is then loaded again and the correct version will be published
|
||||||
|
|
||||||
var child = spawn('npm', ['publish', '--semantic-release-rerun'])
|
const child = spawn('npm', ['publish', '--semantic-release-rerun'])
|
||||||
var handler = exports.handleCloseAndExit.bind(null, cb)
|
const handler = exports.handleCloseAndExit.bind(null, cb)
|
||||||
|
|
||||||
child.stdout.pipe(process.stdout)
|
child.stdout.pipe(process.stdout)
|
||||||
child.stderr.pipe(process.stderr)
|
child.stderr.pipe(process.stderr)
|
||||||
@ -23,8 +21,8 @@ var exports = module.exports = function (cb) {
|
|||||||
exports.handleCloseAndExit = function (cb, code, signal) {
|
exports.handleCloseAndExit = function (cb, code, signal) {
|
||||||
if (code === 0) return cb(null)
|
if (code === 0) return cb(null)
|
||||||
cb({
|
cb({
|
||||||
code: code,
|
code,
|
||||||
signal: signal,
|
signal,
|
||||||
message: 'npm publish failed'
|
message: 'npm publish failed'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
29
src/setup.js
29
src/setup.js
@ -1,32 +1,33 @@
|
|||||||
'use strict'
|
const {
|
||||||
|
readFileSync,
|
||||||
|
writeFileSync
|
||||||
|
} = require('fs')
|
||||||
|
|
||||||
var fs = require('fs')
|
const ini = require('ini')
|
||||||
|
const ghUrl = require('github-url-from-git')
|
||||||
var ini = require('ini')
|
|
||||||
var ghUrl = require('github-url-from-git')
|
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
var pkg = JSON.parse(fs.readFileSync('./package.json') + '')
|
let pkg = JSON.parse(String(readFileSync('./package.json')))
|
||||||
|
|
||||||
// ensure a yet unpublished version
|
// ensure a yet unpublished version
|
||||||
pkg.version = '0.0.0-semantically-released'
|
pkg.version = '0.0.0-semantically-released'
|
||||||
|
|
||||||
// set up scripts
|
// set up scripts
|
||||||
var pre = 'semantic-release pre'
|
const pre = 'semantic-release pre'
|
||||||
var post = 'semantic-release post'
|
const post = 'semantic-release post'
|
||||||
|
|
||||||
if (!pkg.scripts) pkg.scripts = {}
|
if (!pkg.scripts) pkg.scripts = {}
|
||||||
|
|
||||||
if (!pkg.scripts.prepublish) pkg.scripts.prepublish = pre
|
if (!pkg.scripts.prepublish) pkg.scripts.prepublish = pre
|
||||||
else if (!(new RegExp(pre).test(pkg.scripts.prepublish))) pkg.scripts.prepublish += ' && ' + pre
|
else if (!(new RegExp(pre).test(pkg.scripts.prepublish))) pkg.scripts.prepublish += ` && ${pre}`
|
||||||
|
|
||||||
if (!pkg.scripts.postpublish) pkg.scripts.postpublish = post
|
if (!pkg.scripts.postpublish) pkg.scripts.postpublish = post
|
||||||
else if (!(new RegExp(post).test(pkg.scripts.postpublish))) pkg.scripts.postpublish += ' && ' + post
|
else if (!(new RegExp(post).test(pkg.scripts.postpublish))) pkg.scripts.postpublish += ` && ${post}`
|
||||||
|
|
||||||
// set up repository
|
// set up repository
|
||||||
if (!pkg.repository || !pkg.repository.url) {
|
if (!pkg.repository || !pkg.repository.url) {
|
||||||
var config = ini.decode(fs.readFileSync('./.git/config') + '')
|
const config = ini.decode(String(readFileSync('./.git/config')))
|
||||||
var repo = config['remote "origin"'].url
|
const repo = config['remote "origin"'].url
|
||||||
|
|
||||||
if (repo) pkg.repository = { type: 'git', url: ghUrl(repo) }
|
if (repo) pkg.repository = { type: 'git', url: ghUrl(repo) }
|
||||||
}
|
}
|
||||||
@ -35,8 +36,8 @@ module.exports = function () {
|
|||||||
if (!pkg.devDependencies) pkg.devDependencies = {}
|
if (!pkg.devDependencies) pkg.devDependencies = {}
|
||||||
|
|
||||||
if (!pkg.devDependencies['semantic-release']) {
|
if (!pkg.devDependencies['semantic-release']) {
|
||||||
pkg.devDependencies['semantic-release'] = '^' + require('../package.json').version
|
pkg.devDependencies['semantic-release'] = `^${require('../package.json').version}`
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n')
|
writeFileSync('./package.json', `${JSON.stringify(pkg, null, 2)}\n`)
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
'use strict'
|
const { readFileSync } = require('fs')
|
||||||
|
|
||||||
var fs = require('fs')
|
let exports = module.exports = function (input) {
|
||||||
|
const options = exports.verifyOptions(input)
|
||||||
var exports = module.exports = function (input) {
|
const pkg = exports.verifyPackage()
|
||||||
var options = exports.verifyOptions(input)
|
const travis = exports.verifyTravis()
|
||||||
var pkg = exports.verifyPackage()
|
|
||||||
var travis = exports.verifyTravis()
|
|
||||||
return options && pkg && travis
|
return options && pkg && travis
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.verifyTravis = function () {
|
exports.verifyTravis = function () {
|
||||||
|
let travis
|
||||||
try {
|
try {
|
||||||
var travis = fs.readFileSync('.travis.yml') + ''
|
travis = String(readFileSync('.travis.yml'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var passed = true
|
let passed = true
|
||||||
|
|
||||||
if (!/\sdeploy:/m.test(travis)) {
|
if (!/\sdeploy:/m.test(travis)) {
|
||||||
console.error('You should configure deployments inside the ".travis.yml".')
|
console.error('You should configure deployments inside the ".travis.yml".')
|
||||||
@ -32,10 +31,11 @@ exports.verifyTravis = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.verifyPackage = function () {
|
exports.verifyPackage = function () {
|
||||||
var passed = true
|
let passed = true
|
||||||
|
|
||||||
|
let pkg
|
||||||
try {
|
try {
|
||||||
var pkg = fs.readFileSync('./package.json') + ''
|
pkg = String(readFileSync('./package.json'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('You must have a "package.json" present.')
|
console.error('You must have a "package.json" present.')
|
||||||
passed = false
|
passed = false
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
var test = require('tape')
|
|
||||||
|
|
||||||
var createModule = require('./lib/create-module')
|
|
||||||
|
|
||||||
require('./tap/npm-info')(test)
|
|
||||||
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)
|
|
||||||
require('./scenarios/publish')(test, createModule)
|
|
||||||
require('./scenarios/verify')(test, createModule)
|
|
||||||
require('./scenarios/setup')(test, createModule)
|
|
@ -1,34 +1,32 @@
|
|||||||
'use strict'
|
const fs = require('fs')
|
||||||
|
const exec = require('child_process').exec
|
||||||
|
|
||||||
var fs = require('fs')
|
const nixt = require('nixt')
|
||||||
var exec = require('child_process').exec
|
|
||||||
|
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
module.exports = function (t, message, version, code, name, cwd) {
|
module.exports = function (t, message, version, code, name, cwd) {
|
||||||
t.test(name, function (t) {
|
t.test(name, (t) => {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
|
|
||||||
nixt()
|
nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
.env('CI', true)
|
.env('CI', true)
|
||||||
.env('npm_config_registry', 'http://127.0.0.1:4873/')
|
.env('npm_config_registry', 'http://127.0.0.1:4873/')
|
||||||
.exec('git commit --allow-empty -m "' + message + '"')
|
.exec(`git commit --allow-empty -m "${message}"`)
|
||||||
.run('npm run prepublish')
|
.run('npm run prepublish')
|
||||||
.code(code)
|
.code(code)
|
||||||
.stdout(/> semantic-release pre\n\nDetermining new version\n/m)
|
.stdout(/semantic-release.js pre\n\nDetermining new version\n/m)
|
||||||
.end(function (err) {
|
.end((err) => {
|
||||||
t.error(err, 'nixt')
|
t.error(err, 'nixt')
|
||||||
|
|
||||||
var pkg = JSON.parse(fs.readFileSync(cwd + '/package.json'))
|
const pkg = JSON.parse(fs.readFileSync(`${cwd}/package.json`))
|
||||||
t.is(pkg.version, version, 'version')
|
t.is(pkg.version, version, 'version')
|
||||||
|
|
||||||
if (code === 1) {
|
if (code === 1) {
|
||||||
return t.error(null, 'no publish')
|
return t.error(null, 'no publish')
|
||||||
}
|
}
|
||||||
|
|
||||||
exec('npm publish --ignore-scripts', {cwd: cwd}, function (err) {
|
exec('npm publish --ignore-scripts', {cwd}, (err) => {
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
t.error(err, 'publish')
|
t.error(err, 'publish')
|
||||||
}, 300)
|
}, 300)
|
||||||
})
|
})
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
'use strict'
|
const exec = require('child_process').exec
|
||||||
|
const join = require('path').join
|
||||||
|
|
||||||
var exec = require('child_process').exec
|
const efh = require('error-first-handler')
|
||||||
var join = require('path').join
|
const defaults = require('lodash.defaults')
|
||||||
|
const uid = require('nano-uid')()
|
||||||
var efh = require('error-first-handler')
|
|
||||||
var defaults = require('lodash.defaults')
|
|
||||||
var uid = require('nano-uid')()
|
|
||||||
|
|
||||||
module.exports = function (input) {
|
module.exports = function (input) {
|
||||||
var cb = Array.prototype.pop.call(arguments)
|
const cb = Array.prototype.pop.call(arguments)
|
||||||
uid.generate(5, efh(cb)(function (id) {
|
uid.generate(5, efh(cb)((id) => {
|
||||||
var pkg = defaults((typeof input === 'object' ? input : {}), {
|
const pkg = defaults((typeof input === 'object' ? input : {}), {
|
||||||
name: id,
|
name: id,
|
||||||
version: '0.0.0',
|
version: '0.0.0',
|
||||||
devDependencies: {
|
|
||||||
'semantic-release': 'file:../../../'
|
|
||||||
},
|
|
||||||
scripts: {
|
scripts: {
|
||||||
prepublish: 'semantic-release pre',
|
prepublish: '../../../bin/semantic-release.js pre',
|
||||||
postpublish: 'semantic-release post'
|
postpublish: '../../../bin/semantic-release.js post'
|
||||||
},
|
},
|
||||||
publishConfig: {
|
publishConfig: {
|
||||||
registry: 'http://localhost:4873/'
|
registry: 'http://localhost:4873/'
|
||||||
@ -26,19 +21,18 @@ module.exports = function (input) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
id = pkg.name
|
id = pkg.name
|
||||||
var cwd = join(__dirname, '../../.tmp/modules', id)
|
const cwd = join(__dirname, '../../.tmp/modules', id)
|
||||||
|
|
||||||
exec(
|
exec(
|
||||||
'mkdir ' + cwd + ' && ' +
|
`mkdir ${cwd} &&
|
||||||
'cd ' + cwd + ' && ' +
|
cd ${cwd} &&
|
||||||
'git init && ' +
|
git init &&
|
||||||
'echo \'' + JSON.stringify(pkg, null, 2) + '\' >> package.json && ' +
|
echo '${JSON.stringify(pkg, null, 2)}' >> package.json &&
|
||||||
'git add . && ' +
|
git add . &&
|
||||||
'git config user.email "integration@test" && ' +
|
git config user.email "integration@test" &&
|
||||||
'git config user.name "Integration Test" && ' +
|
git config user.name "Integration Test" &&
|
||||||
'git commit -m "initial" && ' +
|
git commit -m "initial"`
|
||||||
'npm install'
|
, efh(cb)((stdout) => {
|
||||||
, efh(cb)(function (stdout) {
|
|
||||||
cb(null, id, cwd)
|
cb(null, id, cwd)
|
||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = function (commits) {
|
module.exports = function (commits) {
|
||||||
var type = null
|
let type = null
|
||||||
|
|
||||||
commits.every(function (commit) {
|
commits.every((commit) => {
|
||||||
if (/FOO/.test(commit.message)) {
|
if (/FOO/.test(commit.message)) {
|
||||||
type = 'major'
|
type = 'major'
|
||||||
return false
|
return false
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = function (cb) {
|
module.exports = function (cb) {
|
||||||
cb(null, 'custom log')
|
cb(null, 'custom log')
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = function (opts, cb) {
|
module.exports = function (opts, cb) {
|
||||||
cb(null, !(opts.commits.length % 2))
|
cb(null, !(opts.commits.length % 2))
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,21 @@
|
|||||||
'use strict'
|
const path = require('path')
|
||||||
|
|
||||||
var path = require('path')
|
const efh = require('error-first-handler')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
|
const commitToVersionTest = require('../lib/commit-to-version-test')
|
||||||
|
|
||||||
var commitToVersionTest = require('../lib/commit-to-version-test')
|
test('custom-analyzer', (t) => {
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
|
||||||
createModule({
|
createModule({
|
||||||
release: {
|
release: {
|
||||||
analyzer: path.join(__dirname, '../lib/custom-analyzer')
|
analyzer: path.join(__dirname, '../lib/custom-analyzer')
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
test('custom-analyzer', function (t) {
|
|
||||||
commitToVersionTest(t, 'HO', '0.0.0', 1, 'abort publish w/o changes', cwd)
|
commitToVersionTest(t, 'HO', '0.0.0', 1, 'abort publish w/o changes', cwd)
|
||||||
commitToVersionTest(t, 'BAZ', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd)
|
commitToVersionTest(t, 'BAZ', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd)
|
||||||
commitToVersionTest(t, 'BAZ', '1.0.1', 0, 'bump patch for fix', cwd)
|
commitToVersionTest(t, 'BAZ', '1.0.1', 0, 'bump patch for fix', cwd)
|
||||||
commitToVersionTest(t, 'BAR', '1.1.0', 0, 'bump minor for feature', cwd)
|
commitToVersionTest(t, 'BAR', '1.1.0', 0, 'bump minor for feature', cwd)
|
||||||
commitToVersionTest(t, 'FOO', '2.0.0', 0, 'bump major for breaking change', cwd)
|
commitToVersionTest(t, 'FOO', '2.0.0', 0, 'bump major for breaking change', cwd)
|
||||||
})
|
|
||||||
}))
|
}))
|
||||||
}
|
})
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
'use strict'
|
const path = require('path')
|
||||||
|
|
||||||
var path = require('path')
|
const efh = require('error-first-handler')
|
||||||
|
const nixt = require('nixt')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
test('custom-verification', (t) => {
|
||||||
createModule({
|
createModule({
|
||||||
release: {
|
release: {
|
||||||
verification: path.join(__dirname, '../lib/custom-verification')
|
verification: path.join(__dirname, '../lib/custom-verification')
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
test('custom-verification', function (t) {
|
t.test('even commit count', (t) => {
|
||||||
t.test('even commit count', function (t) {
|
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
nixt()
|
nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
@ -21,12 +21,10 @@ module.exports = function (test, createModule) {
|
|||||||
.exec('git commit --allow-empty -m "feat: commit"')
|
.exec('git commit --allow-empty -m "feat: commit"')
|
||||||
.run('npm run prepublish')
|
.run('npm run prepublish')
|
||||||
.code(0)
|
.code(0)
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('odd commit count', function (t) {
|
t.test('odd commit count', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
nixt()
|
nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
@ -36,10 +34,7 @@ module.exports = function (test, createModule) {
|
|||||||
.run('npm run prepublish')
|
.run('npm run prepublish')
|
||||||
.code(1)
|
.code(1)
|
||||||
.stdout(/Verification failed/)
|
.stdout(/Verification failed/)
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
}
|
})
|
||||||
|
@ -1,37 +1,36 @@
|
|||||||
'use strict'
|
const fs = require('fs')
|
||||||
|
|
||||||
var fs = require('fs')
|
const efh = require('error-first-handler')
|
||||||
|
const nixt = require('nixt')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
test('ignore', (t) => {
|
||||||
createModule(efh()(function (name, cwd) {
|
createModule(efh()((name, cwd) => {
|
||||||
test('ignore', function (t) {
|
ignoreTest(t, cwd, 'npm install', 'not doing anything when the module is installed')
|
||||||
ignoreTest(t, 'npm install', 'not doing anything when the module is installed')
|
ignoreTest(t, cwd, 'npm i', 'not doing anything when the module is installed with abbrevd command')
|
||||||
ignoreTest(t, 'npm i', 'not doing anything when the module is installed with abbrevd command')
|
ignoreTest(t, cwd, 'npm link', 'not doing anything when the module is linked')
|
||||||
ignoreTest(t, 'npm link', 'not doing anything when the module is linked')
|
ignoreTest(t, cwd, 'npm lin', 'not doing anything when the module is linked with abbrevd command')
|
||||||
ignoreTest(t, 'npm lin', 'not doing anything when the module is linked with abbrevd command')
|
ignoreTest(t, cwd, 'npm pack', 'not doing anything when the module is packed')
|
||||||
ignoreTest(t, 'npm pack', 'not doing anything when the module is packed')
|
ignoreTest(t, cwd, 'npm pa', 'not doing anything when the module is packed with abbrevd command')
|
||||||
ignoreTest(t, 'npm pa', 'not doing anything when the module is packed with abbrevd command')
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
function ignoreTest (t, command, name, last) {
|
function ignoreTest (t, cwd, command, name) {
|
||||||
t.test(name, function (t) {
|
t.test(name, (t) => {
|
||||||
t.plan(2)
|
t.plan(2)
|
||||||
|
|
||||||
var pkg = fs.readFileSync(cwd + '/package.json')
|
const pkg = String(fs.readFileSync(cwd + '/package.json'))
|
||||||
|
|
||||||
nixt()
|
nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
.run(command)
|
.run(command)
|
||||||
.code(0)
|
.code(0)
|
||||||
.stdout(/> semantic-release pre\n$/m)
|
.stdout(/semantic-release.js pre\n$/m)
|
||||||
.end(function (err) {
|
.end((err) => {
|
||||||
t.is(pkg + '', fs.readFileSync(cwd + '/package.json') + '', 'package')
|
t.is(pkg, String(fs.readFileSync(`${cwd}/package.json`)), 'package')
|
||||||
t.error(err, 'nixt')
|
t.error(err, 'nixt')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
'use strict'
|
const path = require('path')
|
||||||
|
|
||||||
var path = require('path')
|
const efh = require('error-first-handler')
|
||||||
|
const GitHubApi = require('github')
|
||||||
|
const nixt = require('nixt')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
var GitHubApi = require('github')
|
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
var github = new GitHubApi({
|
const github = new GitHubApi({
|
||||||
version: '3.0.0',
|
version: '3.0.0',
|
||||||
port: 4343,
|
port: 4343,
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
@ -18,52 +19,46 @@ github.authenticate({
|
|||||||
token: '***'
|
token: '***'
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
test('postpublish', (t) => {
|
||||||
createModule({
|
createModule({
|
||||||
version: '2.0.0',
|
version: '2.0.0',
|
||||||
repository: {
|
repository: {
|
||||||
type: 'git',
|
type: 'git',
|
||||||
url: 'http://github.com/user/repo'
|
url: 'http://github.com/user/repo'
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
test('postpublish', function (t) {
|
const base = getBase(cwd)
|
||||||
var base = getBase(cwd)
|
|
||||||
|
|
||||||
t.test('publish new version to github releases', function (t) {
|
t.test('publish new version to github releases', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
|
|
||||||
base.clone()
|
base.clone()
|
||||||
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
|
.stdout(/semantic-release.js post\n\nGenerating changelog from.*\nParsed/m)
|
||||||
.run('npm run postpublish')
|
.run('npm run postpublish')
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('publish new version (with detached HEAD) to github releases', function (t) {
|
t.test('publish new version (with detached HEAD) to github releases', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
|
|
||||||
base.clone()
|
base.clone()
|
||||||
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
|
.stdout(/semantic-release.js post\n\nGenerating changelog from.*\nParsed/m)
|
||||||
.exec('git checkout `git rev-parse HEAD`')
|
.exec('git checkout `git rev-parse HEAD`')
|
||||||
.run('npm run postpublish')
|
.run('npm run postpublish')
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('correct data published', function (t) {
|
t.test('correct data published', (t) => {
|
||||||
t.plan(4)
|
t.plan(4)
|
||||||
|
|
||||||
github.releases.getRelease({ owner: 'user', repo: 'repo', id: 1}, function (err, raw) {
|
github.releases.getRelease({ owner: 'user', repo: 'repo', id: 1}, (err, raw) => {
|
||||||
var res = JSON.parse(raw)
|
const res = JSON.parse(raw)
|
||||||
t.error(err, 'github')
|
t.error(err, 'github')
|
||||||
t.is(res.tag_name, 'v2.0.0', 'version')
|
t.is(res.tag_name, 'v2.0.0', 'version')
|
||||||
t.is(res.author.login, 'user', 'user')
|
t.is(res.author.login, 'user', 'user')
|
||||||
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\*\n.*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')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
createModule({
|
createModule({
|
||||||
@ -75,34 +70,30 @@ module.exports = function (test, createModule) {
|
|||||||
release: {
|
release: {
|
||||||
notes: path.join(__dirname, '../lib/custom-release-notes')
|
notes: path.join(__dirname, '../lib/custom-release-notes')
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
test('custom-release-notes', function (t) {
|
const base = getBase(cwd)
|
||||||
var base = getBase(cwd)
|
|
||||||
|
|
||||||
t.test('publish new version (with custom notes) to github releases', function (t) {
|
t.test('publish new version (with custom notes) to github releases', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
|
|
||||||
base.clone()
|
base.clone()
|
||||||
.run('npm run postpublish')
|
.run('npm run postpublish')
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('custom notes published', function (t) {
|
t.test('custom notes published', (t) => {
|
||||||
t.plan(4)
|
t.plan(4)
|
||||||
|
|
||||||
github.releases.getRelease({ owner: 'user', repo: 'repo', id: 3}, function (err, raw) {
|
github.releases.getRelease({ owner: 'user', repo: 'repo', id: 3}, (err, raw) => {
|
||||||
var res = JSON.parse(raw)
|
const res = JSON.parse(raw)
|
||||||
t.error(err, 'github')
|
t.error(err, 'github')
|
||||||
t.is(res.tag_name, 'v2.0.0', 'version')
|
t.is(res.tag_name, 'v2.0.0', 'version')
|
||||||
t.is(res.author.login, 'user', 'user')
|
t.is(res.author.login, 'user', 'user')
|
||||||
t.ok(/custom log/.test(res.body), 'body')
|
t.ok(/custom log/.test(res.body), 'body')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}))
|
}))
|
||||||
}
|
})
|
||||||
|
|
||||||
function getBase (cwd) {
|
function getBase (cwd) {
|
||||||
return nixt()
|
return nixt()
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
'use strict'
|
const efh = require('error-first-handler')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
|
const commitToVersionTest = require('../lib/commit-to-version-test')
|
||||||
|
|
||||||
var commitToVersionTest = require('../lib/commit-to-version-test')
|
test('prepublish', (t) => {
|
||||||
|
createModule(efh()((name, cwd) => {
|
||||||
module.exports = function (test, createModule) {
|
|
||||||
createModule(efh()(function (name, cwd) {
|
|
||||||
test('prepublish', function (t) {
|
|
||||||
commitToVersionTest(t, 'refactor: change', '0.0.0', 1, 'abort publish w/o changes', cwd)
|
commitToVersionTest(t, 'refactor: change', '0.0.0', 1, 'abort publish w/o changes', cwd)
|
||||||
commitToVersionTest(t, 'fix: change', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd)
|
commitToVersionTest(t, 'fix: change', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd)
|
||||||
commitToVersionTest(t, 'fix: change', '1.0.1', 0, 'bump patch for fix', cwd)
|
commitToVersionTest(t, 'fix: change', '1.0.1', 0, 'bump patch for fix', cwd)
|
||||||
commitToVersionTest(t, 'feat: change', '1.1.0', 0, 'bump minor for feature', cwd)
|
commitToVersionTest(t, 'feat: change', '1.1.0', 0, 'bump minor for feature', cwd)
|
||||||
commitToVersionTest(t, 'fix: BREAKING CHANGE: change', '2.0.0', 0, 'bump major for breaking change', cwd)
|
commitToVersionTest(t, 'fix: BREAKING CHANGE: change', '2.0.0', 0, 'bump major for breaking change', cwd)
|
||||||
})
|
|
||||||
}))
|
}))
|
||||||
}
|
})
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
'use strict'
|
const efh = require('error-first-handler')
|
||||||
|
const nixt = require('nixt')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
test('publish', (t) => {
|
||||||
test('publish', function (t) {
|
|
||||||
publishTest(t, 'npm publish', 'pre and post hooks work as a part of publish')
|
publishTest(t, 'npm publish', 'pre and post hooks work as a part of publish')
|
||||||
publishTest(t, 'npm pub', 'pre and post hooks work as a part of publish with abbrevd command')
|
publishTest(t, 'npm pub', 'pre and post hooks work as a part of publish with abbrevd command')
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ module.exports = function (test, createModule) {
|
|||||||
type: 'git',
|
type: 'git',
|
||||||
url: 'http://github.com/user/repo'
|
url: 'http://github.com/user/repo'
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
t.test(testname, function (t) {
|
t.test(testname, (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
|
|
||||||
nixt()
|
nixt()
|
||||||
@ -27,11 +27,8 @@ module.exports = function (test, createModule) {
|
|||||||
.run(command)
|
.run(command)
|
||||||
.code(1)
|
.code(1)
|
||||||
.stdout(/Everything is alright/)
|
.stdout(/Everything is alright/)
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
'use strict'
|
const join = require('path').join
|
||||||
|
const readFile = require('fs').readFileSync
|
||||||
|
|
||||||
var join = require('path').join
|
const efh = require('error-first-handler')
|
||||||
var readFile = require('fs').readFileSync
|
const nixt = require('nixt')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
test('setup', (t) => {
|
||||||
createModule({
|
createModule({
|
||||||
repository: {},
|
repository: {},
|
||||||
scripts: {
|
scripts: {
|
||||||
postpublish: 'npm run gh-pages'
|
postpublish: 'npm run gh-pages'
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
test('setup', function (t) {
|
t.test('setup "package.json"', (t) => {
|
||||||
t.test('setup "package.json"', function (t) {
|
|
||||||
t.plan(5)
|
t.plan(5)
|
||||||
|
|
||||||
nixt()
|
nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
.exec('git remote add origin git@github.com:user/repo.git')
|
.exec('git remote add origin git@github.com:user/repo.git')
|
||||||
.run('./node_modules/.bin/semantic-release setup')
|
.run('../../../bin/semantic-release.js setup')
|
||||||
.code(0)
|
.code(0)
|
||||||
.end(function (err) {
|
.end((err) => {
|
||||||
t.error(err, 'nixt')
|
t.error(err, 'nixt')
|
||||||
|
|
||||||
var pkg = JSON.parse(readFile(join(cwd, 'package.json')))
|
const pkg = JSON.parse(readFile(join(cwd, 'package.json')))
|
||||||
|
|
||||||
t.is(pkg.version, '0.0.0-semantically-released', 'version')
|
t.is(pkg.version, '0.0.0-semantically-released', 'version')
|
||||||
t.is(pkg.repository.url, 'https://github.com/user/repo', 'repo')
|
t.is(pkg.repository.url, 'https://github.com/user/repo', 'repo')
|
||||||
@ -33,6 +33,5 @@ module.exports = function (test, createModule) {
|
|||||||
t.is(pkg.scripts.postpublish, 'npm run gh-pages && semantic-release post', 'post')
|
t.is(pkg.scripts.postpublish, 'npm run gh-pages && semantic-release post', 'post')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}))
|
}))
|
||||||
}
|
})
|
||||||
|
@ -1,39 +1,37 @@
|
|||||||
'use strict'
|
const efh = require('error-first-handler')
|
||||||
|
const nixt = require('nixt')
|
||||||
|
const test = require('tap').test
|
||||||
|
|
||||||
var efh = require('error-first-handler')
|
const createModule = require('../lib/create-module')
|
||||||
var nixt = require('nixt')
|
|
||||||
|
|
||||||
module.exports = function (test, createModule) {
|
test('verify', (t) => {
|
||||||
test('verify', function (t) {
|
|
||||||
createModule({
|
createModule({
|
||||||
repository: {},
|
repository: {},
|
||||||
scripts: {
|
scripts: {
|
||||||
prepublish: 'semantic-release pre --no-token'
|
prepublish: '../../../bin/semantic-release.js pre --no-token'
|
||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
t.test('verify package and options before publishing', function (t) {
|
t.test('verify package and options before publishing', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
nixt()
|
nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
.env('CI', true)
|
.env('CI', true)
|
||||||
.run('npm publish')
|
.run('npm publish')
|
||||||
.stderr(new RegExp(
|
.stderr(new RegExp(
|
||||||
'You must define a GitHub token\.\n' +
|
`You must define a GitHub token\.
|
||||||
'You must define your GitHub "repository" inside the "package.json"\.\n' +
|
You must define your GitHub "repository" inside the "package.json"\.
|
||||||
'You must define your "scripts" inside the "package.json"\.'
|
You must define your "scripts" inside the "package.json"\.`
|
||||||
, 'm'
|
, 'm'
|
||||||
))
|
))
|
||||||
.code(1)
|
.code(1)
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
createModule({
|
createModule({
|
||||||
version: '1.0.0-semantically-released'
|
version: '1.0.0-semantically-released'
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()((name, cwd) => {
|
||||||
t.test('not publishing placeholder versions', function (t) {
|
t.test('not publishing placeholder versions', (t) => {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
|
|
||||||
nixt()
|
nixt()
|
||||||
@ -41,10 +39,7 @@ module.exports = function (test, createModule) {
|
|||||||
.env('CI', true)
|
.env('CI', true)
|
||||||
.run('npm publish --semantic-release-rerun')
|
.run('npm publish --semantic-release-rerun')
|
||||||
.code(1)
|
.code(1)
|
||||||
.end(function (err) {
|
.end((err) => t.error(err, 'nixt'))
|
||||||
t.error(err, 'nixt')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
'use strict'
|
const test = require('tap').test
|
||||||
|
const nock = require('nock')
|
||||||
|
|
||||||
var nock = require('nock')
|
const npmInfo = require('../../dist/lib/npm-info.js')
|
||||||
|
|
||||||
var npmInfo = require('../../lib/npm-info.js')
|
const registry = 'http://registry.npmjs.org/'
|
||||||
|
|
||||||
var registry = 'http://registry.npmjs.org/'
|
const defaultModule = {
|
||||||
|
|
||||||
var defaultModule = {
|
|
||||||
'dist-tags': {
|
'dist-tags': {
|
||||||
latest: '1.0.0'
|
latest: '1.0.0'
|
||||||
},
|
},
|
||||||
@ -19,9 +18,8 @@ var defaultModule = {
|
|||||||
|
|
||||||
process.env.npm_config_registry = registry
|
process.env.npm_config_registry = registry
|
||||||
|
|
||||||
module.exports = function (test) {
|
test('npm-info', (t) => {
|
||||||
test('npm-info', function (t) {
|
const regMock = nock(registry, {
|
||||||
var regMock = nock(registry, {
|
|
||||||
reqheaders: {
|
reqheaders: {
|
||||||
'authorization': 'Bearer testtoken'
|
'authorization': 'Bearer testtoken'
|
||||||
}
|
}
|
||||||
@ -31,22 +29,21 @@ module.exports = function (test) {
|
|||||||
.get('/@user%2Fmodule')
|
.get('/@user%2Fmodule')
|
||||||
.reply(200, defaultModule)
|
.reply(200, defaultModule)
|
||||||
|
|
||||||
t.test('get unscoped module', function (t) {
|
t.test('get unscoped module', (t) => {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
npmInfo('express', function (err, info) {
|
npmInfo('express', (err, info) => {
|
||||||
t.error(err, 'error')
|
t.error(err, 'error')
|
||||||
t.is(info.version, '1.0.0', 'version')
|
t.is(info.version, '1.0.0', 'version')
|
||||||
t.is(info.gitHead, 'HEAD', 'gitHead')
|
t.is(info.gitHead, 'HEAD', 'gitHead')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.test('get scoped module', function (t) {
|
t.test('get scoped module', (t) => {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
npmInfo('@user/module', function (err, info) {
|
npmInfo('@user/module', (err, info) => {
|
||||||
t.error(err, 'error')
|
t.error(err, 'error')
|
||||||
t.is(info.version, '1.0.0', 'version')
|
t.is(info.version, '1.0.0', 'version')
|
||||||
t.is(info.gitHead, 'HEAD', 'gitHead')
|
t.is(info.gitHead, 'HEAD', 'gitHead')
|
||||||
regMock.done()
|
regMock.done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user