Skip to content

Commit 1b62332

Browse files
committed
🎉 first commit
1 parent d673751 commit 1b62332

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
GITMOJI_VERSION=v3.0.0
2+
BASE_FILE=https://raw.githubusercontent.com/carloscuesta/gitmoji/$(GITMOJI_VERSION)/src/data/gitmojis.json
3+
4+
gen:
5+
@echo ""
6+
@echo "---- Fetch gitmojis.json ($(GITMOJI_VERSION))----"
7+
mkdir -p build build/src build/dist
8+
curl -so build/src/gitmojis.json $(BASE_FILE)
9+
10+
@echo ""
11+
@echo ""
12+
@echo "---- Add semver field to gitmojis.json from semver.yml ----"
13+
yq '.' semver.yml > build/src/semver.json
14+
node script.js
15+
cat build/dist/tmp.json | jq > build/dist/gitmojis.json
16+
yq -y '.' build/dist/gitmojis.json > build/dist/gitmojis.yml
17+
rm build/dist/tmp.json
18+
19+
@echo ""
20+
@echo ""
21+
@echo "---- Successfully ----"
22+
@echo "Semver field added to gitmojis.json and gitmojis.yml created"
23+
@echo "See ./build/dist"

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# gitmoji-semver
2+
- A simple script to add the semver field to [gitmojis.json](https://github.com/carloscuesta/gitmoji/blob/master/src/data/gitmojis.json).
3+
- Generate the files `gitmojis.json` and `gitmojis.yml` with the semver field added.
4+
- You can easily change the configuration of semver in [./semver.yml](./semver.yml) .
5+
6+
# Usage
7+
## Prepare
8+
require `curl`, `jq`, `yq` and `node` command.
9+
10+
```sh
11+
# Install
12+
$ brew install curl yq jq
13+
```
14+
15+
```sh
16+
# Probably works in other versions too.
17+
$ node --version
18+
v13.14.0
19+
```
20+
21+
## Install
22+
23+
```sh
24+
git clone https://github.com/nkmr-jp/gitmoji-semver
25+
```
26+
27+
## Generate
28+
```sh
29+
$ cd ./gitmoi-semver
30+
$ make gen GITMOJI_VERSION=v3.0.0
31+
```
32+
33+
## Check the generated files
34+
```sh
35+
$ cat build/dist/gitmojis.json | jq '.gitmojis[] | select(.name=="sparkles")'
36+
{
37+
"emoji": "",
38+
"entity": "✨",
39+
"code": ":sparkles:",
40+
"description": "Introduce new features.",
41+
"name": "sparkles",
42+
"semver": "minor"
43+
}
44+
45+
$ cat build/dist/gitmojis.yml | yq '.gitmojis[] | select(.name=="sparkles")'
46+
{
47+
"emoji": "",
48+
"entity": "✨",
49+
"code": ":sparkles:",
50+
"description": "Introduce new features.",
51+
"name": "sparkles",
52+
"semver": "minor"
53+
}
54+
```
55+
56+
## Edit gitmoji for your project
57+
58+
[./semver.yml](./semver.yml)
59+
60+
```yml
61+
semver:
62+
major: [ boom ]
63+
minor: [ sparkles ]
64+
patch: [ bug, ambulance ]
65+
```
66+
67+
68+
# Reference
69+
- https://github.com/carloscuesta/gitmoji/issues/429

script.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs');
2+
const gitmojisObj = JSON.parse(fs.readFileSync('./build/src/gitmojis.json', 'utf8'));
3+
const semverObj = JSON.parse(fs.readFileSync('./build/src/semver.json', 'utf8'));
4+
5+
function run() {
6+
const res = {gitmojis: []};
7+
for (const v of gitmojisObj.gitmojis) {
8+
v.semver = semver(v.name)
9+
res.gitmojis.push(v)
10+
}
11+
12+
fs.writeFileSync('./build/dist/tmp.json', JSON.stringify(res));
13+
}
14+
15+
function semver(name) {
16+
for (const v of Object.keys(semverObj.semver)) {
17+
if (semverObj.semver[v].includes(name)) {
18+
return v
19+
}
20+
}
21+
return 'none'
22+
}
23+
24+
run()

semver.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
semver:
2+
major: [ boom ]
3+
minor: [ sparkles ]
4+
patch: [ bug, ambulance ]

0 commit comments

Comments
 (0)