Giter VIP home page Giter VIP logo

conventional-changelog-core's Introduction

NPM version Build Status: Linux Build Status: Windows Dependency Status Coverage Status

conventional-changelog core

You are probably looking for the cli module. Or use one of the plugins if you are already using the tool: grunt/gulp/atom.

Usage

$ npm install --save conventional-changelog-core
var conventionalChangelogCore = require('conventional-changelog-core');

conventionalChangelogCore()
  .pipe(process.stdout); // or any writable stream

API

conventionalChangelogCore([options, [context, [gitRawCommitsOpts, [parserOpts, [writerOpts]]]]])

Returns a readable stream.

Note: options.transform, options.pkg.transform and writerOpts.transform are different. If you have a better naming suggestion, please send a PR.

options

config

Type: promise, function or object

This should serve as default values for other arguments of conventionalChangelogCore so you don't need to rewrite the same or similar config across your projects. Any value in this could be overwritten. If this is a promise (recommended if async), it should resolve with the config. If this is a function, it expects a node style callback with the config object. If this is an object, it is the config object. The config object should include context, gitRawCommitsOpts, parserOpts and writerOpts.

pkg

Type: object

path

Type: string Default: closest package.json.

The location of your "package.json".

transform

Type: function Default: pass through.

A function that takes package.json data as the argument and returns the modified data. Note this is performed before normalizing package.json data. Useful when you need to add a leading 'v' to your version or modify your repository url, etc.

append

Type: boolean Default: false

Should the log be appended to existing data.

releaseCount

Type: number Default: 1

How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to 0 to regenerate all.

debug

Type: function Default: function() {}

A debug function. EG: console.debug.bind(console)

warn

Type: function Default: options.debug

A warn function. EG: grunt.verbose.writeln

transform

Type: function Default: get the version (without leading 'v') from tag and format date.

function(commit, cb)

A transform function that applies after the parser and before the writer.

This is the place to modify the parsed commits.

####### commit

The commit from conventional-commits-parser.

####### cb

Callback when you are done.

####### this

this arg of through2.

outputUnreleased

Type: boolean Default: true if a different version than last release is given. Otherwise false.

If this value is true and context.version equals last release then context.version will be changed to 'Unreleased'.

context

See the conventional-changelog-writer docs. There are some defaults or changes:

host

Default: normalized host found in package.json.

version

Default: version found in package.json.

owner

Default: extracted from normalized package.json repository.url field.

repository

Default: extracted from normalized package.json repository.url field.

repoUrl

Default: The whole normalized repository url in package.json.

gitSemverTags

Type: array

All git semver tags found in the repository. You can't overwrite this value.

previousTag

Type: string Default: previous semver tag or the first commit hash if no previous tag.

currentTag

Type: string Default: current semver tag or 'v' + version if no current tag.

packageData

Type: object

Your package.json data. You can't overwrite this value.

linkCompare

Type: boolean Default: true if previousTag and currentTag are truthy.

Should link to the page that compares current tag with previous tag?

gitRawCommitsOpts

See the git-raw-commits docs. There are some defaults:

format

Default: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci'

from

Default: based on options.releaseCount.

reverse

Default: true if options.append is truthy.

debug

Type: function Default: options.debug

parserOpts

See the conventional-commits-parser docs.

warn

Default: options.warn

writerOpts

See the conventional-changelog-writer docs. There are some defaults:

finalizeContext

Finalize context is used for generating above context.

NOTE: If you overwrite this value the above context defaults will be gone.

debug

Type: function Default: options.debug

reverse

Default: options.append

doFlush

Default: options.outputUnreleased

Notes for parent modules

This module has options append and releaseCount. However, it doesn't read your previous changelog. Reasons being:

  1. The old logs is just to be appended or prepended to the newly generated logs, which is a very simple thing that could be done in the parent module.
  2. We want it to be very flexible for the parent module. You could create a readable stream from the file or you could just read the file.
  3. We want the duty of this module to be very minimum.

So, when you build a parent module, you need to read the old logs and append or prepend to them based on options.append. However, if options.releaseCount is 0 you need to ignore any previous logs. Please see conventional-github-releaser as an example.

