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-flavor-cli

v1.0.4

Published

this package will run your android react-native project based on you choice of flavors and dimensions

Downloads

7

Readme

react-native-flavor-cli

this package will run your android react-native project based on you choice of flavors and dimensions

oclif Version Downloads/week License

Setup

First install the react-native-flavor-cli in global mode

  npm install -g react-native-flavor-cli

OR

  yarn global add react-native-flavor-cli

and then add needed gradle task to the android/app/build.gradle file

task saveRnfcliData () {
   group "rnfcli"
   def flavorsDetail = []
   def dimensions = []
   doLast {
       android.productFlavors.all {flavor ->
           def temp = ["${flavor.name}" , "${flavor.dimension}"]
           flavorsDetail.add(temp)
           if(!dimensions.contains("${flavor.dimension}")){
               dimensions.add("${flavor.dimension}")
           }
       }
       def flavorDetailsJson = JsonOutput.toJson(flavorsDetail)
       println flavorDetailsJson
       def productFlavorsFile = new File("../flavors.json")
       productFlavorsFile.deleteOnExit()

       productFlavorsFile.write(flavorDetailsJson.toString())

       def dimensionsJson = JsonOutput.toJson(dimensions)
       def dimensionsFile = new File("../dimensions.json")
       dimensionsFile.deleteOnExit()
       dimensionsFile.write(dimensionsJson.toString())
   }
}

and then import groovy.json.JsonOutput in android/app/build.gradle file your android/app/build.gradle should be somthing like this :

apply plugin: "com.android.application"

import com.android.build.OutputFile
import groovy.json.JsonOutput
...
...
...
...
...
task saveRnfcliData () {
   group "rnfcli"
   def flavorsDetail = []
   def dimensions = []
   doLast {
       android.productFlavors.all {flavor ->
           def temp = ["${flavor.name}" , "${flavor.dimension}"]
           flavorsDetail.add(temp)
           if(!dimensions.contains("${flavor.dimension}")){
               dimensions.add("${flavor.dimension}")
           }
       }
       def flavorDetailsJson = JsonOutput.toJson(flavorsDetail)
       println flavorDetailsJson
       def productFlavorsFile = new File("../flavors.json")
       productFlavorsFile.deleteOnExit()

       productFlavorsFile.write(flavorDetailsJson.toString())

       def dimensionsJson = JsonOutput.toJson(dimensions)
       def dimensionsFile = new File("../dimensions.json")
       dimensionsFile.deleteOnExit()
       dimensionsFile.write(dimensionsJson.toString())
   }
}
preBuild.dependsOn(saveRnfcliData)

Important

and then sync gradle in android studio, new task will be added to rnfcli group in gradle panel, when gradle sync finished open gradle panel and open app -> rnfcli, right click on saveRnfcliData and choose Execute Before Build.

after all these steps open a cmd/terminal in your react-native project root directory and run this command :

rnf-cli init

Usage

$ npm install -g react-native-flavor-cli
$ rnf-cli COMMAND
running command...
$ rnf-cli (-v|--version|version)
react-native-flavor-cli/1.0.4 darwin-x64 node-v8.11.4
$ rnf-cli --help [COMMAND]
USAGE
  $ rnf-cli COMMAND
...

Commands

rnf-cli build-android

Generate Apk based on your flavor choices

USAGE
  $ rnf-cli build-android

DESCRIPTION
  ...
  This command will ask you name of product flavors based on dimensions from build.gradle file and then generates new 
  apk for you.

See code: src/commands/build-android.js

rnf-cli clean-android

Cleans Your Android Project

USAGE
  $ rnf-cli clean-android

DESCRIPTION
  ...
  This will run gradle clean in android folder of your react-native project

See code: src/commands/clean-android.js

rnf-cli help [COMMAND]

display help for rnf-cli

USAGE
  $ rnf-cli help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

rnf-cli init

Setup Rnf-cli in you react-native project

USAGE
  $ rnf-cli init

OPTIONS
  -e, --entryfile=entryfile  react-native project entry file

DESCRIPTION
  ...
  This will create new rnf-config.json in your root folder of your project, please add this to your git.

See code: src/commands/init.js

rnf-cli reset

This will run react-native start -- --reset-cache

USAGE
  $ rnf-cli reset

DESCRIPTION
  ...
  Command for reseting metro bundler and restarting it.

See code: src/commands/reset.js

rnf-cli run-android

This will run your react-native android project based on your product flavor choices

USAGE
  $ rnf-cli run-android

OPTIONS
  -f, --fresh=fresh  use fresh run options, user true or false

DESCRIPTION
  ...
  For running your react-native android app with rnf-cli please follow the steps in documentation.

See code: src/commands/run-android.js

rnf-cli start

This will run react-native start in your current working directory (process.cwd)

USAGE
  $ rnf-cli start

DESCRIPTION
  ...
  Please make sure you are in the right project folder when you want to use this command.

See code: src/commands/start.js

rnf-cli build-android

Generate Apk based on your flavor choices

USAGE
  $ rnf-cli build-android

DESCRIPTION
  ...
  This command will ask you name of product flavors based on dimensions from build.gradle file and then generates new
  apk for you.

See code: src/commands/build-android.js

rnf-cli clean-android

Cleans Your The Android Project

USAGE
  $ rnf-cli clean-android

DESCRIPTION
  ...
  This will run gradle clean in andorid folder of your react-native project

See code: src/commands/clean-android.js

rnf-cli help [COMMAND]

display help for rnf-cli

USAGE
  $ rnf-cli help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

rnf-cli init

Setup Rnf-cli in you react-native project

USAGE
  $ rnf-cli init

OPTIONS
  -e, --entryfile=entryfile  react-native project entry file

DESCRIPTION
  ...
  This will create new rnf-config.json in your root folder of your project, please add this to your git.

See code: src/commands/init.js

rnf-cli reset

This will run react-native start -- --reset-cache

USAGE
  $ rnf-cli reset

DESCRIPTION
  ...
  Command for reseting metro bundler and restarting it.

See code: src/commands/reset.js

rnf-cli run-android

This will run your react-native android project based on your product flavor choices

USAGE
  $ rnf-cli run-android

OPTIONS
  -f, --fresh=fresh  use fresh run options, user true or false

DESCRIPTION
  ...
  For running your react-native android app with rnf-cli please follow the steps in documentation.

See code: src/commands/run-android.js

rnf-cli start

This will run react-native start in your current working directory (process.cwd)

USAGE
  $ rnf-cli start

DESCRIPTION
  ...
  Please make sure you are in the right project folder when you want to use this command.

See code: src/commands/start.js