4.4 KiB
4.4 KiB
Publishing to NPM
This document provides step-by-step instructions for publishing the IMG2MP3 package to NPM.
Prerequisites
- NPM Account: Ensure you have an NPM account at npmjs.com
- NPM CLI: Make sure npm is installed and up to date
- Authentication: You need to be logged in to npm
Pre-publication Steps
1. Verify Package Information
Check that all package information is correct:
# Review package.json
cat package.json
# Check package structure
npm pack --dry-run
2. Test the Package Locally
# Install dependencies
npm install
# Test CLI commands
node bin/cli.js --help
node bin/cli.js info --help
# Test the API
node examples/basic_usage.js
3. Check for Available Package Name
# Check if package name is available
npm view img2mp3
# If the package exists, you'll need to choose a different name
# Consider variations like: img2mp3-steganography, img-to-mp3, etc.
4. Verify Package Contents
# See what files will be included in the package
npm pack --dry-run
# The output should include:
# - src/
# - bin/
# - examples/
# - index.d.ts
# - README.md
# - LICENSE
# - package.json
Publishing Steps
1. Login to NPM
npm login
Enter your NPM credentials when prompted.
2. Verify Login
npm whoami
This should display your NPM username.
3. Publish the Package
For first-time publication:
npm publish
If the package name is already taken, you can:
- Choose a scoped package name:
npm publish --access public - Or update the name in package.json and try again
4. Verify Publication
After successful publication:
# Check the package on NPM
npm view img2mp3
# Test installation
npm install -g img2mp3
# Test global installation
img2mp3 --help
Post-publication Steps
1. Create Git Repository
If you haven't already:
git init
git add .
git commit -m "Initial release v1.0.0"
git tag v1.0.0
# Add remote and push (update URL with your repo)
git remote add origin https://github.com/ale/img2mp3.git
git push -u origin main
git push --tags
2. Update Repository Links
Ensure the repository URLs in package.json point to your actual repository.
3. Documentation
- Update the README.md with the correct installation instructions
- Add any platform-specific installation notes
- Include examples and screenshots if possible
Updating the Package
For future updates:
1. Update Version
# For patch updates (bug fixes)
npm version patch
# For minor updates (new features)
npm version minor
# For major updates (breaking changes)
npm version major
2. Update Changelog
Update CHANGELOG.md with the new changes.
3. Publish Update
npm publish
4. Tag the Release
git push --tags
Package Name Alternatives
If "img2mp3" is already taken, consider these alternatives:
img2mp3-encoderimage-to-mp3mp3-steganographyimg2audiosteganography-mp3audio-image-encoderimg-audio-hide@yourname/img2mp3(scoped package)
Troubleshooting
Package Name Already Exists
# Option 1: Use a scoped package
# Update package.json name to "@yourusername/img2mp3"
npm publish --access public
# Option 2: Choose a different name
# Update package.json name field and try again
Authentication Issues
# Clear NPM cache
npm cache clean --force
# Re-login
npm logout
npm login
Permission Errors
# Check if you're added to the package as collaborator
npm owner ls img2mp3
# Add yourself if needed (package owner must do this)
npm owner add yourusername img2mp3
Success Verification
After successful publication, your package should be:
- Searchable: Available at https://www.npmjs.com/package/img2mp3
- Installable:
npm install -g img2mp3works - Executable:
img2mp3 --helpshows help text - Functional: Basic encode/decode operations work
Marketing Your Package
- GitHub README: Ensure your GitHub repository has a comprehensive README
- Keywords: Good keywords in package.json help discoverability
- Documentation: Complete API documentation and examples
- Social Media: Share your package on relevant communities
- Blog Post: Write about the technical implementation and use cases
Remember to respect copyright laws and include appropriate disclaimers about the intended use of steganography tools.