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

@joakimbeng/react-native-version

v3.0.0

Published

Version your React Native or Expo app

Downloads

19

Readme

react-native-version npm npm

A fork of stovmascript/react-native-version which can be used with any other versioning tool as long as a valid Semver tag is generated.

Setup

$ npm install react-native-version --save-dev
# or
$ yarn add react-native-version --dev

Add it in your app's package.json:

{
	"name": "AwesomeProject",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"start": "node node_modules/react-native/local-cli/cli.js start",
+		"release": "standard-version && react-native-version"
	},
	// ...
}

Before you publish a new build of your app, run npm version <newversion> or e.g. standard-version.

react-native-version will then update your android/ and ios/ code. Depending on the script and options you choose, it can also automatically amend the version bump commit and update the Git tag created by npm version or standard-version. This method should be useful in most cases. If you need more control, take a look at the CLI and options below.

CLI

Setup

$ npm install -g react-native-version
# or
$ yarn global add react-native-version

Example usage

$ cd AwesomeProject/
$ standard-version
$ react-native-version

Options

-h, --help                   output usage information
-V, --version                output the version number
-a, --amend                  Amend the previous commit. Use "--no-amend" if you don't want to amend. Also, if the previous commit is tagged with a valid Semver version, react-native-version will update the Git tag pointing to this commit.
--skip-tag                   For use with "--amend", if you don't want to update Git tags. Use this option if you have git-tag-version set to false in your npm config or you use "--no-git-tag-version" during npm-version.
--no-amend                   Don't amend the previous commit.
-b, --increment-build        Only increment build number.
--no-increment-build         Don't increment build number.
-d, --android [path]         Path to your "android/app/build.gradle" file.
-i, --ios [path]             Path to your "ios/" folder.
-q, --quiet                  Be quiet, only report errors.
-r, --reset-build            Reset build number back to "1" (iOS only). Unlike Android's "versionCode", iOS doesn't require you to bump the "CFBundleVersion", as long as "CFBundleShortVersionString" changes. To make it consistent across platforms, react-native-version bumps both by default. You can use this option if you prefer to keep the build number value at "1" after every version change. If you then need to push another build under the same version, you can use "-bt ios" to increment.
-s, --set-build <number>     Set a build number. WARNING: Watch out when setting high values. This option follows Android's app versioning specifics - the value has to be an integer and cannot be greater than 2100000000. You cannot decrement this value after publishing to Google Play! More info at: https://developer.android.com/studio/publish/versioning.html#appversioning
-t, --target <platforms>     Only version specified platforms, eg. "--target android,ios".

You can apply these options to the "version" or "postversion" script too. If for example you want to commit the changes made by RNV yourself, add the "--never-amend" option:

{
	// ...
	"scripts": {
-		"postversion": "react-native-version"
+		"postversion": "react-native-version --never-amend"
	},
	// ...
}

Targeting platforms

The default behaviour is to version all React Native platforms. You can target specific platforms by passing a comma-separated list to the "--target" option, or by using the RNV environment variable:

$ RNV=android,ios npm version patch
# or
$ RNV=android,ios react-native-version

When using the CLI, you can even combine both methods and make your teammates rage :smiling_imp: :suspect:

$ RNV=android react-native-version --target ios

:rage1: :speak_no_evil:

API

import {version} from '@joakimbeng/react-native-version';

async function doSomething() {
	const versionResult = await version({
		amend: true
		// ...
	});
}

// or

version({
	amend: true
	// ...
})
	.then(commitHash => {
		console.log(commitHash);
	})
	.catch(err => {
		console.error(err);
	});

Functions

Typedefs

version(program, projectPath) ⇒ Promise.<(string|Error)>

Versions your app

Kind: global function
Returns: Promise.<(string|Error)> - A promise which resolves with the last commit hash

| Param | Type | Description | | ----------- | ------------------- | --------------------------------------- | | program | Object | commander/CLI-style options, camelCased | | projectPath | string | Path to your React Native project |

Promise

Custom type definition for Promises

Kind: global typedef
Properties

| Name | Type | Description | | ------ | ------------------ | ------------------------------------------------------------------ | | result | * | See the implementing function for the resolve type and description | | result | Error | Rejection error object |

Known issues

SyntaxError: Expected """, "\'", "\"", "\n", or [^\"] but "\" found.

When running react-native link on Windows, native modules will be linked in your Xcode project with paths that include backslashes (\) instead of forward slashes (/). This will break pbxproj-dom, which we rely on to parse Xcode projects. To fix this issue, convert any LIBRARY_SEARCH_PATHS and HEADER_SEARCH_PATHS as shown in this comment. This step could be automated with a library like normalize-path or unixify.

See also