Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

react-native-dotenv

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-dotenv - npm Package Compare versions

Comparing version 2.4.0 to 2.4.1

__tests__/__fixtures__/require-import/.babelrc

32

index.js

@@ -64,21 +64,23 @@ const {readFileSync} = require('fs')

const importedId = specifier.imported.name
const localId = specifier.local.name
if (specifier.imported && specifier.local) {
const importedId = specifier.imported.name
const localId = specifier.local.name
if (Array.isArray(opts.whitelist) && !opts.whitelist.includes(importedId)) {
throw path.get('specifiers')[idx].buildCodeFrameError(`"${importedId}" was not whitelisted`)
}
if (Array.isArray(opts.whitelist) && !opts.whitelist.includes(importedId)) {
throw path.get('specifiers')[idx].buildCodeFrameError(`"${importedId}" was not whitelisted`)
}
if (Array.isArray(opts.blacklist) && opts.blacklist.includes(importedId)) {
throw path.get('specifiers')[idx].buildCodeFrameError(`"${importedId}" was blacklisted`)
}
if (Array.isArray(opts.blacklist) && opts.blacklist.includes(importedId)) {
throw path.get('specifiers')[idx].buildCodeFrameError(`"${importedId}" was blacklisted`)
}
if (!opts.allowUndefined && !Object.prototype.hasOwnProperty.call(this.env, importedId)) {
throw path.get('specifiers')[idx].buildCodeFrameError(`"${importedId}" is not defined in ${opts.path}`)
if (!opts.allowUndefined && !Object.prototype.hasOwnProperty.call(this.env, importedId)) {
throw path.get('specifiers')[idx].buildCodeFrameError(`"${importedId}" is not defined in ${opts.path}`)
}
const binding = path.scope.getBinding(localId)
binding.referencePaths.forEach(refPath => {
refPath.replaceWith(t.valueToNode(this.env[importedId]))
})
}
const binding = path.scope.getBinding(localId)
binding.referencePaths.forEach(refPath => {
refPath.replaceWith(t.valueToNode(this.env[importedId]))
})
})

@@ -85,0 +87,0 @@

{
"name": "react-native-dotenv",
"version": "2.4.0",
"version": "2.4.1",
"description": "Load environment variables using import statements.",

@@ -24,7 +24,7 @@ "repository": "github:goatandsheep/react-native-dotenv",

"devDependencies": {
"@babel/core": "7.11.1",
"@babel/core": "7.11.6",
"codecov": "^3.7.2",
"jest": "26.2.2",
"jest": "26.4.2",
"jest-junit": "^11.0.1",
"xo": "^0.32.1"
"xo": "^0.33.1"
},

@@ -31,0 +31,0 @@ "author": "Kemal Ahmed",

@@ -16,4 +16,2 @@ # react-native-dotenv [![CircleCI](https://circleci.com/gh/goatandsheep/react-native-dotenv.svg?style=svg)](https://circleci.com/gh/goatandsheep/react-native-dotenv)

## Introduction
**Breaking changes**: moving from `v0.x` to `v2.x` changes both the setup and usage of this package. Please see the [migration guide](https://github.com/goatandsheep/react-native-dotenv/wiki/Migration-Guide).

@@ -23,4 +21,6 @@

If you'd like to become an active contributor, please send us a message.
## Introduction
This babel plugin lets you inject your environment variables into your react-native environment using dotenv for multiple environments.
## Usage

@@ -63,3 +63,3 @@

API_URL=https://api.example.org
API_TOKEN=
API_TOKEN=abc123
```

@@ -146,2 +146,20 @@

## Multi-env
This package now supports environment specific variables. This means you may now import environment variables from multiple files, i.e. `.env`, `.env.development`, `.env.production`, and `.env.test`.
Note: it is not recommended that you commit any sensitive information in `.env` file to code in case your git repo is exposed. The best practice is to put a `.env.template` or `.env.development.template` that contains dummy values so other developers know what to configure. Then add your `.env` and `.env.development` to `.gitignore`. In a future release you can keep sensitive keys in a separate `.env.local` (and respective `.env.local.template`) in `.gitignore` and you can use your other `.env` files for non-sensitive config.
The base set of variables will be `.env` and the environment-specific variables will overwrite them.
The variables will automatically be pulled from the appropriate environment and `development` is the default. The choice of environment is based on your Babel environment first and if that value is not set, your NPM environment, which should actually be the same, but this makes it more robust.
In general, **Release** is `production` and **Debug** is `development`.
### Reference Material
* [babel environments](https://babeljs.io/docs/en/6.26.3/babelrc#env-option)
* [dotenv documentation](https://www.npmjs.com/package/dotenv)
* [See the wiki for more troubleshooting tips](https://github.com/goatandsheep/react-native-dotenv/wiki/Multi-env-troubleshooting)
## Caveats

@@ -160,3 +178,3 @@

Multi-environment is still a work in progress.
The tests that use `require('@env')` are also not passing.

@@ -168,2 +186,4 @@ ## Credits

If you'd like to become an active contributor, please send us a message.
## Miscellaneous

@@ -170,0 +190,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc