|
| 1 | +# Contributing to Apsara |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Apsara! This guide will help you understand how to contribute effectively to this project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Contributing to Apsara](#contributing-to-apsara) |
| 8 | + - [Table of Contents](#table-of-contents) |
| 9 | + - [Getting Started](#getting-started) |
| 10 | + - [Development Workflow](#development-workflow) |
| 11 | + - [Code Style Guidelines](#code-style-guidelines) |
| 12 | + - [Component Development](#component-development) |
| 13 | + - [Documentation Development](#documentation-development) |
| 14 | + - [Component Documentation Format](#component-documentation-format) |
| 15 | + - [Working with Documentation](#working-with-documentation) |
| 16 | + - [VS Code Extension Development](#vs-code-extension-development) |
| 17 | + - [Working with the VS Code Extension](#working-with-the-vs-code-extension) |
| 18 | + - [Pull Request Process](#pull-request-process) |
| 19 | + - [Pull Request Guidelines](#pull-request-guidelines) |
| 20 | + - [Commit Convention](#commit-convention) |
| 21 | + - [Release Process](#release-process) |
| 22 | + - [Release Types](#release-types) |
| 23 | + - [Creating a Release](#creating-a-release) |
| 24 | + - [For Maintainers](#for-maintainers) |
| 25 | + - [Release Workflow Details](#release-workflow-details) |
| 26 | + - [NPM Publishing](#npm-publishing) |
| 27 | + - [Getting Help](#getting-help) |
| 28 | + - [Code of Conduct](#code-of-conduct) |
| 29 | + |
| 30 | +## Getting Started |
| 31 | + |
| 32 | +Before contributing, please review our [Development Guide](./DEVELOPMENT.md) to set up your local development environment. |
| 33 | + |
| 34 | +Quick setup: |
| 35 | +```bash |
| 36 | +git clone https://github.com/raystack/apsara.git |
| 37 | +cd apsara |
| 38 | +pnpm install |
| 39 | +pnpm dev |
| 40 | +``` |
| 41 | + |
| 42 | +## Development Workflow |
| 43 | + |
| 44 | +1. **Create a feature branch**: |
| 45 | + ```bash |
| 46 | + git checkout -b feature/your-feature-name |
| 47 | + ``` |
| 48 | + |
| 49 | +2. **Start the development server**: |
| 50 | + ```bash |
| 51 | + # Start both library development and documentation site |
| 52 | + pnpm start |
| 53 | + |
| 54 | + # Or start just the library development server |
| 55 | + pnpm dev |
| 56 | + ``` |
| 57 | + |
| 58 | +3. **Make your changes** in the appropriate directories: |
| 59 | + - **Components**: `packages/raystack/` |
| 60 | + - **Documentation**: `apps/www/` |
| 61 | + |
| 62 | +4. **Test your changes**: |
| 63 | + ```bash |
| 64 | + # Run tests with Vitest |
| 65 | + pnpm test:apsara |
| 66 | + |
| 67 | + # Run tests in watch mode |
| 68 | + cd packages/raystack && pnpm test:watch |
| 69 | + |
| 70 | + # Build to ensure no build errors |
| 71 | + pnpm build |
| 72 | + ``` |
| 73 | + |
| 74 | +5. **Format your code**: |
| 75 | + ```bash |
| 76 | + pnpm format |
| 77 | + ``` |
| 78 | + |
| 79 | +6. **Commit your changes** following conventional commit format: |
| 80 | + ```bash |
| 81 | + git add . |
| 82 | + git commit -m "feat: add amazing new feature" |
| 83 | + ``` |
| 84 | + |
| 85 | +## Code Style Guidelines |
| 86 | + |
| 87 | +- Use TypeScript for all new code |
| 88 | +- Follow existing component patterns |
| 89 | +- Use Biome for code formatting: `pnpm format` |
| 90 | +- Write tests for new components and features |
| 91 | + |
| 92 | +## Component Development |
| 93 | + |
| 94 | +1. Create components in `packages/raystack/` |
| 95 | +2. Follow the existing component structure: |
| 96 | + ``` |
| 97 | + component-name/ |
| 98 | + ├── index.ts # Export barrel file |
| 99 | + ├── component-name.tsx # Main component |
| 100 | + ├── component-name.module.css # Styles |
| 101 | + └── __tests__/ # Tests |
| 102 | + └── component-name.test.tsx |
| 103 | + ``` |
| 104 | + |
| 105 | +3. Export new components from `packages/raystack/index.ts` |
| 106 | +4. Update the component documentation in `apps/www/content/docs` |
| 107 | + |
| 108 | +## Documentation Development |
| 109 | + |
| 110 | +The project includes a documentation website for the library `apps/www`: |
| 111 | + |
| 112 | +- Built with Next.js and Fumadocs |
| 113 | +- Uses MDX for component documentation |
| 114 | + |
| 115 | +### Component Documentation Format |
| 116 | + |
| 117 | +Each component folder in `apps/www/src/content/docs/` contains: |
| 118 | + |
| 119 | +``` |
| 120 | +component-name/ |
| 121 | +├── index.mdx # Main documentation with examples and usage |
| 122 | +├── props.ts # TypeScript definitions for component props |
| 123 | +└── demo.ts # Code for interactive playground and examples |
| 124 | +``` |
| 125 | + |
| 126 | +### Working with Documentation |
| 127 | + |
| 128 | +1. **Adding new component docs**: |
| 129 | + - Create a new folder in `apps/www/src/content/docs/components/` |
| 130 | + - Add `index.mdx` with component description and examples |
| 131 | + - Add `props.ts` with TypeScript prop definitions |
| 132 | + - Add `demo.ts` with interactive examples |
| 133 | + |
| 134 | +2. **Testing documentation changes**: |
| 135 | + ```bash |
| 136 | + # Start the docs site |
| 137 | + cd apps/www && pnpm dev |
| 138 | + ``` |
| 139 | + |
| 140 | +## VS Code Extension Development |
| 141 | + |
| 142 | +The project includes a VS Code extension (`packages/plugin-vscode/`) that provides: |
| 143 | + |
| 144 | +- **Autocomplete**: IntelliSense for Apsara components and design tokens |
| 145 | +- **Hover information**: Component documentation and prop details |
| 146 | +- **Snippets**: Quick component insertion |
| 147 | + |
| 148 | +### Working with the VS Code Extension |
| 149 | + |
| 150 | +1. **Development**: |
| 151 | + Use VS Code Command Palette: **"Tasks: Run Task" → "plugin-vscode: start-dev"** |
| 152 | + This starts the extension in watch mode and opens the Extension Development Host. |
| 153 | + |
| 154 | +2. **Building**: |
| 155 | + ```bash |
| 156 | + pnpm build # Build for production |
| 157 | + ``` |
| 158 | + |
| 159 | +3. **Packaging**: |
| 160 | + ```bash |
| 161 | + pnpm package # Create .vsix file for distribution |
| 162 | + ``` |
| 163 | + |
| 164 | +## Pull Request Process |
| 165 | + |
| 166 | +1. Fork the repository |
| 167 | +2. Create a feature branch |
| 168 | +3. Make your changes |
| 169 | +4. Ensure tests pass and code builds |
| 170 | +5. Format your code |
| 171 | +6. Submit a pull request with a clear description |
| 172 | + |
| 173 | +### Pull Request Guidelines |
| 174 | + |
| 175 | +- Provide a clear description of what your PR does |
| 176 | +- Include screenshots for UI changes |
| 177 | +- Link to any relevant issues |
| 178 | +- Ensure all tests pass |
| 179 | +- Follow the code style guidelines |
| 180 | + |
| 181 | +## Commit Convention |
| 182 | + |
| 183 | +Use conventional commits for better release notes: |
| 184 | + |
| 185 | +- `feat:` for new features |
| 186 | +- `fix:` for bug fixes |
| 187 | +- `docs:` for documentation changes |
| 188 | +- `style:` for formatting changes |
| 189 | +- `refactor:` for code refactoring |
| 190 | +- `test:` for adding tests |
| 191 | +- `chore:` for maintenance tasks |
| 192 | + |
| 193 | +Example: |
| 194 | +```bash |
| 195 | +git commit -m "feat: add new Button variant" |
| 196 | +git commit -m "fix: resolve tooltip positioning issue" |
| 197 | +git commit -m "docs: update component API documentation" |
| 198 | +``` |
| 199 | + |
| 200 | +## Release Process |
| 201 | + |
| 202 | +Apsara follows an automated release process using GitHub Actions and semantic versioning. |
| 203 | + |
| 204 | +### Release Types |
| 205 | + |
| 206 | +1. **Production Releases** (`v1.2.3`): |
| 207 | + - Released from the `main` branch |
| 208 | + - Published to NPM with `latest` tag |
| 209 | + - Triggered by pushing tags matching `v[0-9]+.[0-9]+.[0-9]+` |
| 210 | + |
| 211 | +2. **Release Candidates** (`v1.2.3-rc.1`): |
| 212 | + - Released from the `main` or `release/*` branch |
| 213 | + - Published to NPM with `next` tag |
| 214 | + - Triggered by pushing tags matching `v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+` |
| 215 | + |
| 216 | +### Creating a Release |
| 217 | + |
| 218 | +#### For Maintainers |
| 219 | + |
| 220 | +1. **Prepare the release**: |
| 221 | + ```bash |
| 222 | + # Ensure you're on the correct branch |
| 223 | + git checkout main # for production release |
| 224 | + # OR |
| 225 | + git checkout develop # for release candidate |
| 226 | + |
| 227 | + # Pull latest changes |
| 228 | + git pull origin main # or develop |
| 229 | + ``` |
| 230 | + |
| 231 | +2. **Create and push a tag**: |
| 232 | + ```bash |
| 233 | + # For production release |
| 234 | + git tag v1.2.3 |
| 235 | + git push origin v1.2.3 |
| 236 | + |
| 237 | + # For release candidate |
| 238 | + git tag v1.2.3-rc.1 |
| 239 | + git push origin v1.2.3-rc.1 |
| 240 | + ``` |
| 241 | + |
| 242 | +3. **GitHub Actions will automatically**: |
| 243 | + - Build the library |
| 244 | + - Run tests (if configured) |
| 245 | + - Bump the package version |
| 246 | + - Publish to NPM |
| 247 | + - Create a GitHub release with auto-generated notes |
| 248 | + |
| 249 | +### Release Workflow Details |
| 250 | + |
| 251 | +The release process includes these automated steps: |
| 252 | + |
| 253 | +1. **Checkout** the appropriate branch (`main` or `release/*`) |
| 254 | +2. **Setup** Node.js 22.x and pnpm 9.3.0 |
| 255 | +3. **Install** dependencies |
| 256 | +4. **Build** the library using `pnpm ci:build` |
| 257 | +5. **Bump version** in package.json based on the git tag |
| 258 | +6. **Publish** to NPM using `release-it` |
| 259 | +7. **Generate** GitHub release notes |
| 260 | + |
| 261 | +### NPM Publishing |
| 262 | + |
| 263 | +The library is published as `@raystack/apsara` with the following structure: |
| 264 | + |
| 265 | +```bash |
| 266 | +# Install the library |
| 267 | +npm install @raystack/apsara |
| 268 | +# or |
| 269 | +pnpm add @raystack/apsara |
| 270 | +``` |
| 271 | + |
| 272 | +## Getting Help |
| 273 | + |
| 274 | +If you encounter issues: |
| 275 | + |
| 276 | +1. Check if there are similar issues in the [GitHub Issues](https://github.com/raystack/apsara/issues) |
| 277 | +2. Look at the [documentation site](https://apsara.raystack.org) |
| 278 | +3. Review the [Development Guide](./DEVELOPMENT.md) |
| 279 | +4. Create a new issue if the problem persists |
| 280 | + |
| 281 | +## Code of Conduct |
| 282 | + |
| 283 | +By participating in this project, you agree to abide by our code of conduct. Be respectful, inclusive, and collaborative in all interactions. |
| 284 | + |
| 285 | +--- |
| 286 | + |
| 287 | +For technical setup and local development instructions, see the [Development Guide](./DEVELOPMENT.md). |
0 commit comments