Socket
Socket
Sign inDemoInstall

ezchangelog

Package Overview
Dependencies
19
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.3 to 5.0.0

bin/buildConf.js

13

index.js

@@ -0,3 +1,12 @@

var combine = require('stream-combiner2')
var parse = require('./lib/parse')
var format = require('./lib/format')
exports.parse = require('./lib/parse')
exports.format = require('./lib/format')
exports = module.exports = function (opts) {
return combine.obj(parse(opts), format(opts))
}
exports.format = format
exports.parse = parse
exports.formatter = require('./lib/formatter')
exports.parser = require('./lib/parser')

42

lib/format.js

@@ -5,15 +5,18 @@ var thr = require('through2')

var HEADER_PREFIX = '<!-- LATEST '
var HEADER_SUFFIX = ' -->\n\n'
var HEADER_REGEX = /^<!-- (\w{7}) (\d+) -->\n\n/
var HEADER_PREFIX = '<!-- '
var HASH_OFFSET = HEADER_PREFIX.length
module.exports = function (opts) {
var history = opts && opts.history
opts = opts || {}
var history = opts.history
var header
var hasNewHeader = false
var lastCommit = getLastCommit(history)
var hasHeader = history && history.substring(0, HASH_OFFSET) === HEADER_PREFIX
var hasNewHeader
var latest = getLastCommit(history)
var markdownify = opts.formatter || formatter
function filter(ci, _, next) {
if (lastCommit && lastCommit === ci.commit.short) {
return this.push(null)
if (latest && latest.date >= ci.committer.date) {
return next()
}

@@ -25,3 +28,3 @@ next(null, ci)

if (!header) {
header = getHeader(ci.commit.short)
header = buildHeader(ci)
}

@@ -45,3 +48,3 @@ next(null, ci)

if (history) {
if (hasNewHeader && hasHeader(history)) {
if (hasNewHeader && hasHeader) {
this.push(history.substring(header.length))

@@ -58,3 +61,3 @@ } else {

'header', [ thr.obj(collectHeader) ],
'format', [ formatter() ],
'format', [ markdownify() ],
'pushHeader', [ thr(pushHeader) ],

@@ -65,15 +68,16 @@ 'wrap', [ thr(prepend, append) ],

function getHeader(hash) {
return HEADER_PREFIX + hash + HEADER_SUFFIX
function buildHeader(ci) {
return '<!-- ' + ci.commit.short + ' ' + +ci.committer.date + ' -->\n\n'
}
function hasHeader(s) {
return s && s.substring(0, HASH_OFFSET) === HEADER_PREFIX
}
function getLastCommit(history) {
return history &&
hasHeader(history) &&
history.substring(HASH_OFFSET, HASH_OFFSET + 7)
if (!history) return {}
var matches = history.match(HEADER_REGEX)
if (!matches) return {}
return {
hash: matches[1],
date: new Date(+matches[2]),
raw: matches[0],
}
}

@@ -10,3 +10,4 @@ var thr = require('through2')

}
next(null, '\n\n')
this.push('\n\n')
next()
})

@@ -16,10 +17,15 @@ }

function formatTag(ci) {
return '## ' + linkify(ci.tag, ci.url) +
' (' + formatDate(ci.committer.date) + ')'
var prelude = ci.tag
if (ci.url) {
prelude = linkify(prelude, ci.url)
}
return '## ' + prelude + ' (' + formatDate(ci.committer.date) + ')'
}
function formatMsg(ci) {
return '* [ ' + formatDate(ci.committer.date) +
' ' + linkify(ci.commit.short, ci.url) + ' ] ' +
ci.subject.trim() + (ci.body ? '\n' + ci.body : '')
var prelude = ''
if (ci.url) {
prelude = '[ ' + linkify(ci.commit.short, ci.url) + ' ] '
}
return '* ' + prelude + [ci.subject, ci.body].filter(Boolean).join('\n\n')
}

@@ -32,4 +38,4 @@

function linkify(text, href) {
return href && '[' + text + '](' + href + ')' || text
return '[' + text + '](' + href + ')'
}
var split = require('split2')
var combine = require('stream-combiner2')
var thr = require('through2')
var splicer = require('labeled-stream-splicer')
var parser = require('./parser')
module.exports = function (opts) {
opts = opts || {}
var parser = typeof opts.parser === 'function'
? opts.parser
: require('./parser')
return combine.obj(split(), group(), parser(opts))
return splicer.obj([
'split', [ split() ],
'commit', [ parser.commit() ],
'tag', [ parser.tag() ],
'url', [ parser.url(opts) ],
])
}
function group() {
var ci
var COMMIT_LINE = /^commit \w{40}$/
return thr.obj(function (buf, _, next) {
var line = buf.toString('utf8')
if (COMMIT_LINE.test(line)) {
if (ci) {
this.push(ci)
}
ci = { raws: [ line ] }
} else if (ci) {
ci.raws.push(line)
}
next()
}, function (done) {
if (ci) {
this.push(ci)
}
done()
})
}
{
"name": "ezchangelog",
"version": "4.0.3",
"version": "5.0.0",
"description": "changelog",
"bin": {
"ezchangelog": "./bin/cmd",
"ezchangelogStream": "./bin/stream.js"
"changelog": "./bin/cmd.js"
},
"scripts": {
"test": "gulp"
"test": "npm run lint && tap --cov test/*.js",
"lint": "eslint *.js 'lib/**/*.js' test/*.js bin/*.js",
"coveralls": "COVERALLS_REPO_TOKEN=REPO_TOKEN npm test"
},

@@ -28,14 +29,18 @@ "repository": {

"dependencies": {
"commander": "^2.9.0",
"duplexer2": "^0.1.4",
"labeled-stream-splicer": "^2.0.0",
"minimist": "^1.2.0",
"node-promisify": "^1.0.0",
"split2": "^1.0.0",
"stream-combiner2": "^1.1.1",
"through2": "^2.0.0"
"through2": "^2.0.0",
"util-mix": "^3.0.2"
},
"devDependencies": {
"callback-sequence": "^1.2.1",
"del": "^2.0.2",
"gulp": "^3.9.0",
"gulp-eslint": "^1.0.0"
}
"concat-stream": "^1.5.1",
"del": "^2.1.0",
"eslint": "^1.10.1",
"tap": "^2.3.1"
},
"main": "index.js"
}
# ezchangelog
Log changes easily.
Make it easy to update changelog with commit messages.
[![version](https://img.shields.io/npm/v/ezchangelog.svg)](https://www.npmjs.org/package/ezchangelog)
[![status](https://travis-ci.org/zoubin/ezchangelog.svg?branch=master)](https://travis-ci.org/zoubin/ezchangelog)
[![coverage](https://img.shields.io/coveralls/zoubin/ezchangelog.svg)](https://coveralls.io/github/zoubin/ezchangelog)
[![dependencies](https://david-dm.org/zoubin/ezchangelog.svg)](https://david-dm.org/zoubin/ezchangelog)
[![devDependencies](https://david-dm.org/zoubin/ezchangelog/dev-status.svg)](https://david-dm.org/zoubin/ezchangelog#info=devDependencies)
## Usage

@@ -12,3 +18,3 @@

# create a new changelog.md file
ezchangelog
changelog

@@ -18,6 +24,6 @@ # do some commits

# prepend new changes
ezchangelog
changelog
# Print the new changelog contents
git log | ezchangelogStream -p
git log --before Nov.10 | changelog

@@ -30,30 +36,24 @@ ```

## ezchangelog
## Command line
Use it the way you do `git log`,
and your changelog file will be updated.
`changelog -h` to see options.
By default, `--no-merges` is enabled.
There are two ways in the command line.
## ezchangelogStream
Specify more custom options.
The following command will call `git log --no-merges` to generate changes info:
```bash
git log | ezchangelog-stream
changelog [options]
```
Pass any valid arguments to `git log`.
You can also pipe the changes into it:
Options for `ezchangelog-stream`:
```bash
git log --before Nov.10 | changelog [options]
`-p, --print`: print the changelog contents rather than write to disk.
```
`-o, --out`: specify the changelog file path.
### package.json
`--inc, --incremental`: used together with `--out` to update changelog incrementally.
## package.json
```json

@@ -60,0 +60,0 @@ {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc