Socket
Socket
Sign inDemoInstall

standard-version

Package Overview
Dependencies
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

standard-version - npm Package Compare versions

Comparing version 5.0.2 to 6.0.0-beta.0

.eslintrc

45

CHANGELOG.md

@@ -1,5 +0,48 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [6.0.0](https://github.com/conventional-changelog/standard-version/compare/v5.0.2...v6.0.0) (2019-05-05)
### Bug Fixes
* always pass version to changelog context ([#327](https://github.com/conventional-changelog/standard-version/issues/327)) ([00e3381](https://github.com/conventional-changelog/standard-version/commit/00e3381))
* **deps:** update dependency detect-indent to v6 ([#341](https://github.com/conventional-changelog/standard-version/issues/341)) ([234d9dd](https://github.com/conventional-changelog/standard-version/commit/234d9dd))
* **deps:** update dependency detect-newline to v3 ([#342](https://github.com/conventional-changelog/standard-version/issues/342)) ([02a6093](https://github.com/conventional-changelog/standard-version/commit/02a6093))
* **deps:** update dependency figures to v3 ([#343](https://github.com/conventional-changelog/standard-version/issues/343)) ([7208ded](https://github.com/conventional-changelog/standard-version/commit/7208ded))
* **deps:** update dependency semver to v6 ([#344](https://github.com/conventional-changelog/standard-version/issues/344)) ([c40487a](https://github.com/conventional-changelog/standard-version/commit/c40487a))
* **deps:** update dependency yargs to v13 ([#345](https://github.com/conventional-changelog/standard-version/issues/345)) ([b2c8e59](https://github.com/conventional-changelog/standard-version/commit/b2c8e59))
* prevent duplicate headers from being added ([#305](https://github.com/conventional-changelog/standard-version/issues/305)) ([#307](https://github.com/conventional-changelog/standard-version/issues/307)) ([db2c6e5](https://github.com/conventional-changelog/standard-version/commit/db2c6e5))
### Build System
* add renovate.json ([#273](https://github.com/conventional-changelog/standard-version/issues/273)) ([bf41474](https://github.com/conventional-changelog/standard-version/commit/bf41474))
* drop Node 6 from testing matrix ([#346](https://github.com/conventional-changelog/standard-version/issues/346)) ([6718428](https://github.com/conventional-changelog/standard-version/commit/6718428))
### Features
* adds configurable conventionalcommits preset ([#323](https://github.com/conventional-changelog/standard-version/issues/323)) ([4fcd4a7](https://github.com/conventional-changelog/standard-version/commit/4fcd4a7))
* allow a user to provide a custom changelog header ([#335](https://github.com/conventional-changelog/standard-version/issues/335)) ([1c51064](https://github.com/conventional-changelog/standard-version/commit/1c51064))
* bump minor rather than major, if release is < 1.0.0 ([#347](https://github.com/conventional-changelog/standard-version/issues/347)) ([5d972cf](https://github.com/conventional-changelog/standard-version/commit/5d972cf))
* suggest branch name other than master ([#331](https://github.com/conventional-changelog/standard-version/issues/331)) ([304b49a](https://github.com/conventional-changelog/standard-version/commit/304b49a))
* update commit msg for when using commitAll ([#320](https://github.com/conventional-changelog/standard-version/issues/320)) ([74a040a](https://github.com/conventional-changelog/standard-version/commit/74a040a))
### Tests
* disable gpg signing in temporary test repositories. ([#311](https://github.com/conventional-changelog/standard-version/issues/311)) ([bd0fcdf](https://github.com/conventional-changelog/standard-version/commit/bd0fcdf))
* use const based on new eslint rules ([#329](https://github.com/conventional-changelog/standard-version/issues/329)) ([b6d3d13](https://github.com/conventional-changelog/standard-version/commit/b6d3d13))
### BREAKING CHANGES
* we now bump the minor rather than major if version < 1.0.0; --release-as can be used to bump to 1.0.0.
* tests are no longer run for Node 6
* we now use the conventionalcommits preset by default, which directly tracks conventionalcommits.org.
## [5.0.2](https://github.com/conventional-changelog/standard-version/compare/v5.0.1...v5.0.2) (2019-03-16)

@@ -6,0 +49,0 @@

@@ -1,4 +0,11 @@

var defaults = require('./defaults')
const findUp = require('find-up')
const defaults = require('./defaults')
const { readFileSync } = require('fs')
module.exports = require('yargs')
const configPath = findUp.sync(['.versionrc', '.version.json'])
const config = configPath ? JSON.parse(readFileSync(configPath)) : {}
const spec = require('conventional-changelog-config-spec')
const { START_OF_LAST_RELEASE_PATTERN } = require('./lib/lifecycles/changelog')
const yargs = require('yargs')
.usage('Usage: $0 [options]')

@@ -84,2 +91,6 @@ .option('release-as', {

})
.option('changelogHeader', {
type: 'string',
describe: 'Use a custom header when generating and updating changelog.'
})
.option('preset', {

@@ -99,5 +110,3 @@ type: 'string',

})
.version()
.alias('version', 'v')
.help()
.alias('help', 'h')

@@ -107,2 +116,25 @@ .example('$0', 'Update changelog and tag release')

.pkgConf('standard-version')
.config(config)
.wrap(97)
.check((args) => {
if (args.changelogHeader && args.changelogHeader.search(START_OF_LAST_RELEASE_PATTERN) !== -1) {
throw Error(`custom changelog header must not match ${START_OF_LAST_RELEASE_PATTERN}`)
} else {
return true
}
})
Object.keys(spec.properties).forEach(propertyKey => {
const property = spec.properties[propertyKey]
yargs.option(propertyKey, {
type: property.type,
describe: property.description,
default: property.default,
group: 'Preset Configuration:'
})
})
module.exports = yargs
// TODO: yargs should be populated with keys/descriptions from
// https://github.com/conventional-changelog/conventional-changelog-config-spec

4

defaults.json

@@ -14,3 +14,3 @@ {

"gitTagFallback": true,
"preset": "angular"
}
"preset": "conventionalcommits"
}

@@ -14,5 +14,5 @@ const bump = require('./lib/lifecycles/bump')

if (pkg) return
var pkgPath = path.resolve(process.cwd(), filename)
let pkgPath = path.resolve(process.cwd(), filename)
try {
var data = fs.readFileSync(pkgPath, 'utf8')
let data = fs.readFileSync(pkgPath, 'utf8')
pkg = JSON.parse(data)

@@ -19,0 +19,0 @@ } catch (err) {}

@@ -12,2 +12,3 @@ 'use strict'

const path = require('path')
const presetLoader = require('../preset-loader')
const runLifecycleScript = require('../run-lifecycle-script')

@@ -18,3 +19,3 @@ const semver = require('semver')

var configsToUpdate = {}
let configsToUpdate = {}

@@ -27,3 +28,3 @@ function Bump (args, version) {

if (args.skip.bump) return Promise.resolve()
var newVersion = version
let newVersion = version
return runLifecycleScript(args, 'prerelease')

@@ -33,7 +34,7 @@ .then(runLifecycleScript.bind(this, args, 'prebump'))

if (stdout && stdout.trim().length) args.releaseAs = stdout.trim()
return bumpVersion(args.releaseAs, args)
return bumpVersion(args.releaseAs, version, args)
})
.then((release) => {
if (!args.firstRelease) {
var releaseType = getReleaseType(args.prerelease, release.releaseType, version)
let releaseType = getReleaseType(args.prerelease, release.releaseType, version)
newVersion = semver.valid(releaseType) || semver.inc(version, releaseType, args.prerelease)

@@ -107,3 +108,3 @@ updateConfigs(args, newVersion)

var TypeList = ['major', 'minor', 'patch'].reverse()
let TypeList = ['major', 'minor', 'patch'].reverse()

@@ -117,4 +118,4 @@ /**

function getCurrentActiveType (version) {
var typelist = TypeList
for (var i = 0; i < typelist.length; i++) {
let typelist = TypeList
for (let i = 0; i < typelist.length; i++) {
if (semver[typelist[i]](version)) {

@@ -137,3 +138,3 @@ return typelist[i]

function bumpVersion (releaseAs, args) {
function bumpVersion (releaseAs, currentVersion, args) {
return new Promise((resolve, reject) => {

@@ -145,5 +146,9 @@ if (releaseAs) {

} else {
const presetOptions = presetLoader(args)
if (typeof presetOptions === 'object') {
if (semver.lt(currentVersion, '1.0.0')) presetOptions.preMajor = true
}
conventionalRecommendedBump({
debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'),
preset: args.preset || 'angular',
preset: presetOptions,
path: args.path

@@ -174,9 +179,9 @@ }, function (err, release) {

if (dotgit.ignore(configPath)) return
var stat = fs.lstatSync(configPath)
let stat = fs.lstatSync(configPath)
if (stat.isFile()) {
var data = fs.readFileSync(configPath, 'utf8')
var indent = detectIndent(data).indent
var newline = detectNewline(data)
var config = JSON.parse(data)
var filename = path.basename(configPath)
let data = fs.readFileSync(configPath, 'utf8')
let indent = detectIndent(data).indent
let newline = detectNewline(data)
let config = JSON.parse(data)
let filename = path.basename(configPath)
checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion])

@@ -183,0 +188,0 @@ config.version = newVersion

@@ -6,6 +6,8 @@ const accessSync = require('fs-access').sync

const fs = require('fs')
const presetLoader = require('../preset-loader')
const runLifecycleScript = require('../run-lifecycle-script')
const writeFile = require('../write-file')
const START_OF_LAST_RELEASE_PATTERN = /(^#+ \[?[0-9]+\.[0-9]+\.[0-9]+|<a name=)/m
module.exports = function (args, newVersion) {
function Changelog (args, newVersion) {
if (args.skip.changelog) return Promise.resolve()

@@ -21,18 +23,22 @@ return runLifecycleScript(args, 'prechangelog')

Changelog.START_OF_LAST_RELEASE_PATTERN = START_OF_LAST_RELEASE_PATTERN
module.exports = Changelog
function outputChangelog (args, newVersion) {
return new Promise((resolve, reject) => {
createIfMissing(args)
var header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
var oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
const header = args.changelogHeader || '# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
let oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
let oldContentStart = oldContent.search(START_OF_LAST_RELEASE_PATTERN)
// find the position of the last release and remove header:
const changelogSectionRegExp = /<a name=|##? \[?[0-9]+\.[0-9]+\.[0-9]+\]?/
if (oldContent.search(changelogSectionRegExp) !== -1) {
oldContent = oldContent.substring(oldContent.search(changelogSectionRegExp))
if (oldContentStart !== -1) {
oldContent = oldContent.substring(oldContentStart)
}
var content = ''
var context
if (args.dryRun) context = { version: newVersion }
var changelogStream = conventionalChangelog({
let content = ''
const context = { version: newVersion }
let changelogStream = conventionalChangelog({
debug: args.verbose && console.info.bind(console, 'conventional-changelog'),
preset: args.preset || 'angular',
preset: presetLoader(args),
tagPrefix: args.tagPrefix

@@ -39,0 +45,0 @@ }, context, { merges: null, path: args.path })

@@ -21,6 +21,6 @@ const bump = require('../lifecycles/bump')

function execCommit (args, newVersion) {
var msg = 'committing %s'
var paths = [args.infile]
var verify = args.verify === false || args.n ? '--no-verify ' : ''
var toAdd = ''
let msg = 'committing %s'
let paths = [args.infile]
let verify = args.verify === false || args.n ? '--no-verify ' : ''
let toAdd = ''
// commit any of the config files that we've updated

@@ -35,2 +35,8 @@ // the version # for.

})
if (args.commitAll) {
msg += ' and %s'
paths.push('all staged files')
}
checkpoint(args, msg, paths)

@@ -37,0 +43,0 @@ return runExec(args, 'git add' + toAdd + ' ' + args.infile)

@@ -20,3 +20,3 @@ const chalk = require('chalk')

function execTag (newVersion, pkgPrivate, args) {
var tagOption
let tagOption
if (args.sign) {

@@ -29,4 +29,5 @@ tagOption = '-s '

return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
.then(() => {
var message = 'git push --follow-tags origin master'
.then(() => runExec(args, 'git rev-parse --abbrev-ref HEAD'))
.then((currentBranch) => {
let message = 'git push --follow-tags origin ' + currentBranch.trim()
if (pkgPrivate !== true) {

@@ -33,0 +34,0 @@ message += ' && npm publish'

@@ -8,3 +8,3 @@ const chalk = require('chalk')

if (!hooks[hookName]) return Promise.resolve()
var command = hooks[hookName] + ' --new-version="' + newVersion + '"'
let command = hooks[hookName] + ' --new-version="' + newVersion + '"'
checkpoint(args, 'Running lifecycle hook "%s"', [hookName])

@@ -11,0 +11,0 @@ checkpoint(args, '- hook command: "%s"', [command], chalk.blue(figures.info))

@@ -9,3 +9,3 @@ const chalk = require('chalk')

if (!scripts || !scripts[hookName]) return Promise.resolve()
var command = scripts[hookName]
let command = scripts[hookName]
checkpoint(args, 'Running lifecycle script "%s"', [hookName])

@@ -12,0 +12,0 @@ checkpoint(args, '- execute command: "%s"', [command], chalk.blue(figures.info))

{
"name": "standard-version",
"version": "5.0.2",
"version": "6.0.0-beta.0",
"description": "replacement for `npm version` with automatic CHANGELOG generation",
"bin": "bin/cli.js",
"scripts": {
"pretest": "standard",
"posttest": "eslint .",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"test": "nyc mocha --timeout=20000 test.js",
"test": "nyc mocha --timeout=30000 test.js",
"release": "bin/cli.js"

@@ -41,25 +41,32 @@ },

"dependencies": {
"chalk": "^2.4.1",
"conventional-changelog": "^3.0.6",
"conventional-recommended-bump": "^4.0.4",
"detect-indent": "^5.0.0",
"detect-newline": "^2.1.0",
"dotgitignore": "^2.1.0",
"figures": "^2.0.0",
"fs-access": "^1.0.0",
"git-semver-tags": "^2.0.2",
"semver": "^5.2.0",
"stringify-package": "^1.0.0",
"yargs": "^12.0.2"
"chalk": "2.4.2",
"conventional-changelog": "3.1.8",
"conventional-changelog-config-spec": "1.0.0",
"conventional-recommended-bump": "5.0.0",
"detect-indent": "6.0.0",
"detect-newline": "3.0.0",
"dotgitignore": "2.1.0",
"figures": "3.0.0",
"find-up": "3.0.0",
"fs-access": "1.0.1",
"git-semver-tags": "2.0.2",
"semver": "6.0.0",
"stringify-package": "1.0.0",
"yargs": "13.2.2"
},
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^3.0.1",
"mocha": "^5.2.0",
"mock-git": "^1.0.3",
"mockery": "^2.0.0",
"nyc": "^13.3.0",
"shelljs": "^0.7.8",
"standard": "^12.0.1"
"chai": "4.2.0",
"coveralls": "3.0.3",
"eslint": "5.16.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-import": "2.17.2",
"eslint-plugin-node": "9.0.1",
"eslint-plugin-promise": "4.1.1",
"eslint-plugin-standard": "4.0.0",
"mocha": "6.1.4",
"mock-git": "2.0.0",
"mockery": "2.1.0",
"nyc": "14.1.0",
"shelljs": "0.8.3"
}
}

@@ -68,2 +68,35 @@ # Standard Version

## Configuration
You can configure `standard-version` either by:
1. Placing a `standard-version` stanza in your `package.json` (assuming
your project is JavaScript).
1. Creating a `.versionrc` or `.versionrc.json`.
Any of the command line paramters accepted by `standard-version` can instead
be provided via configuration.
### Customizing CHANGELOG Generation
By default, `standard-version` uses the [conventionalcommits preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits).
This preset:
* adheres closely to the [conventionalcommits.org](https://www.conventionalcommits.org)
specification.
* is highly configurable, following the configuration specification
[maintained here](https://github.com/conventional-changelog/conventional-changelog-config-spec).
* _we've documented these config settings as a recommendation to other tooling makers._
There are a variety of dials and knobs you can turn related to CHANGELOG generation.
As an example, suppose you're using GitLab, rather than GitHub, you might modify the following variables:
* `commitUrlFormat`: the URL format of commit SHAs detected in commit messages.
* `compareUrlFormat`: the URL format used to compare two tags.
* `issueUrlFormat`: the URL format used to link to issues.
Making these URLs match GitLab's format, rather than GitHub's.
## CLI Usage

@@ -236,3 +269,3 @@

If you would like to prefix your tags with something, you can do so with the `-t` flag.
Tags are prefixed with `v` by default. If you would like to prefix your tags with something else, you can do so with the `-t` flag.

@@ -245,2 +278,4 @@ ```sh

If you do not want to have any tag prefix you can use the `-t` flag without value.
### CLI Help

@@ -247,0 +282,0 @@

{
"enabled": false
"extends": [
"config:base"
]
}

@@ -18,3 +18,3 @@ /* global describe it beforeEach afterEach */

var cliPath = path.resolve(__dirname, './bin/cli.js')
let cliPath = path.resolve(__dirname, './bin/cli.js')

@@ -47,3 +47,3 @@ function branch (branch) {

option = option || {}
var pkg = Object.assign(option, { version: version })
let pkg = Object.assign(option, { version: version })
fs.writeFileSync('package.json', JSON.stringify(pkg), 'utf-8')

@@ -54,3 +54,3 @@ }

option = option || {}
var bower = Object.assign(option, { version: version })
let bower = Object.assign(option, { version: version })
fs.writeFileSync('bower.json', JSON.stringify(bower), 'utf-8')

@@ -61,3 +61,3 @@ }

option = option || {}
var manifest = Object.assign(option, { version: version })
let manifest = Object.assign(option, { version: version })
fs.writeFileSync('manifest.json', JSON.stringify(manifest), 'utf-8')

@@ -68,3 +68,3 @@ }

option = option || {}
var shrinkwrap = Object.assign(option, { version: version })
let shrinkwrap = Object.assign(option, { version: version })
fs.writeFileSync('npm-shrinkwrap.json', JSON.stringify(shrinkwrap), 'utf-8')

@@ -75,3 +75,3 @@ }

option = option || {}
var pkgLock = Object.assign(option, { version: version })
let pkgLock = Object.assign(option, { version: version })
fs.writeFileSync('package-lock.json', JSON.stringify(pkgLock), 'utf-8')

@@ -91,3 +91,3 @@ }

shell.mkdir('-p', 'scripts')
var content = script || 'console.error("' + hookName + ' ran")'
let content = script || 'console.error("' + hookName + ' ran")'
content += causeError ? '\nthrow new Error("' + hookName + '-failure")' : ''

@@ -104,2 +104,3 @@ fs.writeFileSync('scripts/' + hookName + '.js', content, 'utf-8')

shell.exec('git init')
shell.exec('git config commit.gpgSign false')
commit('root-commit')

@@ -142,3 +143,3 @@ writePackageJson('1.0.0')

var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/patch release/)

@@ -155,3 +156,3 @@ content.should.not.match(/first commit/)

var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/patch release/)

@@ -164,3 +165,3 @@ content.should.match(/first commit/)

describe('CHANGELOG.md exists', function () {
it('appends the new release above the last release, removing the old header', function () {
it('appends the new release above the last release, removing the old header (legacy format)', function () {
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

@@ -173,3 +174,3 @@

execCli().code.should.equal(0)
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/1\.0\.1/)

@@ -179,2 +180,29 @@ content.should.not.match(/legacy header format/)

// TODO: we should use snapshots which are easier to update than large
// string assertions; we should also consider not using the CLI which
// is slower than calling standard-version directly.
it('appends the new release above the last release, removing the old header (new format)', function () {
// we don't create a package.json, so no {{host}} and {{repo}} tag
// will be populated, let's use a compareUrlFormat without these.
const cliArgs = '--compareUrlFormat=/compare/{{previousTag}}...{{currentTag}}'
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('fix: patch release')
execCli(cliArgs).code.should.equal(0)
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
// remove commit hashes and dates to make testing against a static string easier:
content = content.replace(/patch release [0-9a-f]{6,8}/g, 'patch release ABCDEFXY').replace(/\([0-9]{4}-[0-9]{2}-[0-9]{2}\)/g, '(YYYY-MM-DD)')
content.should.equal('# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n\n### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n')
commit('fix: another patch release')
// we've populated no package.json, so no {{host}} and
execCli(cliArgs).code.should.equal(0)
content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content = content.replace(/patch release [0-9a-f]{6,8}/g, 'patch release ABCDEFXY').replace(/\([0-9]{4}-[0-9]{2}-[0-9]{2}\)/g, '(YYYY-MM-DD)')
content.should.equal('# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n\n### [1.0.2](/compare/v1.0.1...v1.0.2) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* another patch release ABCDEFXY\n\n\n\n### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n')
})
it('commits all staged files', function () {

@@ -193,4 +221,4 @@ fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
var status = shell.exec('git status --porcelain') // see http://unix.stackexchange.com/questions/155046/determine-if-git-working-directory-is-clean-from-a-script
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let status = shell.exec('git status --porcelain') // see http://unix.stackexchange.com/questions/155046/determine-if-git-working-directory-is-clean-from-a-script

@@ -203,2 +231,16 @@ status.should.equal('')

})
it('allows for a custom changelog header', function () {
fs.writeFileSync('CHANGELOG.md', '', 'utf-8')
commit('feat: first commit')
execCli('--changelogHeader="# Pork Chop Log"').code.should.equal(0)
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/# Pork Chop Log/)
})
it('exits with error if changelog header matches last version search regex', function () {
fs.writeFileSync('CHANGELOG.md', '', 'utf-8')
commit('feat: first commit')
execCli('--changelogHeader="## 3.0.2"').code.should.equal(1)
})
})

@@ -213,7 +255,7 @@

var captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) {
let captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) {
return line ? JSON.parse(line) : line
})
captured[captured.length - 3].should.deep.equal(['commit', '-S', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'])
captured[captured.length - 2].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1'])
captured[captured.length - 4].should.deep.equal(['commit', '-S', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'])
captured[captured.length - 3].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1'])

@@ -228,3 +270,3 @@ unmock()

.then(function (unmock) {
var result = execCli()
let result = execCli()
result.code.should.equal(1)

@@ -241,3 +283,3 @@ result.stderr.should.match(/commit yourself/)

.then(function (unmock) {
var result = execCli()
let result = execCli()
result.code.should.equal(1)

@@ -254,3 +296,3 @@ result.stderr.should.match(/addition is hard/)

.then(function (unmock) {
var result = execCli()
let result = execCli()
result.code.should.equal(1)

@@ -269,4 +311,4 @@ result.stderr.should.match(/tag, you're it/)

var result = execCli()
result.code.should.equal(0)
let result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/haha, kidding, this is just a warning/)

@@ -293,3 +335,3 @@

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(0)

@@ -311,3 +353,3 @@ result.stderr.should.match(/prerelease ran/)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(1)

@@ -331,3 +373,3 @@ result.stderr.should.match(/prerelease ran/)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.stdout.should.match(/9\.9\.9/)

@@ -351,3 +393,3 @@ result.code.should.equal(0)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(0)

@@ -369,3 +411,3 @@ result.stderr.should.match(/postbump ran/)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(1)

@@ -389,3 +431,3 @@ result.stderr.should.match(/postbump-failure/)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(0)

@@ -407,3 +449,3 @@ result.stderr.should.match(/precommit ran/)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(1)

@@ -425,3 +467,3 @@ result.stderr.should.match(/precommit-failure/)

commit('feat: first commit')
var result = execCli('--patch')
let result = execCli('--patch')
result.code.should.equal(0)

@@ -481,7 +523,7 @@ shell.exec('git log --oneline -n1').should.match(/delivers #222/)

describe('release-types', function () {
var regularTypes = ['major', 'minor', 'patch']
let regularTypes = ['major', 'minor', 'patch']
regularTypes.forEach(function (type) {
it('creates a ' + type + ' release', function () {
var originVer = '1.0.0'
let originVer = '1.0.0'
writePackageJson(originVer)

@@ -494,3 +536,3 @@ fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

.then(function () {
var version = {
let version = {
major: semver.major(originVer),

@@ -511,3 +553,3 @@ minor: semver.minor(originVer),

it('creates a pre' + type + ' release', function () {
var originVer = '1.0.0'
let originVer = '1.0.0'
writePackageJson(originVer)

@@ -520,3 +562,3 @@ fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

.then(function () {
var version = {
let version = {
major: semver.major(originVer),

@@ -537,3 +579,3 @@ minor: semver.minor(originVer),

it('releases as v100.0.0', function () {
var originVer = '1.0.0'
let originVer = '1.0.0'
writePackageJson(originVer)

@@ -551,3 +593,3 @@ fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

it('releases as 200.0.0-amazing', function () {
var originVer = '1.0.0'
let originVer = '1.0.0'
writePackageJson(originVer)

@@ -618,3 +660,3 @@ fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/this is my fairly long commit message which is testing whether or not we allow for long commit messages/)

@@ -639,3 +681,3 @@ })

var pkgJson = fs.readFileSync('package.json', 'utf-8')
let pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n'))

@@ -645,8 +687,8 @@ })

it('preserves indentation of tabs in package.json', function () {
var indentation = '\t'
var newPkgJson = ['{', indentation + '"version": "1.0.0"', '}', ''].join('\n')
let indentation = '\t'
let newPkgJson = ['{', indentation + '"version": "1.0.0"', '}', ''].join('\n')
fs.writeFileSync('package.json', newPkgJson, 'utf-8')
execCli().code.should.equal(0)
var pkgJson = fs.readFileSync('package.json', 'utf-8')
let pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', indentation + '"version": "1.0.1"', '}', ''].join('\n'))

@@ -656,8 +698,8 @@ })

it('preserves indentation of spaces in package.json', function () {
var indentation = ' '
var newPkgJson = ['{', indentation + '"version": "1.0.0"', '}', ''].join('\n')
let indentation = ' '
let newPkgJson = ['{', indentation + '"version": "1.0.0"', '}', ''].join('\n')
fs.writeFileSync('package.json', newPkgJson, 'utf-8')
execCli().code.should.equal(0)
var pkgJson = fs.readFileSync('package.json', 'utf-8')
let pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', indentation + '"version": "1.0.1"', '}', ''].join('\n'))

@@ -667,7 +709,7 @@ })

it('preserves line feed in package.json', function () {
var newPkgJson = ['{', ' "version": "1.0.0"', '}', ''].join('\n')
let newPkgJson = ['{', ' "version": "1.0.0"', '}', ''].join('\n')
fs.writeFileSync('package.json', newPkgJson, 'utf-8')
execCli().code.should.equal(0)
var pkgJson = fs.readFileSync('package.json', 'utf-8')
let pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n'))

@@ -677,7 +719,7 @@ })

it('preserves carriage return + line feed in package.json', function () {
var newPkgJson = ['{', ' "version": "1.0.0"', '}', ''].join('\r\n')
let newPkgJson = ['{', ' "version": "1.0.0"', '}', ''].join('\r\n')
fs.writeFileSync('package.json', newPkgJson, 'utf-8')
execCli().code.should.equal(0)
var pkgJson = fs.readFileSync('package.json', 'utf-8')
let pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\r\n'))

@@ -696,3 +738,3 @@ })

it('does not print output when the --silent flag is passed', function () {
var result = execCli('--silent')
let result = execCli('--silent')
result.code.should.equal(0)

@@ -706,3 +748,3 @@ result.stdout.should.equal('')

var result = execCli()
let result = execCli()
result.code.should.equal(0)

@@ -712,4 +754,16 @@ result.stdout.should.not.match(/npm publish/)

it('does not display `all staged files` without the --commit-all flag', function () {
const result = execCli()
result.code.should.equal(0)
result.stdout.should.not.match(/and all staged files/)
})
it('does display `all staged files` if the --commit-all flag is passed', function () {
const result = execCli('--commit-all')
result.code.should.equal(0)
result.stdout.should.match(/and all staged files/)
})
it('includes merge commits', function () {
var branchName = 'new-feature'
let branchName = 'new-feature'
commit('feat: first commit')

@@ -725,6 +779,6 @@ shell.exec('git tag -a v1.0.0 -m "my awesome first release"')

var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/new feature from branch/)
var pkgJson = fs.readFileSync('package.json', 'utf-8')
let pkgJson = fs.readFileSync('package.json', 'utf-8')
pkgJson.should.equal(['{', ' "version": "1.1.0"', '}', ''].join('\n'))

@@ -741,3 +795,3 @@ })

commit('feat: first commit')
var result = execCli()
let result = execCli()
result.code.should.equal(1)

@@ -755,3 +809,3 @@ result.stderr.should.match(/scripts must be an object/)

commit('feat: first commit')
var result = execCli()
let result = execCli()
result.code.should.equal(1)

@@ -796,3 +850,3 @@ result.stderr.should.match(/skip must be an object/)

mockery.registerMock('conventional-changelog', function () {
var readable = new stream.Readable({ objectMode: true })
let readable = new stream.Readable({ objectMode: true })
readable._read = function () {

@@ -944,3 +998,3 @@ }

getPackageVersion().should.equal('1.0.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.equal(changelogContent)

@@ -959,3 +1013,3 @@ })

getPackageVersion().should.equal('1.1.0')
var content = fs.readFileSync('CHANGELOG.md', 'utf-8')
let content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.match(/new feature from branch/)

@@ -1029,2 +1083,41 @@ // check last commit message

})
describe('configuration', () => {
it('reads config from .versionrc', function () {
// write configuration that overrides default issue
// URL format.
fs.writeFileSync('.versionrc', JSON.stringify({
issueUrlFormat: 'http://www.foo.com/{{id}}'
}), 'utf-8')
commit('feat: another commit addresses issue #1')
execCli()
// CHANGELOG should have the new issue URL format.
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
content.should.include('http://www.foo.com/1')
})
})
describe('pre-major', () => {
it('bumps the minor rather than major, if version < 1.0.0', function () {
writePackageJson('0.5.0', {
repository: {
url: 'https://github.com/yargs/yargs.git'
}
})
commit('feat!: this is a breaking change')
execCli()
getPackageVersion().should.equal('0.6.0')
})
it('bumps major if --release-as=major specified, if version < 1.0.0', function () {
writePackageJson('0.5.0', {
repository: {
url: 'https://github.com/yargs/yargs.git'
}
})
commit('feat!: this is a breaking change')
execCli('-r major')
getPackageVersion().should.equal('1.0.0')
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc