Skip to content

Commit ebddb42

Browse files
author
Alexey
committed
Merge pull request #70 from rnpm/chore/rework-android-patches
Chore/rework android patches
2 parents 85e4908 + b47dc19 commit ebddb42

36 files changed

+464
-316
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"npmlog": "^2.0.0",
3838
"plist": "^1.2.0",
3939
"semver": "^5.1.0",
40+
"to-camel-case": "^1.0.0",
4041
"xcode": "^0.8.2"
4142
},
4243
"devDependencies": {

src/android/isInstalled.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
const compose = require('lodash').flowRight;
2-
const readFile = require('./fs').readFile;
1+
const fs = require('fs');
2+
const makeBuildPatch = require(`./patches/makeBuildPatch`);
33

4-
module.exports = function isInstalled(projectConfig, name) {
5-
return compose(
6-
(content) => content.indexOf(`:${name}`) >= 0,
7-
readFile(projectConfig.buildGradlePath)
8-
)();
4+
module.exports = function isInstalled(config, name) {
5+
return fs
6+
.readFileSync(config.buildGradlePath)
7+
.indexOf(makeBuildPatch(name).patch) > -1;
98
};

src/android/patches/0.17/addPackagePatch.js

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function makeImportPatch(packageImportPath) {
2+
return {
3+
pattern: 'import android.app.Activity;',
4+
patch: '\n' + packageImportPath,
5+
};
6+
};

src/android/patches/0.17/makeMainActivityPatch.js

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const applyParams = require('../applyParams');
2+
3+
module.exports = function makePackagePatch(packageInstance, params, prefix) {
4+
const processedInstance = applyParams(packageInstance, params, prefix);
5+
6+
return {
7+
pattern: '.addPackage(new MainReactPackage())',
8+
patch: `\n .addPackage(${processedInstance})`,
9+
};
10+
};

src/android/patches/0.18/addPackagePatch.js

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function makeImportPatch(packageImportPath) {
2+
return {
3+
pattern: 'import com.facebook.react.ReactActivity;',
4+
patch: '\n' + packageImportPath,
5+
};
6+
};

src/android/patches/0.18/makeMainActivityPatch.js

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const applyParams = require('../applyParams');
2+
3+
module.exports = function makePackagePatch(packageInstance, params, prefix) {
4+
const processedInstance = applyParams(packageInstance, params, prefix);
5+
6+
return {
7+
pattern: 'new MainReactPackage()',
8+
patch: ',\n ' + processedInstance,
9+
};
10+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy