Socket
Socket
Sign inDemoInstall

changelog.md

Package Overview
Dependencies
238
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

lib/semantic-type.js

20

CHANGELOG.md

@@ -0,1 +1,21 @@

## [Version 0.3.0](https://github.com/egoist/changelog.md/releases/tag/v0.3.0) (2017-1-3)
### Major Changes
- recognize semantic commit type: [`95231d7`](https://github.com/egoist/changelog.md/commit/95231d7)
### Minor Changes
- ignore tweaks: [`e046cd5`](https://github.com/egoist/changelog.md/commit/e046cd5)
### Patches
- support more types: [`66f15fb`](https://github.com/egoist/changelog.md/commit/66f15fb)
- support commit type in commit subject: [`fd41c6b`](https://github.com/egoist/changelog.md/commit/fd41c6b)
- return type directly: [`4e3e309`](https://github.com/egoist/changelog.md/commit/4e3e309)
- tweaks: [`33b96b3`](https://github.com/egoist/changelog.md/commit/33b96b3)
- tweaks should be patch: [`69c0fc9`](https://github.com/egoist/changelog.md/commit/69c0fc9)
[...full changes](https://github.com/egoist/changelog.md/compare/v0.2.0...v0.3.0)
## [Version 0.2.0](https://github.com/egoist/changelog.md/releases/tag/v0.2.0) (2017-1-3)

@@ -2,0 +22,0 @@

66

lib/index.js

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

const addCommit = require('./add-commit')
const semanticType = require('./semantic-type')

@@ -21,2 +22,6 @@ module.exports = co.wrap(function * ({

} = {}) {
if (inputVersion && !semver.valid(inputVersion)) {
throw new AppError(`${inputVersion} is not a valid version`)
}
// check if is a git repo

@@ -47,25 +52,18 @@ if (!fs.existsSync('.git')) {

commits = commits.filter(commit => {
if (commit.subject.substring(0, 3) === '-> ') {
if (semver.valid(commit.subject.substr(3))) {
return false
commits = commits.map(commit => {
const re = /^([^:]+):\s+/
const match = re.exec(commit.subject)
const isReleaseMessage = (commit.subject.substring(0, 3) === '-> ') && (semver.valid(commit.subject.substr(3)))
const isSimpleTweaks = /^tweaks?$/.test(commit.subject)
if (match && match[1]) {
const type = semanticType(match[1])
if (type) {
commit.subject = commit.subject.replace(re, '')
commit.type = type
}
} else if (isReleaseMessage) {
commit.type = 'ignore'
} else if (isSimpleTweaks) {
commit.type = 'patch'
}
if (
/^\[skip]/.test(commit.subject) ||
/^\[ignore]/.test(commit.subject) ||
/^\[skip\s[^\]]*]/.test(commit.subject) ||
/^\[ignore\s[^\]]*]/.test(commit.subject)
) {
return false
}
return true
}).map(commit => {
const re = /^\[([^\]]+)]\s+/
const match = re.exec(commit.subject)
const isValid = match && ['patch', 'minor', 'major'].indexOf(match[1]) > -1
if (isValid) {
commit.subject = commit.subject.replace(re, '')
commit.type = match[1]
}
return commit

@@ -98,11 +96,23 @@ }).reverse()

let incType
if (groupedCommits.major) {
incType = 'major'
} else if (groupedCommits.minor) {
incType = 'minor'
let newVersion
if (inputVersion) {
newVersion = inputVersion
} else {
incType = 'patch'
let incType
// https://github.com/egoist/changelog.md/issues/8
const unstable = semver.lt(lastVersion, '0.999999999999999.0')
if (groupedCommits.major) {
incType = unstable ? 'minor' : 'major'
} else if (groupedCommits.minor) {
incType = unstable ? 'patch' : 'minor'
} else {
incType = 'patch'
}
newVersion = semver.inc(lastVersion, incType)
}
const newVersion = inputVersion || semver.inc(lastVersion, incType)
if (semver.lt(newVersion, lastVersion)) {
throw new AppError(`New version (${newVersion}) could not be lower than older version (${lastVersion})`)
}
const changeLog = yield render({

@@ -109,0 +119,0 @@ commits: groupedCommits,

{
"name": "changelog.md",
"version": "0.2.0",
"version": "0.3.0",
"description": "Manage CHANGELOG.md so easy it hurts.",

@@ -5,0 +5,0 @@ "repository": {

@@ -42,4 +42,25 @@ <h1 align="center">

Besides choosing `ignore` in prompts to exclude commits from changelog, the commit message that starts with `[skip]` `[ignore]` `[skip $foo]` `[ignore $foo]` will also be excluded.
Besides choosing `ignore` in prompts to exclude commits from changelog, the commit message that starts with `ignore: ` will also be excluded.
You can also use format like `type: message` to pre-define commit type, they will be converted to the commit type we use:
|semantic type|description|commit type|0.y.z|
|---|---|---|---|
|chore|changes to build process|ignore||
|docs|documentation only changes|ignore||
|feat|a new feature|minor|patch|
|fix|bug fix|patch||
|refactor|code refactor|patch||
|style|code style changes|ignore||
|test|add missing tests|ignore||
|breaking|introduce breaking changes|major|minor|
|perf|performance improvements|patch||
|tweaks|don't know how to describe|patch||
**Note**: in 0.y.z versions, major changes will affect `y`, other changes and patches will affect `z`. So in such situation you can never reach `1.0.0` do you? Then just explicitly specific the version for your next release, like: `changelog 1.0.0`
For `tweaks: subject`, a message with only `tweaks` or `tweak` will also be a patch.
You don't have to use these types in your commit message since you can set them one by one when actually running `changelog` (only for CHANGELOG.md, will not update the commit itself).
### Work with npm publish

@@ -49,3 +70,3 @@

# made some changes to your code...
$ git commit -am "change the world"
$ git commit -am "feat: change the world"
$ npm test

@@ -57,2 +78,8 @@ $ changelog

## Projects using this
- [SAO](https://github.com/egoist/sao): ⚔️ Futuristic scaffolding tool.
- [docute](https://github.com/egoist/docute): 📜 Effortlessly documentation done right.
- welcome to add your project here...
## Contributing

@@ -59,0 +86,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