Thank you for your interest in contributing to Media Kit! This document provides guidelines and instructions for contributing to this project.
- Code of Conduct
- Getting Started
- Development Workflow
- Project Structure
- Coding Standards
- Testing
- Submitting Changes
- Version Management
We are committed to providing a welcoming and inclusive environment. Please be respectful and professional in all interactions.
Before you begin, ensure you have the following installed:
- Node.js >= 18.x
- pnpm >= 8.x (required - this project uses pnpm workspaces)
- @blocklet/cli >= 1.16.29
- Git
-
Fork and Clone
git clone https://github.com/YOUR_USERNAME/image-bin.git cd image-bin -
Install Dependencies
# This will install dependencies and build shared packages make init # Or manually: pnpm install
-
Setup Blocklet Server
# Initialize in debug mode for development blocklet server init --mode=debug blocklet server start -
Start Development
cd blocklets/image-bin npm run dev
This is a pnpm workspace monorepo with the following structure:
image-bin/
βββ blocklets/
β βββ image-bin/ # Main application
βββ packages/
β βββ uploader/ # @blocklet/uploader package
β βββ uploader-server/ # @blocklet/uploader-server package
β βββ xss/ # @blocklet/xss package
βββ websites/ # Documentation sites
Root Level Commands:
# Install all dependencies
pnpm install
# Build all shared packages
pnpm run build:lib
# Lint all packages
pnpm run lint
# Fix linting issues
pnpm run lint:fix
# Update dependencies
pnpm run update:deps
# Remove all node_modules
pnpm run remove:node_modules
# Deduplicate dependencies
pnpm run deduplicateMain Blocklet Commands (run in blocklets/image-bin/):
# Start development server with blocklet dev
npm run dev
# Start API server with nodemon (development)
npm start
# Build frontend
npm run build
# Lint code
npm run lint
# Create production bundle
npm run bundle
# Bundle and deploy to Blocklet Server
npm run deploy
# Bundle and upload to Blocklet Store
npm run uploadPackage Development Commands (run in packages/*/):
# Build package
npm run build
# Start development mode (watch)
npm run dev
# Lint package
npm run lintWhen developing shared packages (@blocklet/uploader, @blocklet/uploader-server, @blocklet/xss):
- Make changes in the package directory
- Build the package:
npm run buildornpm run dev(watch mode) - The main blocklet will automatically use the updated package via pnpm workspace
Note: In development mode, Vite is configured to use source files directly via aliases, so you may not need to rebuild packages for frontend changes.
blocklets/image-bin/
βββ api/
β βββ index.js # Express app entry
β βββ routes/ # API route handlers
β βββ store/ # Database models and migrations
β βββ libs/ # Utility libraries
β βββ hooks/ # Blocklet lifecycle hooks
βββ src/
β βββ app.jsx # React app entry
β βββ pages/ # Route components
β βββ components/ # React components
β βββ contexts/ # React contexts
β βββ libs/ # Frontend utilities
β βββ locales/ # Internationalization
βββ blocklet.yml # Blocklet configuration
βββ blocklet.prefs.json # User preferences schema
βββ vite.config.mjs # Vite configuration
packages/uploader/: React components for file uploads using Uppypackages/uploader-server/: Express middleware for handling uploads via @tus/serverpackages/xss/: XSS protection utilities for sanitizing SVG and other content
- JavaScript/JSX: Follow @arcblock/eslint-config
- Formatting: Use Prettier (configured in
.prettierrc) - Git Hooks: Husky runs linting and formatting on commit
-
React Components
- Use functional components with hooks
- Implement proper error boundaries
- Use lazy loading for route components
- Follow Material-UI (MUI) patterns
-
API Development
- Use async/await with proper error handling
- Implement middleware for reusable logic
- Validate all user inputs
- Use Sequelize ORM for database operations
-
Security
- Sanitize all user-generated content (especially SVG)
- Validate file paths to prevent directory traversal
- Use CSRF protection for state-changing operations
- Remove EXIF metadata from uploaded images
-
Performance
- Implement pagination for large datasets
- Use LRU cache for frequently accessed data
- Optimize images and media automatically
- Use streaming for file operations
- React Components:
kebab-case.jsx(e.g.,media-item.jsx) - Utility Files:
kebab-case.js(e.g.,file-utils.js) - API Routes:
kebab-case.js(e.g.,upload.js) - Database Migrations:
YYYYMMDDHHMM-description.js(e.g.,2025060401-genesis.js)
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage- Write unit tests for utility functions
- Write integration tests for API endpoints
- Write component tests for React components
- Aim for at least 80% code coverage
-
Create a Branch
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix -
Make Changes
- Follow coding standards
- Write meaningful commit messages
- Add tests for new features
- Update documentation
-
Commit Changes
git add . git commit -m "feat: add new feature" # or git commit -m "fix: resolve issue with..."
-
Push to GitHub
git push origin feature/your-feature-name
-
Open Pull Request
- Go to GitHub and create a pull request
- Fill out the PR template
- Link related issues
- Request review from maintainers
Follow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
feat(upload): add AI image generation support
fix(security): enhance XSS filtering with recursive sanitization
docs(readme): update installation instructions
chore(deps): upgrade @aigne/aigne-hub dependency
- Title: Use conventional commit format
- Description: Clearly describe what and why
- Screenshots: Include for UI changes
- Breaking Changes: Clearly document any breaking changes
- Tests: Ensure all tests pass
- Linting: Ensure code passes linting
- Documentation: Update relevant documentation
# Bump version across all packages
npm run bump-versionThis script will:
- Prompt you for the new version
- Update version in all
package.jsonfiles - Update version in
blocklet.yml - Create a git tag
- Update changelog
We follow Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
-
Update Version
npm run bump-version
-
Update Changelog
- Add release notes to
CHANGELOG.md - Document breaking changes, new features, and bug fixes
- Add release notes to
-
Create Release
- Tag the commit
- Push tags:
git push --tags - Create GitHub release with changelog
-
Publish to Blocklet Store
cd blocklets/image-bin npm run upload
- π¬ Community Forum - Ask questions
- π§ Email: blocklet@arcblock.io
- π GitHub Issues - Report bugs
- π Documentation - Read the docs
By contributing to Media Kit, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to Media Kit! π