Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
💥 new config 🔥️ no theme 🥳️ all gitmoji
Browse files Browse the repository at this point in the history
💥️  BREAKING CHANGE: Trigger breaking change
  • Loading branch information
JeromeFitz authored and kodiakhq[bot] committed May 4, 2021
1 parent 595c947 commit 14a1e2c
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 945 deletions.
184 changes: 51 additions & 133 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# @jeromefitz/git-cz
# 🥳️ git(moji)-cz => @jeromefitz/git-cz

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

## Why this Fork
## 🍴️ Why this Fork

```bash
npm i -g git-cz
Expand All @@ -11,7 +11,7 @@ added 1 package in 0.612s

Installs in 0.6s vs 31.1s.

### But Why _this_ Fork
### 🍽️ But Why _this_ Fork

I needed to customize some things, and seemed like the intent was breaking away from [`streamich/git-cz`](https://github.com/streamich/git-cz).

Expand All @@ -29,7 +29,7 @@ I needed to customize some things, and seemed like the intent was breaking away

📝️ Note: `@jeromefitz/git-cz-v7.0.0` is the main breaking off point

## Install
## 💽️ Install

### Without installation

Expand Down Expand Up @@ -86,15 +86,15 @@ run:
git cz
```

## Custom config
## 🔧️ Custom config

You can provide a custom configuration in a `changelog.config.js` file in your repo, or in any parent folder.

git-cz will search for the closest config file.

