npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-contains-native-code

v1.0.0

Published

A small module to test whether a given react-native dependency contains native or JS-only code. This is useful to determine for example to determine whether a deployment can be made via code-push (if only JS dependencies change).

Downloads

4

Readme

react-native-contains-native-code

A small module to test whether a given react-native dependency contains native or JS-only code.

  • Checks if the dependency contains an xcode or gradle project ✓
  • Checks if the dependency contains RNPM hooks ✓
  • CLI ✓
  • API ✓

ToC

Why

This utility was built in order to support "web-like release agility" for react-native projects.

This means, in detail, that paired with a tool like Microsoft code-push and a little bit of extra scripting, deployments can be made continuously and be released either as JS-only changes via code-push or with native changes through the iOS App Store / Google Play Store.

Usage

CLI

The binary can be used with either absolute or paths:

$ contains-native-code /home/myname/work/myproject/node_modules/a-react-native-dependency

or with the name of a dependency:

$ contains-native-code another-react-native-dependency

In the latter case it will look in the same node_modules folder where it has been installed for a dependeny with the given name.

The binary itself will be installed to node_modules/.bin and is available on the npm path.

API

This package exports a single function that can be called with a path to the dependency in question:

var containsNativeCode = require('react-native-contains-native-code');
console.log(containsNativeCode('/path/to/a/react-native-dependency'));

Or, with ES6 syntax:

import containsNativeCode from 'react-native-contains-native-code';
console.log(containsNativeCode('/path/to/a/react-native-dependency'));

How does it work?

The script reads the package.json manifest of the given dependency and checks:

  • whether the key rnpm is present
  • wheter the given dependency contains a *.xcodeproj file
  • whether the given dependency contains an android/build.gradle or android/app/build.gradle file

This is a similar behaviour to how react-native link works internally.

An example integration

In order to use this script in a automated release process the deployment script needs to do the following tasks:

  1. check if commits have been made inside the projects android/ or ios/ folder
  2. create a list of added/removed/changed dependencies from the package.json
  3. run this script for every dependency that has been found through step 1
    • if it turns out that no native changes were made between the last version and current HEAD do a code-push release
    • otherwise build the native code and push to the app/play store

To be able to execute these steps the source code of the application needs to be versioned via a version control system (for example git).

It is recommended to not directly push to production but to employ a "staging" environment and use manual or automated integration tests to verify the release because this method might not be bullet proof.