This guide covers how to publish the CLI to npm, update the component registry, and how developers use the CLI.
This is how developers will use your published CLI:
npx @replyke/cli initThis prompts them to choose:
- Platform: React (Web), React Native, or Expo
- Style: Inline Styles or Tailwind CSS
- Component path: Where to install components (default:
src/components)
Creates a replyke.json config file:
{
"platform": "react",
"style": "tailwind",
"typescript": true,
"paths": {
"components": "src/components"
},
"aliases": {
"@/components": "./src/components"
}
}# Install threaded comments (Reddit-style)
npx @replyke/cli add comments-threaded
# Install social comments (Instagram-style)
npx @replyke/cli add comments-socialimport ThreadedCommentSection from './components/threaded-comment-section';
function App() {
return (
<ThreadedCommentSection
entityId="post-123"
theme="dark"
/>
);
}Developers can modify the component files directly - that's the whole point of this approach!
-
Make sure you're logged in to npm:
npm login
Use your npm account credentials.
-
Verify your npm account has access to the @replyke scope:
- If not, you need to create the scope on npmjs.com first
-
Update the version in package.json:
cd packages/cli # Edit package.json and bump the version (e.g., 0.1.0 -> 0.1.1)
-
Build the CLI:
pnpm build
This creates the
dist/folder with compiled code. -
Test locally before publishing (optional but recommended):
# In the CLI directory pnpm link --global # Then in any test project replyke add comments-social # When done testing, unlink pnpm unlink --global
-
Publish to npm:
# Make sure you're in packages/cli npm publishIf this is the first time publishing, you might need:
npm publish --access public
-
Verify it worked:
npm view @replyke/cli
The registry files are hosted on GitHub and fetched by the CLI. When you add/update components:
Create/update files in:
registry/
├── react/
│ ├── comments-social/
│ │ └── styled/
│ │ ├── files/ (component files)
│ │ ├── hooks/
│ │ ├── context/
│ │ ├── utils/
│ │ └── registry.json
│ └── comments-threaded/
│ └── styled/
│ └── ...
For each component, make sure registry.json has:
- Correct
registryUrlpointing to:https://raw.githubusercontent.com/replyke/cli/main/registry/react/{component-name}/styled - All files listed in the
filesarray - Correct dependencies
# From repo root
git add registry/
git commit -m "Add/update {component-name} components"
git push origin mainImportant: The CLI fetches from the main branch on GitHub, so make sure you push to main.
After pushing, test that the CLI can fetch the components:
# In a test project
npx @replyke/cli add comments-social
# Or if testing locally:
npx @replyke/cli add comments-social --registry https://raw.githubusercontent.com/replyke/cli/main/registryWhen you update both CLI and components:
- Update components in registry/
- Update CLI code if needed (packages/cli/src/)
- Bump CLI version in packages/cli/package.json
- Build CLI:
cd packages/cli pnpm build - Commit everything:
git add . git commit -m "Release v0.1.x: Description of changes" git push origin main
- Publish CLI to npm:
cd packages/cli npm publish
# 1. Push registry to GitHub
git add registry/
git commit -m "Update components"
git push origin main
# 2. In a test project, use current published CLI
npx @replyke/cli@latest add comments-social# 1. Build CLI
cd packages/cli
pnpm build
# 2. Link it globally
pnpm link --global
# 3. Test in another project
cd /path/to/test-project
replyke add comments-social
# 4. Unlink when done
cd /path/to/cli/packages/cli
pnpm unlink --globalFollow semantic versioning (semver):
- Patch (0.1.0 → 0.1.1): Bug fixes, minor updates
- Minor (0.1.0 → 0.2.0): New features, backward compatible
- Major (0.1.0 → 1.0.0): Breaking changes
- Make sure you're logged in:
npm whoami - Verify scope access on npmjs.com
- Try:
npm publish --access public
- Verify registry URL in registry.json is correct
- Check that files are pushed to GitHub main branch
- Test URL manually:
curl https://raw.githubusercontent.com/replyke/cli/main/registry/react/comments-social/styled/registry.json
- Check all file paths in registry.json match actual file structure
- Verify imports in components use correct relative paths
- Test in a fresh project after installing
# Build CLI
cd packages/cli && pnpm build
# Publish CLI
npm publish
# Add registry files to git
git add registry/
# Commit and push
git commit -m "Update components"
git push origin main
# Test CLI locally
pnpm link --global
# View published package
npm view @replyke/cli