|
| 1 | +# Publishing Guide |
| 2 | + |
| 3 | +Complete guide for publishing `@jpisnice/shadcn-ui-mcp-server` to npm. |
| 4 | + |
| 5 | +## 🎯 Quick Start |
| 6 | + |
| 7 | +### Publish New Version (Recommended) |
| 8 | + |
| 9 | +```bash |
| 10 | +# 1. Bump version |
| 11 | +npm run version:patch # or minor/major |
| 12 | + |
| 13 | +# 2. Publish with automated checks |
| 14 | +npm run publish:auto |
| 15 | +``` |
| 16 | + |
| 17 | +### Quick Publish (Skip Tests) |
| 18 | + |
| 19 | +```bash |
| 20 | +npm run publish:quick |
| 21 | +``` |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 📦 Current Package Status |
| 26 | + |
| 27 | +- **Package**: `@jpisnice/shadcn-ui-mcp-server` |
| 28 | +- **Current Version**: `1.1.4` |
| 29 | +- **Registry**: https://registry.npmjs.org/ |
| 30 | +- **Access**: Public |
| 31 | +- **NPM Page**: https://www.npmjs.com/package/@jpisnice/shadcn-ui-mcp-server |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## 🛠️ Available Commands |
| 36 | + |
| 37 | +### Version Management |
| 38 | + |
| 39 | +```bash |
| 40 | +npm run version:patch # 1.1.4 → 1.1.5 (bug fixes) |
| 41 | +npm run version:minor # 1.1.4 → 1.2.0 (new features) |
| 42 | +npm run version:major # 1.1.4 → 2.0.0 (breaking changes) |
| 43 | +``` |
| 44 | + |
| 45 | +### Publishing |
| 46 | + |
| 47 | +```bash |
| 48 | +npm run publish:auto # Full automation with checks |
| 49 | +npm run publish:quick # Skip tests, auto-confirm |
| 50 | +npm publish --access public # Manual (runs prepublishOnly) |
| 51 | +``` |
| 52 | + |
| 53 | +### Security & Testing |
| 54 | + |
| 55 | +```bash |
| 56 | +npm run security:all # All security checks |
| 57 | +npm run security:audit # npm audit only |
| 58 | +npm run security:licenses # License compliance |
| 59 | +npm run test # Run package tests |
| 60 | +``` |
| 61 | + |
| 62 | +### Build |
| 63 | + |
| 64 | +```bash |
| 65 | +npm run clean # Remove build directory |
| 66 | +npm run build # Compile TypeScript |
| 67 | +npm run dev # Build and run |
| 68 | +``` |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## 🔒 Security Features |
| 73 | + |
| 74 | +### Automated Security Checks |
| 75 | + |
| 76 | +✅ **npm audit** - Vulnerability scanning |
| 77 | +✅ **license-checker** - License compliance |
| 78 | +✅ **Snyk** - Deep security analysis (optional) |
| 79 | +✅ **0 vulnerabilities** in current dependencies |
| 80 | + |
| 81 | +### Pre-publish Validation |
| 82 | + |
| 83 | +The `prepublishOnly` hook automatically runs: |
| 84 | +1. Security audit |
| 85 | +2. License check |
| 86 | +3. Package tests |
| 87 | +4. Clean build |
| 88 | +5. TypeScript compilation |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 📋 Publishing Workflow |
| 93 | + |
| 94 | +### Complete Workflow |
| 95 | + |
| 96 | +```bash |
| 97 | +# 1. Make your changes |
| 98 | +# ... edit files ... |
| 99 | + |
| 100 | +# 2. Test locally |
| 101 | +npm run build |
| 102 | +npm run test |
| 103 | + |
| 104 | +# 3. Bump version |
| 105 | +npm run version:patch |
| 106 | + |
| 107 | +# 4. Publish |
| 108 | +npm run publish:auto |
| 109 | + |
| 110 | +# 5. Push git tags (optional) |
| 111 | +git push --tags |
| 112 | +``` |
| 113 | + |
| 114 | +### What Happens During Publishing |
| 115 | + |
| 116 | +1. ✅ **Project validation** - Verifies package.json exists |
| 117 | +2. ✅ **Authentication check** - Confirms npm login |
| 118 | +3. ✅ **Security scan** - Runs npm audit + license check |
| 119 | +4. ✅ **Package tests** - Validates functionality |
| 120 | +5. ✅ **Clean build** - Removes old files, compiles TypeScript |
| 121 | +6. ✅ **Build verification** - Checks required files exist |
| 122 | +7. ✅ **Package validation** - Tests npm pack |
| 123 | +8. ✅ **Publishing summary** - Shows what will be published |
| 124 | +9. ✅ **User confirmation** - Asks for approval (unless -Force) |
| 125 | +10. ✅ **npm publish** - Publishes to registry |
| 126 | +11. ✅ **Success message** - Shows package URL |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## 🎨 Publishing Options |
| 131 | + |
| 132 | +### Standard Publish (Recommended) |
| 133 | + |
| 134 | +For production releases with full validation: |
| 135 | + |
| 136 | +```bash |
| 137 | +npm run publish:auto |
| 138 | +``` |
| 139 | + |
| 140 | +**Includes:** |
| 141 | +- ✅ Security checks |
| 142 | +- ✅ Package tests |
| 143 | +- ✅ Build verification |
| 144 | +- ✅ User confirmation prompt |
| 145 | + |
| 146 | +### Quick Publish |
| 147 | + |
| 148 | +For urgent fixes or documentation updates: |
| 149 | + |
| 150 | +```bash |
| 151 | +npm run publish:quick |
| 152 | +``` |
| 153 | + |
| 154 | +**Skips:** |
| 155 | +- ⏭️ Package tests |
| 156 | +- ⏭️ User confirmation |
| 157 | + |
| 158 | +**Still runs:** |
| 159 | +- ✅ Security checks |
| 160 | +- ✅ Build verification |
| 161 | + |
| 162 | +### Manual Publish |
| 163 | + |
| 164 | +For advanced users or CI/CD: |
| 165 | + |
| 166 | +```bash |
| 167 | +npm publish --access public |
| 168 | +``` |
| 169 | + |
| 170 | +**Note:** This still runs the `prepublishOnly` hook which includes all checks. |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## 🐛 Troubleshooting |
| 175 | + |
| 176 | +### Error: "Not logged in to npm" |
| 177 | + |
| 178 | +**Solution:** |
| 179 | +```bash |
| 180 | +npm login |
| 181 | +``` |
| 182 | + |
| 183 | +### Error: "Package version already exists" |
| 184 | + |
| 185 | +**Solution:** |
| 186 | +```bash |
| 187 | +# Bump version first |
| 188 | +npm run version:patch |
| 189 | + |
| 190 | +# Then publish |
| 191 | +npm run publish:auto |
| 192 | +``` |
| 193 | + |
| 194 | +### Error: "Tests failed" |
| 195 | + |
| 196 | +**Solutions:** |
| 197 | +1. Fix the tests: |
| 198 | + ```bash |
| 199 | + npm run test # See what's failing |
| 200 | + ``` |
| 201 | + |
| 202 | +2. Skip tests (if safe): |
| 203 | + ```bash |
| 204 | + npm run publish:quick |
| 205 | + ``` |
| 206 | + |
| 207 | +### Error: "Build failed" |
| 208 | + |
| 209 | +**Solution:** |
| 210 | +```bash |
| 211 | +# Clean and rebuild |
| 212 | +npm run clean |
| 213 | +npm run build |
| 214 | + |
| 215 | +# Check for TypeScript errors |
| 216 | +tsc --noEmit |
| 217 | +``` |
| 218 | + |
| 219 | +### Error: "Security vulnerabilities found" |
| 220 | + |
| 221 | +**Solution:** |
| 222 | +```bash |
| 223 | +# Check details |
| 224 | +npm audit |
| 225 | + |
| 226 | +# Fix automatically (if possible) |
| 227 | +npm audit fix |
| 228 | + |
| 229 | +# Or fix manually |
| 230 | +npm update [package-name] |
| 231 | +``` |
| 232 | + |
| 233 | +--- |
| 234 | + |
| 235 | +## 📚 Version Numbering |
| 236 | + |
| 237 | +We follow [Semantic Versioning](https://semver.org/): |
| 238 | + |
| 239 | +### MAJOR.MINOR.PATCH (e.g., 1.1.4) |
| 240 | + |
| 241 | +- **MAJOR** (1.x.x) - Breaking changes |
| 242 | + - API changes |
| 243 | + - Removed features |
| 244 | + - Incompatible updates |
| 245 | + |
| 246 | +- **MINOR** (x.1.x) - New features |
| 247 | + - New functionality |
| 248 | + - Backwards compatible |
| 249 | + - Deprecations |
| 250 | + |
| 251 | +- **PATCH** (x.x.4) - Bug fixes |
| 252 | + - Bug fixes |
| 253 | + - Performance improvements |
| 254 | + - Documentation updates |
| 255 | + |
| 256 | +### Examples |
| 257 | + |
| 258 | +```bash |
| 259 | +# Bug fix: 1.1.4 → 1.1.5 |
| 260 | +npm run version:patch |
| 261 | + |
| 262 | +# New feature: 1.1.4 → 1.2.0 |
| 263 | +npm run version:minor |
| 264 | + |
| 265 | +# Breaking change: 1.1.4 → 2.0.0 |
| 266 | +npm run version:major |
| 267 | +``` |
| 268 | + |
| 269 | +--- |
| 270 | + |
| 271 | +## 🎯 Best Practices |
| 272 | + |
| 273 | +1. **Always test before publishing** |
| 274 | + ```bash |
| 275 | + npm run test |
| 276 | + npm run build |
| 277 | + ``` |
| 278 | + |
| 279 | +2. **Use appropriate version bumps** |
| 280 | + - Bug fixes = patch |
| 281 | + - New features = minor |
| 282 | + - Breaking changes = major |
| 283 | + |
| 284 | +3. **Review security audits** |
| 285 | + ```bash |
| 286 | + npm audit |
| 287 | + ``` |
| 288 | + |
| 289 | +4. **Keep dependencies updated** |
| 290 | + ```bash |
| 291 | + npm update |
| 292 | + npm audit fix |
| 293 | + ``` |
| 294 | + |
| 295 | +5. **Document changes** |
| 296 | + - Update README.md for user-facing changes |
| 297 | + - Update comments for code changes |
| 298 | + |
| 299 | +6. **Push git tags** |
| 300 | + ```bash |
| 301 | + git push --tags |
| 302 | + ``` |
| 303 | + |
| 304 | +--- |
| 305 | + |
| 306 | +## 📝 Files & Scripts |
| 307 | + |
| 308 | +### Publishing Scripts |
| 309 | + |
| 310 | +- `scripts/publish.ps1` - Main publishing automation (Windows) |
| 311 | +- `scripts/bump-version.js` - Version management |
| 312 | +- `scripts/README.md` - Detailed script documentation |
| 313 | + |
| 314 | +### Configuration Files |
| 315 | + |
| 316 | +- `package.json` - Package metadata and scripts |
| 317 | +- `.npmignore` - Files excluded from npm package |
| 318 | +- `tsconfig.json` - TypeScript configuration |
| 319 | + |
| 320 | +### Test Files |
| 321 | + |
| 322 | +- `test-package.ps1` - Windows PowerShell tests |
| 323 | +- `test-package.sh` - Bash tests (for reference) |
| 324 | + |
| 325 | +--- |
| 326 | + |
| 327 | +## 🔗 Useful Links |
| 328 | + |
| 329 | +- **NPM Package**: https://www.npmjs.com/package/@jpisnice/shadcn-ui-mcp-server |
| 330 | +- **GitHub Repo**: https://github.com/Jpisnice/shadcn-ui-mcp-server |
| 331 | +- **npm Documentation**: https://docs.npmjs.com/ |
| 332 | +- **Semantic Versioning**: https://semver.org/ |
| 333 | +- **Security Best Practices**: https://docs.npmjs.com/packages-and-modules/securing-your-code |
| 334 | + |
| 335 | +--- |
| 336 | + |
| 337 | +## ✅ Checklist Before Publishing |
| 338 | + |
| 339 | +- [ ] All changes committed to git |
| 340 | +- [ ] Tests passing (`npm run test`) |
| 341 | +- [ ] Build successful (`npm run build`) |
| 342 | +- [ ] Security audit clean (`npm audit`) |
| 343 | +- [ ] Version bumped (`npm run version:*`) |
| 344 | +- [ ] README.md updated (if needed) |
| 345 | +- [ ] Ready to publish (`npm run publish:auto`) |
| 346 | + |
| 347 | +--- |
| 348 | + |
| 349 | +## 📊 Package Statistics |
| 350 | + |
| 351 | +- **Size**: 46.7 kB (packaged) |
| 352 | +- **Unpacked Size**: 249.5 kB |
| 353 | +- **Files**: 35 |
| 354 | +- **Dependencies**: 8 production, 4 dev |
| 355 | +- **Node Version**: ≥18.0.0 |
| 356 | +- **License**: MIT |
| 357 | + |
| 358 | +--- |
| 359 | + |
| 360 | +**Happy Publishing! 🚀** |
| 361 | + |
0 commit comments