diff --git a/.gitignore b/.gitignore index 3c3629e64..c9106a73f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.nyc_output diff --git a/.travis.yml b/.travis.yml index ab1680399..bcf6c98bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,7 @@ node_js: - "0.10" - "0.12" - "node" +before_script: + - git config --global user.name 'Travis-CI' + - git config --global user.email 'dummy@example.org' +after_success: npm run coverage diff --git a/README.md b/README.md index 186da6844..04cbe923e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Build Status](https://travis-ci.org/conventional-changelog/standard-version.svg)](https://travis-ci.org/conventional-changelog/standard-version) [![NPM version](https://img.shields.io/npm/v/standard-version.svg)](https://www.npmjs.com/package/standard-version) +[![Coverage Status](https://coveralls.io/repos/conventional-changelog/standard-version/badge.svg?branch=)](https://coveralls.io/r/conventional-changelog/standard-version?branch=master) +[![Standard Version](https://img.shields.io/badge/standard-version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) > stop using `npm version`, use `standard-version` it does so much more: @@ -36,6 +38,10 @@ When you're generating your changelog for the first time, simply do: ## Automating +Do this: + +`npm i standard-version --save-dev` + Add this to your _package.json_ ```json @@ -46,6 +52,14 @@ Add this to your _package.json_ } ``` +## Badges! + +Tell your users that you adhere to the `standard-version` commit guidelines: + +```markdown +[![Standard Version](https://img.shields.io/badge/standard-version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) +``` + ## License ISC diff --git a/index.js b/index.js index 7378f465b..2b9c2b0fc 100755 --- a/index.js +++ b/index.js @@ -37,15 +37,14 @@ var argv = require('yargs') .wrap(97) .argv -var addStream = require('add-stream') var chalk = require('chalk') +var figures = require('figures') var exec = require('child_process').exec var fs = require('fs') +var accessSync = require('fs-access').sync var pkgPath = path.resolve(process.cwd(), './package.json') var pkg = require(pkgPath) var semver = require('semver') -var tempfile = require('tempfile') -var rimraf = require('rimraf') var util = require('util') conventionalRecommendedBump({ @@ -59,12 +58,11 @@ conventionalRecommendedBump({ var newVersion = pkg.version if (!argv.firstRelease) { newVersion = semver.inc(pkg.version, release.releaseAs) - - console.log(chalk.bold('1.') + ' bump version ' + chalk.bold(release.releaseAs) + ' in package.json (' + pkg.version + ' → ' + chalk.green(newVersion) + ')') + checkpoint('bumping version in package.json from %s to %s', [pkg.version, newVersion]) pkg.version = newVersion fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf-8') } else { - console.log(chalk.yellow('skip package.json update on first release')) + console.log(chalk.red(figures.cross) + ' skip version bump on first release') } outputChangelog(argv, function () { @@ -75,15 +73,14 @@ conventionalRecommendedBump({ }) function outputChangelog (argv, cb) { - console.log(chalk.bold('2.') + ' update changelog (' + chalk.bold(argv.infile) + ')') - createIfMissing(argv) - - var readStream = fs.createReadStream(argv.infile) - .on('error', function (err) { - console.warn(chalk.yellow(err.message)) - }) - + 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 = fs.readFileSync(argv.infile, 'utf-8') + // find the position of the last release and remove header: + if (oldContent.indexOf('\n', 'utf-8') + + commit('feat: first commit') + shell.exec('git tag -a v1.0.0 -m "my awesome first release"') + commit('fix: patch release') + + shell.exec(cliPath).code.should.equal(0) + var content = fs.readFileSync('CHANGELOG.md', 'utf-8') + content.should.match(/1\.0\.1/) + content.should.not.match(/legacy header format/) + }) + }) +})