react-native-repackager
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "react-native-repackager", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Custom extension for react-native packager", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
# react-native-repackager | ||
Adding support for custom extension's files for react-native packager | ||
Adding support for custom extension 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. | ||
`react-native-repackager` is a [React Native](https://facebook.github.io/react-native/) packager extension 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 a 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 | ||
One of the biggest challenges when writing e2e tests with react environment is easy mocking. | ||
Another case, is running your app with different behavior in different environments or debug\release. | ||
@@ -24,4 +16,4 @@ Consider the following use-cases: | ||
<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. | ||
In order to make it super easy to mock stuff for tests, this package approach it like we handle imports 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. | ||
@@ -32,3 +24,3 @@ | ||
**Currently support RN 0.38 or 0.42** | ||
**Currently supports only RN 0.44** | ||
@@ -41,2 +33,9 @@ * Install the package from npm | ||
## API | ||
* `repackager setup`: apply the code changes to the react-native packager | ||
* `repackager injectReleaseSourceMap`: apply injection of sourcemap to release builds | ||
* `repackager injectReleaseMockedE2E`: apply injection of `--customExtensions=e2e` to release builds | ||
* `repackager <command> --reverse`: reverses the command, applies the reverse changes | ||
## Usage | ||
@@ -53,3 +52,3 @@ | ||
* run react-packager with --custom-extension parameter | ||
* run react-packager with --customExtension parameter | ||
@@ -67,12 +66,8 @@ ``` | ||
**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 (!) | ||
* This package injects 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 |
@@ -38,3 +38,3 @@ #!/usr/bin/env node | ||
console.log(`injecting support for --customExtensions`); | ||
apply('rn44PackagerCustomExtensions'); | ||
patch('rn44PackagerCustomExtensions'); | ||
} | ||
@@ -44,3 +44,3 @@ | ||
console.log(`${shouldReverse ? 'reversing' : 'injecting'} bundle sourcemap arg to release builds`); | ||
apply('rn44PackagerReleaseSourceMap'); | ||
patch('rn44PackagerReleaseSourceMap'); | ||
} | ||
@@ -50,3 +50,3 @@ | ||
console.log(`${shouldReverse ? 'reversing' : 'injecting'} bundle customExtensions=e2e to release builds`); | ||
apply('rn44PackagerReleaseMockedE2E'); | ||
patch('rn44PackagerReleaseMockedE2E'); | ||
} | ||
@@ -72,1 +72,5 @@ | ||
} | ||
function patch(patchFileName) { | ||
exec.execSync(`patch ${shouldReverse ? '--reverse' : ''} --strip 1 --directory node_modules/react-native < ${scriptDir}/${patchFileName}.patch`); | ||
} |
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
39679
15
60
69
1