Compare commits

...

12 Commits

Author SHA1 Message Date
di-sukharev
3d50a67ece 1.1.23 2023-03-28 11:32:13 +08:00
di-sukharev
a2d03e054c 🔀 chore(CommandsEnum.ts): reorder COMMANDS enum values
🐛 fix(config.ts): add missing new lines
🐛 fix(githook.ts): capitalize OpenCommit and fix grammar
The COMMANDS enum values were reordered to improve readability and consistency. In config.ts, missing new lines were added to improve code readability. In githook.ts, OpenCommit was capitalized and grammar was fixed to improve clarity.
2023-03-28 11:31:42 +08:00
di-sukharev
1c113c2901 style(commit.ts): add question mark to confirm message
feat(commit.ts): add support for pushing to selected remote instead of default remote
refactor(commit.ts): extract push command to a function and reuse it for both default and selected remote
2023-03-28 11:22:57 +08:00
di-sukharev
18dcb8e8c2 docs(CONTRIBUTING.md): fix typo in Contacts section
chore(package.json): change license from ISC to MIT
2023-03-28 11:20:09 +08:00
jessicakuijer
8b17b5e906 fix(commit.ts): add --verbose flag to git push command (#43)
* 🐛 fix(commit.ts): add --verbose flag to git push command
The --verbose flag is added to the git push command to provide more detailed output. This helps with debugging and identifying any issues that may arise during the push process.
2023-03-28 11:18:34 +08:00
Dang Quang Linh
284604f6a4 feat(i18n): add support for Vietnamese (Vietnam) language (vi_VN) (#51)
Co-authored-by: Sukharev <57486732+di-sukharev@users.noreply.github.com>
2023-03-28 11:16:17 +08:00
Esmerlin Joel Mieses
bdce94f2ac [FEAT](i18n): Add support for Spanish language (es_ES) (#58)
<3
2023-03-28 11:15:17 +08:00
Moret84
a3fade4d42 refactor(git.ts): use git rev-parse to get the root directory of the repository (#46)
The function getStagedFiles has been refactored to use git rev-parse to
get the root directory of the repository. This improves the reliability
of the function as it will work regardless of the current working
directory. The root directory is then passed to the git diff command to
get the list of staged files. With only the --relative flag, staged
diff(s) on files in a different same level directory as the current
working one would not be found by the command.
2023-03-24 10:11:50 +08:00
di-sukharev
83906fc704 docs(CONTRIBUTING.md): update branch name in step 6 from master to dev 2023-03-21 18:23:38 +08:00
di-sukharev
e7f7bfc2bd 1.1.22 2023-03-21 15:52:54 +08:00
di-sukharev
3885ae5893 1.1.21 2023-03-21 15:52:50 +08:00
di-sukharev
b8e05a5852 refactor(cli.ts): comment out checkIsLatestVersion function call
chore(checkIsLatestVersion.ts): add import for chalk library
2023-03-21 15:52:32 +08:00
14 changed files with 69 additions and 28 deletions

View File

@@ -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
View File

@@ -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",

View File

@@ -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/**/*"
],

View File

@@ -1,4 +1,4 @@
export enum COMMANDS {
config = 'config',
hook = 'hook'
hook = 'hook',
config = 'config'
}

View File

@@ -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 {

View File

@@ -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);
}

View File

@@ -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,

View File

@@ -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`
);
}

View File

@@ -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
View 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."
}

View File

@@ -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
View 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."
}

View File

@@ -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();

View File

@@ -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 [];