@condenast/commit-analyzer

1.0.0 • Public • Published

commit-analyzer

semantic-release plugin to analyze commits with conventional-changelog

Travis Codecov Greenkeeper badge

npm latest version npm next version

Step Description
analyzeCommits Determine the type of release by analyzing commits with conventional-changelog.

Install

$ npm install @semantic-release/commit-analyzer -D

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular",
        "releaseRules": [
          { "type": "docs", "scope": "README", "release": "patch" },
          { "type": "refactor", "release": "patch" },
          { "type": "style", "release": "patch" }
        ],
        "parserOpts": {
          "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
        }
      }
    ],
    "@semantic-release/release-notes-generator"
  ]
}

With this example:

  • the commits that contains BREAKING CHANGE or BREAKING CHANGES in their body will be considered breaking changes.
  • the commits with a 'docs' type, a 'README' scope will be associated with a patch release
  • the commits with a 'refactor' type will be associated with a patch release
  • the commits with a 'style' type will be associated with a patch release

Note: Your commits must be formatted exactly as specified by the chosen convention. For example the Angular Commit Message Conventions require the BREAKING CHANGE keyword to be followed by a colon (:) and to be in the footer of the commit message.

Configuration

Options

Option Description Default
preset conventional-changelog preset (possible values: angular, atom, codemirror, ember, eslint, express, jquery, jshint). angular
config npm package name of a custom conventional-changelog preset. -
parserOpts Additional conventional-commits-parser options that will extends the ones loaded by preset or config. This is convenient to use a conventional-changelog preset with some customizations without having to create a new module. -
releaseRules An external module, a path to a module or an Array of rules. See releaseRules. See releaseRules
useDefaultReleaseRules Whether to use default release rules for non-matching releaseRules. See releaseRules. See releaseRules

Notes: in order to use a preset it must be installed (for example to use the eslint preset you must install it with npm install conventional-changelog-eslint -D)

Note: config will be overwritten by the values of preset. You should use either preset or config, but not both.

Note: Individual properties of parserOpts will override ones loaded with an explicitly set preset or config. If preset or config are not set, only the properties set in parserOpts will be used.

releaseRules

Release rules are used when deciding if the commits since the last release warrant a new release. If you define custom release rules the default rules will be used if nothing matched. Those rules will be matched against the commit objects resulting of conventional-commits-parser parsing.

Rules definition

This is an Array of rule objects. A rule object has a release property and 1 or more criteria.

{
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular",
        "releaseRules": [
          { "type": "docs", "scope": "README", "release": "patch" },
          { "type": "refactor", "scope": "/core-.*/", "release": "minor" },
          { "type": "refactor", "release": "patch" }
        ]
      }
    ],
    "@semantic-release/release-notes-generator"
  ]
}
Rules matching

Each commit will be compared with each rule and when it matches, the commit will be associated with the release type in the rule's release property. If a commit match multiple rules, the highest release type (major > minor > patch) is associated with the commit.

See release types for the release types hierarchy.

With the previous example:

  • Commits with type 'docs' and scope 'README' will be associated with a patch release.
  • Commits with type 'refactor' and scope starting with 'core-' (i.e. 'core-ui', 'core-rules', ...) will be associated with a minor release.
  • Other commits with type 'refactor' (without scope or with a scope not matching the regexp /core-.*/) will be associated with a patch release.
Default rules matching

If a commit doesn't match any rule in releaseRules it will be evaluated against the default release rules. Set useDefaultReleaseRules to false to ignore this behavior.

With the previous example:

  • Commits with a breaking change will be associated with a major release.
  • Commits with type 'feat' will be associated with a minor release.
  • Commits with type 'fix' will be associated with a patch release.
  • Commits with type 'perf' will be associated with a patch release.
No rules matching

If a commit doesn't match any rules in releaseRules or in default release rules then no release type will be associated with the commit.

