Coder Social home page Coder Social logo

skyinglyh1 / commit-message Goto Github PK

View Code? Open in Web Editor NEW

This project forked from selfrefactor/services

0.0 1.0 0.0 442 KB

Assisted generation of commit messages

Home Page: https://selfrefactor.github.io/commit-message/index.html

License: MIT License

JavaScript 0.34% TypeScript 99.66%

commit-message's Introduction

Commit-message

Standardized commit message generation

Argumentation

Writing commit messages should benefit of automated assistance.

While the rules of this library are not perfect, it still helps writing commit messages with consistent style.

How it works

The library uses Inquirer to take text or choice from the user. Generating the message includes the following steps:

  • STEP 1 - Choosing the type of the commit

The user can select one among:

'feat' - Significant change in functionality

'fix' - Fixing an issue

'test' - Writing unit or end-to-end tests for specific feature

'chore' - Update build tasks, lint files or similar(no production code change)

'docs' - Edit the documentation of the project

'typings' - Change Typescript definitions

STEP1


  • STEP 2 - Choosing the label of the commit

User can select empty label, write his own label or use one of the suggested.

Suggested labels depends on the selection in STEP1.

STEP2


  • STEP 3 - Writing the commit message

In this step the user writes the actual commit message.

Install

yarn add https://github.com/selfrefactor/commit-message#1.0.0

commitMessage

import { commitMessage } from 'commit-message'

commitMessage().then((commitMessageValue: string) => {
  console.log(commitMessageValue)
  //=> 'feat@UI: use animation when logout'
})

commitAndPush

commitAndPush method will take the generated commit message and run the following commands for you:

1.git add . --all

2.git commit -m COMMIT_MESSAGE

3.git push

import { commitAndPush } from 'commit-message'

commitAndPush().then((commitMessageValue: string) => {
  console.log(commitMessageValue)
  //=> Pushed with message 'feat@UI: use animation when logout'
})

Usage

Recommended way is to add the following in the scripts property of your package.json

{
  ...
  scripts:{
    "commit":"commit"
  }
  ...
}

Now running yarn commit will execute the commitAndPush method.

STEP3


START, PROGRESS, STOP

Every time STOP label is selected, the commit message will stay as WORK_IN_PROGRESS text.

Later if PROGRESS or STOP is selected, the WORK_IN_PROGRESS text will be prepended to the user input.

When STOP is selected WORK_IN_PROGRESS is reset back to an empty string.

Custom labels

Add commitMessage field in your package.json like so:

{
  ...
  "commitMessage":{
    "labels":[
      "foo",
      "bar",
      "baz"
    ]
  }
  ...
}

Custom labels belong to feat, fix, test commit types.

Change format to type(label): COMMIT_MESSAGE

You just need to pass true like so:

commitMessage(true).then((commitMessageValue: string) => {
  console.log(commitMessageValue)
  //=> 'feat(UI): use animation when logout'
})

Support extended custom label settings

You can further customize the behaviour of this library with setting commitMessage field in your package.json:

 "commitMessage": {
    "labels": [
      "choose-word",
      "learning-meme"
    ],
    "feature": [
      "speed"
    ],
    "support": [
      "webpack"
    ]
  }

In the above example, all labels members will be labels in feat, fix, test commit types.

All feature members will be labels in feat commit type.

All support members will be labels in chore commit type.

commit-message's People

Contributors

selfrefactor avatar

Watchers

James Cloos avatar

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.