+0
-4
| exports.options = [ | ||
| { | ||
| label: 'Random', | ||
| emoji: '๐', | ||
| }, | ||
| { | ||
| label: 'New beginnings', | ||
@@ -8,0 +4,0 @@ emoji: '๐', |
+40
-2
@@ -5,7 +5,45 @@ const Git = require('simple-git')(); | ||
| const random = require('random'); | ||
| const fs = require('fs'); | ||
| let options = [ | ||
| { | ||
| label: 'Random', | ||
| emoji: '๐', | ||
| }, | ||
| ]; | ||
| let emojiPool = config.emojiPool; | ||
| try { | ||
| if (fs.existsSync('.gimmitrc.json')) { | ||
| const customConfig = JSON.parse(fs.readFileSync('.gimmitrc.json', 'utf8')); | ||
| if (customConfig.options) { | ||
| options = [ | ||
| ...options, | ||
| ...customConfig.options, | ||
| ].map((option, index) => { | ||
| const key = index === 0 ? 'Key ' : ''; | ||
| return { | ||
| ...option, | ||
| label: `${option.label} [${key}${index}]`, | ||
| }; | ||
| }); | ||
| } | ||
| if (customConfig.emojiPool) { | ||
| if (customConfig.emojiPool.length < 2) { | ||
| throw 'Your custom emoji pool for random option length is less than 2. Please add more.'; | ||
| } | ||
| emojiPool = customConfig.emojiPool; | ||
| } | ||
| } | ||
| } catch (err) { | ||
| console.error(err); | ||
| } | ||
| const promptSelectType = new Select({ | ||
| name: 'type', | ||
| message: 'Select commit flavor', | ||
| choices: config.options.map(option => { | ||
| choices: options.map(option => { | ||
| return `${option.emoji} ${option.label}`; | ||
@@ -17,3 +55,3 @@ }), | ||
| const randIndex = random.int(0, config.emojiPool.length); | ||
| return config.emojiPool[randIndex]; | ||
| return emojiPool[randIndex]; | ||
| }; | ||
@@ -20,0 +58,0 @@ |
+2
-1
| { | ||
| "name": "gimmit", | ||
| "version": "0.0.7", | ||
| "version": "0.0.8", | ||
| "description": "Git commit but cuter", | ||
@@ -28,2 +28,3 @@ "main": "gimmit.js", | ||
| "enquirer": "^2.3.2", | ||
| "fs": "^0.0.1-security", | ||
| "random": "^2.1.1", | ||
@@ -30,0 +31,0 @@ "simple-git": "^1.128.0" |
+50
-3
@@ -20,12 +20,59 @@ # Gimmit | ||
| Simply install globally via `npm instal -g gimmit` or `yarn global add gimmit`. | ||
| Assuming you already have `git` cli installed on your machine: simply install globally via `npm instal -g gimmit` or `yarn global add gimmit`. | ||
| Once installed, You can now simply type `gimmit` when you want to make a commit to your repo and just follow the prompts. | ||
| ## Custom configuration | ||
| Just make a `.gimmitrc.json` in your root directory. | ||
| You can pass in your own options for both `commit flavors` and the `pool` of emoji the random function selects from. | ||
| *Note:* The random option is always the first option even though you pass in your own set. | ||
| ```json | ||
| // .gimmitrc.json | ||
| { | ||
| "options": [ | ||
| { | ||
| "label": "Custom option", | ||
| "emoji": "๐ฆ" | ||
| } | ||
| ], | ||
| "emojiPool": [ | ||
| "๐", | ||
| "๐ป" | ||
| ] | ||
| } | ||
| ``` | ||
| You can have fun with this! You can replace the `emoji` with anything: say, you want to have consistent "labeled" commits in your team, or just for yourself, then you can do something like: | ||
| ```json | ||
| // .gimmitrc.json | ||
| { | ||
| "options": [ | ||
| { | ||
| "label": "Visual Design", | ||
| "emoji": "[VISUAL]" | ||
| }, { | ||
| "label": "Final final", | ||
| "emoji": "[FINALFINALv3]", | ||
| } | ||
| ], | ||
| "emojiPool": [ | ||
| "[I ATE BANANA]", | ||
| "[GIMME BURGER]" | ||
| ] | ||
| } | ||
| ``` | ||
| Have fun! | ||
| ## Plans | ||
| - Override configuration and customize the selects via a .gimmitconfig | ||
| - Add the possibility for validations for commit messages | ||
| - [x] Override configuration and customize the selects via a .gimmitconfig | ||
| - [ ] Add the possibility for validations for commit messages | ||
| ### P.S. | ||
| Peace and love ๐ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
50440
3.69%131
28.43%77
156.67%4
33.33%1
Infinity%+ Added
+ Added