standard-version
Advanced tools
Comparing version 5.0.0-candidate.0 to 5.0.0
@@ -5,2 +5,32 @@ # Change Log | ||
# [5.0.0](https://github.com/conventional-changelog/standard-version/compare/v4.4.0...v5.0.0) (2019-02-14) | ||
### Bug Fixes | ||
* bin now enforces Node.js > 4 ([#274](https://github.com/conventional-changelog/standard-version/issues/274)) ([e1b5780](https://github.com/conventional-changelog/standard-version/commit/e1b5780)) | ||
* no --tag prerelease for private module ([#296](https://github.com/conventional-changelog/standard-version/issues/296)) ([27e2ab4](https://github.com/conventional-changelog/standard-version/commit/27e2ab4)), closes [#294](https://github.com/conventional-changelog/standard-version/issues/294) | ||
* show correct pre-release tag in help output ([#259](https://github.com/conventional-changelog/standard-version/issues/259)) ([d90154a](https://github.com/conventional-changelog/standard-version/commit/d90154a)) | ||
### chore | ||
* update testing matrix ([1d46627](https://github.com/conventional-changelog/standard-version/commit/1d46627)) | ||
### Features | ||
* adds support for bumping for composer versions ([#262](https://github.com/conventional-changelog/standard-version/issues/262)) ([fee872f](https://github.com/conventional-changelog/standard-version/commit/fee872f)) | ||
* cli application accept path/preset option ([#279](https://github.com/conventional-changelog/standard-version/issues/279)) ([69c62cf](https://github.com/conventional-changelog/standard-version/commit/69c62cf)) | ||
* fallback to tags if no meta-information file found ([#275](https://github.com/conventional-changelog/standard-version/issues/275)) ([844cde6](https://github.com/conventional-changelog/standard-version/commit/844cde6)) | ||
* preserve formatting when writing to package.json ([#282](https://github.com/conventional-changelog/standard-version/issues/282)) ([96216da](https://github.com/conventional-changelog/standard-version/commit/96216da)) | ||
### BREAKING CHANGES | ||
* if no package.json, bower.json, etc., is found, we now fallback to git tags | ||
* removed Node 4/5 from testing matrix | ||
<a name="4.4.0"></a> | ||
@@ -7,0 +37,0 @@ # [4.4.0](https://github.com/conventional-changelog/standard-version/compare/v4.3.0...v4.4.0) (2018-05-21) |
@@ -80,2 +80,11 @@ var defaults = require('./defaults') | ||
}) | ||
.option('path', { | ||
type: 'string', | ||
describe: 'Only populate commits made under this path' | ||
}) | ||
.option('preset', { | ||
type: 'string', | ||
default: defaults.preset, | ||
describe: 'Commit message guideline preset (default: angular)' | ||
}) | ||
.check((argv) => { | ||
@@ -82,0 +91,0 @@ if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) { |
@@ -13,3 +13,4 @@ { | ||
"dryRun": false, | ||
"gitTagFallback": true | ||
"gitTagFallback": true, | ||
"preset": "angular" | ||
} |
13
index.js
@@ -0,8 +1,8 @@ | ||
const bump = require('./lib/lifecycles/bump') | ||
const changelog = require('./lib/lifecycles/changelog') | ||
const commit = require('./lib/lifecycles/commit') | ||
const fs = require('fs') | ||
const latestSemverTag = require('./lib/latest-semver-tag') | ||
const path = require('path') | ||
const printError = require('./lib/print-error') | ||
const bump = require('./lib/lifecycles/bump') | ||
const changelog = require('./lib/lifecycles/changelog') | ||
const commit = require('./lib/lifecycles/commit') | ||
const tag = require('./lib/lifecycles/tag') | ||
@@ -16,3 +16,4 @@ | ||
try { | ||
pkg = require(pkgPath) | ||
var data = fs.readFileSync(pkgPath, 'utf8') | ||
pkg = JSON.parse(data) | ||
} catch (err) {} | ||
@@ -29,3 +30,3 @@ }) | ||
} else if (!pkg) { | ||
return Promise.reject(new Error('no package file found')) | ||
throw new Error('no package file found') | ||
} else { | ||
@@ -32,0 +33,0 @@ return pkg.version |
@@ -6,2 +6,4 @@ 'use strict' | ||
const conventionalRecommendedBump = require('conventional-recommended-bump') | ||
const detectIndent = require('detect-indent') | ||
const detectNewline = require('detect-newline') | ||
const figures = require('figures') | ||
@@ -13,2 +15,3 @@ const fs = require('fs') | ||
const semver = require('semver') | ||
const stringifyPackage = require('stringify-package') | ||
const writeFile = require('../write-file') | ||
@@ -29,3 +32,3 @@ | ||
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim() | ||
return bumpVersion(args.releaseAs) | ||
return bumpVersion(args.releaseAs, args) | ||
}) | ||
@@ -131,3 +134,3 @@ .then((release) => { | ||
function bumpVersion (releaseAs, callback) { | ||
function bumpVersion (releaseAs, args) { | ||
return new Promise((resolve, reject) => { | ||
@@ -140,3 +143,5 @@ if (releaseAs) { | ||
conventionalRecommendedBump({ | ||
preset: 'angular' | ||
debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'), | ||
preset: args.preset || 'angular', | ||
path: args.path | ||
}, function (err, release) { | ||
@@ -168,7 +173,10 @@ if (err) return reject(err) | ||
if (stat.isFile()) { | ||
var config = require(configPath) | ||
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) | ||
checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion]) | ||
config.version = newVersion | ||
writeFile(args, configPath, JSON.stringify(config, null, 2) + '\n') | ||
writeFile(args, configPath, stringifyPackage(config, indent, newline)) | ||
// flag any config files that we modify the version # for | ||
@@ -175,0 +183,0 @@ // as having been updated. |
@@ -33,5 +33,6 @@ const accessSync = require('fs-access').sync | ||
var changelogStream = conventionalChangelog({ | ||
preset: 'angular', | ||
debug: args.verbose && console.info.bind(console, 'conventional-changelog'), | ||
preset: args.preset || 'angular', | ||
tagPrefix: args.tagPrefix | ||
}, context, { merges: null }) | ||
}, context, { merges: null, path: args.path }) | ||
.on('error', function (err) { | ||
@@ -38,0 +39,0 @@ return reject(err) |
@@ -30,4 +30,12 @@ const chalk = require('chalk') | ||
var message = 'git push --follow-tags origin master' | ||
if (pkgPrivate !== true) message += ' && npm publish' | ||
if (args.prerelease !== undefined) message += ' --tag prerelease' | ||
if (pkgPrivate !== true) { | ||
message += ' && npm publish' | ||
if (args.prerelease !== undefined) { | ||
if (args.prerelease === '') { | ||
message += ' --tag prerelease' | ||
} else { | ||
message += ' --tag ' + args.prerelease | ||
} | ||
} | ||
} | ||
@@ -34,0 +42,0 @@ checkpoint(args, 'Run `%s` to publish', [message], chalk.blue(figures.info)) |
{ | ||
"name": "standard-version", | ||
"version": "5.0.0-candidate.0", | ||
"version": "5.0.0", | ||
"description": "replacement for `npm version` with automatic CHANGELOG generation", | ||
@@ -42,8 +42,12 @@ "bin": "bin/cli.js", | ||
"chalk": "^2.4.1", | ||
"conventional-changelog": "^3.0.5", | ||
"conventional-changelog": "^3.0.6", | ||
"conventional-recommended-bump": "^4.0.4", | ||
"detect-indent": "^5.0.0", | ||
"detect-newline": "^2.1.0", | ||
"dotgitignore": "^1.0.3", | ||
"figures": "^2.0.0", | ||
"fs-access": "^1.0.0", | ||
"semver": "^5.1.0", | ||
"git-semver-tags": "^2.0.2", | ||
"semver": "^5.2.0", | ||
"stringify-package": "^1.0.0", | ||
"yargs": "^12.0.2" | ||
@@ -57,3 +61,3 @@ }, | ||
"mockery": "^2.0.0", | ||
"nyc": "^13.1.0", | ||
"nyc": "^13.3.0", | ||
"shelljs": "^0.7.8", | ||
@@ -60,0 +64,0 @@ "standard": "^12.0.1" |
@@ -22,4 +22,4 @@ # Standard Version | ||
2. run `standard-version` | ||
3. `git push --follow-tags origin master && npm publish | ||
_(or, `docker push`, `gem push`, etc.)_ | ||
3. `git push --follow-tags origin master && npm publish` | ||
_(or, `docker push`, `gem push`, etc.)_ | ||
@@ -234,2 +234,12 @@ `standard-version` does the following: | ||
### Prefix Tags | ||
If you would like to prefix your tags with something, you can do so with the `-t` flag. | ||
```sh | ||
standard-version -t @scope/package\@ | ||
``` | ||
This will prefix your tags to look something like `@scope/package@2.0.0` | ||
### CLI Help | ||
@@ -250,5 +260,6 @@ | ||
```js | ||
var standardVersion = require('standard-version') | ||
const standardVersion = require('standard-version') | ||
// Options are the same as command line, except camelCase | ||
// standardVersion returns a Promise | ||
standardVersion({ | ||
@@ -258,7 +269,6 @@ noVerify: true, | ||
silent: true | ||
}, function (err) { | ||
if (err) { | ||
}).then(() => { | ||
// standard-version is done | ||
}).catch(err => { | ||
console.error(`standard-version failed with message: ${err.message}`) | ||
} | ||
// standard-version is done | ||
}) | ||
@@ -315,3 +325,3 @@ ``` | ||
`standard-version` is different because it handles the versioning, changelog generation, and git tagging for you **without** automatic pushing (to GitHub) or publishing (to an npm registry). Use of `standard-version` only affects your local git repo - it doesn't affect remote resources at all. After you run `standard-version`, you still have to ability to review things and correct mistakes if you want to. | ||
`standard-version` is different because it handles the versioning, changelog generation, and git tagging for you **without** automatic pushing (to GitHub) or publishing (to an npm registry). Use of `standard-version` only affects your local git repo - it doesn't affect remote resources at all. After you run `standard-version`, you still have the ability to review things and correct mistakes if you want to. | ||
@@ -318,0 +328,0 @@ They are both based on the same foundation of structured commit messages (using [Angular format](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md)), but `standard-version` is a good choice for folks who are not yet comfortable letting publishes go out automatically. In this way, you can view `standard-version` as an incremental step to adopting `semantic-release`. |
64
test.js
@@ -98,12 +98,2 @@ /* global describe it beforeEach afterEach */ | ||
commit('root-commit') | ||
;['package.json', | ||
'manifest.json', | ||
'bower.json' | ||
].forEach(metadata => { | ||
try { | ||
delete require.cache[require.resolve(path.join(process.cwd(), metadata))] | ||
} catch (err) { | ||
// we haven't loaded the metadata file yet. | ||
} | ||
}) | ||
writePackageJson('1.0.0') | ||
@@ -436,2 +426,18 @@ } | ||
}) | ||
it('advises use of --tag alpha for publishing to npm when tagging alpha', function () { | ||
writePackageJson('1.0.0') | ||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
commit('feat: first commit') | ||
execCli('--prerelease alpha').stdout.should.include('--tag alpha') | ||
}) | ||
it('does not advise use of --tag prerelease for private modules', function () { | ||
writePackageJson('1.0.0', { private: true }) | ||
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8') | ||
commit('feat: first commit') | ||
execCli('--prerelease').stdout.should.not.include('--tag prerelease') | ||
}) | ||
}) | ||
@@ -604,2 +610,40 @@ | ||
it('preserves indentation of tabs in package.json', function () { | ||
var indentation = '\t' | ||
var 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') | ||
pkgJson.should.equal(['{', indentation + '"version": "1.0.1"', '}', ''].join('\n')) | ||
}) | ||
it('preserves indentation of spaces in package.json', function () { | ||
var indentation = ' ' | ||
var 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') | ||
pkgJson.should.equal(['{', indentation + '"version": "1.0.1"', '}', ''].join('\n')) | ||
}) | ||
it('preserves line feed in package.json', function () { | ||
var 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') | ||
pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n')) | ||
}) | ||
it('preserves carriage return + line feed in package.json', function () { | ||
var 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') | ||
pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\r\n')) | ||
}) | ||
it('does not run git hooks if the --no-verify flag is passed', function () { | ||
@@ -606,0 +650,0 @@ writeGitPreCommitHook() |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
81545
1401
0
340
6
12
+ Addeddetect-indent@^5.0.0
+ Addeddetect-newline@^2.1.0
+ Addedgit-semver-tags@^2.0.2
+ Addedstringify-package@^1.0.0
+ Addeddetect-indent@5.0.0(transitive)
+ Addeddetect-newline@2.1.0(transitive)
+ Addedstringify-package@1.0.1(transitive)
Updatedsemver@^5.2.0