react-native-repackager
Advanced tools
Comparing version 0.0.9 to 0.1.0
{ | ||
"name": "react-native-repackager", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"description": "Custom extension for react-native packager", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"test": ":", | ||
"postinstall": "echo '--Root directory--'; pwd; echo '-------'; patch -p1 -d ${PWD%/*/*} < add_custom_extensions_to_react_packager.patch" | ||
"postinstall": "node ./postinstall.js" | ||
}, | ||
@@ -16,2 +16,5 @@ "repository": { | ||
"author": "Omri Bruchim <omrib@wix.com>", | ||
"contributors": [ | ||
"Daniel Zlotin <zlotindaniel@gmail.com>" | ||
], | ||
"license": "MIT", | ||
@@ -18,0 +21,0 @@ "bugs": { |
# react-native-repackager | ||
Custom extensions for react-native packager | ||
Adding support for custom extension's files for react-native packager | ||
`react-native-repackager` is a [React Native](https://facebook.github.io/react-native/) npm extension package which provide you an easy way to add files with custom extensions and to use them to override the original file while running RN packager with special parameter. | ||
* [Why do we need this package?](#why-do-we-need-this-package) | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [Implementation Details](#implementation-details) | ||
* [License](#license) | ||
## why-do-we-need-this-package | ||
One of the biggest challenges when writing tests with react environment is easy mocking. | ||
Another case, is running your app with different behavior in diffeent environments or debug\release | ||
Consider the following use-cases: | ||
* Under e2e tests, use localhost mock HTTP server instead of the production service endpoint | ||
* When running ios simulator, instead of natively accessing the contacts on the device, return mock contacts | ||
<br/> | ||
In order to make it's super easy to mock stuff for tests, this package approach it like we handle in JavaScript code that is different between iOS and Android. | ||
So in order to replace someFile.js, we will also create someFile.mock.js in the same directory. | ||
When the packager will run for the e2e tests, it will pick up this file instead of the original. This way, the mocks files will not find themselves in our production code. | ||
## Installation | ||
**Currently support RN 0.38 or 0.42** | ||
* Install the package from npm | ||
``` | ||
npm install react-native-repackager --save | ||
``` | ||
## Usage | ||
* First add your custom extension (mock) file to your project, for example: | ||
<img src="http://i.imgur.com/g8AU012.png"/> | ||
The packager will search for custom files in the following order: | ||
1) filename.ios.[customExtension].js \ filename.android.[customExtension].js | ||
2) filename.[customExtension].js | ||
3) filename.ios.js \ filename.android.js | ||
* run react-packager with --custom-extension parameter | ||
``` | ||
node node_modules/react-native/local-cli/cli.js start --customExtensions=foo | ||
``` | ||
<img src="http://i.imgur.com/NEIDDgH.png"/> | ||
* for more then one file extension type | ||
``` | ||
node node_modules/react-native/local-cli/cli.js start --customExtensions='foo, bar' | ||
``` | ||
**Limitation - Currently support only react native packager in debug mode (will not replace file for Release version)** | ||
## Implementation Details | ||
* This package inject code into the RN packager implementation (!) | ||
* The repository contain only one patch file, and postinstall script. After npm install the package will replace the relevant files in RN packager to make the magic. | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
7
5
74
19490
3