Compare commits

..

6 Commits

Author SHA1 Message Date
di-sukharev
40297e0c6a chore(package.json): update version to 3.0.2
The version in package.json has been updated from 3.0.1 to 3.0.2. This change is made to reflect the latest version of the project.
2023-09-05 13:49:17 +08:00
di-sukharev
75f0cd47b8 chore(package.json): update version to 3.0.1
The version in package.json has been updated from 3.0.0 to 3.0.1. This change is made to reflect the new version of the project.
2023-09-05 13:48:09 +08:00
Sukharev
c76313737d #247: fix (#248) 2023-09-05 13:45:34 +08:00
di-sukharev
ac8c87be9e docs(README.md): add note about MacOS potentially requiring 'sudo' when installing package globally
The README.md file now includes a note that MacOS may prompt the user to run the 'npm install -g opencommit' command with 'sudo' when installing the package globally. This note is added to provide clarity and help users who encounter this situation.
2023-09-03 15:22:47 +08:00
di-sukharev
a9050fda39 build 2023-09-03 15:17:12 +08:00
Sukharev
b98b892ba1 v3.0.0 (#243)
* update major version

---------

Co-authored-by: E Einowski <5124085+EwiththeBowtie@users.noreply.github.com>
Co-authored-by: Max Zavodniuk <lovemaxonly@gmail.com>
Co-authored-by: Malthe Poulsen <30603252+malpou@users.noreply.github.com>
Co-authored-by: Sébastien Fichot <fichot.sebastien@gmail.com>
2023-09-03 15:16:02 +08:00
11 changed files with 26 additions and 4006 deletions

View File

@@ -29,6 +29,8 @@ You can use OpenCommit by simply running it via the CLI like this `oco`. 2 secon
npm install -g opencommit
```
MacOS may ask to run the command with `sudo` when installing a package globally.
2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.
3. Set the key to OpenCommit config:

View File

@@ -1,12 +0,0 @@
// @ts-ignore
// import { jest } from '@jest/globals';
import { generateCommitMessageByDiff } from '../src/generateCommitMessageFromGitDiff';
test.skip('generateCommitMessageFromGitDiff', async () => {
const GIT_DIFF = ``;
const res = await generateCommitMessageByDiff(GIT_DIFF);
expect(res).toBe('lol');
});

View File

@@ -1,79 +0,0 @@
import { getCommitMsgsPromisesFromFileDiffs } from '../src/generateCommitMessageFromGitDiff';
const oneFileThreeChanges = `diff --git a/example.txt b/example.txt
index e69de29..3f6a3fa 100644
--- a/example.txt
+++ b/example.txt
@@ -1,2 +1,2 @@
-Hello, World!
+Hello, everyone!
This is an example file.
@@ -4,2 +4,2 @@
-Goodbye, World!
+Goodbye, everyone!
Have a great day!
@@ -7,2 +7,2 @@
-It's a sunny day!
+It's a rainy day!
Let's go for a walk.`;
const fourFilesOneChangeEach = `diff --git a/file1.txt b/file1.txt
index e69de29..3f6a3fa 100644
--- a/file1.txt
+++ b/file1.txt
@@ -1,2 +1,2 @@
-Hello, World!
+Hello, everyone!
This is file 1.
diff --git a/file2.txt b/file2.txt
index 87c0ddc..d7b182e 100644
--- a/file2.txt
+++ b/file2.txt
@@ -1,3 +1,3 @@
This is file 2.
-Goodbye, World!
+Goodbye, everyone!
Have a great day!
diff --git a/file3.txt b/file3.txt
index e69de29..3f6a3fa 100644
--- a/file3.txt
+++ b/file3.txt
@@ -1,4 +1,4 @@
This is file 3.
-It's a sunny day!
+It's a rainy day!
Let's go for a walk.
diff --git a/file4.txt b/file4.txt
index 3f6a3fa..87c0ddc 100644
--- a/file4.txt
+++ b/file4.txt
@@ -1,5 +1,5 @@
This is file 4.
-It's time to sleep.
+It's time to wake up.
Goodnight.
`;
test('1', async () => {
const MAX_LENGTH = 50;
const oneFile3Changes = await getCommitMsgsPromisesFromFileDiffs(
oneFileThreeChanges,
MAX_LENGTH
);
expect(oneFile3Changes).toBe('lol');
});
test('2', async () => {
const MAX_LENGTH = 50;
const fourFilesOneChange = await getCommitMsgsPromisesFromFileDiffs(
fourFilesOneChangeEach,
MAX_LENGTH
);
expect(fourFilesOneChange).toBe('lol');
});

View File

@@ -1,21 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest';
const jestConfig: JestConfigWithTsJest = {
// [...]
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true
}
]
}
};
export default jestConfig;

View File

