chore(tsconfig.json): change target to ESNext
The @dqbd/tiktoken dependency was removed from the package.json file. This dependency was not being used in the project and was therefore removed to reduce the size of the project. The target in the tsconfig.json file was changed from ES2020 to ESNext to allow for the use of the latest ECMAScript features.
chore(githook.ts): remove unused import
refactor(tokenCount.ts): simplify token count calculation
The console output now correctly capitalizes OpenCommit for consistency with the project name. The unused import of fileURLToPath is removed. The tokenCount function is refactored to simplify the calculation of the token count. The Tiktoken library is no longer used, and the token count is now calculated based on the length of the content divided by an average token length of 2.7 characters.
The code has been reformatted to use consistent indentation and quotes. This improves the readability and maintainability of the code. No functionality has been changed.
feat(generateCommitMessageFromGitDiff.ts): split file diffs into changes in files if they exceed the maximum token count
The mergeStrings function was renamed to mergeDiffs to better reflect its purpose. The function now takes an additional parameter, maxDiffLength, which is used to split file diffs into changes in files if they exceed the maximum token count. This change improves the efficiency of the function and reduces the number of tokens used.
fix(prepare-commit-msg-hook.ts): add missing await keyword to getStagedFiles() function call
feat(prepare-commit-msg-hook.ts): add spinner to indicate commit message generation progress
feat(utils/mergeDiffs.ts): add mergeDiffs function to merge array of strings into an array of strings with a maximum length
The test.ts file is now ignored by git. The missing await keyword has been added to the getStagedFiles() function call. A spinner has been added to indicate the progress of commit message generation. The mergeDiffs function has been added to merge an array of strings into an array of strings with a maximum length.
* 1.1.23
* 1.1.24
* feat(package.json): add @dqbd/tiktoken dependency
refactor(generateCommitMessageFromGitDiff.ts): add tokenCount function to count the number of tokens in a string
refactor(generateCommitMessageFromGitDiff.ts): change the way the length of INIT_MESSAGES_PROMPT is calculated to use tokenCount function
refactor(generateCommitMessageFromGitDiff.ts): change the way the length of diff is calculated to use tokenCount function
refactor(generateCommitMessageFromGitDiff.ts): rename function parameter from diff to fileDiff and update function calls accordingly
feat(generateCommitMessageFromGitDiff.ts): add tokenCount function to count tokens in fileDiff and use it to check if fileDiff is bigger than MAX_REQ_TOKENS
feat(utils): add tokenCount function to count the number of tokens in a string
refactor(utils/mergeStrings.ts): use tokenCount function to count the number of tokens in a string instead of checking the length of the concatenated string
---------
Co-authored-by: di-sukharev <dim.sukharev@gmail.com>
🐛 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.
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
* 🐛 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.
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.
feat(api.ts): add function to get the latest version of opencommit from unpkg.com
feat(commit.ts): add support for pushing to multiple remotes and prompt user to choose which remote to push to
feat(i18n): add support for Portuguese (Brazil) language and translation for commit messages in pt_br.json
feat(utils): add checkIsLatestVersion function to check if the current version is the latest version
fix(git.ts): add --relative flag to getStagedFiles function to return relative paths
refactor(commit.ts): rename getStagedGitDiff to getChangedFiles and remove unused import of generateCommitMessageWithChatCompletion
refactor(commit.ts): reformat import statements for better readability
refactor(commit.ts): reformat code for better readability
feat(commit.ts): add support for selecting remote to push to when multiple remotes are available
refactor(commit.ts): remove unnecessary code and fix formatting
feat(commit.ts): add support for extraArgs parameter in generateCommitMessageFromGitDiff function
chore(checkIsLatestVersion.ts): update console message for clarity and readability
fix(git.ts): handle empty output from git command
fix(git.ts): add -- argument to git diff command to handle file names with leading hyphens
refactor(mergeStrings.ts): remove unnecessary whitespace and add missing semicolon
* 🔨 refactor(commit.ts): rename function to getGitRemotes and improve comments
This commit renames the function to getGitRemotes to better reflect its purpose. Additionally, the comments have been improved to better explain the function's behavior.
🚀 chore(commit.ts): add support for pushing to selected remote
This commit adds support for pushing to the selected remote. The user is prompted to choose a remote from the list of available remotes, and the selected remote is used to push the changes. The push command is run with the selected remote as an argument.
🐛 fix(commit.ts): fix formatting and add missing newline at end of file
This commit fixes the formatting of the code and adds a missing newline at the end of the file. The changes do not affect the functionality of the code.
* 🐛 fix(commit.ts): fix push command to include remote name
✨ feat(commit.ts): add support for multiple remotes
The push command was not including the remote name, which caused the push to fail. This has been fixed. Support for multiple remotes has been added, allowing the user to choose which remote to push to. If there is only one remote, the push command will automatically use that remote.
* ✨ feat(cli.ts): add checkIsLatestVersion function
This commit adds a new function that checks if the current version of OpenCommit is the latest version. The function uses the getOpenCommitLatestVersion function from the api module to get the latest version of OpenCommit. If the current version is not the latest version, a warning message is printed to the console, informing the user to update to the latest version to get the latest features and bug fixes.
The relative flag has been added to the git diff command in the
getStagedFiles function. This flag makes the output of the command
relative to the current working directory, which makes it easier to work
with the file paths and enables executing opencommit from anywhere in
the repository, not just from the root.
refactor(commit.ts): add types to commit function parameters
fix(git.ts): handle empty string returned from getStagedFiles function
refactor(mergeStrings.ts): remove unnecessary blank line and add missing semicolon