mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-12 23:28:16 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d50a67ece | ||
|
|
a2d03e054c | ||
|
|
1c113c2901 | ||
|
|
18dcb8e8c2 | ||
|
|
8b17b5e906 | ||
|
|
284604f6a4 | ||
|
|
bdce94f2ac | ||
|
|
a3fade4d42 | ||
|
|
83906fc704 | ||
|
|
e7f7bfc2bd | ||
|
|
3885ae5893 | ||
|
|
b8e05a5852 |
8
.github/CONTRIBUTING.md
vendored
8
.github/CONTRIBUTING.md
vendored
@@ -1,6 +1,6 @@
|
||||
# Contribution Guidelines
|
||||
|
||||
Thank you for considering contributing to the project. Let's shake it baby.
|
||||
Thanks for considering contributing to the project.
|
||||
|
||||
## How to contribute
|
||||
|
||||
@@ -9,7 +9,7 @@ Thank you for considering contributing to the project. Let's shake it baby.
|
||||
3. Create a new branch for your changes.
|
||||
4. Make your changes and commit them with descriptive commit messages.
|
||||
5. Push your changes to your forked repository.
|
||||
6. Create a pull request from your branch to the `master` branch.
|
||||
6. Create a pull request from your branch to the `dev` branch.
|
||||
|
||||
## Getting started
|
||||
|
||||
@@ -28,9 +28,9 @@ Use the library to generate commits, stage the files and run `npm run dev` :)
|
||||
|
||||
If you encounter any issues while using the project, please report them on the GitHub issue tracker. When reporting issues, please include as much information as possible, such as steps to reproduce the issue, expected behavior, and actual behavior.
|
||||
|
||||
## Contact us
|
||||
## Contacts
|
||||
|
||||
If you have any questions about contributing to the project, please contact us by [creating an issue](https://github.com/di-sukharev/open-commit/issues) on the GitHub issue tracker.
|
||||
If you have any questions about contributing to the project, please contact by [creating an issue](https://github.com/di-sukharev/open-commit/issues) on the GitHub issue tracker.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "opencommit",
|
||||
"version": "1.1.20",
|
||||
"version": "1.1.23",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "opencommit",
|
||||
"version": "1.1.20",
|
||||
"license": "ISC",
|
||||
"version": "1.1.23",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^0.6.1",
|
||||
"axios": "^1.3.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "opencommit",
|
||||
"version": "1.1.20",
|
||||
"version": "1.1.23",
|
||||
"description": "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
||||
"keywords": [
|
||||
"git",
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"author": "https://github.com/di-sukharev",
|
||||
"license": "ISC",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"out/**/*"
|
||||
],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export enum COMMANDS {
|
||||
config = 'config',
|
||||
hook = 'hook'
|
||||
hook = 'hook',
|
||||
config = 'config'
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ 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 { checkIsLatestVersion } from './utils/checkIsLatestVersion';
|
||||
// import { checkIsLatestVersion } from './utils/checkIsLatestVersion';
|
||||
|
||||
const extraArgs = process.argv.slice(2);
|
||||
|
||||
@@ -21,7 +21,7 @@ cli(
|
||||
help: { description: packageJSON.description }
|
||||
},
|
||||
async () => {
|
||||
await checkIsLatestVersion();
|
||||
// await checkIsLatestVersion();
|
||||
if (isHookCalled) {
|
||||
prepareCommitMessageHook();
|
||||
} else {
|
||||
|
||||
@@ -63,7 +63,7 @@ ${chalk.grey('——————————————————')}`
|
||||
);
|
||||
|
||||
const isCommitConfirmedByUser = await confirm({
|
||||
message: 'Confirm the commit message'
|
||||
message: 'Confirm the commit message?'
|
||||
});
|
||||
|
||||
if (isCommitConfirmedByUser && !isCancel(isCommitConfirmedByUser)) {
|
||||
@@ -86,11 +86,19 @@ ${chalk.grey('——————————————————')}`
|
||||
|
||||
if (isPushConfirmedByUser && !isCancel(isPushConfirmedByUser)) {
|
||||
const pushSpinner = spinner();
|
||||
|
||||
pushSpinner.start(`Running \`git push ${remotes[0]}\``);
|
||||
const { stdout } = await execa('git', ['push', remotes[0]]);
|
||||
|
||||
const { stdout } = await execa('git', [
|
||||
'push',
|
||||
'--verbose',
|
||||
remotes[0]
|
||||
]);
|
||||
|
||||
pushSpinner.stop(
|
||||
`${chalk.green('✔')} successfully pushed all commits to ${remotes[0]}`
|
||||
);
|
||||
|
||||
if (stdout) outro(stdout);
|
||||
}
|
||||
} else {
|
||||
@@ -101,8 +109,11 @@ ${chalk.grey('——————————————————')}`
|
||||
|
||||
if (!isCancel(selectedRemote)) {
|
||||
const pushSpinner = spinner();
|
||||
|
||||
pushSpinner.start(`Running \`git push ${selectedRemote}\``);
|
||||
|
||||
const { stdout } = await execa('git', ['push', selectedRemote]);
|
||||
|
||||
pushSpinner.stop(
|
||||
`${chalk.green(
|
||||
'✔'
|
||||
@@ -196,6 +207,5 @@ export async function commit(
|
||||
outro(`${chalk.red('✖')} ${generateCommitError}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ const validateConfig = (
|
||||
outro(
|
||||
`${chalk.red('✖')} Unsupported config key ${key}: ${validationMessage}`
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
@@ -49,6 +50,7 @@ export const configValidators = {
|
||||
|
||||
return value;
|
||||
},
|
||||
|
||||
[CONFIG_KEYS.description](value: any) {
|
||||
validateConfig(
|
||||
CONFIG_KEYS.description,
|
||||
@@ -58,6 +60,7 @@ export const configValidators = {
|
||||
|
||||
return value;
|
||||
},
|
||||
|
||||
[CONFIG_KEYS.emoji](value: any) {
|
||||
validateConfig(
|
||||
CONFIG_KEYS.emoji,
|
||||
@@ -67,6 +70,7 @@ export const configValidators = {
|
||||
|
||||
return value;
|
||||
},
|
||||
|
||||
[CONFIG_KEYS.language](value: any) {
|
||||
validateConfig(
|
||||
CONFIG_KEYS.language,
|
||||
|
||||
@@ -55,18 +55,18 @@ export const hookCommand = command(
|
||||
}
|
||||
|
||||
if (mode === 'unset') {
|
||||
intro(`unsetting opencommit as '${HOOK_NAME}' hook`);
|
||||
intro(`unsetting OpenCommit as '${HOOK_NAME}' hook`);
|
||||
|
||||
if (!isHookExists) {
|
||||
return outro(
|
||||
`opencommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove`
|
||||
`OpenCommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove`
|
||||
);
|
||||
}
|
||||
|
||||
const realpath = await fs.realpath(SYMLINK_URL);
|
||||
if (realpath !== HOOK_URL) {
|
||||
return outro(
|
||||
`opencommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually`
|
||||
`OpenCommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { mergeStrings } from './utils/mergeStrings';
|
||||
import { i18n, I18nLocals } from './i18n';
|
||||
|
||||
const config = getConfig();
|
||||
const translation = i18n[config?.language as I18nLocals || 'en']
|
||||
const translation = i18n[(config?.language as I18nLocals) || 'en'];
|
||||
|
||||
const INIT_MESSAGES_PROMPT: Array<ChatCompletionRequestMessage> = [
|
||||
{
|
||||
@@ -20,7 +20,7 @@ const INIT_MESSAGES_PROMPT: Array<ChatCompletionRequestMessage> = [
|
||||
}, use the present tense. ${
|
||||
config?.description
|
||||
? 'Add a short description of what commit is about 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.'
|
||||
: "Don't add any descriptions to the commit, only commit message."
|
||||
} Use ${translation.localLanguage} to answer.`
|
||||
},
|
||||
{
|
||||
|
||||
7
src/i18n/es_ES.json
Normal file
7
src/i18n/es_ES.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"localLanguage": "spanish",
|
||||
"commitFix": "fix(server.ts): cambiar la variable port de minúsculas a mayúsculas PORT",
|
||||
"commitFeat": "feat(server.ts): añadir soporte para la variable de entorno process.env.PORT",
|
||||
"commitDescription": "La variable port ahora se llama PORT, lo que mejora la coherencia con las convenciones de nomenclatura, ya que PORT es una constante. El soporte para una variable de entorno permite que la aplicación sea más flexible, ya que ahora puede ejecutarse en cualquier puerto disponible especificado a través de la variable de entorno process.env.PORT."
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import zh_CN from '../i18n/zh_CN.json' assert { type: 'json' };
|
||||
import zh_TW from '../i18n/zh_TW.json' assert { type: 'json' };
|
||||
import ja from '../i18n/ja.json' assert { type: 'json' };
|
||||
import pt_br from '../i18n/pt_br.json' assert { type: 'json' };
|
||||
import vi_VN from '../i18n/vi_VN.json' assert { type: 'json' };
|
||||
import es_ES from '../i18n/es_ES.json' assert { type: 'json' };
|
||||
|
||||
export enum I18nLocals {
|
||||
'en' = 'en',
|
||||
@@ -17,7 +19,8 @@ export enum I18nLocals {
|
||||
'fr' = 'fr',
|
||||
'it' = 'it',
|
||||
'ko' = 'ko',
|
||||
'pt_br' = 'pt_br'
|
||||
'pt_br' = 'pt_br',
|
||||
'es_ES' = 'es_ES'
|
||||
};
|
||||
|
||||
export const i18n = {
|
||||
@@ -29,7 +32,9 @@ export const i18n = {
|
||||
fr,
|
||||
it,
|
||||
ko,
|
||||
pt_br
|
||||
pt_br,
|
||||
vi_VN,
|
||||
es_ES
|
||||
};
|
||||
|
||||
export const I18N_CONFIG_ALIAS: { [key: string]: string[] } = {
|
||||
@@ -41,7 +46,9 @@ export const I18N_CONFIG_ALIAS: { [key: string]: string[] } = {
|
||||
fr: ['fr', 'French', 'française'],
|
||||
it: ['it', 'Italian', 'italiano'],
|
||||
pt_br: ['pt_br', 'Portuguese', 'português'],
|
||||
vi_VN: ['vi_VN', 'Vietnamese', 'tiếng Việt'],
|
||||
en: ['en', 'English', 'english'],
|
||||
es_ES: ['es_ES', 'Spanish', 'español'],
|
||||
};
|
||||
|
||||
export function getI18nLocal(value: string): string | boolean {
|
||||
|
||||
6
src/i18n/vi_VN.json
Normal file
6
src/i18n/vi_VN.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"localLanguage": "vietnamese",
|
||||
"commitFix": "fix(server.ts): thay đổi chữ viết thường của biến port thành chữ viết hoa PORT",
|
||||
"commitFeat": "feat(server.ts): thêm hỗ trợ cho biến môi trường process.env.PORT",
|
||||
"commitDescription": "Biến port đã được đổi tên thành PORT, giúp cải thiện tính nhất quán trong việc đặt tên theo quy ước vì PORT là một hằng số. Hỗ trợ cho biến môi trường cho phép ứng dụng linh hoạt hơn khi có thể chạy trên bất kỳ cổng nào được chỉ định thông qua biến môi trường process.env.PORT."
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getOpenCommitLatestVersion } from '../api';
|
||||
import currentPackage from '../../package.json' assert { type: 'json' };
|
||||
import chalk from 'chalk';
|
||||
|
||||
export const checkIsLatestVersion = async () => {
|
||||
const latestVersion = await getOpenCommitLatestVersion();
|
||||
|
||||
|
||||
@@ -26,11 +26,17 @@ export const getOpenCommitIgnore = (): Ignore => {
|
||||
};
|
||||
|
||||
export const getStagedFiles = async (): Promise<string[]> => {
|
||||
const { stdout: files } = await execa('git', [
|
||||
'diff',
|
||||
'--name-only',
|
||||
'--cached',
|
||||
'--relative'
|
||||
const { stdout: gitDir } = await execa("git", [
|
||||
"rev-parse",
|
||||
"--show-toplevel"
|
||||
]);
|
||||
|
||||
const { stdout: files } = await execa("git", [
|
||||
"diff",
|
||||
"--name-only",
|
||||
"--cached",
|
||||
"--relative",
|
||||
gitDir
|
||||
]);
|
||||
|
||||
if (!files) return [];
|
||||
|
||||
Reference in New Issue
Block a user