You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.7 KiB
2.7 KiB
Publishing GitRepublic CLI to npm
Prerequisites
-
Create npm account (if you don't have one):
- Visit https://www.npmjs.com/signup
- Or run:
npm adduser
-
Login to npm:
npm loginEnter your username, password, and email.
-
Check if package name is available:
npm view gitrepublic-cliIf it returns 404, the name is available. If it shows package info, the name is taken.
Publishing Steps
1. Update version (if needed)
# Patch version (1.0.0 -> 1.0.1)
npm version patch
# Minor version (1.0.0 -> 1.1.0)
npm version minor
# Major version (1.0.0 -> 2.0.0)
npm version major
Or manually edit package.json and update the version field.
2. Verify package contents
# See what will be published
npm pack --dry-run
This shows the files that will be included (based on files field in package.json).
3. Test the package locally
# Pack the package
npm pack
# Install it locally to test
npm install -g ./gitrepublic-cli-1.0.0.tgz
# Test the commands
gitrepublic-path --credential
gitrepublic-path --hook
4. Publish to npm
cd gitrepublic-cli
npm publish
For scoped packages (if you want @your-org/gitrepublic-cli):
npm publish --access public
5. Verify publication
# Check on npm website
# Visit: https://www.npmjs.com/package/gitrepublic-cli
# Or via command line
npm view gitrepublic-cli
After Publishing
Users can now install via:
npm install -g gitrepublic-cli
Updating the Package
- Make your changes
- Update version:
npm version patch(or minor/major) - Publish:
npm publish
Important Notes
- Package name:
gitrepublic-climust be unique on npm. If taken, use a scoped name like@your-org/gitrepublic-cli - Version: Follow semantic versioning (semver)
- Files: Only files listed in
filesarray (or not in.npmignore) will be published - Unpublishing: You can unpublish within 72 hours, but it's discouraged. Use deprecation instead:
npm deprecate gitrepublic-cli@1.0.0 "Use version 1.0.1 instead"
Troubleshooting
"Package name already exists"
- The name
gitrepublic-cliis taken - Options:
- Use a scoped package: Change name to
@your-org/gitrepublic-cliin package.json - Choose a different name
- Contact the owner of the existing package
- Use a scoped package: Change name to
"You do not have permission"
- Make sure you're logged in:
npm whoami - If using scoped package, add
--access publicflag
"Invalid package name"
- Package names must be lowercase
- Can contain hyphens and underscores
- Cannot start with dot or underscore
- Max 214 characters