Arguments passed to conventionalChangelogCore will be mutated.

License

MIT

conventional-changelog-core's People

Contributors

hutson avatar marionebl avatar stevemao avatar tapppi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

conventional-changelog-core's Issues

writer not grouping by type when used with `transform`

Hi, great library guys.

I started using this library for my project. While all the commits appear as output, they are not being grouped by type, which is meant to be the default for the writer?

I am running this as: node changelog.js

var conventionalChangelogCore = require('conventional-changelog-core');

conventionalChangelogCore({
    transform : function(commit, cb) {

      if(/^FIX/.test(commit.header)) {
        commit.type = 'bug';
      }

      if(/^NEW|FEATURE/.test(commit.header)) {
        commit.type = 'feat';
      }

      if(/^bump version --skip-ci/.test(commit.header)) {
        commit = null;
      }

      cb(null, commit);
    },
  })
  .pipe(process.stdout); // or any writable stream

Improve tests

  1. ATM one have to depend on another. This means we can't do mocha --grep and only test certain tests so its hard to work with break points. Maybe we could detect if the git history is good before running the it block.
  2. The construction of git history is partially in it blocks. This is fine but the performance tests with mocha would count those. Although we don't care about the milliseconds, this could be improved.

Low priority ๐Ÿ˜„

flow issue

I have the following error when running [email protected]:

$ flow
node_modules/conventional-changelog-core/test/fixtures/_malformation.json:1
1:
^ Unexpected end of input

I fixed it by adding the following lines in my .flowconfig file:

[ignore]
.*/node_modules/conventional-changelog-core/.*\.json$

Would it makes sense to remove the tests files from the package?

No more commit hash links in changelog since version 1.3.3

Since version 1.3.3 is released our changelog task does not generate any commit links anymore.

My guess is that the change in lib/merge-config.js in commit eaa3b6f breaks it when calling the changelog task without a context object (and within a git repo).

repo.browse() will never be called because context.host is filled in through calling getPkgRepo(pkg) which calls git-remote-origin-url

Stray "S" included in breaking changes if commit message is spelled "BREAKING CHANGES"

See this commit message: angular/angular@098b461

Notice it says "BREAKING CHANGES:" with an S at the end.

If I generate a changelog with preset: angular, releaseCount: 1 including that commit, the breaking change ends up having an "S" after the scope, like so:

* core: S:

Previously multiple template bindings on one element
(ex. `<div *ngIf='..' *ngFor='...'>`) were allowed but most of the time
were leading to undesired result. It is possible that a small number
of applications will see template parse errors that shuld be fixed by
nesting elements or using `<template>` tags explicitly.

A lot of commit messages add the S at the end of breaking changes, so I think it would be worthwhile to add a special case for that. Happy to open a PR if this sounds reasonable :).

Dependency versions:

  • gulp-conventional-changelog 1.1.0
  • conventional-changelog 1.1.0
  • conventional-changelog-core 1.5.0

issuePrefixes Parser Option No Longer Respected

I use a package similar to conventional-changelog-angular with a single major difference.

Inside the parserOpts object (https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/index.js#L18) I set issuePrefixes to ['#', '@']. However, only the # prefix is respected by conventional-commits-parser.

It seems this line is replacing my issuePrefixes value with the default for my SCM system (as retrieved from here).

If I comment out that line, my prefix is respected, and my changelog is generated correctly.

Tag in GitHub compare link incorrectly prefixed with a 'v'

I recently updated gulp-conventional-changelog from 0.5.1 to 1.1.0. I use it with the angular preset.

When I update my repository from 1.0.0-alpha.7 to 1.0.0-alpha.8 the 'GitHub compare' link on the title will unnecessarily prefix the most recent tag with a v:
SteveVanOpstal/LegendBuilder@1.0.0-alpha.7...v1.0.0-alpha.8

For the link to work, it should be:
SteveVanOpstal/LegendBuilder@1.0.0-alpha.7...1.0.0-alpha.8

It seems like you assume tags are always prefixed with a v in merge-config.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.