Skip to content

Commit 5e0a971

Browse files
endormifrinyvonnick
andcommitted
:docs: Add the documentation site (#194)
Co-authored-by: FRIN Yvonnick <frin.yvonnick@gmail.com>
1 parent 20cf369 commit 5e0a971

File tree

7 files changed

+1042
-139
lines changed

7 files changed

+1042
-139
lines changed

PRESETS.md

Lines changed: 0 additions & 113 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ npx gitmoji-changelog --preset generic
5555

5656
## 📖 Documentation
5757

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

6060
## ✍ Author
6161

packages/gitmoji-changelog-documentation/.nojekyll

Whitespace-only changes.

DOCUMENTATION.md renamed to packages/gitmoji-changelog-documentation/README.md

Lines changed: 135 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Documentation
1+
![gitmoji-changelog logo](https://raw.githubusercontent.com/frinyvonnick/gitmoji-changelog/master/misc/logo.png)
22

3-
## Usage
3+
## 🚀 Usage
44

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

7-
Run the following command at the root of your project and answer questions.
7+
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.
88

99
with npx:
1010
```sh
@@ -19,6 +19,26 @@ cd my-project
1919
gitmoji-changelog
2020
```
2121

22+
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`.
23+
24+
.gitmoji-changelogrc:
25+
```json
26+
{
27+
"project": {
28+
"name": "gitmoji-changelog",
29+
"description": "A changelog generator for gitmoji 😜",
30+
"version": "2.0.1"
31+
}
32+
}
33+
```
34+
35+
You can change the preset used by `gitmoji-changelog` with the preset option.
36+
37+
```sh
38+
npx gitmoji-changelog --preset generic
39+
```
40+
41+
2242
### Available commands
2343

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

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

51-
## How it works
71+
## 📚 How it works
5272

5373
### Behavior
5474

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

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

81-
## Presets
101+
## ⚙️ Presets
82102

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

85105
- node (default preset)
86106
- generic
87107
- maven
88108

89-
Here is the [documentation](/PRESETS.md) about presets (how they works and how to create a new one).
109+
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.
110+
111+
### Existing presets
112+
113+
#### Node
114+
115+
The node preset looks for a `package.json` file.
116+
117+
```json
118+
{
119+
"name": "project-name",
120+
"version": "0.0.1",
121+
"description": "Some description",
122+
}
123+
```
124+
125+
#### Generic
126+
127+
The generic preset looks a `gitmoji-changelogrc` file.
128+
129+
```json
130+
{
131+
"project": {
132+
"name": "yvonnickfrin.dev",
133+
"description": "My blog",
134+
"version": "1.1.0"
135+
}
136+
}
137+
```
138+
139+
It must contain all mandatory properties in a `project` property. The `gitmoji-changelogrc` file can contain other configuration properties like a custom commit categorization.
140+
141+
#### Maven
142+
143+
The maven preset looks for 4 properties in you `pom.xml`:
144+
145+
- groupid
146+
- artifactid
147+
- version
148+
- description
149+
150+
### Add a preset
151+
152+
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.
153+
154+
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.
155+
156+
```js
157+
module.exports = () => {
158+
return null
159+
}
160+
```
161+
162+
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`.
163+
164+
```js
165+
const readPkgUp = require('read-pkg-up')
166+
167+
module.exports = async () => {
168+
try {
169+
const packageInfo = await readPkgUp()
170+
171+
if (!packageInfo.pkg) {
172+
throw Error('Empty package.json')
173+
}
174+
} catch (e) {
175+
return null
176+
}
177+
}
178+
```
179+
180+
If everything went fine we return the three mandatory information (name, description, version).
181+
182+
```js
183+
const readPkgUp = require('read-pkg-up')
184+
185+
module.exports = async () => {
186+
try {
187+
const packageInfo = await readPkgUp()
188+
189+
if (!packageInfo.pkg) {
190+
throw Error('Empty package.json')
191+
}
192+
193+
return {
194+
name: packageInfo.pkg.name,
195+
description: packageInfo.pkg.description,
196+
version: packageInfo.pkg.version,
197+
}
198+
} catch (e) {
199+
return null
200+
}
201+
}
202+
```
203+
204+
That's it. Feel free to open an issue to ask for a new preset or open a pull request to add one.
205+
206+
All preset needs at least 3 pieces of informations to work:
207+
208+
- A project name
209+
- A current version
210+
- A description
211+
212+
They have their own way to get these.
213+
90214

91215
## 🐳 Using Docker image
92216

@@ -124,3 +248,8 @@ with npm:
124248
```sh
125249
npm install -g gitmoji-changelog@canary
126250
```
251+
252+
## 📝 License
253+
254+
Copyright © 2019 [Yvonnick FRIN (https://github.com/frinyvonnick)](https://github.com/frinyvonnick).<br />
255+
This project is [MIT](https://github.com/frinyvonnick/gitmoji-changelog/blob/master/LICENSE) licensed.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>gitmoji-changelog | docs</title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7+
<meta name="description" content="Description">
8+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css">
10+
</head>
11+
<body>
12+
<div id="app">Loading...</div>
13+
<script>
14+
window.$docsify = {
15+
name: 'gitmoji-changelog',
16+
repo: 'https://github.com/frinyvonnick/gitmoji-changelog'
17+
}
18+
</script>
19+
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
20+
</body>
21+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"private": "true",
3+
"name": "@gitmoji-changelog/documentation",
4+
"version": "1.0.0",
5+
"main": "index.html",
6+
"license": "MIT",
7+
"scripts": {
8+
"start": "docsify serve"
9+
},
10+
"dependencies": {},
11+
"devDependencies": {
12+
"docsify-cli": "^4.4.1"
13+
}
14+
}

0 commit comments

Comments
 (0)