Detailed guide for publishing and managing versions of the WriteChoice Mint CLI package.
- Create an account at npmjs.com
- Verify your email address
- Enable two-factor authentication (recommended)
npm loginEnter your credentials:
- Username
- Password
- (If 2FA is enabled) One-time password
Verify authentication:
npm whoami-
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", "repository": { "type": "git", "url": "https://github.com/writechoice/mint-cli.git" } } -
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
Ensure:
- Source files included (
src/,bin/) - Test files excluded
node_modules/excludedREADME.md,LICENSE,package.jsonincluded
- Source files included (
npm publish --access publicThe --access public flag is required for scoped packages the first time.
- Check on npm: https://www.npmjs.com/package/@writechoice/mint-cli
- Test installation:
npm install -g @writechoice/mint-cli writechoice --version
Follow SemVer:
- MAJOR (1.0.0 → 2.0.0): Breaking changes
- MINOR (1.0.0 → 1.1.0): New features, backwards compatible
- PATCH (1.0.0 → 1.0.1): Bug fixes, backwards compatible
git checkout -b feature/new-feature
# ... make changes ...
git add .
git commit -m "Add new feature"Use npm's version command (updates package.json and creates git tag):
# Patch (bug fixes)
npm version patch # 1.0.0 → 1.0.1
# Minor (new features)
npm version minor # 1.0.0 → 1.1.0
# Major (breaking changes)
npm version major # 1.0.0 → 2.0.0
# Or specify exact version
npm version 1.2.3This command:
- Updates
package.jsonversion - Creates a git commit with the version change
- Creates a git tag (e.g.,
v1.0.1)
Create or update CHANGELOG.md:
# Changelog
## [1.1.0] - 2024-01-20
### Added
- New MDX parsing validation command
- CI/CD integration examples
### Fixed
- Fixed anchor parsing for special characters
- Improved error messages
### Changed
- Updated default concurrency to 30
## [1.0.0] - 2024-01-15
### Initial Release
- Link validation for MDX files
- Auto-fix for incorrect anchors
- Browser automation with Playwrightnpm link
writechoice --version
npm test
# Test with real documentation
writechoice check parse
writechoice check links docs.example.com --dry-rungit push origin main
git push origin --tagsnpm publishNo need for --access public after first publication.
npm view @writechoice/mint-cli
npm install -g @writechoice/mint-cli@latest
writechoice --versionFor testing before stable release:
npm version 1.1.0-beta.1
npm publish --tag beta# Specific beta version
npm install -g @writechoice/mint-cli@1.1.0-beta.1
# Latest beta
npm install -g @writechoice/mint-cli@betanpm version 1.1.0
npm publish# Check current version
npm version
# View package info
npm view @writechoice/mint-cli
# View all published versions
npm view @writechoice/mint-cli versions
# Deprecate a version (recommended over unpublish)
npm deprecate @writechoice/mint-cli@1.0.0 "Please upgrade to 1.0.1"
# Add dist-tag
npm dist-tag add @writechoice/mint-cli@1.1.0-beta.1 beta
# Publish with tag
npm publish --tag beta
# Unpublish (within 72 hours, use carefully!)
npm unpublish @writechoice/mint-cli@1.0.1Automate releases with GitHub Actions:
# .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 }}npm login- Check if you own the
@writechoicescope on npm - Ask the scope owner to add you as a collaborator
- Choose a different name or scope
- Or request ownership of abandoned package
# Increment version again
npm version patch
# Or specify new version
npm version 1.0.2-
Always test before publishing
- Link locally with
npm link - Test all CLI commands
- Check included files with
npm pack --dry-run
- Link locally with
-
Follow semantic versioning
- Breaking changes = major version
- New features = minor version
- Bug fixes = patch version
-
Maintain a changelog
- Document all changes
- Make it easy for users to see what's new
-
Use git tags
- Tag each release with
v{version} npm versiondoes this automatically
- Tag each release with
-
Test installations
- Install the published package globally
- Verify it works as expected
-
Use prerelease versions
- Beta test with
1.0.0-beta.1before stable release - Use tags:
npm publish --tag beta
- Beta test with
-
Document breaking changes
- Clearly indicate breaking changes in changelog
- Consider migration guides for major versions
-
Deprecate old versions
- Use
npm deprecateinstead of unpublishing - Provide upgrade instructions
- Use