今天午夜,我做了一些我以前從未做過的事情;就是把我的程式gimme_readme發佈到npm註冊中心,供全世界使用!
gimme_readme 命令列工具取得使用者的本機原始碼文件,並使用它們建立一個解釋其程式碼的 README.md 文件。 gimme_readme 可讓您選擇不同的 AI API(例如 Gemini 的 gemini-1.5-flash 模型和 Groq 的 llama3-8b-8192 模型)來分析提供的程式碼並建立解釋程式碼的文件。
要了解有關 gimme_readme 的更多信息,我邀請您查看下面我的存儲庫,或者觀看 0.1 的發布演示,該演示也鏈接在我的存儲庫中。
gimme_readme 是一個由 AI 提供支援的命令列工具,可為您的專案產生全面的 README.md 檔案。它可以同時分析多個原始碼文件,並在一個易於閱讀的文檔中提供每個文件的用途、功能和關鍵組件的簡明解釋。這使得您的專案對其他人來說更容易理解和理解。
查看我們的 0.1 版本示範!
要開始使用 gimme_readme,請依照下列步驟操作:
為您的作業系統安裝最新版本的 Node.js。
執行以下命令全域安裝 gimme_readme:
npm i -g gimme_readme
注意:MAC/LINUX 使用者可能需要執行 sudo npm i -g gimme_readme
透過在您想要的任何資料夾中運行來產生設定檔:
gr-ai -c
此指令會在您的主目錄中建立一個 .gimme_readme_config 檔案。 請勿從此位置移動此文件。
…
"Stand on the shoulders of giants"
This quote echoed in my head as I was creating my command-line tool since I know very well that without the work of many other companies and distinct individuals, I would not be able to release my own project.
To that end, let me delve into some of the technologies I used to create gimme_readme.
To start, I knew I wanted to work with JavaScript because of its simple syntax, and its ability to run on Linux, Mac, and Windows. Since cross-platform availability is something I value, I knew I wanted to work with JavaScript from the start.
After choosing JavaScript as the programming language I'd write in, I thought about how I would publish my code. The first thought that came to mind was npm. npm or the node package manager is the largest open source registry in the world. People from around the world use code from npm and share their code to npm and the process of using npm is very straightforward.
When I started my computer science journey in 2022, I was fascinated with how easy it was to just write:
npm i NPM_PACKAGE
and my code would magically work. I was even more impressed when I found out that the packages that were installed (if they were maintained correctly), were able to be installed on different operating systems.
To show you how easy node / npm's ecosystem is, let me show you how easy it is to make your JavaScript code into an executable that runs on every operating system.
You can make your script executable by adding a line similar to this to your package.json file:
{ "bin": { // Makes an executable called "gr-ai" which simply calls my JS script "gr-ai": "./src/_gr.js" } }
How neat is that? With just a few lines of code (minus my comment), you are halfway done with making an executable called gr-ai which calls ./src/_gr.js that can run on all operating systems.
The final piece of the puzzle for making an executable is simulating how you would publish your code OR publishing your code for real.
To simulate publishing your code, run the following command in the root of your JavaScript project (i.e., where your package.json is):
npm link
This command simulates you having installed your program globally and will give you access to your own gr-ai command!
In the event that you no longer want to have the code for this command installed globally (whether it be your simulated code / code that you installed globally via npm), you can run:
npm uninstall -g gimme_readme
Please note, that you need to specify the name of your package when uninstalling and not the name of your executable.
I had to simulate publishing my code several times before actually publishing it to npm. For a really good guide on publishing your code to the npm registry, I suggest watching Web Dev Simplified's video on creating and publishing your first npm package.
With direction on how I'd publish my code, I was able to start thinking about all the different dependencies I would need to get my program to work.
The dependencies and packages I'm currently using for gimme_readme are:
It was with these great APIs and libraries that I was able to produce a tool of my own. With that said, let me show you how you can get started with gimme_readme so you can make heads or tails of your local source code files.
To get started with gimme_readme, follow these steps:
The download for Node.js can be found here: https://nodejs.org/en/download/package-manager.
Node.js will come with npm and allow you to install gimme_readme.
npm i -g gimme_readme
NOTE: MAC/LINUX users may need to run sudo npm i -g gimme_readme
gr-ai -c
This command creates a .gimme_readme_config file in your home directory. Do not move this file from this location.
Follow the instructions in the file to create your own API keys and set your own default values.
Congratulations! You just installed gimme_readme to your system and if you created your own API keys, you should be able to use gimme_readme on the command-line!
With installation out of the way, let's delve into how you can use gimme_readme.
At a top level, gimme_readme supports the following features:
Let's show you demonstrations of each feature.
The most basic gimme_readme command is:
gr-ai
This shows us how use gr-ai and its different options.
Providing the -v option to the gr-ai command returns the version number
gr-ai -v
gr-ai -c
# file file model output file gr-ai -f .prettierignore .gitignore -m gemini-1.5-flash -o explain.md
If you made it this far, I'd like to thank you for giving this blog a read. Creating the 0.1 release of gimme_readme has been a great experience, and I’m excited to continue developing new features and improving the tool. If you're interested in trying it out or contributing, feel free to check out the GitHub repository.
Stay tuned for more updates in the coming weeks!
以上是開發日誌:gimme_readme 版本的詳細內容。更多資訊請關注PHP中文網其他相關文章!