- [Default Config](https://github.com/JeromeFitz/git-cz/blob/main/lib/themes/default.js))
- [Default Config](https://github.com/JeromeFitz/git-cz/blob/main/src/themes/gitmoji.js))

## Non-interactive mode
## 🚧️ Non-interactive mode

Using `--non-interactive` flag you can run `git-cz` non-interactive mode.

Expand All @@ -114,75 +114,78 @@ CLI parameters:
- `--subject`
- `--type`

## Disable Emoji
<!-- ## Disable Emoji
Using `--disable-emoji` flag will disable emoji.
For example:
```bash
git-cz --disable-emoji
```

## Commit message format

- A commit message consists of a **header**, **body** and **footer**.
- The header has a **type** and a **subject**:

```bash
<type>[(<scope>)]: <emoji> <subject>
[BLANK LINE]
[body]
[BLANK LINE]
[breaking changes]
[BLANK LINE]
[footer]
```

The **header** is the only mandatory part of the commit message.
``` -->

The first line (type + subject) is limited to 50 characters **[enforced]**
## :octocat: Commit

Any other line should be limited to 72 character **[automatic wrapping]**
### Subject via Format

This allows the message to be easier to read on GitHub as well as in various git tools.

### Format

By default the subject format is: `{type}{scope}: {emoji}{subject}`
By default the subject format is: `{emoji} {scope} {branchName}{subject}`

```bash
--format "{type}{scope}: {emoji}{subject}"
--format "{emoji} {scope} {branchName}{subject}"
```

```json
{
"format": "{type}{scope}: {subject}"
"commit": {
"format": "{emoji} {scope} {branchName}{subject}"
}
}
```

You can configure your own using the following fields:

- `{branchName}`
- `{emoji}`
- `{scope}`
- `{subject}`
- `{type}`

These are the _only_ fields that will be dynamically replaced by `git-cz`.
These are the _only_ fields that will be dynamically replaced by `@jeromefitz/git-cz`.

These are not `${type}` so in your configuration if you need to pass dynamically values to `format` you can while keeping these separate. Helpful for when adding ` [skip ci]` to `format` conditionally.

📝️ Note: If your configuration file _is_ dynamic and you want to override these change yours at run time to `${type}` 😅️. These fields are only replaced _if_ they exist. Heck, you can have a format of: `format: "static(hard): code value"` if you really want (please do not).

#### branchName

This is really only useful if you are using an issue tracker like Jira.

```bash
▲ git-cz [ABC-1234] git-cz
```

Would pull `ABC-1234` in for `{branchName}`

If you were doing something like:

```bash
▲ git-cz [feature/gitflow-branch-names]
```

You would not want to pass `branchPrefix` as that would be a long commit message.

Also most likely if you are doing feature branches you are doing `ABC-1234`'s into it.

<!--
📝️ Note: If you want to keep emojis in the cli and not in your code commits you can do so by not `disable-emoji|disableEmoji` and not putting `{emoji}` in your format:
```bash
--format "{type}{scope}: {subject}"
```
Have fun in your console if you can't in your codebase. 🤣️
Have fun in your console if you can't in your codebase. 🤣️ -->

### Theme
<!-- ### Theme
`git-cz` provides two themes out of the box:
Expand Down Expand Up @@ -223,11 +226,11 @@ These are the emojis you know and love from `git-cz` available as an **override*
{
"theme": "original"
}
```
``` -->

### Type
### Types

Default is from `gitmoji`:
From `gitmoji`:

- `access`: Improve accessibility
- `analytics`: Add or update analytics or track code
Expand Down Expand Up @@ -307,22 +310,17 @@ The subject contains succinct description of the change:
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

#### Affects [only on [lerna](https://lernajs.io/) environments]
<!-- #### Affects [only on [lerna](https://lernajs.io/) environments]
Select the packages the commit affected.
Select the packages the commit affected. -->

### Breaking Changes

**Breaking Changes** must start with the words `BREAKING CHANGE:`.

### Footer
<!-- ### Footer
The footer is the place to reference any tasks related to this commit.

```bash
npm i -g mol-conventional-changelog
added 345 packages in 31.076s
```
The footer is the place to reference any tasks related to this commit. -->

## Husky

Expand All @@ -340,94 +338,14 @@ yarn git-cz --hook || true

- ref: https://typicode.github.io/husky/#/?id=locally-installed-binaries

## Gitflow Branching

Eject from commit message and create a branch via:

```bash
git-cz --branch
```

There are new configs that you can override:

- `branch` ([Config](https://github.com/JeromeFitz/git-cz/blob/main/lib/themes/default.js#L3))
- `branchTypes` ([Config](https://github.com/JeromeFitz/git-cz/blob/main/lib/themes/gitmoji.js#L9))

```js
module.exports = {
branch: {
format: '{branchName}',
projectCode: '',
questions: ['branchName'],
ticketUrl: '',
},
branchTypes: {
feature: {
code: ':sparkles:',
description: 'Introduce new features.',
emoji: '',
entity: '&#x2728;',
gitflow: 'feature',
hidden: false,
name: 'sparkles',
release: 'minor',
section: 'Introduce new features.',
semver: 'minor',
value: 'feat',
},
fix: {
code: ':bug:',
description: 'Fix a bug.',
emoji: '🐛',
entity: '&#x1f41b;',
gitflow: 'fix',
hidden: false,
name: 'bug',
release: 'patch',
section: 'Fix a bug.',
semver: 'patch',
value: 'fix',
},
hotfix: {
code: ':ambulance:',
description: 'Critical hotfix.',
emoji: '🚑️',
entity: '&#128657;',
gitflow: 'hotfix',
hidden: false,
name: 'ambulance',
release: 'patch',
section: 'Critical hotfix.',
semver: 'patch',
value: 'hotfix',
},
},
format: '{type}{scope}: {emoji}{branchName}{subject}',
}
```

The only `branch.questions` required is `branchName`. So should probably make that rqeuired.

If you pass `{branchName}` in `format` currently it _needs_ to have the `questions` `'branchPrefix'` set so it can "find" it.
## Branch

This is really only useful if you are using an issue tracker like Jira.

```bash
▲ git-cz [ABC-1234] git-cz
```

Would pull `ABC-1234` in for `{branchName}`

If you were doing something like:
Change the `mode` and create branches via gitflow:

```bash
git-cz [feature/gitflow-branch-names]
git-cz -m branch
```

You would not want to pass `branchPrefix` as that would be a long commit message.

Also most likely if you are doing feature branches you are doing `ABC-1234`'s into it.

### Roadmap

This is not going to be great to type, but may be good to move to:
Expand Down
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const cli = async () => {
}
} catch (error) {
// eslint-disable-next-line no-console
console.dir(chalkPipe('red.bold')('⚠️ error:'))
console.log(chalkPipe('red.bold')('⚠️ error:'))
// eslint-disable-next-line no-console
console.dir(chalkPipe('white.italic')(error))
console.log(chalkPipe('white.italic')(error))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/themes/gitmoji.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const gitmoji = {
branch: {
format: '{branchType}{branchName}',
prefix: 'ABC-',
prefix: '',
questions: ['branchFlag', 'branchTypes', 'branchName'],
url: 'https://abc.atlassian.net/browse/',
url: '',
},
commit: {
format: '{emoji} {scope}{branchName}{subject}',
Expand Down
37 changes: 24 additions & 13 deletions src/utils/runNonInteractiveMode.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import chalkPipe from 'chalk-pipe'

/* eslint-disable no-console */
const runNonInteractiveMode = (
state,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
{ type = 'chore', subject = 'automated commit', ...restAnswers }
) => {
// eslint-disable-next-line no-console
console.dir('0000 todo')
const answers = {
subject,
type,
...restAnswers,
}
//
console.log(chalkPipe('yellow.bold')('🚧️ runNonInteractiveMode is not finished'))
console.log(
chalkPipe('yellow')('🤕️ Help at: https://github.com/JeromeFitz/git-cz')
)

// eslint-disable-next-line no-process-exit
process.exit()

// const answers = {
// subject,
// type,
// ...restAnswers,
// }

Object.keys(state.answers).forEach((key) => {
if (answers[key]) {
state.answers[key] = answers[key]
delete answers[key]
}
})
// Object.keys(state.answers).forEach((key) => {
// if (answers[key]) {
// state.answers[key] = answers[key]
// delete answers[key]
// }
// })
}

export default runNonInteractiveMode
Loading

0 comments on commit 14a1e2c

Please sign in to comment.