8 Commits

Author SHA1 Message Date
di-sukharev
9c67a3774f 0.0.6 2023-03-06 19:08:01 +08:00
di-sukharev
deeb7cdf97 0.0.5 2023-03-06 19:07:58 +08:00
di-sukharev
fe819f0814 0.0.4 2023-03-06 19:07:56 +08:00
di-sukharev
578a30c330 0.0.3 2023-03-06 19:07:54 +08:00
di-sukharev
973a4a2843 * 🐛 fix(package.json): change cli file extension from .mjs to .cjs
*  feat(package.json): add publish script
The cli file extension has been changed from .mjs to .cjs to improve compatibility with Node.js. The publish script has been added to simplify the process of publishing a new version of the package to npm.

* 🎨 style(api.ts): remove unused import statement
* 🐛 fix(api.ts): remove setConfig function call
* 🚧 chore(api.ts): add comment to explain apiKey variable initialization
* 🚧 chore(api.ts): comment out code block that prompts user for OPENAI_API_KEY
The unused import statement for `text` function from `@clack/prompts` has been removed. The `setConfig` function call has been removed as it is not needed and was causing an error. A comment has been added to explain the initialization of the `apiKey` variable. The code block that prompts the user for `OPENAI_API_KEY` has been commented out as it is not needed and was causing an error.

* 🐛 fix(tsconfig.json): change target to ES6
The target was previously set to ESNext, which is not supported by all browsers. Changing it to ES6 ensures that the emitted JavaScript is compatible with a wider range of browsers.
2023-03-06 19:07:48 +08:00
di-sukharev
144f6b4499 0.0.2 2023-03-06 18:52:08 +08:00
di-sukharev
4b7cb77ea4 * 📦 chore(package.json): add repository and author fields
The repository field is added to specify the URL of the project's repository. The author field is updated to include the author's GitHub profile URL.
2023-03-06 18:47:22 +08:00
di-sukharev
4795a69580 * 🆕 chore(.eslintrc.json): add ESLint configuration file
The commit adds a new ESLint configuration file to the project. The configuration extends the recommended rules from ESLint, adds recommended rules from the @typescript-eslint plugin, and adds the prettier plugin to format code. The configuration also includes rules to enforce sorting of imports, disallow console statements, and disallow non-null assertions.

* 📝 docs(CONTRIBUTING.md): add contribution guidelines
This commit adds a CONTRIBUTING.md file to the project repository, which outlines the steps to follow when contributing to the project. It includes instructions on how to contribute, how to report issues, and how to contact the project maintainers. It also includes guidelines for writing commit messages.

* 🎨 style(.github/logo-black.png): add black version of the logo
A new black version of the logo has been added to the .github directory. This will be used in situations where a black background is present, to ensure the logo is visible and clear.

* 🎨 style(logo-grad.svg): add company logo
A new company logo has been added to the .github directory. The logo is an SVG file with a width of 78 and a height of 75. It consists of a gradient of two colors, #D33075 and #6157D8. The logo is intended to be used as the company's official logo.

* 🎨 style(logo.svg): add company logo
The company logo has been added to the .github directory. The logo is an SVG file with a width of 78 and a height of 75. It consists of two paths that are filled with black color.

