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

rn-environment

v0.1.22

Published

A react native library to manage environment and configuration files for every server configuration eg. local, development, staging and production.

Downloads

6

Readme

RN Environment

Description

A react native library to manage environment and configuration files for every server configuration eg. local, development, staging and production.

Features

  • Setup Environments and configuration files.
  • Set Current environment using command

Dependency

No Dependencies so far.

Installation

  • Using npm: npm install rn-environment --save
  • Using Yarn: yarn add rn-environment

Setup

  • Insert following line in the scripts section of your package.json file.
    "rn-environment": "rn-environment"
  • Insert following lines in your .gitignore file
    # Environment files
    app/src/config/environment.json
    ios/GoogleService-Info.plist
    android/app/google-services.json

    # Secrets
    .decrypted
    *.dec.yaml
  • Run Setup script in your project directory. See syntax below.
npm run rn-environment -- --setup
  • Update configuration files.

After running above command you can see that your project directory have a environment folder and inside the folder have some server environment folders local, development, staging and production. Inside each of these server environment folder you have some configurations files environment.json, google-services.json, and GoogleService-Info.plist .

Now you have to update all these files as per the server environment values or only those files which you are going to use. For example replace BaseUrl value in each environment.json file to choose different server base url in local, development, staging and production. You can also add other you own values in environment.json file. I have given some example there.

  • Create GPG Key please refer gpg tutorial or run following command
gpg --full-generate-key
  • Once the gpg key is created you can check the appropriate fingerprint using following command
gpg --fingerprint
  • Copy the correct fingerprint and run following commands
export SOPS_GPG_EXEC="gpg"
export SOPS_PGP_FP="<fingerprint>"
export SOPS_GPG_KEYSERVER="keyserver.ubuntu.com"
  • Fill the secrets that you dont want to commit in environment/secrets.dec.yaml file

  • Then encryp the file using sops. The environment/secrets.yaml file can be commited.

sops --encrypt environment/secrets.dec.yaml > environment/secrets.yaml

Setup environment files

Once all possible fields are filled out you can run following command to set current environment. Becore you can run this command you need to have following directory structure app/src/config so that you can place environment.json file in there.

npm run rn-environment -- --current $ENV

with $ENV be one of:

  • local
  • development
  • staging
  • production

If this command gives following error.

Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  <Random digist>: FAILED
    - | could not decrypt data key with PGP key:
      | golang.org/x/crypto/openpgp error: Could not load secring:
      | open /Users/<username>/.gnupg/secring.gpg: no such file
      | or directory; GPG binary error: exit status 2

Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.

Run below commands and then run current command again.

reset
GPG_TTY=$(tty)
export GPG_TTY

How to run scripts

You can use the below command to run any script. Note that rn-environment should be added in script section of your package.json file before running any script.

    npm run rn-environment -- --<script-name>

Scripts

  • Setup Script : --setup this script is used to setup the environment files and configuration files in a react native project.
  • Current Script : --current this script is used to setup the current environment and replace all files. Available environments are local, development, staging and production.
  • Help Script : --help this script is used for displaying available scripts.

Requirements

  • [x] Initialize directries and create files
  • [x] Set PGP key and secrets files
  • [x] Set Current environment using command
  • [ ] Configure more secrets without updating decrypt-env.sh
  • [ ] Add example