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

@brettdh/standard-version-expo

v1.1.1

Published

Automatic Expo versioning with Standard Version

Downloads

365

Readme

What's inside?

Standard version is a tool to automate the versioning of your project using semver and conventional commits. This package includes some helpful bumpers to update the Expo manifest automatically. With these bumpers you can automate updating the version, Android versionCode, and/or iOS buildNumber. You should be able to automate versioning of your app by using a single command, like:

$ npx standard-version --release-as minor

If you receive an error like Invalid Version: undefined, make sure your package.json has a starting version.

Getting started

It's recommended to install both Standard Version and this package as devDependency. You can do this with the npm command listed at the top of this read me. After you installed the packages, we need to configure Standard Version using any of the configuration methods listed here. Here is an example configuration that updates the version, Android versionCode, and iOS buildNumber using the recommended approaches.

// .versionrc.js
module.exports = {
  bumpFiles: [
    {
      filename: 'package.json',
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo'),
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo/android'),
    },
    {
      filename: 'app.json',
      updater: require.resolve('standard-version-expo/ios'),
    }
  ]
};

If you're using the bare workflow, you'll need a couple more bumpers to keep your native project config files in sync:

// .versionrc.js
const sdkVersion = '37.0.0';  // or pull from app.json

module.exports = [
  // ...
  {
    filename: 'ios/<YourAppName>/Info.plist',
    updater: require.resolve('standard-version-expo/ios/native/app-version'),
  },
  {
    filename: 'ios/<YourAppName>/Info.plist',
    updater: require.resolve('standard-version-expo/ios/native/buildnum/increment'),
  },
  {
    filename: 'android/app/build.gradle',
    updater: require.resolve('standard-version-expo/android/native/app-version'),
  },
  {
    filename: 'android/app/build.gradle',
    updater: require.resolve('standard-version-expo/android/native/buildnum/code')(sdkVersion),
  },
];

To test if your configuration works as expected, you can run standard version in dry mode. This shows you what will happen, without actually applying the versions and tags.

$ npx standard-version --dry-run

Usage

Standard Version's version bumpers are pretty simple; each bump only updates a single file using a single updater. This package exposes multiple kinds of updaters, for different areas of the manifest. You can "compose" your own set of bumpFiles entries to suit your needs.

updater | example | description --- | --- | --- <root> | 3.2.1 | alias of manifest/version manifest | 3.2.1 | alias of manifest/version manifest/version | 3.2.1 | Replace expo.version with the exact calculated semver. (recommended) android | 360030201 | alias of android/code android/code | 350010000 | Replace expo.android.versionCode with the method described by Maxi Rosson. (recommended) android/increment | 8 | Replace expo.android.versionCode with an incremental version. ios | 3.2.1 | alias of ios/version ios/code | 360030201 | Replace expo.ios.buildNumber with the method described by Maxi Rosson. ios/increment | 9 | Replace expo.ios.buildNumber with an incremental version. ios/version | 3.2.1 | Replace expo.ios.buildNumber with the exact calculated semver. (recommended)

And for the native build config files:

updater | example | file path | description --- | --- | --- | --- native/ios/app-version | 3.2.1 | ios/<YourAppName>/Info.plist | Replace CFBundleShortVersionString with the exact calculated semver. native/ios/buildnum/code | 36030201 | ios/<YourAppName>/Info.plist | Replace CFBundleVersion with the method described by Maxi Rosson. native/ios/buildnum/increment | 8 | ios/<YourAppName>/Info.plist | Replace CFBundleVersion with an incremental version. native/ios/buildnum/version | 3.2.1 | ios/<YourAppName>/Info.plist | Replace CFBundleVersion with the exact calculated semver. (recommended) native/android/app-version | 3.2.1 | android/app/build.gradle | Replace versionName with the exact calculated semver. native/android/buildnum/code | 36030201 | android/app/build.gradle | Replace versionCode with the method described by Maxi Rosson. (recommended) native/android/buildnum/increment | 8 | android/app/build.gradle | Replace versionCode with an incremental version.

Note that the native/{ios,android}/buildnum/code bumpers are only supported in .versionrc.js file, not in .versionrc or .versionrc.json files. Since a bumper only operates on one file, the Expo manifest is unavailable to the bumper when it's operating on a native build config file. Because of this, you must provide the Expo SDK version via javascript (see example above).

However, this means that you can also use these bumpers with non-Expo React Native projects, and even plain Android projects, simply by supplying the minimum Android API level rather than the Expo SDK version.

Version code

Semver is one of the most popular versioning methods; it generates a string with a syntax that even humans can read. Unfortunately, in Android, we are limited to use a numeric versionCode as version. The version code uses an approach from Maxi Rosson to calculate a numeric value from semver. It's a deterministic solution that removes some of the ambiguity of incremental build numbers, like security-patching old versions.

The method initially uses the Android minimum API level. For Expo, we replaced this with the major Expo SDK version.