With the previous example:

  • Commits with type 'style' will not be associated with a release type.
  • Commits with type 'test' will not be associated with a release type.
  • Commits with type 'chore' will not be associated with a release type.
Multiple commits

If there is multiple commits that match one or more rules, the one with the highest release type will determine the global release type.

Considering the following commits:

  • docs(README): Add more details to the API docs
  • feat(API): Add a new method to the public API

With the previous example the release type determined by the plugin will be minor.

Specific commit properties

The properties to set in the rules will depends on the commit style chosen. For example conventional-changelog-angular use the commit properties type, scope and subject but conventional-changelog-eslint uses tag and message.

For example with eslint preset:

{
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "eslint",
        "releaseRules": [
          { "tag": "Docs", "message": "/README/", "release": "patch" },
          { "tag": "New", "release": "patch" }
        ]
      }
    ],
    "@semantic-release/release-notes-generator"
  ]
}

With this configuration:

  • Commits with tag 'Docs', that contains 'README' in their header message will be associated with a patch release.
  • Commits with tag 'New' will be associated with a patch release.
  • Commits with tag 'Breaking' will be associated with a major release (per default release rules).
  • Commits with tag 'Fix' will be associated with a patch release (per default release rules).
  • Commits with tag 'Update' will be associated with a minor release (per default release rules).
  • Commits with tag 'New' will be associated with a minor release (per default release rules).
  • All other commits will not be associated with a release type.
External package / file

releaseRules can also reference a module, either by it's npm name or path:

{
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular",
        "releaseRules": "./config/release-rules.js"
      }
    ],
    "@semantic-release/release-notes-generator"
  ]
}
// File: config/release-rules.js
module.exports = [
  { type: "docs", scope: "README", release: "patch" },
  { type: "refactor", scope: /core-.*/, release: "minor" },
  { type: "refactor", release: "patch" },
];

Package Sidebar

Install

npm i @condenast/commit-analyzer

Weekly Downloads

330

Version

1.0.0

License

MIT

Unpacked Size

32.1 kB

Total Files

10

Last publish