@@ -16384,7 +16384,7 @@ function G3(t, e2) {
// package.json
var package_default = {
name: "opencommit",
version: "2.4.2",
version: "3.0.0",
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
keywords: [
"git",
@@ -16410,7 +16410,8 @@ var package_default = {
author: "https://github.com/di-sukharev",
license: "MIT",
files: [
"out/**/*"
"out/cli.cjs",
"out/tiktoken_bg.wasm"
],
release: {
branches: [
@@ -16426,7 +16427,7 @@ var package_default = {
dev: "ts-node ./src/cli.ts",
build: "rimraf out && node esbuild.config.js",
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
deploy: "npm run build:push && npm version patch && git push --tags && git push && npm publish --tag latest",
deploy: "npm run build:push && npm version patch && git push --follow-tags && npm publish --tag latest",
lint: "eslint src --ext ts && tsc --noEmit",
format: "prettier --write src"
},
@@ -21906,7 +21907,7 @@ var commitlintPrompts = {
// src/modules/commitlint/pwd-commitlint.ts
var import_path2 = __toESM(require("path"), 1);
var nodeModulesPath = import_path2.default.join(
process.env.PWD,
process.env.PWD || process.cwd(),
"node_modules",
"@commitlint",
"load"
@@ -21997,10 +21998,10 @@ var translation3 = i18n[config5?.OCO_LANGUAGE || "en"];
var IDENTITY = "You are to act as the author of a commit message in git.";
var INIT_MAIN_PROMPT2 = (language) => ({
role: import_openai3.ChatCompletionRequestMessageRoleEnum.System,
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the conventional commit convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the conventional commit convention and explain WHAT were the changes and mainly WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.
${config5?.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
${config5?.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
Use the present tense. Lines must not be longer than 74 characters. Use ${language} to answer.`
Use the present tense. Lines must not be longer than 74 characters. Use ${language} for the commit message.`
});
var INIT_DIFF_PROMPT = {
role: import_openai3.ChatCompletionRequestMessageRoleEnum.User,

View File

@@ -28320,7 +28320,7 @@ var commitlintPrompts = {
// src/modules/commitlint/pwd-commitlint.ts
var import_path2 = __toESM(require("path"), 1);
var nodeModulesPath = import_path2.default.join(
process.env.PWD,
process.env.PWD || process.cwd(),
"node_modules",
"@commitlint",
"load"
@@ -28411,10 +28411,10 @@ var translation3 = i18n[config5?.OCO_LANGUAGE || "en"];
var IDENTITY = "You are to act as the author of a commit message in git.";
var INIT_MAIN_PROMPT2 = (language) => ({
role: import_openai3.ChatCompletionRequestMessageRoleEnum.System,
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the conventional commit convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the conventional commit convention and explain WHAT were the changes and mainly WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.
${config5?.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
${config5?.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
Use the present tense. Lines must not be longer than 74 characters. Use ${language} to answer.`
Use the present tense. Lines must not be longer than 74 characters. Use ${language} for the commit message.`
});
var INIT_DIFF_PROMPT = {
role: import_openai3.ChatCompletionRequestMessageRoleEnum.User,

3877
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "3.0.0",
"version": "3.0.2",
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
"keywords": [
"git",
@@ -43,25 +43,21 @@
"dev": "ts-node ./src/cli.ts",
"build": "rimraf out && node esbuild.config.js",
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
"deploy": "npm run build:push && npm version patch && git push --tags && npm publish --tag latest",
"deploy": "npm run build:push && npm version patch && git push --follow-tags && npm publish --tag latest",
"lint": "eslint src --ext ts && tsc --noEmit",
"format": "prettier --write src",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage --config jest.config.ts"
"format": "prettier --write src"
},
"devDependencies": {
"@commitlint/types": "^17.4.4",
"@types/ini": "^1.3.31",
"@types/inquirer": "^9.0.3",
"@types/jest": "^29.5.4",
"@types/node": "^16.18.14",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"dotenv": "^16.0.3",
"esbuild": "^0.15.18",
"eslint": "^8.28.0",
"jest": "^29.6.4",
"prettier": "^2.8.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},

View File

@@ -199,17 +199,17 @@ export async function commit(
}
if (stagedFiles.length === 0 && changedFiles.length > 0) {
const files = await multiselect({
const files = (await multiselect({
message: chalk.cyan('Select the files you want to add to the commit:'),
options: changedFiles.map((file) => ({
value: file,
label: file
}))
});
})) as string[];
if (isCancel(files)) process.exit(1);
await gitAdd({ files: files as string[] });
await gitAdd({ files });
}
await commit(extraArgs, false);

View File

@@ -1,7 +1,7 @@
import path from 'path';
const nodeModulesPath = path.join(
process.env.PWD as string,
process.env.PWD || process.cwd(),
'node_modules',
'@commitlint',
'load'

View File

@@ -1,9 +1,9 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["ES5", "ES6"],
"module": "ESNext",
// "rootDir": "./src",
"resolveJsonModule": true,
"moduleResolution": "node",