Skip to content

Commit addc754

Browse files
committed
feat: Add publishing script
1 parent 01bd2e0 commit addc754

File tree

3 files changed

+625
-2
lines changed

3 files changed

+625
-2
lines changed

PUBLISHING.md

Lines changed: 338 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,338 @@
1+
# Publishing Plugins to Codify Registry
2+
3+
This guide explains how to publish your Codify plugin to the public registry at [codifycli.com/registry](https://codifycli.com/registry).
4+
5+
## Prerequisites
6+
7+
1. **Build your plugin** - Your plugin must be built and have a `dist/` folder with:
8+
- `index.js` - Bundled plugin code
9+
- `manifest.json` - Plugin metadata
10+
- `schemas.json` - Resource schemas
11+
12+
2. **Authentication** - You need an API token stored in `~/.codify/credentials.json`:
13+
```json
14+
{
15+
"apiToken": "your-token-here"
16+
}
17+
```
18+
19+
Get a token by running `codify login` (CLI command) or manually creating the file.
20+
21+
3. **Package.json metadata** - Ensure your `package.json` has:
22+
```json
23+
{
24+
"name": "@your-org/plugin-name",
25+
"version": "1.0.0",
26+
"description": "Clear description of what your plugin does",
27+
"repository": {
28+
"type": "git",
29+
"url": "https://github.com/your-org/plugin-name"
30+
},
31+
"license": "MIT",
32+
"keywords": ["codify", "plugin", "your", "tags"],
33+
"homepage": "https://your-plugin-website.com"
34+
}
35+
```
36+
37+
## Publishing Workflow
38+
39+
### 1. Build Your Plugin
40+
41+
```bash
42+
npm run build
43+
```
44+
45+
This runs `bin/build.js` which:
46+
- Bundles your plugin with Rollup
47+
- Generates `dist/manifest.json` with plugin metadata
48+
- Generates `dist/schemas.json` with resource schemas
49+
- Copies documentation from `src/resources/*/README.md` to `dist/documentation/`
50+
51+
### 2. Run the Publish Wizard
52+
53+
```bash
54+
npm run publish-plugin
55+
```
56+
57+
Or using the global command:
58+
59+
```bash
60+
npx codify-publish
61+
```
62+
63+
The interactive wizard will:
64+
65+
1. **Verify build artifacts** - Checks for `dist/index.js` and `dist/manifest.json`
66+
2. **Suggest version bump** - Offers patch/minor/major or custom version
67+
3. **Collect keywords** - Optional tags for searchability
68+
4. **Collect categories** - Tags like "developer-tools", "productivity", etc.
69+
5. **Scan README** - Includes `README.md` if present
70+
6. **Scan /docs folder** - Includes all `.md` and `.mdx` files from `/docs`
71+
7. **Show summary** - Reviews all metadata before publishing
72+
8. **Confirm publish** - Final confirmation before upload
73+
74+
### 3. Upload to Registry
75+
76+
The wizard uploads:
77+
- `manifest` (JSON) - Plugin metadata
78+
- `source` (File) - `dist/index.js` bundle
79+
- `readme` (File) - `README.md` (optional)
80+
- `/documentation/*` (Files) - All docs from `/docs` folder (optional)
81+
82+
The API endpoint validates:
83+
- Semantic versioning (must be > latest version)
84+
- Reserved plugin names (e.g., "core", "official", "codify")
85+
- Manifest schema
86+
- Computes SHA256 checksum of bundle
87+
88+
## Documentation Structure
89+
90+
### README.md (Plugin-Level)
91+
92+
Place a `README.md` in your plugin root:
93+
94+
```
95+
my-plugin/
96+
├── README.md # Plugin overview, installation, usage
97+
├── package.json
98+
├── src/
99+
└── docs/ # Optional: Additional documentation
100+
```
101+
102+
This README is displayed on the plugin's main page in the registry.
103+
104+
### Resource Documentation
105+
106+
Resource-specific docs go in `src/resources/{resource-type}/README.md`:
107+
108+
```
109+
src/
110+
└── resources/
111+
├── homebrew/
112+
│ └── README.md # Homebrew resource docs
113+
├── git/
114+
│ └── README.md # Git resource docs
115+
└── python/
116+
└── README.md # Python resource docs
117+
```
118+
119+
These are automatically copied to `dist/documentation/` during build and uploaded to R2.
120+
121+
### /docs Folder (Fumadocs Integration)
122+
123+
For comprehensive documentation with navigation, create a `/docs` folder:
124+
125+
```
126+
docs/
127+
├── index.mdx # Overview
128+
├── getting-started.mdx
129+
├── resources/
130+
│ ├── homebrew.mdx
131+
│ ├── git.mdx
132+
│ └── python.mdx
133+
└── examples/
134+
├── basic.mdx
135+
└── advanced.mdx
136+
```
137+
138+
All `.md` and `.mdx` files are uploaded and rendered on the registry using Fumadocs.
139+
140+
**Frontmatter example:**
141+
```mdx
142+
---
143+
title: Homebrew Resource
144+
description: Manage Homebrew formulas with Codify
145+
---
146+
147+
# Homebrew Resource
148+
149+
The Homebrew resource allows you to...
150+
```
151+
152+
## Versioning
153+
154+
Follow [Semantic Versioning](https://semver.org/):
155+
156+
- **Patch (1.0.1)** - Bug fixes, documentation updates
157+
- **Minor (1.1.0)** - New resources, backward-compatible features
158+
- **Major (2.0.0)** - Breaking changes to resource schemas or behavior
159+
160+
### Pre-release Versions
161+
162+
Use suffixes for pre-releases:
163+
- `1.0.0-alpha.1` - Early testing
164+
- `1.0.0-beta.1` - Feature complete, testing
165+
- `1.0.0-rc.1` - Release candidate
166+
167+
Pre-release versions are automatically detected (via regex: `version ~ '-'`) and marked in the database.
168+
169+
## Metadata Fields
170+
171+
### Manifest Structure
172+
173+
```json
174+
{
175+
"name": "@your-org/plugin-name",
176+
"version": "1.0.0",
177+
"description": "Plugin description",
178+
"displayName": "Your Plugin Name",
179+
"homepage": "https://plugin-website.com",
180+
"repository": "https://github.com/your-org/plugin-name",
181+
"license": "MIT",
182+
"keywords": ["codify", "plugin", "homebrew"],
183+
"tags": ["developer-tools", "productivity"],
184+
"resources": [
185+
{
186+
"type": "homebrew",
187+
"description": "Manage Homebrew formulas",
188+
"schema": { ... },
189+
"documentationKey": "homebrew"
190+
}
191+
]
192+
}
193+
```
194+
195+
### Keywords vs Tags
196+
197+
- **Keywords** - Free-form search terms (from `package.json`)
198+
- **Tags** - Predefined categories for filtering:
199+
- `developer-tools`
200+
- `productivity`
201+
- `devops`
202+
- `security`
203+
- `web-dev`
204+
- `data-science`
205+
206+
## Best Practices
207+
208+
### 1. Comprehensive README
209+
210+
Include:
211+
- Clear description of what the plugin does
212+
- Installation instructions
213+
- Configuration examples
214+
- List of resources provided
215+
- System requirements (OS, dependencies)
216+
217+
### 2. Resource Documentation
218+
219+
Each resource should have:
220+
- Description of what it manages
221+
- Configuration schema reference
222+
- Example configurations
223+
- Common use cases
224+
- Troubleshooting tips
225+
226+
### 3. Version Changelog
227+
228+
Maintain a `CHANGELOG.md`:
229+
230+
```markdown
231+
# Changelog
232+
233+
## [1.1.0] - 2025-03-24
234+
### Added
235+
- New Python resource for managing Python versions
236+
237+
### Fixed
238+
- Homebrew formula installation on macOS 14+
239+
240+
## [1.0.0] - 2025-03-01
241+
- Initial release
242+
```
243+
244+
### 4. Testing Before Publishing
245+
246+
1. **Build locally**: `npm run build`
247+
2. **Test plugin**: Use it in a real Codify project
248+
3. **Validate schemas**: Ensure resources validate correctly
249+
4. **Check documentation**: Review generated docs in `dist/documentation/`
250+
251+
### 5. Keywords for Discoverability
252+
253+
Choose keywords that users would search for:
254+
- Technology names: "homebrew", "git", "docker"
255+
- Use cases: "development", "automation", "devops"
256+
- Platforms: "macos", "linux"
257+
258+
## Troubleshooting
259+
260+
### "Plugin name is reserved"
261+
262+
Some names are reserved: `core`, `official`, `codify`, `default`, `admin`, `api`, `docs`, `registry`, `system`, `internal`.
263+
264+
Choose a different name or prefix with your organization (e.g., `@myorg/core`).
265+
266+
### "Version not greater than latest"
267+
268+
Your version must be semantically greater than the latest published version. Check the registry for the current version and bump accordingly.
269+
270+
### "Invalid manifest"
271+
272+
Ensure your manifest follows the schema:
273+
- `name` (string, required)
274+
- `version` (string, semver, required)
275+
- `resources` (array, required)
276+
- Each resource must have `type` and `schema`
277+
278+
### "No API token found"
279+
280+
Create `~/.codify/credentials.json`:
281+
282+
```json
283+
{
284+
"apiToken": "your-token-here"
285+
}
286+
```
287+
288+
Or run `codify login` to authenticate.
289+
290+
## Registry URLs
291+
292+
After publishing, your plugin will be available at:
293+
294+
- **Main page**: `https://codifycli.com/registry/{plugin-name}`
295+
- **Specific version**: `https://codifycli.com/registry/{plugin-name}/{version}`
296+
- **Documentation**: `https://codifycli.com/registry/{plugin-name}/docs`
297+
- **Download URL**: `https://plugins.codifycli.com/{name}/{version}/index.js`
298+
299+
## Example: Publishing Workflow
300+
301+
```bash
302+
# 1. Make changes to your plugin
303+
vim src/resources/my-resource/index.ts
304+
305+
# 2. Update tests
306+
npm test
307+
308+
# 3. Build
309+
npm run build
310+
311+
# 4. Publish (interactive)
312+
npm run publish-plugin
313+
314+
# Output:
315+
# 🚀 Codify Plugin Publisher
316+
# 📦 Plugin: @myorg/my-plugin
317+
# 📄 Description: My awesome plugin
318+
# 🔖 Current version in manifest: 1.0.0
319+
#
320+
# 📌 Suggested versions:
321+
# 1. Patch (1.0.1) - Bug fixes, minor changes
322+
# 2. Minor (1.1.0) - New features, backward compatible
323+
# 3. Major (2.0.0) - Breaking changes
324+
# 4. Custom version
325+
#
326+
# 🔢 Select version increment (1-4): 2
327+
# ✅ Publishing version: 1.1.0
328+
# ...
329+
# ✅ Successfully published!
330+
# 🔗 View at: https://codifycli.com/registry/@myorg/my-plugin
331+
```
332+
333+
## Support
334+
335+
For issues or questions:
336+
- GitHub: [github.com/codifycli/codify](https://github.com/codifycli/codify)
337+
- Discord: [discord.gg/codify](https://discord.gg/codify)
338+
- Docs: [codifycli.com/docs/publishing-plugins](https://codifycli.com/docs/publishing-plugins)

0 commit comments

Comments
 (0)