Collaborators

  • joshcondenast
  • vikas-sc
  • vishu_1007
  • vmishra2305
  • skumar7
  • cyrilpanicker-condenast
  • sreenu-condenast
  • ronjr_owlbear
  • boygao1992
  • saikat_conde
  • ashanatesh
  • priyadarshinitao
  • naresh.kandhan
  • deepakmohan
  • husnabushra
  • ramjeetm
  • imleodc
  • skumar3conde
  • mounika-boyapati
  • nagaraja_h
  • jasonmarlin
  • arunconde
  • roberlander
  • josemanuel.barea.ortiz
  • nprabhu-cn
  • sahildshah1
  • jmundycn
  • juliendevlin
  • sheetalparsa
  • unviradiya
  • ssingh417
  • dev-anand-94
  • vinitha_thiagarajan
  • prasil1107
  • swarupshankar
  • areadman
  • abhishek_pandey_cn
  • vchand-cn
  • harsh_condenast
  • swati_verso
  • samruddhidube24
  • gapurdev
  • akshayjain10
  • utkarsh24
  • suma_k
  • mohnish_vurity
  • piyush_das
  • kshitiz_choudhary
  • cnmanju
  • vvkudachi
  • vijeshrj
  • jkraus
  • vaseemakram
  • sharvanipatil
  • cn-rahul-tiwari
  • dhanashri027
  • mukarthik
  • blue-rigel
  • mguyromelle
  • bharathikarunanithi
  • cn_priyanka14
  • mehulpiruka
  • kishor-kumar07
  • ngsangeeta
  • prashant_singhparihar
  • snehak
  • shrutinivedita
  • sandhya_rani
  • cedric_mascarenhas
  • m-mallikarjuna
  • imran-conde
  • smantriconde
  • machelslackatcondenast
  • sachin-ns
  • jorge_guerra2
  • pratima_cn
  • harsha_mahadevaiah
  • richa_cn
  • karthik_cn
  • muthuprakashvelumani
  • imleo_conde
  • issanjana
  • a-rena
  • colin-alexa
  • bxh-io-cn
  • benknowlesnews
  • timklimowicz
  • ramkun
  • kamal_conde
  • aditijhacn
  • namansingh_bhandari
  • max-prin
  • cnarkhede
  • nrajeshnpm
  • vinothkumar_bala
  • aksingh5
  • shashank_jaiswal
  • saicharan7766
  • vineethd
  • hebsibal_selvaraj
  • akeshavamurthy
  • priyanka_jha
  • saniyashk
  • jbs-cn
  • gargi-c
  • hippolin
  • klnarayanan
  • cn_joy_sen
  • cn-andres
  • ganavi_j
  • sellapandi1998
  • jsharma-cn
  • spoorthi.chandrashekar
  • venkatesh547
  • dinakar25
  • hegdem
  • erikveland
  • asinghconde
  • joselee43
  • eunianina
  • gchaithra
  • patternwise
  • omar.wl
  • andrixb
  • raxs
  • vivekans
  • susel_retana
  • praveenppk
  • rafalpuche
  • conde_jode
  • subbiah_ramakrishna
  • fernandolara23
  • sarahshincn
  • jordi.escude
  • nnasirov
  • unnatik
  • tania.delatorre
  • vinayashreeram
  • mohitsharma-news
  • aaaanti
  • psundar
  • wljoel
  • arhovale
  • sgdurham
  • fsanchezvilela
  • alfonsocondenast
  • rashmicn
  • slarty667
  • christinahara
  • nanjacn
  • siddhu-23
  • atp-engineering
  • katiasfihi
  • luisenriquegutierrez
  • akhil_npm_condenast
  • danj-cn
  • sudeshna_cn
  • vikash_cn
  • lakshmi.priya
  • sumanth_cn
  • shahu_cn
  • utsav_cn
  • mmorris9
  • maila-labib
  • mala-shanbhag
  • anilc93
  • lavishgambhir
  • vmanzanilla
  • tdscondenast
  • nitish-tandia
  • murali-condenast
  • alejandroaltf4dev
  • omsun22
  • ksriniva2
  • aleccuster_cn
  • andregcab
  • bhoopalt
  • niclasbork
  • pramita21
  • tchathur
  • kangkanbora
  • suhas-cn
  • vinay-pr
  • rjcn
  • vikramchowdary_parimi
  • sugumarv
  • josephrussell-cn
  • seking31
  • eliza.nieves
  • anaedzm
  • naveen1601
  • kajal-sikka
  • cn-connorbrannigan
  • prajwal_keshav
  • arjunpa
  • sharique10
  • babincondenast
  • cn-oramirez
  • guru05111984
  • subinjoeconde
  • edistel
  • saahithisri
  • balar20
  • s_dwivedi
  • nhrqz
  • monicar
  • richsancho
  • tanya-sah
  • cn_jenkins
  • frandevinney
  • renovate
  • jyoti_3009
  • r0r71z
  • jaemega
  • aman-shinde-07
  • condenastadmin
  • angrymongoose
  • copilot-robot
  • cry4dawn_2000
  • fennen529
  • fmadrie
  • gkilian
  • gmedina
  • bigzed
  • raagul-conde
  • stan
  • stanley
  • andi.anderson522
  • tamal_banerjee
  • davidkofahl
  • biku
  • taniabhullar
  • dkorenblyum
  • tollmanz
  • amalamchtal
  • tdshap
  • nidhi-tcs
  • rishutcs
  • sayeedcn
  • pitchfork-dev
  • danhaller
  • rajasinghcondenast
  • derrickatcn
  • tce
  • lboylan
  • cnid_engineering
  • lilyhealey
  • varun9110
  • megrymo
  • prajaktak
  • manthanbhosle
  • rutujavetal
  • niharanil
  • psharma2
  • bhumikakhatri
  • sarthak_mohanty
  • igostu
  • rajashreearvikar19
  • tobe998
  • cwoldt
  • ndi
  • nishkala
  • sahana2104
  • mladhane
  • mtzhang
  • manthanraut
  • jfrederick12
  • rajashree-devaraj
  • sdconde
  • rigelsong
  • drosenbaum
  • roopeshrkn
  • aswani_gupta
  • garryyao
  • charuagrawal
  • sabarni-condenast
  • yakshita
  • kalyanikasar
  • talk2rajeev
  • shreyapa
  • stefanpenner
  • natelawscn
  • bbui
  • alexli
  • brian_mathews
  • crmartin
  • leahzxxz
  • hmehta06
  • srigurutcs
  • husheric
  • katemont
  • eddleston
  • rtt
  • eshno
  • jcorcino
  • anwaukoni
  • richardsjustind
  • eduardoveras
  • mrgentax
  • thehiddenhaku
  • cl4m
  • spollini
  • fedeava
  • sasha04
  • guidop91
  • gostfield
  • nithya10
  • satnam_gandhi
  • abigaild45
  • mb_dev
  • rmohamma
  • emilyatk
  • asolovyev
  • vaishnavisenthilvel
  • stefano-sarioli
  • sarah-chekfa
  • luis_gomez
  • danielbaldwin
  • karmenn
  • khiaraortiz
  • dmitriy_komarov-cn
  • jhraue
  • sviatoslav_maslov
  • hcet
  • jmcamacho
  • ishita_tiwari
  • sanjana_s
  • hariprasath_cn
  • harinikiruba
  • condenastfr
  • iamsuneeth
  • suhitrathi-condenast
  • zeeshan-wani
  • imakshath
  • srikanthns
  • mitchellstewart
  • pushp-1992
  • anoopk-cn
  • mithunsathyanmits
  • surbhi_cn
  • vikasshetty
  • midhunmurali001
  • sudiptacondenast
  • salvador-ahumada
  • suba56
  • skt-dev
  • ganeshnca
  • belal_kazmi
  • rszmacinski
  • prakashn37
  • utkarsh_sanjivan-conde
  • mallica
  • shobith
  • rashmi-rao
  • sahoo.sandhya
  • sardendu
  • agururajan
  • skumari
  • sikindar_mirza
  • ankitkumar02
  • avinash_iitb
  • upenpanging
  • speluri
  • anubalakrishnan
  • sbhattac
  • rjain198
  • ashwini_uppar
  • pmasade
  • jbergdol
  • suresharam
  • vnallasa
  • dhanraj_cn
  • pratik-gupta
  • anita-y
  • arvipandey
  • sandesh4777
  • vishnusimvisfear
  • ilankumaran
  • samtiffin
  • harsha-condenast
  • adityaanand534
  • rkamble
  • chandan-condenast
  • pratham7674
  • alokreddycn
  • anurag-cn
  • odtoribio
  • pranjal_sharma306500
  • vijayalakshmi-sunagar
  • helena-ong
  • namankumarsinha
  • grannitsejdiu
  • rkharecondenast
  • sumitmaurya21
  • pashoka
  • shubham_condenast
  • sourav_condenast
  • tanmoy_condenast
  • nidhiarya-condenast
  • vmehrotr
  • smita2022
  • pariharcondenast
  • subiabre
  • snehadg
  • sourav909
  • surabhidesai
  • syed_faizan
  • raveena-ram
  • statavar
  • jatinbabbarcondenast
  • ankushvijay93
  • likhita
  • indu-sagi
  • jakir-coder
  • priyankanandi
  • nikhilcondenast
  • stahirah
  • sparganiha-cn
  • aswanth_condenast
  • vinay_kumar
  • rajeswari-cn
  • soumyagundu
  • cnrahulrkr
  • ramya-cn
  • dikshita_khandke
  • somsekhardash
  • ambay_chaurasia
  • manikandancn
  • rghvndr99
  • shubhamkheracn
  • akhil_pasham
  • mulla2
  • spandey10
  • srawat-cn