mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-12 23:28:16 -05:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e76db8276b | ||
|
|
c2ae98170c | ||
|
|
91987030f0 | ||
|
|
2a55b08b51 | ||
|
|
ed4d6e0109 | ||
|
|
6712e798c5 | ||
|
|
1347962a93 | ||
|
|
3ca9b9752f | ||
|
|
50e2f67a9b | ||
|
|
c1a4c3daf2 | ||
|
|
e4de6d8186 | ||
|
|
5abe5d715d | ||
|
|
32c34abd22 | ||
|
|
1050cad95d | ||
|
|
7bbc97980e | ||
|
|
2a9a3d5818 |
BIN
.github/opencommit-example.png
vendored
Normal file
BIN
.github/opencommit-example.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 KiB |
11
README.md
11
README.md
@@ -5,13 +5,16 @@
|
||||
<h4 align="center">Author <a href="https://github.com/di-sukharev">@di-sukharev</a> <a href="https://twitter.com/io_Y_oi"><img src="https://img.shields.io/twitter/follow/io_Y_oi?style=flat&label=io_Y_oi&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
|
||||
</h4>
|
||||
</div>
|
||||
<p>AI generates conventional commits with mind-blowing accuracy</p>
|
||||
<h2>GPT CLI to auto-generate impressive commits in 1 second</h2>
|
||||
<p>Killing lame commits with AI 🤯🔫</p>
|
||||
<a href="https://www.npmjs.com/package/opencommit"><img src="https://img.shields.io/npm/v/opencommit" alt="Current version"></a>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
<div align="center">
|
||||
<img src=".github/opencommit-example.png" alt="OpenCommit example"/>
|
||||
</div>
|
||||
|
||||
All the commits in this repo are done with OpenCommit — look into [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emoji and long commit description text is configurable.
|
||||
|
||||
@@ -30,10 +33,10 @@ All the commits in this repo are done with OpenCommit — look into [the commits
|
||||
3. Set the key to opencommit config:
|
||||
|
||||
```sh
|
||||
opencommit config set OPENAI_API_KEY=<your token>
|
||||
opencommit config set OPENAI_API_KEY=<your_api_key>
|
||||
```
|
||||
|
||||
Your token isn't sent to anyone, it's saved in `~/.opencommit` config file.
|
||||
Your api key is stored locally in `~/.opencommit` config file.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "open-commit",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.13",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "open-commit",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.13",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^0.6.1",
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
{
|
||||
"name": "opencommit",
|
||||
"version": "1.0.7",
|
||||
"description": "AI generates conventional commits with mind-blowing accuracy 🤯🔫",
|
||||
"version": "1.0.13",
|
||||
"description": "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
||||
"keywords": [
|
||||
"git",
|
||||
"chatgpt",
|
||||
"gpt",
|
||||
"ai",
|
||||
"openai",
|
||||
"opencommit",
|
||||
"aicommit",
|
||||
"aicommits",
|
||||
"gptcommit",
|
||||
"commit"
|
||||
],
|
||||
"main": "cli.js",
|
||||
|
||||
@@ -11,7 +11,9 @@ const config = getConfig();
|
||||
|
||||
let apiKey = config?.OPENAI_API_KEY;
|
||||
|
||||
if (!apiKey) {
|
||||
const [command, mode] = process.argv.slice(2);
|
||||
|
||||
if (!apiKey && command !== 'config' && mode !== 'set') {
|
||||
intro('opencommit');
|
||||
|
||||
outro(
|
||||
@@ -20,6 +22,8 @@ if (!apiKey) {
|
||||
outro(
|
||||
'For help Look into README https://github.com/di-sukharev/opencommit#setup'
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// if (!apiKey) {
|
||||
|
||||
14
src/cli.ts
14
src/cli.ts
@@ -7,6 +7,8 @@ import { configCommand } from './commands/config';
|
||||
import { hookCommand, isHookCalled } from './commands/githook.js';
|
||||
import { prepareCommitMessageHook } from './commands/prepare-commit-msg-hook';
|
||||
import { commit } from './commands/commit';
|
||||
import { execa } from 'execa';
|
||||
import { outro } from '@clack/prompts';
|
||||
|
||||
const rawArgv = process.argv.slice(2);
|
||||
|
||||
@@ -19,11 +21,17 @@ cli(
|
||||
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
|
||||
help: { description: packageJSON.description }
|
||||
},
|
||||
() => {
|
||||
async () => {
|
||||
if (isHookCalled) {
|
||||
prepareCommitMessageHook();
|
||||
await prepareCommitMessageHook();
|
||||
} else {
|
||||
commit();
|
||||
await commit();
|
||||
const { stdout } = await execa('npm', ['view', 'opencommit', 'version']);
|
||||
|
||||
if (stdout !== packageJSON.version)
|
||||
outro(
|
||||
'new opencommit version is available, update with `npm i -g opencommit`'
|
||||
);
|
||||
}
|
||||
},
|
||||
rawArgv
|
||||
|
||||
@@ -53,10 +53,12 @@ ${chalk.grey('——————————————————')}`
|
||||
|
||||
if (isPushConfirmedByUser && !isCancel(isPushConfirmedByUser)) {
|
||||
const pushSpinner = spinner();
|
||||
|
||||
pushSpinner.start('Running `git push`');
|
||||
const { stdout } = await execa('git', ['push']);
|
||||
pushSpinner.stop(`${chalk.green('✔')} successfully pushed all commits`);
|
||||
outro(stdout);
|
||||
|
||||
if (stdout) outro(stdout);
|
||||
}
|
||||
} else outro(`${chalk.gray('✖')} process cancelled`);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user