Coder Social home page Coder Social logo

matipl01 / react-native-library-template Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 2.73 MB

An optimized React Native library boilerplate equipped with valuable tools, simplifying library development and ensuring high-quality code.

License: MIT License

Shell 1.09% JavaScript 54.03% TypeScript 11.37% Ruby 9.29% Objective-C 9.77% Objective-C++ 3.44% Kotlin 11.00%
boilerplate expo library npm react-native react-native-cli setup template typescript

react-native-library-template's Introduction

πŸ“š React Native Library Template

This repository is an optimized React Native library boilerplate, designed to boost your library development process.πŸ§‘β€πŸ’»πŸ”§ It's tailored for both bare React Native applications and Expo-created ones. This boilerplate is equipped with valuable tools, simplifying library development and ensuring high-quality code.

🌟 Features

  • Enforces code style with eslint, prettier, and TypeScript,
  • Precommit hooks checking code style and type issues,
  • GitHub Actions to aid in your development process,
  • Automated library deployments to npm and hassle-free versioning thanks to semantic-release,
  • Provides an example app for both bare React Native projects and Expo-managed ones,
  • jest setup is also available with example tests

πŸ“‹ Requirements

Node 18 or greater is required. Development for iOS needs a Mac and Xcode.

πŸš€ Quick Start

To create a fresh project, just run:

npx rn-lib-temp init <projectName>

Before starting development, go to the directory where you created the template project and install all necessary dependencies with yarn:

yarn

For iOS only: Install required Pods for the bare React Native example app:

yarn example:bare pod

Getting help

For more details about the npx rn-lib-temp command use the following command:

npx rn-lib-temp help

πŸ’« GitHub Actions

To use the GitHub Actions bundled with this boilerplate, you'll need to provide 2 secrets (refer to this page for more about secrets):

  • GH_TOKEN - a GitHub token with repo permissions (check docs for more on GitHub access tokens).
  • NPM_TOKEN - an npm token employed by semantic-release for automatic library deployment (see docs for info on npm access tokens).

Alternatively, remove workflows from the .github directory if you prefer not to use GitHub Actions.

πŸ› οΈ Library Development

πŸ—οΈ Project Structure

The project can be categorized into 2 subprojects:

  • Library Source Code
  • Example App

πŸ› οΈ Library Scope

The root directory of the project houses several configuration files for tools like prettier, eslint, and TypeScript. It also contains the config of the semantic-release library and the react-native-builder-bob config for convenient npm deployments and proper versioning.

Library Source Files

By default, the resulting library will include files specified under the files key in the package.json:

  • src directory - where you write all library source code,
  • dist directory - generated by react-native-builder-bob during the build process,
  • LICENSE - you should include your LICENSE file because it's not provided by default,
  • CHANGELOG.md - a file containing all version history with included changes, automatically generated by the semantic-release library

Library Dependencies

If you want to add dependency that will be used by your library, you should add it in the project root. I decided to use the yarn package manager as it is one of the most commonly used package managers which has good support for monorepos with workspaces (the example app). All dependencies should be installed with yarn.

πŸ“± Example App

This template also includes an example app that is handy for testing features implemented in the library and showcasing them to your users. The example app is not part of the library source files deployed to npm.

The example app resides in the example directory. Inside, you'll find three subdirectories:

  • app - Where the example app source code is located.
  • bare - A bare example of a React Native app.
  • expo - An example of a React Native Expo app.

If you don't need to support Expo or a bare React Native apps, you can just remove the corresponding directory.

Example App Dependencies

Install all example app dependencies in the example/app directory. Similarly to the library, use yarn package manager to handle your example app dependencies.

Useful Commands

For launching the bare React Native example app:

yarn example:bare start|android|ios|pod

For the Expo React Native app:

yarn example:expo start|android|ios
  • start - starts metro client
  • android - starts example app on the Android emulator/device,
  • ios - starts example app on the iOS simulator/device,
  • pod - installs Pods required by example app native iOS dependencies.

πŸ”„ Automatic deployments

The release.yaml workflow included in the project contains the auto deployment logic. By default, the deployment will be caused on the workflow dispatch action (manually from the GitHub Actions page). You can change this behavior by modifying the workflow triggers.

react-native-library-template's People

Contributors

matipl01 avatar semantic-release-bot avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

react-native-library-template's Issues

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.