Publishing Guide
Detailed guide for publishing and managing versions of the WriteChoice Mint CLI package.
Prerequisites
npm Account Setup
- Create an account at npmjs.com
- Verify your email address
- Enable two-factor authentication (recommended)
npm CLI Authentication
npm login
npm whoami # verify authentication
Initial Publication
1. Prepare the Package
Verify package.json metadata:
{
"name": "@writechoice/mint-cli",
"version": "1.0.0",
"description": "CLI tool for Mintlify documentation validation and utilities",
"author": "WriteChoice",
"license": "MIT"
}
Test the package locally:
npm install
npx playwright install chromium
node bin/cli.js check links --help
npm link
writechoice --version
Check what will be published:
npm pack --dry-run
Verify that:
- Source files are included (
src/,bin/) - Test files are excluded
node_modules/is excludedREADME.md,LICENSE,package.jsonare included
2. Publish
npm publish --access public
The --access public flag is required for scoped packages on first publication.
3. Verify
npm view @writechoice/mint-cli
npm install -g @writechoice/mint-cli
writechoice --version
Publishing New Versions
Semantic Versioning
Follow SemVer:
| Change type | Version bump | Example |
|---|---|---|
| Breaking changes | MAJOR | 1.0.0 → 2.0.0 |
| New features (backwards compatible) | MINOR | 1.0.0 → 1.1.0 |
| Bug fixes | PATCH | 1.0.0 → 1.0.1 |
Version Update Workflow
1. Update Version
npm version patch # 1.0.0 → 1.0.1
npm version minor # 1.0.0 → 1.1.0
npm version major # 1.0.0 → 2.0.0
This updates package.json, creates a git commit, and creates a git tag.
2. Push Changes
git push origin main
git push origin --tags
3. Publish
npm publish
No need for --access public after first publication.
4. Verify
npm view @writechoice/mint-cli
npm install -g @writechoice/mint-cli@latest
writechoice --version
Pre-release Versions
# Create a beta version
npm version 1.1.0-beta.1
npm publish --tag beta
# Install the beta
npm install -g @writechoice/mint-cli@beta
# Promote to stable when ready
npm version 1.1.0
npm publish
npm Commands Reference
npm version # check current version
npm view @writechoice/mint-cli # view package info
npm view @writechoice/mint-cli versions # see all published versions
GitHub Actions Automation
# .github/workflows/publish.yml
name: Publish to npm
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm test
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Best Practices
- Always test before publishing — use
npm linkand test all CLI commands - Check included files — run
npm pack --dry-runbefore every publish - Follow semantic versioning — breaking changes = major, features = minor, fixes = patch
- Maintain a changelog — document all changes in
CHANGELOG.md - Use git tags —
npm versiondoes this automatically - Use pre-release versions for beta testing before stable release
- Deprecate instead of unpublish — use
npm deprecateto preserve version history
Troubleshooting
"You must be logged in to publish packages":
npm login
"You do not have permission to publish":
Check if you own the @writechoice scope on npm, or ask the scope owner to add you as a collaborator.
"Version already exists":
npm version patch # increment version