Thank you for your interest in contributing to NativeCN! This document provides guidelines and instructions for contributing to this open-source project.
- Code of Conduct
- Development Setup
- Project Structure
- Development Workflow
- Adding New Components
- Pull Request Process
- Coding Style
- Commit Message Guidelines
- Documentation
- Releasing
Please read and follow our Code of Conduct to foster an inclusive and respectful community.
- Node.js (v18 or higher)
- npm (v8 or higher)
- A React Native development environment
- Clone the repository
git clone https://github.com/tailwiinder/nativecn.git
cd nativecn- Install dependencies
npm install- Build all packages
npm run build- Link the CLI for local development
# Link the package globally
npm link
# Now you can run the CLI locally
npx @nativecn/cli init
npx @nativecn/cli add button- Alternatively, link individual packages
npm link @nativecn/cli- Start development mode (watches for changes and rebuilds)
npm run devThe project is organized as a monorepo using npm workspaces:
packages/cli: Command-line interface for managing NativeCN componentspackages/lib: Utility functions and common codeexamples/: Example applications for testing and showcasing componentsexamples/expo/nativecn: Expo example applicationexamples/react-native-cli/nativecn: React Native CLI example application (coming soon)
- Create a new branch for your changes
git checkout -b feature/your-feature-name-
Make your changes
-
Run linting and tests
npm run lintTests are not yet implemented, but will be added in the future. To run those tests, you will need to use the following command:
npm run test-
Commit your changes (see Commit Message Guidelines below)
-
Submit a pull request
We follow a test-first approach for component development:
-
Test in Example Apps First: Before adding a new component to the library, you should first implement and test it in our example applications:
- Expo Example App:
/examples/expo/nativecn - React Native CLI Example App: (coming soon)
This ensures components work properly in real application environments before being formalized in the component library.
- Expo Example App:
-
Once Tested: After validating your component in the example apps, proceed with adding it to the library as described below.
To add a new component:
-
Add component template files in
packages/cli/templates/<component-name>/:index.tsx.template: Component templatestyles.ts.template: Styles template
-
Update the component dependencies in
packages/cli/src/commands/add.tsif needed -
Add component documentation
-
Add tests for the component
When you add a new component template, it won't be immediately available in applications that use the CLI until the package is published. To test new components during development:
The recommended workflow is to test your components in our provided example apps:
-
Navigate to the appropriate example app:
# For the Expo example cd examples/expo/nativecn # For the React Native CLI example (coming soon) # cd examples/react-native-cli/nativecn
-
Use one of the methods below to make your local CLI changes available to the example app.
-
Build the CLI package to include your new templates:
cd packages/cli npm run build -
Create a local package (tarball):
npm pack
This creates a file like
nativecn-cli-x.y.z.tgzin the current directory. -
Install this local package in your example application:
cd /path/to/nativecn/examples/expo/nativecn npm install /path/to/nativecn/packages/cli/nativecn-cli-x.y.z.tgz -
Now you can test your new component:
npx @nativecn/cli add your-new-component
-
Build the CLI package:
cd packages/cli npm run build -
Link the package globally:
npm link
-
In your example application, link to the global package:
cd /path/to/nativecn/examples/expo/nativecn npm link @nativecn/cli -
Test your new component:
npx @nativecn/cli add your-new-component
-
When finished testing, unlink the package:
npm unlink @nativecn/cli
-
Build the CLI package:
cd packages/cli npm run build -
Install the package directly from the local path:
cd /path/to/nativecn/examples/expo/nativecn npm install /path/to/nativecn/packages/cli -
Test your new component:
npx @nativecn/cli add your-new-component
Remember to rebuild the CLI package after making changes to component templates!
After thoroughly testing your component in the example apps:
- Make any necessary refinements to your component templates
- Ensure documentation is complete
- Submit a pull request following the Pull Request Process
- Ensure your code follows the project's coding style
- Update the documentation as needed
- Include tests for new features
- Verify that all tests pass
- Submit a pull request to the
mainbranch - Address any feedback from reviewers
This project uses ESLint and Prettier for code formatting. Please follow the existing style:
- Use TypeScript for type safety
- Follow React Native best practices
- Keep components small and focused
- Use NativeWind for styling when possible
- Write clear and concise code comments
Run the formatting tools before committing:
npm run format
npm run lint:fixWe follow conventional commits to maintain a readable git history:
type(scope): short description
Optional longer description
Optional footer
Types:
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary tools
Example: feat(button): add new outline variant
- Update README.md with any necessary information
- Document components with proper JSDoc comments
- Include usage examples for new components
- Provide clear and concise descriptions of props and behavior
The release process is managed by maintainers. However, contributors should:
- Update CHANGELOG.md with their changes
- Bump version numbers according to semver guidelines
- Test build processes before requesting a release
Thank you for contributing to NativeCN!