Compare commits
+1
-6
@@ -1,14 +1,9 @@
|
|||||||
# common
|
|
||||||
coverage
|
coverage
|
||||||
node_modules
|
node_modules
|
||||||
test/registry/couch
|
test/registry/couch
|
||||||
test/registry/data
|
test/registry/data
|
||||||
|
test/tmp
|
||||||
*.log
|
*.log
|
||||||
*.dump
|
*.dump
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.nyc_output
|
.nyc_output
|
||||||
.test
|
|
||||||
.tmp
|
|
||||||
|
|
||||||
# build-artifacts
|
|
||||||
dist
|
|
||||||
|
|||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
# common
|
|
||||||
coverage
|
|
||||||
node_modules
|
|
||||||
test/registry/couch
|
|
||||||
test/registry/data
|
|
||||||
*.log
|
|
||||||
*.dump
|
|
||||||
.DS_Store
|
|
||||||
.nyc_output
|
|
||||||
.test
|
|
||||||
.tmp
|
|
||||||
|
|
||||||
# source/config
|
|
||||||
src
|
|
||||||
*.yml
|
|
||||||
.gitignore
|
|
||||||
.editorconfig
|
|
||||||
.npmrc
|
|
||||||
+8
-10
@@ -1,19 +1,17 @@
|
|||||||
sudo: false
|
dist: trusty
|
||||||
language: node_js
|
language: node_js
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- $HOME/.npm
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
node_js:
|
node_js:
|
||||||
- iojs-v2
|
- 8
|
||||||
- iojs-v1
|
|
||||||
- '0.12'
|
|
||||||
- '0.10'
|
|
||||||
before_install:
|
|
||||||
- npm i -g npm@^2.0.0
|
|
||||||
before_script:
|
|
||||||
- npm prune
|
|
||||||
after_success:
|
after_success:
|
||||||
- npm run coverage:upload
|
- npm run coverage:upload
|
||||||
- npm run semantic-release
|
- npm run semantic-release
|
||||||
|
services:
|
||||||
|
- couchdb
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- /^v\d+\.\d+\.\d+$/
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ This removes the immediate connection between human emotions and version numbers
|
|||||||
|
|
||||||
## How does it work?
|
## How does it work?
|
||||||
|
|
||||||
Instead of writing [meaningless commit messages](http://whatthecommit.com/), we can take our time to think about the changes in the codebase and write them down. Following formalized conventions it this then possible to generate a helpful changelog and to derive the next semantic version number from them.
|
Instead of writing [meaningless commit messages](http://whatthecommit.com/), we can take our time to think about the changes in the codebase and write them down. Following formalized conventions it is then possible to generate a helpful changelog and to derive the next semantic version number from them.
|
||||||
|
|
||||||
When `semantic-release` got setup it will do that after every successful continuous integration build of your master branch (or any other branch you specify) and publish the new version for you. That way no human is directly involved in the release process and your releases are guaranteed to be [unromantic and unsentimental](http://sentimentalversioning.org/).
|
When `semantic-release` is set up it will do that after every successful continuous integration build of your master branch (or any other branch you specify) and publish the new version for you. This way no human is directly involved in the release process and your releases are guaranteed to be [unromantic and unsentimental](http://sentimentalversioning.org/).
|
||||||
|
|
||||||
If you fear the loss of control over timing and marketing implications of software releases you should know that `semantic-release` supports [release channels](https://github.com/npm/npm/issues/2718) using `npm`’s [dist-tags](https://docs.npmjs.com/cli/tag). This way you can keep control over what your users end up using by default, you can decide when to promote an automatically released version to the stable channel and you can choose which versions to write blogposts and tweets about. You can use the same mechanism to [support older versions of your software](https://gist.github.com/boennemann/54042374e49c7ade8910), for example with important security fixes.
|
If you fear the loss of control over timing and marketing implications of software releases you should know that `semantic-release` supports [release channels](https://github.com/npm/npm/issues/2718) using `npm`’s [dist-tags](https://docs.npmjs.com/cli/dist-tag). This way you can keep control over what your users end up using by default, you can decide when to promote an automatically released version to the stable channel, and you can choose which versions to write blogposts and tweets about. You can use the same mechanism to [support older versions of your software](https://gist.github.com/boennemann/54042374e49c7ade8910), for example with important security fixes.
|
||||||
|
|
||||||
This is what happens in series:
|
This is what happens in series:
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ _Note:_ The current release/tag implementation is tied to GitHub, but could be o
|
|||||||
This module ships with the [AngularJS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) and changelog generator, but you can [define your own](#plugins) style.
|
This module ships with the [AngularJS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) and changelog generator, but you can [define your own](#plugins) style.
|
||||||
|
|
||||||
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
|
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
|
||||||
format that includes a **type**, a **scope** and a **subject**:
|
format that includes a **type**, a **scope** and a **subject** ([full explanation](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)):
|
||||||
|
|
||||||
```
|
```
|
||||||
<type>(<scope>): <subject>
|
<type>(<scope>): <subject>
|
||||||
@@ -106,7 +106,27 @@ format that includes a **type**, a **scope** and a **subject**:
|
|||||||
<footer>
|
<footer>
|
||||||
```
|
```
|
||||||
|
|
||||||
[Full explanation](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
|
You can simplify using this convention for yourself and contributors by using [commitizen](https://github.com/commitizen/cz-cli) and [validate-commit-msg](https://github.com/kentcdodds/validate-commit-msg) or [semantic-git-commit-cli](https://github.com/JPeer264/node-semantic-git-commit-cli).
|
||||||
|
|
||||||
|
### Patch Release
|
||||||
|
|
||||||
|
```
|
||||||
|
fix(pencil): stop graphite breaking when too much pressure applied
|
||||||
|
```
|
||||||
|
|
||||||
|
### ~~Minor~~ Feature Release
|
||||||
|
|
||||||
|
```
|
||||||
|
feat(pencil): add 'graphiteWidth' option
|
||||||
|
```
|
||||||
|
|
||||||
|
### ~~Major~~ Breaking Release
|
||||||
|
|
||||||
|
```
|
||||||
|
perf(pencil): remove graphiteWidth option
|
||||||
|
|
||||||
|
BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reason.
|
||||||
|
```
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@@ -121,7 +141,7 @@ semantic-release-cli setup
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
_[This is what happens under the hood.](https://github.com/semantic-release/cli#manual-setup)_
|
_[This is what happens under the hood.](https://github.com/semantic-release/cli#what-it-does)_
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
@@ -137,6 +157,7 @@ These options are currently available:
|
|||||||
- `debug`: If true doesn’t actually publish to npm or write things to file. Default: `!process.env.CI`
|
- `debug`: If true doesn’t actually publish to npm or write things to file. Default: `!process.env.CI`
|
||||||
- `githubToken`: The token used to authenticate with GitHub. Default: `process.env.GH_TOKEN`
|
- `githubToken`: The token used to authenticate with GitHub. Default: `process.env.GH_TOKEN`
|
||||||
- `githubUrl`: Optional. Pass your GitHub Enterprise endpoint.
|
- `githubUrl`: Optional. Pass your GitHub Enterprise endpoint.
|
||||||
|
- `githubApiPathPrefix`: Optional. The path prefix for your GitHub Enterprise API.
|
||||||
|
|
||||||
_A few notes on `npm` config_:
|
_A few notes on `npm` config_:
|
||||||
1. The `npm` token can only be defined in the environment as `NPM_TOKEN`, because that’s where `npm` itself is going to read it from.
|
1. The `npm` token can only be defined in the environment as `NPM_TOKEN`, because that’s where `npm` itself is going to read it from.
|
||||||
@@ -185,7 +206,11 @@ module.exports = function (pluginConfig, config, callback) {}
|
|||||||
|
|
||||||
### `analyzeCommits`
|
### `analyzeCommits`
|
||||||
|
|
||||||
This plugin is responsible for determining the type of the next release. It additionally receives a `commits` array inside `config`. One commit is an object with a `message` and `hash` property. Call the callback with `'major'`, `'premajor'`, `'minor'`, `'preminor'`, `'patch'`, `'prepatch'`, `'prerelease'`, or `null` if nothing changed. Have a look at the [default implementation](https://github.com/semantic-release/commit-analyzer/).
|
This plugin is responsible for determining the type of the next release. It additionally receives a `commits` array inside `config`. One commit is an object with a `message` and `hash` property. Call the callback with `'major'`, `'premajor'`, `'minor'`, `'preminor'`, `'patch'`, `'prepatch'`, `'prerelease'`, or `null` if nothing changed.
|
||||||
|
|
||||||
|
While it may be tempting to use `'prepatch'`, `'preminor'` & `'prerelease'` as part of a release process, this is strongly discouraged. A better approach is to use [dist-tags](https://docs.npmjs.com/cli/dist-tag) to create release channels (such as 'latest', 'next', 'stable') and to return only `'major'`, `'premajor'` and `'minor'` from the commit analyzer.
|
||||||
|
|
||||||
|
Have a look at the [default implementation](https://github.com/semantic-release/commit-analyzer/).
|
||||||
|
|
||||||
### `generateNotes`
|
### `generateNotes`
|
||||||
|
|
||||||
@@ -237,9 +262,13 @@ It is indeed a great idea because it _forces_ you to follow best practices. If y
|
|||||||
|
|
||||||
### Why should I trust `semantic-release` with my releases?
|
### Why should I trust `semantic-release` with my releases?
|
||||||
|
|
||||||
`semantic-release` has a full unit- and integration-test-suite that tests _actual_ `npm` publishes against the [npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp/) on node.js `^0.10`, `^0.12` and io.js `^1`, `^2`. A new version won’t get published if it doesn’t pass on all these engines.
|
`semantic-release` has a full unit- and integration-test-suite that tests _actual_ `npm` publishes against the [npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp/). A new version won’t get published if it doesn’t pass on all these engines.
|
||||||
|
|
||||||
Note: Currently integration-tests don’t run on Travis CI. If you know stuff about npm/Travis/Couch: Please help!
|
### Why does `semantic-release` require node version >= 8
|
||||||
|
|
||||||
|
Being able to write code for just the most recent node versions greatly simplifies development. More language features are available, no transpilation is required, less test builds are to be run, awaited and debugged.
|
||||||
|
|
||||||
|
For a special purpose tool like `semantic-release`, that's only meant to be used in controlled CI environments, we think it's okay to have such a high version requirement. As `semantic-release` handles package publishing we expect almost every project to have at least one build job running node 8 already – and that's all it takes. Even if that's not that case `semantic-release` can still be executed with the help of [npx](https://www.npmjs.com/package/npx) (`npx -p node@8 npm run semantic-release`).
|
||||||
|
|
||||||
## Badge
|
## Badge
|
||||||
|
|
||||||
|
|||||||
+22
-10
@@ -1,13 +1,25 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/* istanbul ignore next */
|
// Bad news: We have to write plain ES5 in this file
|
||||||
try {
|
// Good news: It's the only file of the entire project
|
||||||
require('../dist')
|
|
||||||
} catch (err) {
|
var semver = require('semver')
|
||||||
if (err.code === 'MODULE_NOT_FOUND') {
|
|
||||||
require('babel/register')
|
if (semver.lt(process.version, '8.0.0')) {
|
||||||
require('../src')
|
console.error(
|
||||||
} else {
|
`semantic-release: node version >= 8 is required. Found ${process.version}.
|
||||||
console.log(err)
|
|
||||||
}
|
If there is another job running on node version >= 8, it will be picked as
|
||||||
|
the build leader and you can safely ignore this message.
|
||||||
|
|
||||||
|
If you don't have node 8 in your build matrix you can use "npx" to restore
|
||||||
|
compatibility with minimal overhead:
|
||||||
|
|
||||||
|
$ npx -p node@8 npm run semantic-release
|
||||||
|
|
||||||
|
npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx`)
|
||||||
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// node 8+ from this point on
|
||||||
|
require('../src')
|
||||||
|
|||||||
Generated
+7490
File diff suppressed because it is too large
Load Diff
+37
-44
@@ -1,62 +1,60 @@
|
|||||||
{
|
{
|
||||||
"name": "semantic-release",
|
"name": "semantic-release",
|
||||||
"description": "automated semver compliant package publishing",
|
"description": "automated semver compliant package publishing",
|
||||||
|
"version": "0.0.0-placeholder",
|
||||||
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semantic-release": "./bin/semantic-release.js"
|
"semantic-release": "bin/semantic-release.js"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/semantic-release/semantic-release/issues"
|
"url": "https://github.com/semantic-release/semantic-release/issues"
|
||||||
},
|
},
|
||||||
"config": {
|
|
||||||
"nyc": {
|
|
||||||
"exclude": [
|
|
||||||
".test",
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"czConfig": {
|
"czConfig": {
|
||||||
"path": "node_modules/cz-conventional-changelog/"
|
"path": "node_modules/cz-conventional-changelog/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@semantic-release/commit-analyzer": "^2.0.0",
|
"@semantic-release/commit-analyzer": "^2.0.0",
|
||||||
"@semantic-release/condition-travis": "^4.1.0",
|
"@semantic-release/condition-travis": "^6.0.0",
|
||||||
"@semantic-release/error": "^1.0.0",
|
"@semantic-release/error": "^1.0.0",
|
||||||
"@semantic-release/last-release-npm": "^1.2.1",
|
"@semantic-release/last-release-npm": "^1.2.1",
|
||||||
"@semantic-release/release-notes-generator": "^2.0.0",
|
"@semantic-release/release-notes-generator": "^3.0.1",
|
||||||
"git-head": "^1.2.1",
|
"git-head": "^1.2.1",
|
||||||
"github": "^0.2.4",
|
"github": "^8.0.0",
|
||||||
"lodash": "^3.9.3",
|
"lodash": "^4.0.0",
|
||||||
"nerf-dart": "^1.0.0",
|
"nerf-dart": "^1.0.0",
|
||||||
"nopt": "^3.0.3",
|
"nopt": "^4.0.0",
|
||||||
|
"normalize-package-data": "^2.3.4",
|
||||||
"npmconf": "^2.1.2",
|
"npmconf": "^2.1.2",
|
||||||
"npmlog": "^1.2.1",
|
"npmlog": "^4.0.0",
|
||||||
"parse-github-repo-url": "^1.0.0",
|
"parse-github-repo-url": "^1.3.0",
|
||||||
"require-relative": "^0.8.7",
|
"require-relative": "^0.8.7",
|
||||||
"run-auto": "^1.1.2",
|
"run-auto": "^2.0.0",
|
||||||
"run-series": "^1.1.2",
|
"run-series": "^1.1.3",
|
||||||
"semver": "^5.0.1"
|
"semver": "^5.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel": "^5.5.8",
|
"coveralls": "^2.11.4",
|
||||||
"coveralls": "^2.11.2",
|
"cz-conventional-changelog": "^1.1.4",
|
||||||
"cz-conventional-changelog": "^1.1.0",
|
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"nixt": "^0.4.1",
|
"mock-spawn": "^0.2.6",
|
||||||
"nock": "^2.5.0",
|
"nixt": "^0.5.0",
|
||||||
"npm-registry-couchapp": "^2.6.11",
|
"nock": "^9.0.2",
|
||||||
"nyc": "^3.0.0",
|
"npm-registry-couchapp": "^2.6.12",
|
||||||
"proxyquire": "^1.5.0",
|
"nyc": "^10.0.0",
|
||||||
"rimraf": "^2.4.0",
|
"proxyquire": "^1.7.3",
|
||||||
"standard": "^5.0.2",
|
"rimraf": "^2.5.0",
|
||||||
"tap": "^1.3.1"
|
"standard": "^9.0.0",
|
||||||
|
"tap": "^10.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10",
|
"node": ">=8",
|
||||||
"npm": ">=2"
|
"npm": ">=2"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/semantic-release/semantic-release/tree/next#readme",
|
"files": [
|
||||||
|
"bin",
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/semantic-release/semantic-release#readme",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"author",
|
"author",
|
||||||
"automation",
|
"automation",
|
||||||
@@ -69,7 +67,7 @@
|
|||||||
"version"
|
"version"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
"main": "bin/semantic-release.js",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"tag": "next"
|
"tag": "next"
|
||||||
},
|
},
|
||||||
@@ -81,17 +79,12 @@
|
|||||||
"url": "git+https://github.com/semantic-release/semantic-release.git"
|
"url": "git+https://github.com/semantic-release/semantic-release.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rimraf dist && mkdirp dist && babel src --out-dir dist",
|
|
||||||
"coverage": "nyc report",
|
"coverage": "nyc report",
|
||||||
"coverage:upload": "npm run coverage -- --reporter=lcovonly && coveralls < coverage/lcov.info",
|
"coverage:upload": "npm run coverage -s -- --reporter=text-lcov | coveralls",
|
||||||
"prepublish": "npm run build",
|
"pretest": "standard",
|
||||||
"pretest:integration": "npm run build && npm run test:build",
|
"semantic-release": "./bin/semantic-release.js pre && npm publish && ./bin/semantic-release.js post",
|
||||||
"pretest:unit": "npm run build && npm run test:build",
|
"test": "npm run test:unit && npm run test:integration",
|
||||||
"semantic-release": "./bin/semantic-release.js pre && npm dedupe && npm publish && ./bin/semantic-release.js post",
|
"test:integration": "tap --no-cov test/scenarios/*.js",
|
||||||
"test": "npm run test:style && npm run test:unit",
|
"test:unit": "nyc tap --no-cov test/specs/*.js"
|
||||||
"test:build": "rimraf .test && mkdirp .test && babel test --out-dir .test",
|
|
||||||
"test:integration": "tap --no-cov .test/scenarios/*.js",
|
|
||||||
"test:style": "standard",
|
|
||||||
"test:unit": "nyc tap --no-cov .test/specs/*.js"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-44
@@ -1,16 +1,19 @@
|
|||||||
const { readFileSync, writeFileSync } = require('fs')
|
var fs = require('fs')
|
||||||
const path = require('path')
|
var path = require('path')
|
||||||
const url = require('url')
|
var url = require('url')
|
||||||
|
|
||||||
const _ = require('lodash')
|
var _ = require('lodash')
|
||||||
const log = require('npmlog')
|
var log = require('npmlog')
|
||||||
const nopt = require('nopt')
|
var nopt = require('nopt')
|
||||||
const npmconf = require('npmconf')
|
var npmconf = require('npmconf')
|
||||||
|
var normalizeData = require('normalize-package-data')
|
||||||
|
|
||||||
log.heading = 'semantic-release'
|
log.heading = 'semantic-release'
|
||||||
const env = process.env
|
var env = process.env
|
||||||
const pkg = JSON.parse(readFileSync('./package.json'))
|
var pkg = JSON.parse(fs.readFileSync('./package.json'))
|
||||||
const knownOptions = {
|
var originalPkg = _.cloneDeep(pkg)
|
||||||
|
normalizeData(pkg)
|
||||||
|
var knownOptions = {
|
||||||
branch: String,
|
branch: String,
|
||||||
debug: Boolean,
|
debug: Boolean,
|
||||||
'github-token': String,
|
'github-token': String,
|
||||||
@@ -20,8 +23,10 @@ const knownOptions = {
|
|||||||
'verify-conditions': [path, String],
|
'verify-conditions': [path, String],
|
||||||
'verify-release': [path, String]
|
'verify-release': [path, String]
|
||||||
}
|
}
|
||||||
const options = _.defaults(
|
var options = _.defaults(
|
||||||
_.mapKeys(nopt(knownOptions), (value, key) => _.camelCase(key)),
|
_.mapKeys(nopt(knownOptions), function (value, key) {
|
||||||
|
return _.camelCase(key)
|
||||||
|
}),
|
||||||
pkg.release,
|
pkg.release,
|
||||||
{
|
{
|
||||||
branch: 'master',
|
branch: 'master',
|
||||||
@@ -33,20 +38,21 @@ const options = _.defaults(
|
|||||||
githubUrl: env.GH_URL
|
githubUrl: env.GH_URL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const plugins = require('./lib/plugins')(options)
|
var plugins = require('../src/lib/plugins')(options)
|
||||||
|
|
||||||
npmconf.load({}, (err, conf) => {
|
npmconf.load({}, function (err, conf) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('init', 'Failed to load npm config.', err)
|
log.error('init', 'Failed to load npm config.', err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
let npm = {
|
var npm = {
|
||||||
auth: {
|
auth: {
|
||||||
token: env.NPM_TOKEN
|
token: env.NPM_TOKEN
|
||||||
},
|
},
|
||||||
|
cafile: conf.get('cafile'),
|
||||||
loglevel: conf.get('loglevel'),
|
loglevel: conf.get('loglevel'),
|
||||||
registry: require('./lib/get-registry')(pkg, conf),
|
registry: require('../src/lib/get-registry')(pkg, conf),
|
||||||
tag: (pkg.publishConfig || {}).tag || conf.get('tag') || 'latest'
|
tag: (pkg.publishConfig || {}).tag || conf.get('tag') || 'latest'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,95 +61,103 @@ npmconf.load({}, (err, conf) => {
|
|||||||
|
|
||||||
log.level = npm.loglevel
|
log.level = npm.loglevel
|
||||||
|
|
||||||
const config = {env, pkg, options, plugins, npm}
|
var config = {
|
||||||
|
env: env,
|
||||||
|
pkg: pkg,
|
||||||
|
options: options,
|
||||||
|
plugins: plugins,
|
||||||
|
npm: npm
|
||||||
|
}
|
||||||
|
|
||||||
let hide = {}
|
var hide = {}
|
||||||
if (options.githubToken) hide.githubToken = '***'
|
if (options.githubToken) hide.githubToken = '***'
|
||||||
|
|
||||||
log.verbose('init', 'options:', _.assign({}, options, hide))
|
log.verbose('init', 'options:', _.assign({}, options, hide))
|
||||||
log.verbose('init', 'Verifying config.')
|
log.verbose('init', 'Verifying config.')
|
||||||
|
|
||||||
const errors = require('./lib/verify')(config)
|
var errors = require('../src/lib/verify')(config)
|
||||||
errors.forEach((err) => log.error('init', `${err.message} ${err.code}`))
|
errors.forEach(function (err) {
|
||||||
|
log.error('init', err.message + ' ' + err.code)
|
||||||
|
})
|
||||||
if (errors.length) process.exit(1)
|
if (errors.length) process.exit(1)
|
||||||
|
|
||||||
if (options.argv.remain[0] === 'pre') {
|
if (options.argv.remain[0] === 'pre') {
|
||||||
log.verbose('pre', 'Running pre-script.')
|
log.verbose('pre', 'Running pre-script.')
|
||||||
log.verbose('pre', 'Veriying conditions.')
|
log.verbose('pre', 'Veriying conditions.')
|
||||||
|
|
||||||
plugins.verifyConditions(config, (err) => {
|
plugins.verifyConditions(config, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log[options.debug ? 'warn' : 'error']('pre', err.message)
|
log[options.debug ? 'warn' : 'error']('pre', err.message)
|
||||||
if (!options.debug) process.exit(1)
|
if (!options.debug) process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const nerfDart = require('nerf-dart')(npm.registry)
|
var nerfDart = require('nerf-dart')(npm.registry)
|
||||||
let wroteNpmRc = false
|
var wroteNpmRc = false
|
||||||
|
|
||||||
if (env.NPM_TOKEN) {
|
if (env.NPM_OLD_TOKEN && env.NPM_EMAIL) {
|
||||||
conf.set(`${nerfDart}:_authToken`, '${NPM_TOKEN}', 'project')
|
|
||||||
wroteNpmRc = true
|
|
||||||
} else if (env.NPM_OLD_TOKEN && env.NPM_EMAIL) {
|
|
||||||
// Using the old auth token format is not considered part of the public API
|
// Using the old auth token format is not considered part of the public API
|
||||||
// This might go away anytime (i.e. once we have a better testing strategy)
|
// This might go away anytime (i.e. once we have a better testing strategy)
|
||||||
conf.set('_auth', '${NPM_OLD_TOKEN}', 'project')
|
conf.set('_auth', '${NPM_OLD_TOKEN}', 'project') // eslint-disable-line no-template-curly-in-string
|
||||||
conf.set('email', '${NPM_EMAIL}', 'project')
|
conf.set('email', '${NPM_EMAIL}', 'project') // eslint-disable-line no-template-curly-in-string
|
||||||
|
wroteNpmRc = true
|
||||||
|
} else if (env.NPM_TOKEN) {
|
||||||
|
conf.set(nerfDart + ':_authToken', '${NPM_TOKEN}', 'project') // eslint-disable-line no-template-curly-in-string
|
||||||
wroteNpmRc = true
|
wroteNpmRc = true
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.save('project', (err) => {
|
conf.save('project', function (err) {
|
||||||
if (err) return log.error('pre', 'Failed to save npm config.', err)
|
if (err) return log.error('pre', 'Failed to save npm config.', err)
|
||||||
|
|
||||||
if (wroteNpmRc) log.verbose('pre', 'Wrote authToken to .npmrc.')
|
if (wroteNpmRc) log.verbose('pre', 'Wrote authToken to .npmrc.')
|
||||||
|
|
||||||
require('./pre')(config, (err, release) => {
|
require('../src/pre')(config, function (err, release) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('pre', 'Failed to determine new version.')
|
log.error('pre', 'Failed to determine new version.')
|
||||||
|
|
||||||
const args = ['pre', (err.code ? `${err.code} ` : '') + err.message]
|
var args = ['pre', (err.code ? err.code + ' ' : '') + err.message]
|
||||||
if (err.stack) args.push(err.stack)
|
if (err.stack) args.push(err.stack)
|
||||||
log.error(...args)
|
log.error.apply(log, args)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = `Determined version ${release.version} as "${npm.tag}".`
|
var message = 'Determined version ' + release.version + ' as "' + npm.tag + '".'
|
||||||
|
|
||||||
log.verbose('pre', message)
|
log.verbose('pre', message)
|
||||||
|
|
||||||
if (options.debug) {
|
if (options.debug) {
|
||||||
log.error('pre', `${message} Not publishing in debug mode.`, release)
|
log.error('pre', message + ' Not publishing in debug mode.', release)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let shrinkwrap = JSON.parse(readFileSync('./npm-shrinkwrap.json'))
|
var shrinkwrap = JSON.parse(fs.readFileSync('./npm-shrinkwrap.json'))
|
||||||
shrinkwrap.version = release.version
|
shrinkwrap.version = release.version
|
||||||
writeFileSync('./npm-shrinkwrap.json', JSON.stringify(shrinkwrap, null, 2))
|
fs.writeFileSync('./npm-shrinkwrap.json', JSON.stringify(shrinkwrap, null, 2))
|
||||||
log.verbose('pre', `Wrote version ${release.version} to npm-shrinkwrap.json.`)
|
log.verbose('pre', 'Wrote version ' + release.version + 'to npm-shrinkwrap.json.')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.silly('pre', `Couldn't find npm-shrinkwrap.json.`)
|
log.silly('pre', 'Couldn\'t find npm-shrinkwrap.json.')
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFileSync('./package.json', JSON.stringify(_.assign(pkg, {
|
fs.writeFileSync('./package.json', JSON.stringify(_.assign(originalPkg, {
|
||||||
version: release.version
|
version: release.version
|
||||||
}), null, 2))
|
}), null, 2))
|
||||||
|
|
||||||
log.verbose('pre', `Wrote version ${release.version} to package.json.`)
|
log.verbose('pre', 'Wrote version ' + release.version + ' to package.json.')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else if (options.argv.remain[0] === 'post') {
|
} else if (options.argv.remain[0] === 'post') {
|
||||||
log.verbose('post', 'Running post-script.')
|
log.verbose('post', 'Running post-script.')
|
||||||
|
|
||||||
require('./post')(config, (err, published, release) => {
|
require('../src/post')(config, function (err, published, release) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('post', 'Failed to publish release notes.', err)
|
log.error('post', 'Failed to publish release notes.', err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.verbose('post', `${published ? 'Published' : 'Generated'} release notes.`, release)
|
log.verbose('post', (published ? 'Published' : 'Generated') + ' release notes.', release)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
log.error('post', `Command "${options.argv.remain[0]}" not recognized. User either "pre" or "post"`)
|
log.error('post', 'Command "' + options.argv.remain[0] + '" not recognized. Use either "pre" or "post"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+43
-29
@@ -1,40 +1,44 @@
|
|||||||
const { exec } = require('child_process')
|
var childProcess = require('child_process')
|
||||||
|
|
||||||
const log = require('npmlog')
|
var log = require('npmlog')
|
||||||
|
|
||||||
const SemanticReleaseError = require('@semantic-release/error')
|
var SemanticReleaseError = require('@semantic-release/error')
|
||||||
|
|
||||||
module.exports = function ({lastRelease, options}, cb) {
|
module.exports = function (config, cb) {
|
||||||
const branch = options.branch
|
var lastRelease = config.lastRelease
|
||||||
const from = lastRelease.gitHead
|
var options = config.options
|
||||||
const range = (from ? from + '..' : '') + 'HEAD'
|
var branch = options.branch
|
||||||
|
var from = lastRelease.gitHead
|
||||||
|
var range = (from ? from + '..' : '') + 'HEAD'
|
||||||
|
|
||||||
if (!from) return extract()
|
if (!from) return extract()
|
||||||
|
|
||||||
exec(`git branch --contains ${from}`, (err, stdout) => {
|
childProcess.exec('git branch --no-color --contains ' + from, function (err, stdout) {
|
||||||
let inHistory = false
|
var inHistory = false
|
||||||
let branches
|
var branches
|
||||||
|
|
||||||
if (!err && stdout) {
|
if (!err && stdout) {
|
||||||
branches = stdout.split('\n')
|
branches = stdout.split('\n')
|
||||||
.map((result) => {
|
.map(function (result) {
|
||||||
if (branch === result.replace('*', '').trim()) {
|
if (branch === result.replace('*', '').trim()) {
|
||||||
inHistory = true
|
inHistory = true
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return result.trim()
|
return result.trim()
|
||||||
})
|
})
|
||||||
.filter(branch => !!branch)
|
.filter(function (branch) {
|
||||||
|
return !!branch
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inHistory) {
|
if (!inHistory) {
|
||||||
log.error('commits',
|
log.error('commits',
|
||||||
`The commit the last release of this package was derived from is not in the direct history of the "${branch}" branch.
|
'The commit the last release of this package was derived from is not in the direct history of the "' + branch + '" branch.\n' +
|
||||||
This means semantic-release can not extract the commits between now and then.
|
'This means semantic-release can not extract the commits between now and then.\n' +
|
||||||
This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
|
'This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.\n' +
|
||||||
You can recover from this error by publishing manually or restoring the commit "${from}".` + (branches && branches.length ?
|
'You can recover from this error by publishing manually or restoring the commit "' + from + '".' + (branches && branches.length
|
||||||
`\nHere is a list of branches that still contain the commit in question: \n * ${branches.join('\n * ')}` :
|
? '\nHere is a list of branches that still contain the commit in question: \n * ' + branches.join('\n * ')
|
||||||
''
|
: ''
|
||||||
))
|
))
|
||||||
return cb(new SemanticReleaseError('Commit not in history', 'ENOTINHISTORY'))
|
return cb(new SemanticReleaseError('Commit not in history', 'ENOTINHISTORY'))
|
||||||
}
|
}
|
||||||
@@ -43,23 +47,33 @@ You can recover from this error by publishing manually or restoring the commit "
|
|||||||
})
|
})
|
||||||
|
|
||||||
function extract () {
|
function extract () {
|
||||||
exec(
|
var child = childProcess.spawn('git', ['log', '-E', '--format=%H==SPLIT==%B==END==', range])
|
||||||
`git log -E --format=%H==SPLIT==%B==END== ${range}`,
|
var stdout = ''
|
||||||
(err, stdout) => {
|
var err = ''
|
||||||
if (err) return cb(err)
|
|
||||||
|
|
||||||
cb(null, String(stdout).split('==END==\n')
|
child.stdout.on('data', function (data) {
|
||||||
|
stdout += data
|
||||||
|
})
|
||||||
|
|
||||||
.filter((raw) => !!raw.trim())
|
child.stderr.on('data', function (data) {
|
||||||
|
err += data
|
||||||
|
})
|
||||||
|
|
||||||
.map((raw) => {
|
child.on('close', function (code) {
|
||||||
const data = raw.split('==SPLIT==')
|
if (err || code) return cb(err)
|
||||||
|
|
||||||
|
cb(null, String(stdout).split('==END==\n')
|
||||||
|
.filter(function (raw) {
|
||||||
|
return !!raw.trim()
|
||||||
|
})
|
||||||
|
.map(function (raw) {
|
||||||
|
var data = raw.split('==SPLIT==')
|
||||||
return {
|
return {
|
||||||
hash: data[0],
|
hash: data[0],
|
||||||
message: data[1]
|
message: data[1]
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
}
|
)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ module.exports = function (pkg, conf) {
|
|||||||
|
|
||||||
if (pkg.name[0] !== '@') return conf.get('registry') || 'https://registry.npmjs.org/'
|
if (pkg.name[0] !== '@') return conf.get('registry') || 'https://registry.npmjs.org/'
|
||||||
|
|
||||||
const scope = pkg.name.split('/')[0]
|
var scope = pkg.name.split('/')[0]
|
||||||
const scopedRegistry = conf.get(`${scope}/registry`)
|
var scopedRegistry = conf.get(scope + '/registry')
|
||||||
|
|
||||||
if (scopedRegistry) return scopedRegistry
|
if (scopedRegistry) return scopedRegistry
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -1,26 +1,26 @@
|
|||||||
const relative = require('require-relative')
|
var relative = require('require-relative')
|
||||||
const series = require('run-series')
|
var series = require('run-series')
|
||||||
|
|
||||||
let exports = module.exports = function (options) {
|
var exports = module.exports = function (options) {
|
||||||
var plugins = {
|
var plugins = {
|
||||||
analyzeCommits: exports.normalize(options.analyzeCommits, '@semantic-release/commit-analyzer'),
|
analyzeCommits: exports.normalize(options.analyzeCommits, '@semantic-release/commit-analyzer'),
|
||||||
generateNotes: exports.normalize(options.generateNotes, '@semantic-release/release-notes-generator'),
|
generateNotes: exports.normalize(options.generateNotes, '@semantic-release/release-notes-generator'),
|
||||||
getLastRelease: exports.normalize(options.getLastRelease, '@semantic-release/last-release-npm')
|
getLastRelease: exports.normalize(options.getLastRelease, '@semantic-release/last-release-npm')
|
||||||
}
|
}
|
||||||
|
|
||||||
;['verifyConditions', 'verifyRelease'].forEach((plugin) => {
|
;['verifyConditions', 'verifyRelease'].forEach(function (plugin) {
|
||||||
if (!Array.isArray(options[plugin])) {
|
if (!Array.isArray(options[plugin])) {
|
||||||
plugins[plugin] = exports.normalize(
|
plugins[plugin] = exports.normalize(
|
||||||
options[plugin],
|
options[plugin],
|
||||||
plugin === 'verifyConditions' ?
|
plugin === 'verifyConditions'
|
||||||
'@semantic-release/condition-travis' :
|
? '@semantic-release/condition-travis'
|
||||||
'./plugin-noop'
|
: './plugin-noop'
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins[plugin] = function (pluginOptions, cb) {
|
plugins[plugin] = function (pluginOptions, cb) {
|
||||||
var tasks = options[plugin].map((step) => {
|
var tasks = options[plugin].map(function (step) {
|
||||||
return exports.normalize(step, './plugin-noop').bind(null, pluginOptions)
|
return exports.normalize(step, './plugin-noop').bind(null, pluginOptions)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -1,9 +1,10 @@
|
|||||||
const SemanticReleaseError = require('@semantic-release/error')
|
var SemanticReleaseError = require('@semantic-release/error')
|
||||||
|
|
||||||
module.exports = function (config, cb) {
|
module.exports = function (config, cb) {
|
||||||
const { plugins, lastRelease } = config
|
var plugins = config.plugins
|
||||||
|
var lastRelease = config.lastRelease
|
||||||
|
|
||||||
plugins.analyzeCommits(config, (err, type) => {
|
plugins.analyzeCommits(config, function (err, type) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
|
|||||||
+6
-10
@@ -1,9 +1,10 @@
|
|||||||
const parseSlug = require('parse-github-repo-url')
|
var SemanticReleaseError = require('@semantic-release/error')
|
||||||
|
|
||||||
const SemanticReleaseError = require('@semantic-release/error')
|
module.exports = function (config) {
|
||||||
|
var pkg = config.pkg
|
||||||
module.exports = function ({pkg, options, env}) {
|
var options = config.options
|
||||||
let errors = []
|
var env = config.env
|
||||||
|
var errors = []
|
||||||
|
|
||||||
if (!pkg.name) {
|
if (!pkg.name) {
|
||||||
errors.push(new SemanticReleaseError(
|
errors.push(new SemanticReleaseError(
|
||||||
@@ -17,11 +18,6 @@ module.exports = function ({pkg, options, env}) {
|
|||||||
'No "repository" found in package.json.',
|
'No "repository" found in package.json.',
|
||||||
'ENOPKGREPO'
|
'ENOPKGREPO'
|
||||||
))
|
))
|
||||||
} else if (!parseSlug(pkg.repository.url)) {
|
|
||||||
errors.push(new SemanticReleaseError(
|
|
||||||
'The "repository" field in the package.json is malformed.',
|
|
||||||
'EMALFORMEDPKGREPO'
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.debug) return errors
|
if (options.debug) return errors
|
||||||
|
|||||||
+39
-19
@@ -1,33 +1,41 @@
|
|||||||
const url = require('url')
|
var url = require('url')
|
||||||
|
|
||||||
const gitHead = require('git-head')
|
var gitHead = require('git-head')
|
||||||
const GitHubApi = require('github')
|
var GitHubApi = require('github')
|
||||||
const parseSlug = require('parse-github-repo-url')
|
var parseSlug = require('parse-github-repo-url')
|
||||||
|
|
||||||
module.exports = function (config, cb) {
|
module.exports = function (config, cb) {
|
||||||
const { pkg, options, plugins } = config
|
var pkg = config.pkg
|
||||||
const ghConfig = options.githubUrl ? url.parse(options.githubUrl) : {}
|
var options = config.options
|
||||||
|
var plugins = config.plugins
|
||||||
|
var ghConfig = options.githubUrl ? url.parse(options.githubUrl) : {}
|
||||||
|
|
||||||
const github = new GitHubApi({
|
var github = new GitHubApi({
|
||||||
version: '3.0.0',
|
|
||||||
port: ghConfig.port,
|
port: ghConfig.port,
|
||||||
protocol: (ghConfig.protocol || '').split(':')[0] || null,
|
protocol: (ghConfig.protocol || '').split(':')[0] || null,
|
||||||
host: ghConfig.hostname
|
host: ghConfig.hostname,
|
||||||
|
pathPrefix: options.githubApiPathPrefix || null
|
||||||
})
|
})
|
||||||
|
|
||||||
plugins.generateNotes(config, (err, log) => {
|
plugins.generateNotes(config, function (err, log) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|
||||||
gitHead((err, hash) => {
|
gitHead(function (err, hash) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|
||||||
const ghRepo = parseSlug(pkg.repository.url)
|
var ghRepo = parseSlug(pkg.repository.url)
|
||||||
const release = {
|
var tag = {
|
||||||
owner: ghRepo[0],
|
owner: ghRepo[0],
|
||||||
repo: ghRepo[1],
|
repo: ghRepo[1],
|
||||||
name: `v${pkg.version}`,
|
ref: 'refs/tags/v' + pkg.version,
|
||||||
tag_name: `v${pkg.version}`,
|
sha: hash
|
||||||
target_commitish: hash,
|
}
|
||||||
|
var release = {
|
||||||
|
owner: ghRepo[0],
|
||||||
|
repo: ghRepo[1],
|
||||||
|
tag_name: 'v' + pkg.version,
|
||||||
|
name: 'v' + pkg.version,
|
||||||
|
target_commitish: options.branch,
|
||||||
draft: !!options.debug,
|
draft: !!options.debug,
|
||||||
body: log
|
body: log
|
||||||
}
|
}
|
||||||
@@ -37,14 +45,26 @@ module.exports = function (config, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
github.authenticate({
|
github.authenticate({
|
||||||
type: 'oauth',
|
type: 'token',
|
||||||
token: options.githubToken
|
token: options.githubToken
|
||||||
})
|
})
|
||||||
|
|
||||||
github.releases.createRelease(release, (err) => {
|
if (options.debug) {
|
||||||
|
return github.repos.createRelease(release, function (err) {
|
||||||
|
if (err) return cb(err)
|
||||||
|
|
||||||
|
cb(null, true, release)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
github.gitdata.createReference(tag, function (err) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|
||||||
cb(null, true, release)
|
github.repos.createRelease(release, function (err) {
|
||||||
|
if (err) return cb(err)
|
||||||
|
|
||||||
|
cb(null, true, release)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+15
-15
@@ -1,43 +1,43 @@
|
|||||||
const _ = require('lodash')
|
var _ = require('lodash')
|
||||||
const auto = require('run-auto')
|
var auto = require('run-auto')
|
||||||
const semver = require('semver')
|
var semver = require('semver')
|
||||||
|
|
||||||
const getCommits = require('./lib/commits')
|
var getCommits = require('./lib/commits')
|
||||||
const getType = require('./lib/type')
|
var getType = require('./lib/type')
|
||||||
|
|
||||||
module.exports = function (config, cb) {
|
module.exports = function (config, cb) {
|
||||||
const { plugins } = config
|
var plugins = config.plugins
|
||||||
|
|
||||||
auto({
|
auto({
|
||||||
lastRelease: plugins.getLastRelease.bind(null, config),
|
lastRelease: plugins.getLastRelease.bind(null, config),
|
||||||
commits: ['lastRelease', (cb, results) => {
|
commits: ['lastRelease', function (results, cb) {
|
||||||
getCommits(_.assign({
|
getCommits(_.assign({
|
||||||
lastRelease: results.lastRelease
|
lastRelease: results.lastRelease
|
||||||
}, config),
|
}, config),
|
||||||
cb)
|
cb)
|
||||||
}],
|
}],
|
||||||
type: ['commits', 'lastRelease', (cb, results) => {
|
type: ['commits', 'lastRelease', function (results, cb) {
|
||||||
getType(_.assign({
|
getType(_.assign({
|
||||||
commits: results.commits,
|
commits: results.commits,
|
||||||
lastRelease: results.lastRelease
|
lastRelease: results.lastRelease
|
||||||
}, config),
|
}, config),
|
||||||
cb)
|
cb)
|
||||||
}]
|
}]
|
||||||
}, (err, results) => {
|
}, function (err, results) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
|
|
||||||
const nextRelease = {
|
var nextRelease = {
|
||||||
type: results.type,
|
type: results.type,
|
||||||
version: results.type === 'initial' ?
|
version: results.type === 'initial'
|
||||||
'1.0.0' :
|
? '1.0.0'
|
||||||
semver.inc(results.lastRelease.version, results.type)
|
: semver.inc(results.lastRelease.version, results.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins.verifyRelease(_.assign({
|
plugins.verifyRelease(_.assign({
|
||||||
commits: results.commits,
|
commits: results.commits,
|
||||||
lastRelease: results.lastRelease,
|
lastRelease: results.lastRelease,
|
||||||
nextRelease
|
nextRelease: nextRelease
|
||||||
}, config), (err) => {
|
}, config), function (err) {
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
cb(null, nextRelease)
|
cb(null, nextRelease)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
const nixt = require('nixt')
|
var nixt = require('nixt')
|
||||||
|
|
||||||
module.exports = function (cwd, uri) {
|
module.exports = function (cwd, uri) {
|
||||||
return nixt()
|
return nixt()
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
.env('NPM_OLD_TOKEN', 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==')
|
.env('NPM_OLD_TOKEN', 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==')
|
||||||
.env('NPM_EMAIL', 'integration@test.com')
|
.env('NPM_EMAIL', 'integration@test.com')
|
||||||
.env('GH_TOKEN', 'ghtoken')
|
.env('GH_TOKEN', 'ghtoken')
|
||||||
.env('CI', 'true')
|
.env('CI', 'true')
|
||||||
.env('TRAVIS', 'true')
|
|
||||||
.env('TRAVIS_BRANCH', 'master')
|
|
||||||
.env('npm_config_registry', uri)
|
.env('npm_config_registry', uri)
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-26
@@ -1,40 +1,31 @@
|
|||||||
const { exec } = require('child_process')
|
var exec = require('child_process').exec
|
||||||
const { join } = require('path')
|
var join = require('path').join
|
||||||
const { writeFileSync } = require('fs')
|
var writeFileSync = require('fs').writeFileSync
|
||||||
|
|
||||||
const mkdirp = require('mkdirp')
|
var mkdirp = require('mkdirp')
|
||||||
|
|
||||||
module.exports = function (name, cb) {
|
module.exports = function (name, registry, cb) {
|
||||||
const cwd = join(__dirname, '../tmp', name)
|
var cwd = join(__dirname, '../tmp', name)
|
||||||
|
|
||||||
mkdirp.sync(cwd)
|
mkdirp.sync(cwd)
|
||||||
|
|
||||||
writeFileSync(join(cwd, '.npmrc'), `
|
|
||||||
//localhost:1337/registry/_design/app/_rewrite/:username=integration
|
|
||||||
//localhost:1337/registry/_design/app/_rewrite/:email=integration@test.com`, null, 2)
|
|
||||||
|
|
||||||
writeFileSync(join(cwd, 'package.json'), JSON.stringify({
|
writeFileSync(join(cwd, 'package.json'), JSON.stringify({
|
||||||
name,
|
name: name,
|
||||||
repository: {
|
repository: {
|
||||||
url: 'git+https://github.com/semantic-release/test'
|
url: 'git+https://github.com/semantic-release/test'
|
||||||
},
|
},
|
||||||
_npmUser: {
|
release: {
|
||||||
name: 'integration',
|
verifyConditions: '../../../src/lib/plugin-noop'
|
||||||
email: 'integration@test.com'
|
}
|
||||||
},
|
|
||||||
maintainers: [{
|
|
||||||
name: 'integration',
|
|
||||||
email: 'integration@test.com'
|
|
||||||
}]
|
|
||||||
}, null, 2))
|
}, null, 2))
|
||||||
|
|
||||||
exec(`
|
exec(
|
||||||
git init &&
|
'git init && ' +
|
||||||
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 add . &&
|
'git add . && ' +
|
||||||
git commit -m "chore: root"`
|
'git commit -m "chore: root"'
|
||||||
, {cwd}, (err, stdout, stderr) => {
|
, {cwd: cwd}, function (err, stdout, stderr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(stdout, stderr)
|
console.log(stdout, stderr)
|
||||||
return cb(err)
|
return cb(err)
|
||||||
|
|||||||
@@ -1,21 +1,30 @@
|
|||||||
|
var mockSpawn = require('mock-spawn')()
|
||||||
|
mockSpawn.setStrategy(function (command, args, opts) {
|
||||||
|
return function (cb) {
|
||||||
|
this.stdout.write(
|
||||||
|
/\.\.HEAD/.test(args.join(' '))
|
||||||
|
? rawCommits[0]
|
||||||
|
: rawCommits.join()
|
||||||
|
)
|
||||||
|
cb(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const rawCommits = [
|
const rawCommits = [
|
||||||
'hash-one==SPLIT==commit-one==END==\n',
|
'hash-one==SPLIT==commit-one==END==\n',
|
||||||
'hash-two==SPLIT==commit-two==END==\n'
|
'hash-two==SPLIT==commit-two==END==\n'
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
exec: (command, cb) => {
|
exec: function (command, options, cb) {
|
||||||
|
if (typeof cb === 'undefined' && typeof options === 'function') {
|
||||||
|
cb = options
|
||||||
|
}
|
||||||
if (/contains/.test(command)) {
|
if (/contains/.test(command)) {
|
||||||
if (/notinhistory/.test(command)) return cb(new Error())
|
if (/notinhistory/.test(command)) return cb(new Error())
|
||||||
return cb(null, `whatever\nmaster\n`)
|
return cb(null, 'whatever\nmaster\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
cb(
|
|
||||||
null,
|
|
||||||
/\.\.HEAD/.test(command) ?
|
|
||||||
rawCommits[0] :
|
|
||||||
rawCommits.join()
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
spawn: mockSpawn,
|
||||||
'@noCallThru': true
|
'@noCallThru': true
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-5
@@ -1,6 +1,17 @@
|
|||||||
module.exports = () => ({
|
module.exports = function () {
|
||||||
authenticate: () => true,
|
return {
|
||||||
releases: {
|
authenticate: function () {
|
||||||
createRelease: (release, cb) => cb(null)
|
return true
|
||||||
|
},
|
||||||
|
gitdata: {
|
||||||
|
createReference: function (release, cb) {
|
||||||
|
cb(null)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
repos: {
|
||||||
|
createRelease: function (release, cb) {
|
||||||
|
cb(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
const { exec } = require('child_process')
|
var exec = require('child_process').exec
|
||||||
const { join } = require('path')
|
|
||||||
|
|
||||||
const opts = {
|
var opts = {
|
||||||
cwd: join(__dirname, '../../test/registry')
|
cwd: __dirname
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
start: exec.bind(null, './start.sh', opts),
|
start: exec.bind(null, './start.sh', opts),
|
||||||
stop: exec.bind(null, './stop.sh', opts),
|
stop: exec.bind(null, './stop.sh', opts),
|
||||||
uri: 'http://localhost:15986/registry/_design/app/_rewrite/'
|
uri: 'http://localhost:' + (process.env.TRAVIS === 'true' ? 5984 : 15986) + '/registry/_design/app/_rewrite/'
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -7,25 +7,29 @@ cd $(dirname $0)
|
|||||||
|
|
||||||
mkdir -p couch
|
mkdir -p couch
|
||||||
|
|
||||||
# start couchdb as a background process, load local config, specify writable logfiles
|
|
||||||
if [[ $TRAVIS = true ]]
|
if [[ $TRAVIS = true ]]
|
||||||
then
|
then
|
||||||
echo 'starting couch with sudo'
|
COUCH=http://admin:password@127.0.0.1:5984
|
||||||
sudo couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
|
|
||||||
|
curl -X PUT http://127.0.0.1:5984/_config/admins/admin -d '"password"'
|
||||||
|
|
||||||
|
curl -X PUT $COUCH/_config/couchdb/delayed_commits -d '"false"'
|
||||||
|
curl -X PUT $COUCH/_config/couch_httpd_auth/users_db_public -d '"true"'
|
||||||
|
curl -X PUT $COUCH/_config/couch_httpd_auth/public_fields -d '"appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev"'
|
||||||
|
curl -X PUT $COUCH/_config/httpd/secure_rewrites -d '"false"'
|
||||||
|
|
||||||
else
|
else
|
||||||
|
COUCH=http://admin:password@127.0.0.1:15986
|
||||||
couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
|
couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
|
||||||
|
# wait for couch to start
|
||||||
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# wait for couch to start
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
COUCH=http://admin:password@127.0.0.1:15986
|
|
||||||
|
|
||||||
# create "registry" database
|
# create "registry" database
|
||||||
curl -X PUT $COUCH/registry
|
curl -X PUT $COUCH/registry
|
||||||
|
|
||||||
# create sample npm user
|
# create sample npm user
|
||||||
curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration","name": "integration","roles": [],"type": "user","password": "suchsecure","email": "integration@test.com"}'
|
curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration", "name": "integration", "roles": [], "type": "user", "password": "suchsecure", "email": "integration@test.com"}'
|
||||||
|
|
||||||
# npm-registry-couchpp needs this variable set to run
|
# npm-registry-couchpp needs this variable set to run
|
||||||
export DEPLOY_VERSION=nope
|
export DEPLOY_VERSION=nope
|
||||||
@@ -33,4 +37,5 @@ export DEPLOY_VERSION=nope
|
|||||||
# setup npm-registry-couchapp
|
# setup npm-registry-couchapp
|
||||||
npm explore npm-registry-couchapp -- npm start --npm-registry-couchapp:couch=$COUCH/registry
|
npm explore npm-registry-couchapp -- npm start --npm-registry-couchapp:couch=$COUCH/registry
|
||||||
npm explore npm-registry-couchapp -- npm run load --npm-registry-couchapp:couch=$COUCH/registry
|
npm explore npm-registry-couchapp -- npm run load --npm-registry-couchapp:couch=$COUCH/registry
|
||||||
npm explore npm-registry-couchapp -- NO_PROMPT=yes npm run copy --npm-registry-couchapp:couch=$COUCH/registry
|
export NO_PROMPT=yes
|
||||||
|
npm explore npm-registry-couchapp -- npm run copy --npm-registry-couchapp:couch=$COUCH/registry
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ cd $(dirname $0)
|
|||||||
|
|
||||||
cat couch/{couch,stdout,stderr}.log
|
cat couch/{couch,stdout,stderr}.log
|
||||||
|
|
||||||
|
cat couch/pid | xargs kill
|
||||||
rm -rf couch
|
rm -rf couch
|
||||||
rm -rf data
|
rm -rf data
|
||||||
|
|||||||
+22
-24
@@ -1,30 +1,27 @@
|
|||||||
const { join } = require('path')
|
var join = require('path').join
|
||||||
|
|
||||||
const { test, tearDown } = require('tap')
|
var tap = require('tap')
|
||||||
const rimraf = require('rimraf')
|
var rimraf = require('rimraf')
|
||||||
|
|
||||||
const registry = require('../registry')
|
var registry = require('../registry')
|
||||||
const testModule = require('../lib/test-module')
|
var testModule = require('../lib/test-module')
|
||||||
const baseScenario = require('../lib/base-scenario')
|
var baseScenario = require('../lib/base-scenario')
|
||||||
|
|
||||||
test('change version', (t) => {
|
var tearDown = tap.tearDown
|
||||||
|
var test = tap.test
|
||||||
|
|
||||||
|
test('change version', {bail: process.env.TRAVIS === 'true'}, function (t) {
|
||||||
t.plan(7)
|
t.plan(7)
|
||||||
|
|
||||||
registry.start((err) => {
|
registry.start(function (err, stdout, stderr) {
|
||||||
t.error(err, 'registry started')
|
t.error(err, 'registry started')
|
||||||
if (err) {
|
if (err) return t.end()
|
||||||
t.end()
|
|
||||||
t.bailout('registry not started')
|
|
||||||
}
|
|
||||||
|
|
||||||
testModule('change-version', (err, cwd) => {
|
testModule('change-version', registry.uri, function (err, cwd) {
|
||||||
t.error(err, 'test-module created')
|
t.error(err, 'test-module created')
|
||||||
if (err) {
|
if (err) return t.end()
|
||||||
t.end()
|
|
||||||
t.bailout('test-module not created')
|
|
||||||
}
|
|
||||||
|
|
||||||
t.test('no version', (tt) => {
|
t.test('no version', function (tt) {
|
||||||
tt.plan(1)
|
tt.plan(1)
|
||||||
|
|
||||||
baseScenario(cwd, registry.uri)
|
baseScenario(cwd, registry.uri)
|
||||||
@@ -35,7 +32,7 @@ test('change version', (t) => {
|
|||||||
.end(tt.error)
|
.end(tt.error)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('initial version', (tt) => {
|
t.test('initial version', function (tt) {
|
||||||
tt.plan(1)
|
tt.plan(1)
|
||||||
|
|
||||||
baseScenario(cwd, registry.uri)
|
baseScenario(cwd, registry.uri)
|
||||||
@@ -47,7 +44,7 @@ test('change version', (t) => {
|
|||||||
.end(tt.error)
|
.end(tt.error)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('patch version', (tt) => {
|
t.test('patch version', function (tt) {
|
||||||
tt.plan(1)
|
tt.plan(1)
|
||||||
|
|
||||||
baseScenario(cwd, registry.uri)
|
baseScenario(cwd, registry.uri)
|
||||||
@@ -59,7 +56,7 @@ test('change version', (t) => {
|
|||||||
.end(tt.error)
|
.end(tt.error)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('feature version', (tt) => {
|
t.test('feature version', function (tt) {
|
||||||
tt.plan(1)
|
tt.plan(1)
|
||||||
|
|
||||||
baseScenario(cwd, registry.uri)
|
baseScenario(cwd, registry.uri)
|
||||||
@@ -71,7 +68,7 @@ test('change version', (t) => {
|
|||||||
.end(tt.error)
|
.end(tt.error)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('breaking version', (tt) => {
|
t.test('breaking version', function (tt) {
|
||||||
tt.plan(1)
|
tt.plan(1)
|
||||||
|
|
||||||
baseScenario(cwd, registry.uri)
|
baseScenario(cwd, registry.uri)
|
||||||
@@ -86,10 +83,11 @@ test('change version', (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
tearDown(() => {
|
tearDown(function () {
|
||||||
|
if (process.env.TRAVIS === 'true') return
|
||||||
|
|
||||||
function cb (err, stdout, stderr) {
|
function cb (err, stdout, stderr) {
|
||||||
if (err) console.log(err)
|
if (err) console.log(err)
|
||||||
if (stdout) console.log(stdout)
|
|
||||||
if (stderr) console.log(stderr)
|
if (stderr) console.log(stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-10
@@ -1,13 +1,16 @@
|
|||||||
const test = require('tap').test
|
var test = require('tap').test
|
||||||
const proxyquire = require('proxyquire')
|
var proxyquire = require('proxyquire')
|
||||||
|
|
||||||
const commits = proxyquire('../../dist/lib/commits', {
|
var commits = proxyquire('../../src/lib/commits', {
|
||||||
|
'npmlog': {
|
||||||
|
error: function () {}
|
||||||
|
},
|
||||||
'child_process': require('../mocks/child-process')
|
'child_process': require('../mocks/child-process')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('commits since last release', (t) => {
|
test('commits since last release', function (t) {
|
||||||
t.test('get all commits', (tt) => {
|
t.test('get all commits', function (tt) {
|
||||||
commits({lastRelease: {}, options: {branch: 'master'}}, (err, commits) => {
|
commits({lastRelease: {}, options: {branch: 'master'}}, function (err, commits) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(commits.length, 2, 'all commits')
|
tt.is(commits.length, 2, 'all commits')
|
||||||
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
||||||
@@ -17,8 +20,8 @@ test('commits since last release', (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('get commits since hash', (tt) => {
|
t.test('get commits since hash', function (tt) {
|
||||||
commits({lastRelease: {gitHead: 'hash'}, options: {branch: 'master'}}, (err, commits) => {
|
commits({lastRelease: {gitHead: 'hash'}, options: {branch: 'master'}}, function (err, commits) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(commits.length, 1, 'specified commits')
|
tt.is(commits.length, 1, 'specified commits')
|
||||||
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
||||||
@@ -28,8 +31,8 @@ test('commits since last release', (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('get commits since hash', (tt) => {
|
t.test('get commits since hash', function (tt) {
|
||||||
commits({lastRelease: {gitHead: 'notinhistory'}, options: {branch: 'notmaster'}}, (err, commits) => {
|
commits({lastRelease: {gitHead: 'notinhistory'}, options: {branch: 'notmaster'}}, function (err, commits) {
|
||||||
tt.ok(err)
|
tt.ok(err)
|
||||||
tt.is(err.code, 'ENOTINHISTORY')
|
tt.is(err.code, 'ENOTINHISTORY')
|
||||||
tt.end()
|
tt.end()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const test = require('tap').test
|
const test = require('tap').test
|
||||||
|
|
||||||
const getRegistry = require('../../dist/lib/get-registry')
|
const getRegistry = require('../../src/lib/get-registry')
|
||||||
|
|
||||||
test('get correct registry', (t) => {
|
test('get correct registry', function (t) {
|
||||||
t.is(getRegistry({
|
t.is(getRegistry({
|
||||||
name: 'publish-config',
|
name: 'publish-config',
|
||||||
publishConfig: {
|
publishConfig: {
|
||||||
@@ -10,20 +10,34 @@ test('get correct registry', (t) => {
|
|||||||
}},
|
}},
|
||||||
{}), 'a')
|
{}), 'a')
|
||||||
|
|
||||||
t.is(getRegistry({name: 'normal'}, {get: () => 'b'}), 'b')
|
t.is(getRegistry({name: 'normal'}, {
|
||||||
|
get: function () {
|
||||||
|
return 'b'
|
||||||
|
}
|
||||||
|
}), 'b')
|
||||||
|
|
||||||
t.is(getRegistry({name: 'normal'}, {get: () => null}), 'https://registry.npmjs.org/')
|
t.is(getRegistry({name: 'normal'}, {
|
||||||
|
get: function () {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}), 'https://registry.npmjs.org/')
|
||||||
|
|
||||||
t.is(getRegistry({name: '@scoped/foo'}, {
|
t.is(getRegistry({name: '@scoped/foo'}, {
|
||||||
get: (input) => input === '@scoped/registry' ? 'c' : 'd'
|
get: function (input) {
|
||||||
|
return input === '@scoped/registry' ? 'c' : 'd'
|
||||||
|
}
|
||||||
}), 'c')
|
}), 'c')
|
||||||
|
|
||||||
t.is(getRegistry({name: '@scoped/bar'}, {
|
t.is(getRegistry({name: '@scoped/bar'}, {
|
||||||
get: () => 'e'
|
get: function () {
|
||||||
|
return 'e'
|
||||||
|
}
|
||||||
}), 'e')
|
}), 'e')
|
||||||
|
|
||||||
t.is(getRegistry({name: '@scoped/baz'}, {
|
t.is(getRegistry({name: '@scoped/baz'}, {
|
||||||
get: () => null
|
get: function () {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}), 'https://registry.npmjs.org/')
|
}), 'https://registry.npmjs.org/')
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
|
|||||||
+34
-33
@@ -1,11 +1,11 @@
|
|||||||
const test = require('tap').test
|
var test = require('tap').test
|
||||||
|
|
||||||
const plugins = require('../../dist/lib/plugins')
|
var plugins = require('../../src/lib/plugins')
|
||||||
|
|
||||||
test('export plugins', (t) => {
|
test('export plugins', function (t) {
|
||||||
t.plan(5)
|
t.plan(5)
|
||||||
|
|
||||||
const defaultPlugins = plugins({})
|
var defaultPlugins = plugins({})
|
||||||
|
|
||||||
t.is(typeof defaultPlugins.analyzeCommits, 'function')
|
t.is(typeof defaultPlugins.analyzeCommits, 'function')
|
||||||
t.is(typeof defaultPlugins.generateNotes, 'function')
|
t.is(typeof defaultPlugins.generateNotes, 'function')
|
||||||
@@ -14,51 +14,51 @@ test('export plugins', (t) => {
|
|||||||
t.is(typeof defaultPlugins.getLastRelease, 'function')
|
t.is(typeof defaultPlugins.getLastRelease, 'function')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('plugin pipelines', (t) => {
|
test('plugin pipelines', function (t) {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
|
|
||||||
t.test('get all results', (tt) => {
|
t.test('get all results', function (tt) {
|
||||||
const pipelinePlugins = plugins({
|
var pipelinePlugins = plugins({
|
||||||
verifyRelease: [
|
verifyRelease: [
|
||||||
'./dist/lib/plugin-noop',
|
'./src/lib/plugin-noop',
|
||||||
'./.test/mocks/plugin-result-a',
|
'./test/mocks/plugin-result-a',
|
||||||
'./.test/mocks/plugin-result-b'
|
'./test/mocks/plugin-result-b'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
pipelinePlugins.verifyRelease({}, (err, results) => {
|
pipelinePlugins.verifyRelease({}, function (err, results) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.same(results, [undefined, 'a', 'b'])
|
tt.same(results, [undefined, 'a', 'b'])
|
||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('get first error', (tt) => {
|
t.test('get first error', function (tt) {
|
||||||
const pipelinePlugins = plugins({
|
var pipelinePlugins = plugins({
|
||||||
verifyConditions: [
|
verifyConditions: [
|
||||||
'./dist/lib/plugin-noop',
|
'./src/lib/plugin-noop',
|
||||||
'./.test/mocks/plugin-error-a',
|
'./test/mocks/plugin-error-a',
|
||||||
'./.test/mocks/plugin-error-b'
|
'./test/mocks/plugin-error-b'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
pipelinePlugins.verifyConditions({}, (err) => {
|
pipelinePlugins.verifyConditions({}, function (err) {
|
||||||
tt.is(err.message, 'a')
|
tt.is(err.message, 'a')
|
||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('get error and only results before', (tt) => {
|
t.test('get error and only results before', function (tt) {
|
||||||
const pipelinePlugins = plugins({
|
var pipelinePlugins = plugins({
|
||||||
verifyRelease: [
|
verifyRelease: [
|
||||||
'./dist/lib/plugin-noop',
|
'./src/lib/plugin-noop',
|
||||||
'./.test/mocks/plugin-result-a',
|
'./test/mocks/plugin-result-a',
|
||||||
'./.test/mocks/plugin-error-b',
|
'./test/mocks/plugin-error-b',
|
||||||
'./.test/mocks/plugin-result-b'
|
'./test/mocks/plugin-result-b'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
pipelinePlugins.verifyRelease({}, (err, results) => {
|
pipelinePlugins.verifyRelease({}, function (err, results) {
|
||||||
tt.is(err.message, 'b')
|
tt.is(err.message, 'b')
|
||||||
tt.same(results, [undefined, 'a', undefined])
|
tt.same(results, [undefined, 'a', undefined])
|
||||||
tt.end()
|
tt.end()
|
||||||
@@ -66,19 +66,18 @@ test('plugin pipelines', (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('normalize and load plugin', (t) => {
|
test('normalize and load plugin', function (t) {
|
||||||
|
t.test('load from string', function (tt) {
|
||||||
t.test('load from string', (tt) => {
|
var plugin = plugins.normalize('./src/lib/plugin-noop')
|
||||||
const plugin = plugins.normalize('./dist/lib/plugin-noop')
|
|
||||||
|
|
||||||
tt.is(typeof plugin, 'function')
|
tt.is(typeof plugin, 'function')
|
||||||
|
|
||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('load from object', (tt) => {
|
t.test('load from object', function (tt) {
|
||||||
const plugin = plugins.normalize({
|
var plugin = plugins.normalize({
|
||||||
path: './dist/lib/plugin-noop'
|
path: './src/lib/plugin-noop'
|
||||||
})
|
})
|
||||||
|
|
||||||
tt.is(typeof plugin, 'function')
|
tt.is(typeof plugin, 'function')
|
||||||
@@ -86,11 +85,13 @@ test('normalize and load plugin', (t) => {
|
|||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('load from object', (tt) => {
|
t.test('load from fallback', function (tt) {
|
||||||
const plugin = plugins.normalize(null, '../../dist/lib/plugin-noop')
|
var plugin = plugins.normalize(null, '../../src/lib/plugin-noop')
|
||||||
|
|
||||||
tt.is(typeof plugin, 'function')
|
tt.is(typeof plugin, 'function')
|
||||||
|
|
||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.end()
|
||||||
})
|
})
|
||||||
|
|||||||
+30
-24
@@ -1,35 +1,39 @@
|
|||||||
const { defaults } = require('lodash')
|
var defaults = require('lodash').defaults
|
||||||
const test = require('tap').test
|
var test = require('tap').test
|
||||||
const proxyquire = require('proxyquire')
|
var proxyquire = require('proxyquire')
|
||||||
|
|
||||||
const post = proxyquire('../../dist/post', {
|
var post = proxyquire('../../src/post', {
|
||||||
'git-head': require('../mocks/git-head'),
|
'git-head': require('../mocks/git-head'),
|
||||||
github: require('../mocks/github')
|
github: require('../mocks/github')
|
||||||
})
|
})
|
||||||
|
|
||||||
const pkg = {
|
var pkg = {
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
repository: {url: 'http://github.com/whats/up.git'}
|
repository: {url: 'http://github.com/whats/up.git'}
|
||||||
}
|
}
|
||||||
|
|
||||||
const plugins = {generateNotes: (pkg, cb) => cb(null, 'the log')}
|
var plugins = {
|
||||||
|
generateNotes: function (pkg, cb) {
|
||||||
|
cb(null, 'the log')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const defaultRelease = {
|
var defaultRelease = {
|
||||||
owner: 'whats',
|
owner: 'whats',
|
||||||
repo: 'up',
|
repo: 'up',
|
||||||
name: 'v1.0.0',
|
name: 'v1.0.0',
|
||||||
tag_name: 'v1.0.0',
|
tag_name: 'v1.0.0',
|
||||||
target_commitish: 'bar',
|
target_commitish: 'master',
|
||||||
body: 'the log'
|
body: 'the log'
|
||||||
}
|
}
|
||||||
|
|
||||||
test('full post run', (t) => {
|
test('full post run', function (t) {
|
||||||
t.test('in debug mode w/o token', (tt) => {
|
t.test('in debug mode w/o token', function (tt) {
|
||||||
post({
|
post({
|
||||||
options: {debug: true},
|
options: {debug: true, branch: 'master'},
|
||||||
pkg,
|
pkg: pkg,
|
||||||
plugins
|
plugins: plugins
|
||||||
}, (err, published, release) => {
|
}, function (err, published, release) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(published, false)
|
tt.is(published, false)
|
||||||
tt.match(release, defaults({draft: true}, defaultRelease))
|
tt.match(release, defaults({draft: true}, defaultRelease))
|
||||||
@@ -38,12 +42,12 @@ test('full post run', (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('in debug mode w/token', (tt) => {
|
t.test('in debug mode w/token', function (tt) {
|
||||||
post({
|
post({
|
||||||
options: {debug: true, githubToken: 'yo'},
|
options: {debug: true, githubToken: 'yo', branch: 'master'},
|
||||||
pkg,
|
pkg: pkg,
|
||||||
plugins
|
plugins: plugins
|
||||||
}, (err, published, release) => {
|
}, function (err, published, release) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(published, true)
|
tt.is(published, true)
|
||||||
tt.match(release, defaults({draft: true}, defaultRelease))
|
tt.match(release, defaults({draft: true}, defaultRelease))
|
||||||
@@ -52,12 +56,12 @@ test('full post run', (t) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('production', (tt) => {
|
t.test('production', function (tt) {
|
||||||
post({
|
post({
|
||||||
options: {githubToken: 'yo'},
|
options: {githubToken: 'yo', branch: 'master'},
|
||||||
pkg,
|
pkg: pkg,
|
||||||
plugins
|
plugins: plugins
|
||||||
}, (err, published, release) => {
|
}, function (err, published, release) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(published, true)
|
tt.is(published, true)
|
||||||
tt.match(release, defaultRelease)
|
tt.match(release, defaultRelease)
|
||||||
@@ -65,4 +69,6 @@ test('full post run', (t) => {
|
|||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.end()
|
||||||
})
|
})
|
||||||
|
|||||||
+24
-20
@@ -1,55 +1,59 @@
|
|||||||
const test = require('tap').test
|
var test = require('tap').test
|
||||||
const proxyquire = require('proxyquire')
|
var proxyquire = require('proxyquire')
|
||||||
|
|
||||||
require('../mocks/registry')
|
require('../mocks/registry')
|
||||||
const pre = proxyquire('../../dist/pre', {
|
var pre = proxyquire('../../src/pre', {
|
||||||
'./lib/commits': proxyquire('../../dist/lib/commits', {
|
'./lib/commits': proxyquire('../../src/lib/commits', {
|
||||||
'child_process': require('../mocks/child-process')
|
'child_process': require('../mocks/child-process')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const versions = {
|
var versions = {
|
||||||
available: '1.0.0'
|
available: '1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
const plugins = {
|
var plugins = {
|
||||||
verifyRelease: (release, cb) => cb(null, release),
|
verifyRelease: function (release, cb) {
|
||||||
analyzeCommits: (commits, cb) => cb(null, 'major'),
|
cb(null, release)
|
||||||
getLastRelease: ({ pkg }, cb) => {
|
},
|
||||||
cb(null, {version: versions[pkg.name] || null, gitHead: 'HEAD'})
|
analyzeCommits: function (commits, cb) {
|
||||||
|
cb(null, 'major')
|
||||||
|
},
|
||||||
|
getLastRelease: function (config, cb) {
|
||||||
|
cb(null, {version: versions[config.pkg.name] || null, gitHead: 'HEAD'})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const npm = {
|
var npm = {
|
||||||
registry: 'http://registry.npmjs.org/',
|
registry: 'http://registry.npmjs.org/',
|
||||||
tag: 'latest'
|
tag: 'latest'
|
||||||
}
|
}
|
||||||
|
|
||||||
test('full pre run', (t) => {
|
test('full pre run', function (t) {
|
||||||
t.test('increase version', (tt) => {
|
t.test('increase version', function (tt) {
|
||||||
tt.plan(3)
|
tt.plan(3)
|
||||||
|
|
||||||
pre({
|
pre({
|
||||||
options: {branch: 'master'},
|
options: {branch: 'master'},
|
||||||
npm,
|
npm: npm,
|
||||||
pkg: {name: 'available'},
|
pkg: {name: 'available'},
|
||||||
plugins
|
plugins: plugins
|
||||||
}, (err, release) => {
|
}, function (err, release) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(release.type, 'major')
|
tt.is(release.type, 'major')
|
||||||
tt.is(release.version, '2.0.0')
|
tt.is(release.version, '2.0.0')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('increase version', (tt) => {
|
t.test('increase version', function (tt) {
|
||||||
tt.plan(3)
|
tt.plan(3)
|
||||||
|
|
||||||
pre({
|
pre({
|
||||||
options: {branch: 'master'},
|
options: {branch: 'master'},
|
||||||
npm,
|
npm: npm,
|
||||||
pkg: {name: 'unavailable'},
|
pkg: {name: 'unavailable'},
|
||||||
plugins
|
plugins: plugins
|
||||||
}, (err, release) => {
|
}, function (err, release) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(release.type, 'initial')
|
tt.is(release.type, 'initial')
|
||||||
tt.is(release.version, '1.0.0')
|
tt.is(release.version, '1.0.0')
|
||||||
|
|||||||
+24
-12
@@ -1,9 +1,9 @@
|
|||||||
const test = require('tap').test
|
var test = require('tap').test
|
||||||
|
|
||||||
const type = require('../../dist/lib/type')
|
var type = require('../../src/lib/type')
|
||||||
|
|
||||||
test('get type from commits', (t) => {
|
test('get type from commits', function (t) {
|
||||||
t.test('get type from plugin', (tt) => {
|
t.test('get type from plugin', function (tt) {
|
||||||
tt.plan(2)
|
tt.plan(2)
|
||||||
|
|
||||||
type({
|
type({
|
||||||
@@ -12,33 +12,45 @@ test('get type from commits', (t) => {
|
|||||||
message: 'a'
|
message: 'a'
|
||||||
}],
|
}],
|
||||||
lastRelease: {version: '1.0.0'},
|
lastRelease: {version: '1.0.0'},
|
||||||
plugins: {analyzeCommits: (config, cb) => cb(null, 'major')}
|
plugins: {
|
||||||
}, (err, type) => {
|
analyzeCommits: function (config, cb) {
|
||||||
|
cb(null, 'major')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (err, type) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(type, 'major')
|
tt.is(type, 'major')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('error when no changes', (tt) => {
|
t.test('error when no changes', function (tt) {
|
||||||
tt.plan(1)
|
tt.plan(1)
|
||||||
|
|
||||||
type({
|
type({
|
||||||
commits: [],
|
commits: [],
|
||||||
lastRelease: {},
|
lastRelease: {},
|
||||||
plugins: {analyzeCommits: (config, cb) => cb(null, null)}
|
plugins: {
|
||||||
}, (err) => {
|
analyzeCommits: function (config, cb) {
|
||||||
|
cb(null, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (err) {
|
||||||
tt.is(err.code, 'ENOCHANGE')
|
tt.is(err.code, 'ENOCHANGE')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('initial version', (tt) => {
|
t.test('initial version', function (tt) {
|
||||||
tt.plan(2)
|
tt.plan(2)
|
||||||
|
|
||||||
type({
|
type({
|
||||||
commits: [],
|
commits: [],
|
||||||
lastRelease: {},
|
lastRelease: {},
|
||||||
plugins: {analyzeCommits: (config, cb) => cb(null, 'major')}
|
plugins: {
|
||||||
}, (err, type) => {
|
analyzeCommits: function (config, cb) {
|
||||||
|
cb(null, 'major')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (err, type) {
|
||||||
tt.error(err)
|
tt.error(err)
|
||||||
tt.is(type, 'initial')
|
tt.is(type, 'initial')
|
||||||
})
|
})
|
||||||
|
|||||||
+18
-14
@@ -1,10 +1,10 @@
|
|||||||
const test = require('tap').test
|
var test = require('tap').test
|
||||||
|
|
||||||
const verify = require('../../dist/lib/verify')
|
var verify = require('../../src/lib/verify')
|
||||||
|
|
||||||
test('verify pkg, options and env', (t) => {
|
test('verify pkg, options and env', function (t) {
|
||||||
t.test('dry run verification', (tt) => {
|
t.test('dry run verification', function (tt) {
|
||||||
const noErrors = verify({
|
var noErrors = verify({
|
||||||
options: {debug: true},
|
options: {debug: true},
|
||||||
pkg: {
|
pkg: {
|
||||||
name: 'package',
|
name: 'package',
|
||||||
@@ -16,7 +16,7 @@ test('verify pkg, options and env', (t) => {
|
|||||||
|
|
||||||
tt.is(noErrors.length, 0)
|
tt.is(noErrors.length, 0)
|
||||||
|
|
||||||
const errors = verify({
|
var errors = verify({
|
||||||
options: {debug: true},
|
options: {debug: true},
|
||||||
pkg: {}
|
pkg: {}
|
||||||
})
|
})
|
||||||
@@ -25,24 +25,26 @@ test('verify pkg, options and env', (t) => {
|
|||||||
tt.is(errors[0].code, 'ENOPKGNAME')
|
tt.is(errors[0].code, 'ENOPKGNAME')
|
||||||
tt.is(errors[1].code, 'ENOPKGREPO')
|
tt.is(errors[1].code, 'ENOPKGREPO')
|
||||||
|
|
||||||
const errors2 = verify({
|
tt.end()
|
||||||
|
})
|
||||||
|
|
||||||
|
t.test('dry run verification for gitlab repo', function (tt) {
|
||||||
|
var noErrors = verify({
|
||||||
options: {debug: true},
|
options: {debug: true},
|
||||||
pkg: {
|
pkg: {
|
||||||
name: 'package',
|
name: 'package',
|
||||||
repository: {
|
repository: {
|
||||||
url: 'lol'
|
url: 'http://gitlab.corp.com/whats/up.git'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tt.is(errors2.length, 1)
|
tt.is(noErrors.length, 0)
|
||||||
tt.is(errors2[0].code, 'EMALFORMEDPKGREPO')
|
|
||||||
|
|
||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('publish verification', (tt) => {
|
t.test('publish verification', function (tt) {
|
||||||
const noErrors = verify({
|
var noErrors = verify({
|
||||||
env: {NPM_TOKEN: 'yo'},
|
env: {NPM_TOKEN: 'yo'},
|
||||||
options: {githubToken: 'sup'},
|
options: {githubToken: 'sup'},
|
||||||
pkg: {
|
pkg: {
|
||||||
@@ -55,7 +57,7 @@ test('verify pkg, options and env', (t) => {
|
|||||||
|
|
||||||
tt.is(noErrors.length, 0)
|
tt.is(noErrors.length, 0)
|
||||||
|
|
||||||
const errors = verify({env: {}, options: {}, pkg: {}})
|
var errors = verify({env: {}, options: {}, pkg: {}})
|
||||||
|
|
||||||
tt.is(errors.length, 4)
|
tt.is(errors.length, 4)
|
||||||
tt.is(errors[0].code, 'ENOPKGNAME')
|
tt.is(errors[0].code, 'ENOPKGNAME')
|
||||||
@@ -65,4 +67,6 @@ test('verify pkg, options and env', (t) => {
|
|||||||
|
|
||||||
tt.end()
|
tt.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.end()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user