mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-12 23:28:16 -05:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fa438ab17 | ||
|
|
4ad7a5f779 | ||
|
|
5c0b31600f | ||
|
|
d785b821ea | ||
|
|
c50c416dfc | ||
|
|
f8720ff089 | ||
|
|
afa5949c06 | ||
|
|
b1ec69e4dd | ||
|
|
0061816b6a | ||
|
|
352b81c6c6 | ||
|
|
430776af29 | ||
|
|
c573edea97 | ||
|
|
5282734583 | ||
|
|
9c67a3774f | ||
|
|
deeb7cdf97 | ||
|
|
fe819f0814 | ||
|
|
578a30c330 | ||
|
|
973a4a2843 |
@@ -83,7 +83,7 @@ To remove description:
|
||||
opencommit config set description=false
|
||||
```
|
||||
|
||||
## Git hook
|
||||
<!-- ## Git hook
|
||||
|
||||
You can set opencommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
|
||||
|
||||
@@ -106,7 +106,7 @@ To use the hook:
|
||||
git commit
|
||||
```
|
||||
|
||||
Or follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow.
|
||||
Or follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow. -->
|
||||
|
||||
## Payments
|
||||
|
||||
|
||||
6
TODO.md
6
TODO.md
@@ -1,4 +1,8 @@
|
||||
# TODOs
|
||||
|
||||
- [] [build for both mjs and cjs](https://snyk.io/blog/best-practices-create-modern-npm-package/)
|
||||
- []
|
||||
- [] make bundle smaller by properly configuring esbuild
|
||||
- [] do // TODOs in the code
|
||||
- [] batch small files in one request
|
||||
- [] add tests
|
||||
- [] make hook work
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "open-commit",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "open-commit",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.12",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^0.6.1",
|
||||
|
||||
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "opencommit",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.12",
|
||||
"description": "AI generates conventional commits with mind-blowing accuracy.",
|
||||
"keywords": [
|
||||
"git",
|
||||
@@ -12,8 +12,8 @@
|
||||
],
|
||||
"main": "cli.js",
|
||||
"bin": {
|
||||
"opencommit": "./out/cli.mjs",
|
||||
"oc": "./out/cli.mjs"
|
||||
"opencommit": "./out/cli.cjs",
|
||||
"oc": "./out/cli.cjs"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://github.com/di-sukharev/opencommit"
|
||||
@@ -34,9 +34,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "npm run -S build -- --sourcemap --watch",
|
||||
"start": "node ./out/cli.mjs",
|
||||
"start": "node ./out/cli.cjs",
|
||||
"dev": "ts-node ./src/cli.ts",
|
||||
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.mjs --format=esm --platform=node",
|
||||
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node",
|
||||
"patch": "npm version patch",
|
||||
"lint": "eslint src --ext ts && tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
27
src/api.ts
27
src/api.ts
@@ -1,4 +1,4 @@
|
||||
import { intro, outro, text } from '@clack/prompts';
|
||||
import { intro, outro } from '@clack/prompts';
|
||||
import {
|
||||
ChatCompletionRequestMessage,
|
||||
ChatCompletionResponseMessage,
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
OpenAIApi
|
||||
} from 'openai';
|
||||
|
||||
import { CONFIG_KEYS, getConfig, setConfig } from './commands/config';
|
||||
import { getConfig } from './commands/config';
|
||||
|
||||
const config = getConfig();
|
||||
|
||||
@@ -14,15 +14,26 @@ let apiKey = config?.OPENAI_API_KEY;
|
||||
|
||||
if (!apiKey) {
|
||||
intro('opencommit');
|
||||
const apiKey = await text({
|
||||
message: 'input your OPENAI_API_KEY'
|
||||
});
|
||||
|
||||
setConfig([[CONFIG_KEYS.OPENAI_API_KEY as string, apiKey as any]]);
|
||||
|
||||
outro('OPENAI_API_KEY is set');
|
||||
outro(
|
||||
'OPENAI_API_KEY is not set, please run `oc config set OPENAI_API_KEY=<your token>`'
|
||||
);
|
||||
outro(
|
||||
'For help Look into README https://github.com/di-sukharev/opencommit#setup'
|
||||
);
|
||||
}
|
||||
|
||||
// if (!apiKey) {
|
||||
// intro('opencommit');
|
||||
// const apiKey = await text({
|
||||
// message: 'input your OPENAI_API_KEY'
|
||||
// });
|
||||
|
||||
// setConfig([[CONFIG_KEYS.OPENAI_API_KEY as string, apiKey as any]]);
|
||||
|
||||
// outro('OPENAI_API_KEY is set');
|
||||
// }
|
||||
|
||||
class OpenAi {
|
||||
private openAiApiConfiguration = new OpenAiApiConfiguration({
|
||||
apiKey: apiKey
|
||||
|
||||
@@ -20,7 +20,7 @@ export const hookCommand = command(
|
||||
parameters: ['<set/unset>']
|
||||
},
|
||||
async (argv) => {
|
||||
const HOOK_PATH = fileURLToPath(new URL('cli.mjs', import.meta.url));
|
||||
const HOOK_PATH = fileURLToPath(new URL('./out/cli.cjs', import.meta.url));
|
||||
|
||||
try {
|
||||
await assertGitRepo();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* Language and Environment */
|
||||
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
||||
"lib": [
|
||||
"ESNext"
|
||||
"ES6"
|
||||
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
|
||||
|
||||
/* Modules */
|
||||
|
||||
Reference in New Issue
Block a user