Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 0 additions & 113 deletions PRESETS.md

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ npx gitmoji-changelog --preset generic

## 📖 Documentation

:point_right: The full documentation is available [here](DOCUMENTATION.md).
:point_right: The full documentation is available [here](packages/gitmoji-changelog-documentation/README.md).

## ✍ Author

Expand Down
Empty file.
141 changes: 135 additions & 6 deletions DOCUMENTATION.md → ...gitmoji-changelog-documentation/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Documentation
![gitmoji-changelog logo](https://raw.githubusercontent.com/frinyvonnick/gitmoji-changelog/master/misc/logo.png)

## Usage
## 🚀 Usage

Make sure you have [npx](https://www.npmjs.com/package/npx) installed (`npx` is shipped by default since npm `5.2.0`)

Run the following command at the root of your project and answer questions.
Run the following command at the root of your project and answer questions. `gitmoji-changelog` uses a [preset system](/PRESETS.md) to handle different type of project. The preset used by default is the Node.js one that look for project's information in the `package.json` file.

with npx:
```sh
Expand All @@ -19,6 +19,26 @@ cd my-project
gitmoji-changelog
```

It exists a generic preset that works for every kind of project. It looks for information in a `.gitmoji-changelogrc` file at the root of your project. This file must contain three mandatory properties: `name`, `description` and `version`.

.gitmoji-changelogrc:
```json
{
"project": {
"name": "gitmoji-changelog",
"description": "A changelog generator for gitmoji 😜",
"version": "2.0.1"
}
}
```

You can change the preset used by `gitmoji-changelog` with the preset option.

```sh
npx gitmoji-changelog --preset generic
```


### Available commands

```sh
Expand Down Expand Up @@ -48,7 +68,7 @@ The first command listed above is the idiomatic usage of `gitmoji-changelog` (re

**Here an example output:** [CHANGELOG.md](https://github.com/frinyvonnick/gitmoji-changelog/blob/master/CHANGELOG.md)

## How it works
## 📚 How it works

### Behavior

Expand Down Expand Up @@ -78,15 +98,119 @@ Here the recommended workflow to generate your changelog file using `gitmoji-cha

_This workflow is related to the `node` preset but can be adapted to your own technology._

## Presets
## ⚙️ Presets

`gitmoji-changelog` use presets to get project metadata useful for its smooth operation. Here is the list of available presets:

- node (default preset)
- generic
- maven

Here is the [documentation](/PRESETS.md) about presets (how they works and how to create a new one).
Didn't see the preset you need in the list? Consider adding it. Presets are stored in a [presets](packages/gitmoji-changelog-cli/src/presets) folder in the `cli` package.

### Existing presets

#### Node

The node preset looks for a `package.json` file.

```json
{
"name": "project-name",
"version": "0.0.1",
"description": "Some description",
}
```

#### Generic

The generic preset looks a `gitmoji-changelogrc` file.

```json
{
"project": {
"name": "yvonnickfrin.dev",
"description": "My blog",
"version": "1.1.0"
}
}
```

It must contain all mandatory properties in a `project` property. The `gitmoji-changelogrc` file can contain other configuration properties like a custom commit categorization.

#### Maven

The maven preset looks for 4 properties in you `pom.xml`:

- groupid
- artifactid
- version
- description

### Add a preset

A preset need to export a function. When called this function must return three mandatory information about the project in which the cli has been called. The name of the project, a short description of it and its current version.

Let's dissect the `node` preset to see how it works. First of all the module must export a function. In case something went wrong return `null`. The cli will tell the user a problem occurred.

```js
module.exports = () => {
return null
}
```

There is a package called `read-pkg-up` to get the first `package.json` in the parent folder structure. It returns its content as a JavaScript object. If we can't find a `package.json` or it is empty we return `null`.

```js
const readPkgUp = require('read-pkg-up')

module.exports = async () => {
try {
const packageInfo = await readPkgUp()

if (!packageInfo.pkg) {
throw Error('Empty package.json')
}
} catch (e) {
return null
}
}
```

If everything went fine we return the three mandatory information (name, description, version).

```js
const readPkgUp = require('read-pkg-up')

module.exports = async () => {
try {
const packageInfo = await readPkgUp()

if (!packageInfo.pkg) {
throw Error('Empty package.json')
}

return {
name: packageInfo.pkg.name,
description: packageInfo.pkg.description,
version: packageInfo.pkg.version,
}
} catch (e) {
return null
}
}
```

That's it. Feel free to open an issue to ask for a new preset or open a pull request to add one.

All preset needs at least 3 pieces of informations to work:

- A project name
- A current version
- A description

They have their own way to get these.


## 🐳 Using Docker image

Expand Down Expand Up @@ -124,3 +248,8 @@ with npm:
```sh
npm install -g gitmoji-changelog@canary
```

## 📝 License

Copyright © 2019 [Yvonnick FRIN (https://github.com/frinyvonnick)](https://github.com/frinyvonnick).<br />
This project is [MIT](https://github.com/frinyvonnick/gitmoji-changelog/blob/master/LICENSE) licensed.
21 changes: 21 additions & 0 deletions packages/gitmoji-changelog-documentation/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>gitmoji-changelog | docs</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css">
</head>
<body>
<div id="app">Loading...</div>
<script>
window.$docsify = {
name: 'gitmoji-changelog',
repo: 'https://github.com/frinyvonnick/gitmoji-changelog'
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions packages/gitmoji-changelog-documentation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"private": "true",
"name": "@gitmoji-changelog/documentation",
"version": "1.0.0",
"main": "index.html",
"license": "MIT",
"scripts": {
"start": "docsify serve"
},
"dependencies": {},
"devDependencies": {
"docsify-cli": "^4.4.1"
}
}
Loading