* 📝 chore(.gitignore): add files and directories to ignore list
Added files and directories to the ignore list to prevent them from being committed to the repository. The added files and directories include node_modules/, coverage/, out/, temp/, build/, dist/, application.log, .DS_Store, *.env, logfile.log, uncaughtExceptions.log, .vscode, and src/*.json.

* 🆕 chore(.prettierignore): add /build and /dist directories to ignore list for Prettier
This commit adds the /build and /dist directories to the ignore list for Prettier. This ensures that Prettier does not format files in these directories, which are typically generated by build tools and should not be modified directly.

* 🆕 chore(.prettierrc): add Prettier configuration file
A new Prettier configuration file has been added to the project root directory. The configuration file sets the `trailingComma` option to "none" and the `singleQuote` option to true. This ensures that code formatting is consistent across the project.

* 🆕 add(LICENSE): add MIT License
Added a MIT License to the project, which grants permission to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, subject to the conditions outlined in the license. The license also includes a disclaimer of warranties and limitations of liability.

* 🆕 feat(README.md): add OpenCommit documentation
This commit adds the documentation for OpenCommit, a tool that generates conventional commits with high accuracy using AI. The documentation includes instructions on how to set up and use OpenCommit, as well as its features such as GitMoji convention, descriptions of changes, and Git hook integration. Additionally, the documentation includes information on payments for OpenAI API usage.

* 📝 docs(TODO.md): add build for both mjs and cjs task
Added a task to build for both mjs and cjs as per the best practices outlined in the linked article.

* 🆕 feat(package.json): add dependencies and devDependencies
This commit adds the dependencies and devDependencies to the package.json file. The dependencies include axios, chalk, cleye, execa, ini, inquirer, and openai. The devDependencies include typescript, eslint, esbuild, dotenv, and ts-node.

* 🎉 feat(api.ts): add OpenAI class with generateCommitMessage method
The OpenAI class is added to the project, which provides a generateCommitMessage method that uses the OpenAI API to generate commit messages. The method takes an array of ChatCompletionRequestMessage objects and returns a ChatCompletionResponseMessage object. The apiKey is retrieved from the configuration file, and if it is not present, the user is prompted to input it.

* 🆕 feat(cli.ts): add CLI support for opencommit
This commit adds a new file `cli.ts` which contains the CLI implementation for opencommit. The CLI is built using the `cleye` package and supports the following commands: `config` and `hook`. The `config` command is used to configure opencommit, while the `hook` command is used to set up the Git hook. The CLI also supports a `--version` flag to display the version number and a `--help` flag to display the help message.

*  feat(commit.ts): add ability to commit staged files with generated commit message
The commit command now supports committing staged files with a generated commit message. The user is prompted to confirm the commit message before the commit is made. If there are no staged files, the user is prompted to stage all files and generate a commit message. If the user confirms, all files are staged and the commit message is generated.

* 🚀 feat(config.ts): add support for setting and getting configuration values
The `config.ts` file now contains functions for setting and getting configuration values. The `getConfig` function reads the configuration file from the user's home directory and returns the configuration object. The `setConfig` function sets the configuration values passed as arguments and writes them to the configuration file. The `configCommand` function is a command-line interface for the `getConfig` and `setConfig` functions. It supports two modes: "get" and "set". The "get" mode retrieves the configuration values for the specified keys, and the "set" mode sets the configuration values for the specified keys.

*  feat(githook.ts): add support for setting and unsetting prepare-commit-msg hook
This commit adds a new command to set and unset the prepare-commit-msg hook. The hook is set to opencommit, which is a tool that helps to write conventional commit messages. The command checks if the hook is already set and if it is, it verifies that it is set to opencommit. If the hook is set to a different tool, it throws an error and asks the user to remove it manually. If the hook is not set, it creates a symlink to opencommit. The command also supports unsetting the hook, which removes the symlink.

*  feat(prepare-commit-msg-hook.ts): add support for generating commit messages with chat completion
This commit adds support for generating commit messages with chat completion. The `prepare-commit-msg-hook.ts` file now imports the `generateCommitMessageWithChatCompletion` function from the `generateCommitMessageFromGitDiff` module. The function generates a commit message based on the staged git diff and appends it to the commit message file. If the `OPENAI_API_KEY` environment variable is not set, an error is thrown. If the commit source is specified, the function returns without generating a commit message.

* 🆕 feat(generateCommitMessageFromGitDiff.ts): add support for generating commit messages from git diff
This commit adds a new module that generates commit messages from git diff. The module uses the OpenAI API to prompt the user to create a commit message in the conventional commit convention. The user is given the option to use Gitmoji convention to preface the commit and add a short description of what the commit is about. The user can also choose not to add any descriptions to the commit, only the commit message.

* 🐛 fix(server.ts): change port variable case from lowercase port to uppercase PORT
*  feat(server.ts): add support for process.env.PORT environment variable
The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable.

*  feat: add function to generate commit messages from diff files
This commit adds a new function that generates commit messages from diff files. The function takes in a diff string and splits it by files. It then generates commit messages for each file using a separate function. The commit messages are then concatenated and returned as a single string. If the commit message is empty, it is skipped. If there is an error generating the commit message, an error is returned.

*  feat(git.ts): add function to assert git repository existence
*  feat(git.ts): add function to get staged git diff
The assertGitRepo function checks if the current directory is a git repository by running the 'git rev-parse' command. If the command fails, an error is thrown.

The getStagedGitDiff function returns the staged diff of the git repository. It takes an optional boolean argument isStageAllFlag, which when true stages all changes before getting the diff. The function uses the 'git diff --staged' command to get the diff and excludes big files from the diff. The function returns an object with two properties: files, which is an array of the names of the files that have changes, and diff, which is the diff of the staged changes.

* 🎉 feat(tsconfig.json): add tsconfig.json file
This commit adds a new tsconfig.json file to the project. The file contains compiler options that specify how TypeScript should compile the project. The options include the target language version, module code generation, output directory, and type checking options. The file also excludes the node_modules directory from compilation and includes options for ts-node.
2023-03-06 18:35:41 +08:00