I wanted to share my experience of publishing the package to NPM. This blog post details the process, challenges, and lessons learned during the release.
Choosing the Package Registry
For DialectMorph, I chose to publish on NPM (Node Package Manager) as our primary package registry. The decision was influenced by:
- NPM’s widespread adoption in the JavaScript/TypeScript ecosystem
- Excellent integration with both Node.js and Bun
- Robust documentation and community support
- Built-in versioning and dependency management
Release Process
1. Package Preparation
First, I had to prepare the package for NPM publication. This involved:
{
"name": "dialect-morph",
"version": "1.0.0",
"bin": {
"dialectMorph": "./dist/index.js
}
The critical changes included:
- Setting up the version correctly
- making sure that the binary was being made available to the user when downloaded as an independent package
- Ensuring all dependencies were correctly listed
2. Build Process Configuration
I configured the build process using Bun:
- Added TypeScript compilation settings
- Set up the build script to create the
dist
directory - Ensured the binary was properly executable
3. Testing and Verification
Before publication, I:
- Ran local installation tests using
bun link
- Verified the CLI worked globally
- Tested all supported language conversions
- Validated configuration file handling
Issues Encountered
Before going to the user testing phase, I wanted to install this globally on my machine to test but since I already have it on my machine, so I ran a docker instance of NodeJS to verify all of the installation instructions
P.S The docker instance is really more useful than using a VM in these instances, if you want to set it up, you can use the following command
docker run --rm -it node:latest /bin/bash
this will open up a bash terminal to an instance that has node installed locally
when I installed this, what I found was the binary was not being included in the dialectMorph
package , which was bad, so I had to make fixes for the same and publish my package again.
User Testing Insights
One of my friends tested the total installation process out and the following was found from his experience:
- Installation Confusion: Users were unclear about the difference between global and local installation. This led to adding clearer installation instructions:
npm i -g dialect-morph # for global installation
-
API Key Configuration: Users struggled with setting up API keys. We added multiple configuration options:
- Environment variables
- TOML configuration file
- Command-line arguments
Current Installation and Usage
DialectMorph can now be installed globally via NPM:
npm i -g dialect-morph
Basic usage:
dialectMorph ./path/to/file.py -l java # Convert Python to Java
dialectMorph ./path/to/file.cpp -l python # Convert C++ to Python
For configuration, users can either:
- Create a
~/.dialectMorph.config.toml
file - Use command-line arguments
- Set environment variables
Full documentation is available on my GitHub repository.
Conclusion
This release process has been a valuable learning experience, highlighting the importance of thorough documentation, user testing, and flexible configuration options. The NPM ecosystem provides an excellent platform for distributing CLI tools, and my friend’s feedback has been invaluable in improving DialectMorph.
Source link
lol