Compare commits

..

1 Commits

Author SHA1 Message Date
di-sukharev
c71a9e6604 chore(prompts.ts): update INIT_MAIN_PROMPT content to provide clearer instructions and improve readability
The content of the INIT_MAIN_PROMPT has been updated to provide clearer instructions on how to create clean and comprehensive commit messages in the conventional commit convention. The changes include clarifying the purpose of the mission, specifying the use of 'git diff --staged' command, and providing guidelines on prefaces, descriptions, tense, and line length. The update also includes using the language variable for the commit message. This improves the readability and usability of the prompt for users.
2023-09-03 15:38:37 +08:00
7 changed files with 11 additions and 3994 deletions

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;

3877
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -45,23 +45,19 @@
"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",
"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,9 +1,9 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["ES5", "ES6"],
"module": "ESNext",
// "rootDir": "./src",
"resolveJsonModule": true,
"moduleResolution": "node",