mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
18
Commits
nc/react-sync
...
v0.53.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
847a6f9eec | ||
|
|
f7f400fb7e | ||
|
|
2f70001c6c | ||
|
|
9775308458 | ||
|
|
2c63f49269 | ||
|
|
f7bd2a333c | ||
|
|
9b877d6692 | ||
|
|
cf19833ad8 | ||
|
|
df8da3b6c4 | ||
|
|
997bfb50e1 | ||
|
|
b4375b4606 | ||
|
|
0b996577e3 | ||
|
|
49cbca7464 | ||
|
|
dd4611721d | ||
|
|
82b123e744 | ||
|
|
7c3a61f3b6 | ||
|
|
796122d8f3 | ||
|
|
aebb34a294 |
@@ -46,11 +46,11 @@ aliases:
|
||||
|
||||
- &restore-cache-buck
|
||||
keys:
|
||||
- v2-buck-{{ arch }}-v2017.11.16.01
|
||||
- v2-buck-{{ arch }}-v2017.09.04.02
|
||||
- &save-cache-buck
|
||||
paths:
|
||||
- ~/buck
|
||||
key: v2-buck-{{ arch }}-v2017.11.16.01
|
||||
key: v2-buck-{{ arch }}-v2017.09.04.02
|
||||
|
||||
- &restore-cache-watchman
|
||||
keys:
|
||||
@@ -67,7 +67,7 @@ aliases:
|
||||
- &install-buck
|
||||
|
|
||||
if [[ ! -e ~/buck ]]; then
|
||||
git clone https://github.com/facebook/buck.git ~/buck --branch v2017.11.16.01 --depth=1
|
||||
git clone https://github.com/facebook/buck.git ~/buck --branch v2017.09.04.02 --depth=1
|
||||
fi
|
||||
cd ~/buck && ant
|
||||
buck --version
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
exports.version = {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
minor: 53,
|
||||
patch: 2,
|
||||
prerelease: null,
|
||||
};
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
59E6049B1FE9CB4A00BD90C5 /* RCTUITextField.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 59E604501FE9CAF100BD90C5 /* RCTUITextField.h */; };
|
||||
59E8C5CC1F8833D100204F5E /* RCTFontAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = A85C82991F742AA20036C019 /* RCTFontAttributes.m */; };
|
||||
A85C829A1F742AA20036C019 /* RCTFontAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = A85C82991F742AA20036C019 /* RCTFontAttributes.m */; };
|
||||
AD50D1DF20067E6F00A34797 /* RCTBaseTextInputViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5989E14C20018A2200EA444A /* RCTBaseTextInputViewManager.m */; };
|
||||
AF3225F91DE5574F00D3E7E7 /* RCTConvert+Text.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3225F81DE5574F00D3E7E7 /* RCTConvert+Text.m */; };
|
||||
AF3225FA1DE5574F00D3E7E7 /* RCTConvert+Text.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3225F81DE5574F00D3E7E7 /* RCTConvert+Text.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
@@ -380,6 +381,7 @@
|
||||
59E6045D1FE9CAF100BD90C5 /* RCTMultilineTextInputShadowView.m in Sources */,
|
||||
59E604591FE9CAF100BD90C5 /* RCTRawTextShadowView.m in Sources */,
|
||||
59E604551FE9CAF100BD90C5 /* RCTTextView.m in Sources */,
|
||||
AD50D1DF20067E6F00A34797 /* RCTBaseTextInputViewManager.m in Sources */,
|
||||
59E604691FE9CAF100BD90C5 /* RCTTextSelection.m in Sources */,
|
||||
59E6045F1FE9CAF100BD90C5 /* RCTMultilineTextInputView.m in Sources */,
|
||||
59E604611FE9CAF100BD90C5 /* RCTMultilineTextInputViewManager.m in Sources */,
|
||||
|
||||
@@ -121,7 +121,7 @@ Error: ${e.message}`
|
||||
}
|
||||
case 'error': {
|
||||
HMRLoadingView.hide();
|
||||
throw new Error(data.body.type + ' ' + data.body.description);
|
||||
throw new Error(`${data.body.type}: ${data.body.message}`);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unexpected message: ${data}`);
|
||||
|
||||
+3
-3
@@ -139,13 +139,13 @@ Pod::Spec.new do |s|
|
||||
s.subspec "cxxreact" do |ss|
|
||||
ss.dependency "React/jschelpers"
|
||||
ss.dependency "React/jsinspector"
|
||||
ss.dependency "boost"
|
||||
ss.dependency "boost-for-react-native", "1.63.0"
|
||||
ss.dependency "Folly", "2016.09.26.00"
|
||||
ss.compiler_flags = folly_compiler_flags
|
||||
ss.source_files = "ReactCommon/cxxreact/*.{cpp,h}"
|
||||
ss.exclude_files = "ReactCommon/cxxreact/SampleCxxModule.*"
|
||||
ss.private_header_files = "ReactCommon/cxxreact/*.h"
|
||||
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Folly\"" }
|
||||
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Folly\"" }
|
||||
end
|
||||
|
||||
s.subspec "ART" do |ss|
|
||||
@@ -204,7 +204,7 @@ Pod::Spec.new do |s|
|
||||
|
||||
s.subspec "RCTText" do |ss|
|
||||
ss.dependency "React/Core"
|
||||
ss.source_files = "Libraries/Text/*.{h,m}"
|
||||
ss.source_files = "Libraries/Text/**/*.{h,m}"
|
||||
end
|
||||
|
||||
s.subspec "RCTVibration" do |ss|
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#define RCT_REACT_NATIVE_VERSION @{ \
|
||||
@"major": @(0), \
|
||||
@"minor": @(0), \
|
||||
@"patch": @(0), \
|
||||
@"minor": @(53), \
|
||||
@"patch": @(2), \
|
||||
@"prerelease": [NSNull null], \
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
// If the control is refreshing when mounted we need to call
|
||||
// beginRefreshing in layoutSubview or it doesn't work.
|
||||
if (_currentRefreshingState && _isInitialRender) {
|
||||
[self beginRefreshing];
|
||||
[self beginRefreshingProgrammatically];
|
||||
}
|
||||
_isInitialRender = false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
VERSION_NAME=1000.0.0-master
|
||||
VERSION_NAME=0.53.2
|
||||
GROUP=com.facebook.react
|
||||
|
||||
POM_NAME=ReactNative
|
||||
|
||||
@@ -12,7 +12,6 @@ android_library(
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
@@ -16,7 +16,6 @@ android_library(
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
+11
-7
@@ -9,14 +9,17 @@
|
||||
|
||||
package com.facebook.react.devsupport;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.JavaJSExecutor;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.JavaJSExecutor;
|
||||
|
||||
/**
|
||||
* Executes JS remotely via the react nodejs server as a proxy to a browser on the host machine.
|
||||
@@ -157,7 +160,8 @@ public class WebsocketJavaScriptExecutor implements JavaJSExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadApplicationScript(String sourceURL) throws JavaJSExecutor.ProxyExecutorException {
|
||||
public void loadApplicationScript(String sourceURL)
|
||||
throws ProxyExecutorException {
|
||||
JSExecutorCallbackFuture callback = new JSExecutorCallbackFuture();
|
||||
Assertions.assertNotNull(mWebSocketClient).loadApplicationScript(
|
||||
sourceURL,
|
||||
@@ -172,7 +176,7 @@ public class WebsocketJavaScriptExecutor implements JavaJSExecutor {
|
||||
|
||||
@Override
|
||||
public @Nullable String executeJSCall(String methodName, String jsonArgsArray)
|
||||
throws JavaJSExecutor.ProxyExecutorException {
|
||||
throws ProxyExecutorException {
|
||||
JSExecutorCallbackFuture callback = new JSExecutorCallbackFuture();
|
||||
Assertions.assertNotNull(mWebSocketClient).executeJSCall(
|
||||
methodName,
|
||||
|
||||
@@ -3,7 +3,6 @@ include_defs("//ReactAndroid/DEFS")
|
||||
android_library(
|
||||
name = "annotations",
|
||||
srcs = glob(["**/*.java"]),
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import java.util.Map;
|
||||
public class ReactNativeVersion {
|
||||
public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
|
||||
"major", 0,
|
||||
"minor", 0,
|
||||
"patch", 0,
|
||||
"minor", 53,
|
||||
"patch", 2,
|
||||
"prerelease", null);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ android_library(
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
@@ -3,7 +3,6 @@ include_defs("//ReactAndroid/DEFS")
|
||||
android_library(
|
||||
name = "annotations",
|
||||
srcs = glob(["*.java"]),
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import android.view.animation.Transformation;
|
||||
*/
|
||||
/* package */ class OpacityAnimation extends Animation {
|
||||
|
||||
static class OpacityAnimationListener implements Animation.AnimationListener {
|
||||
static class OpacityAnimationListener implements AnimationListener {
|
||||
|
||||
private final View mView;
|
||||
private boolean mLayerTypeChanged = false;
|
||||
|
||||
@@ -11,7 +11,6 @@ android_library(
|
||||
react_native_dep("third-party/android/support-annotations:android-support-annotations"),
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
|
||||
@@ -3,7 +3,6 @@ include_defs("//ReactAndroid/DEFS")
|
||||
android_library(
|
||||
name = "modal",
|
||||
srcs = glob(["*.java"]),
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
@@ -3,7 +3,6 @@ include_defs("//ReactAndroid/DEFS")
|
||||
android_library(
|
||||
name = "text",
|
||||
srcs = glob(["*.java"]),
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
@@ -6,7 +6,6 @@ android_library(
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
@@ -54,13 +54,13 @@ public class ReactViewGroup extends ViewGroup implements
|
||||
|
||||
/**
|
||||
* This listener will be set for child views when removeClippedSubview property is enabled. When
|
||||
* children layout is updated, it will call {@link #updateSubviewClipStatus} to notify parent view
|
||||
* about that fact so that view can be attached/detached if necessary.
|
||||
* children layout is updated, it will call {@link #updateSubviewClipStatus} to notify parent
|
||||
* view about that fact so that view can be attached/detached if necessary.
|
||||
*
|
||||
* <p>TODO(7728005): Attach/detach views in batch - once per frame in case when multiple children
|
||||
* TODO(7728005): Attach/detach views in batch - once per frame in case when multiple children
|
||||
* update their layout.
|
||||
*/
|
||||
private static final class ChildrenLayoutChangeListener implements View.OnLayoutChangeListener {
|
||||
private static final class ChildrenLayoutChangeListener implements OnLayoutChangeListener {
|
||||
|
||||
private final ReactViewGroup mParent;
|
||||
|
||||
@@ -422,7 +422,7 @@ public class ReactViewGroup extends ViewGroup implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
||||
public void addView(View child, int index, LayoutParams params) {
|
||||
// This will get called for every overload of addView so there is not need to override every method.
|
||||
mDrawingOrderHelper.handleAddView(child);
|
||||
setChildrenDrawingOrderEnabled(mDrawingOrderHelper.shouldEnableCustomDrawingOrder());
|
||||
@@ -494,8 +494,7 @@ public class ReactViewGroup extends ViewGroup implements
|
||||
addViewWithSubviewClippingEnabled(child, index, sDefaultLayoutParam);
|
||||
}
|
||||
|
||||
/*package*/ void addViewWithSubviewClippingEnabled(
|
||||
View child, int index, ViewGroup.LayoutParams params) {
|
||||
/*package*/ void addViewWithSubviewClippingEnabled(View child, int index, LayoutParams params) {
|
||||
Assertions.assertCondition(mRemoveClippedSubviews);
|
||||
Assertions.assertNotNull(mClippingRect);
|
||||
Assertions.assertNotNull(mAllChildren);
|
||||
|
||||
@@ -6,7 +6,6 @@ android_library(
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
|
||||
package com.facebook.react.views.viewpager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import com.facebook.react.uimanager.events.NativeGestureUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Wrapper view for {@link ViewPager}. It's forwarding calls to {@link ViewGroup#addView} to add
|
||||
@@ -116,7 +118,7 @@ public class ReactViewPager extends ViewPager {
|
||||
}
|
||||
}
|
||||
|
||||
private class PageChangeListener implements ViewPager.OnPageChangeListener {
|
||||
private class PageChangeListener implements OnPageChangeListener {
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
@@ -2,7 +2,7 @@ include_defs("//ReactAndroid/DEFS")
|
||||
|
||||
# This target is only used in open source
|
||||
if IS_OSS_BUILD:
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = 'jni',
|
||||
soname = 'libfb.$(ext)',
|
||||
srcs = glob(['*.cpp', 'jni/*.cpp', 'lyra/*.cpp']),
|
||||
|
||||
@@ -2,7 +2,7 @@ include_defs("//ReactAndroid/DEFS")
|
||||
|
||||
include_defs("//ReactCommon/DEFS")
|
||||
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "fbgloginit",
|
||||
srcs = [
|
||||
"glog_init.cpp",
|
||||
|
||||
@@ -7,7 +7,7 @@ include_defs("//ReactAndroid/DEFS")
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "jni-hack",
|
||||
header_namespace = "",
|
||||
exported_headers = [
|
||||
|
||||
@@ -2,7 +2,7 @@ include_defs("//ReactAndroid/DEFS")
|
||||
|
||||
# This target is only used in open source
|
||||
if IS_OSS_BUILD:
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = 'jni',
|
||||
soname = 'libyoga.$(ext)',
|
||||
srcs = glob(['jni/*.cpp']),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
include_defs("//ReactAndroid/DEFS")
|
||||
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "jni",
|
||||
srcs = glob(["*.cpp"]),
|
||||
headers = glob(
|
||||
|
||||
@@ -20,7 +20,7 @@ EXPORTED_HEADERS = [
|
||||
"WritableNativeMap.h",
|
||||
]
|
||||
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "jni",
|
||||
srcs = glob(["*.cpp"]),
|
||||
headers = glob(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
include_defs("//ReactAndroid/DEFS")
|
||||
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "perftests",
|
||||
srcs = ["OnLoad.cpp"],
|
||||
compiler_flags = [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
include_defs("//ReactCommon/DEFS")
|
||||
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "microprofiler",
|
||||
srcs = [
|
||||
"MicroProfiler.cpp",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fb_xplat_cxx_library(
|
||||
cxx_library(
|
||||
name = "yoga",
|
||||
srcs = glob(["yoga/*.cpp"]),
|
||||
header_namespace = "",
|
||||
|
||||
@@ -27,18 +27,27 @@ describe('findPlugins', () => {
|
||||
jest.mock(pjsonPath, () => ({
|
||||
dependencies: {'rnpm-plugin-test': '*'},
|
||||
}));
|
||||
expect(findPlugins([ROOT])).toHaveLength(1);
|
||||
expect(findPlugins([ROOT])[0]).toBe('rnpm-plugin-test');
|
||||
|
||||
expect(findPlugins([ROOT])).toHaveProperty('commands');
|
||||
expect(findPlugins([ROOT])).toHaveProperty('platforms');
|
||||
expect(findPlugins([ROOT]).commands).toHaveLength(1);
|
||||
expect(findPlugins([ROOT]).commands[0]).toBe('rnpm-plugin-test');
|
||||
expect(findPlugins([ROOT]).platforms).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('returns an empty array if there are no plugins in this folder', () => {
|
||||
jest.mock(pjsonPath, () => ({}));
|
||||
expect(findPlugins([ROOT])).toHaveLength(0);
|
||||
expect(findPlugins([ROOT])).toHaveProperty('commands');
|
||||
expect(findPlugins([ROOT])).toHaveProperty('platforms');
|
||||
expect(findPlugins([ROOT]).commands).toHaveLength(0);
|
||||
expect(findPlugins([ROOT]).platforms).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('returns an empty array if there is no package.json in the supplied folder', () => {
|
||||
expect(Array.isArray(findPlugins(['fake-path']))).toBeTruthy();
|
||||
expect(findPlugins(['fake-path'])).toHaveLength(0);
|
||||
it('returns an object with empty arrays if there is no package.json in the supplied folder', () => {
|
||||
expect(findPlugins(['fake-path'])).toHaveProperty('commands');
|
||||
expect(findPlugins(['fake-path'])).toHaveProperty('platforms');
|
||||
expect(findPlugins(['fake-path']).commands).toHaveLength(0);
|
||||
expect(findPlugins(['fake-path']).platforms).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('returns plugins from both dependencies and dev dependencies', () => {
|
||||
@@ -46,7 +55,10 @@ describe('findPlugins', () => {
|
||||
dependencies: {'rnpm-plugin-test': '*'},
|
||||
devDependencies: {'rnpm-plugin-test-2': '*'},
|
||||
}));
|
||||
expect(findPlugins([ROOT])).toHaveLength(2);
|
||||
expect(findPlugins([ROOT])).toHaveProperty('commands');
|
||||
expect(findPlugins([ROOT])).toHaveProperty('platforms');
|
||||
expect(findPlugins([ROOT]).commands).toHaveLength(2);
|
||||
expect(findPlugins([ROOT]).platforms).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('returns unique list of plugins', () => {
|
||||
@@ -54,6 +66,6 @@ describe('findPlugins', () => {
|
||||
dependencies: {'rnpm-plugin-test': '*'},
|
||||
devDependencies: {'rnpm-plugin-test': '*'},
|
||||
}));
|
||||
expect(findPlugins([ROOT])).toHaveLength(1);
|
||||
expect(findPlugins([ROOT]).commands).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -126,3 +126,5 @@ exports.dependencyConfig = function dependencyConfigAndroid(folder, userConfig)
|
||||
|
||||
return { sourceDir, folder, manifest, packageImportPath, packageInstance };
|
||||
};
|
||||
|
||||
exports.linkConfig = require('../../link/android');
|
||||
|
||||
@@ -37,11 +37,19 @@ const findPluginsInReactNativePackage = (pjson) => {
|
||||
return path.join(pjson.name, pjson.rnpm.plugin);
|
||||
};
|
||||
|
||||
const findPlatformsInPackage = (pjson) => {
|
||||
if (!pjson.rnpm || !pjson.rnpm.platform) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return path.join(pjson.name, pjson.rnpm.platform);
|
||||
};
|
||||
|
||||
const findPluginInFolder = (folder) => {
|
||||
const pjson = readPackage(folder);
|
||||
|
||||
if (!pjson) {
|
||||
return [];
|
||||
return {commands: [], platforms: []};
|
||||
}
|
||||
|
||||
const deps = union(
|
||||
@@ -51,27 +59,33 @@ const findPluginInFolder = (folder) => {
|
||||
|
||||
return deps.reduce(
|
||||
(acc, pkg) => {
|
||||
let commands = acc.commands;
|
||||
let platforms = acc.platforms;
|
||||
if (isRNPMPlugin(pkg)) {
|
||||
return acc.concat(pkg);
|
||||
commands = commands.concat(pkg);
|
||||
}
|
||||
if (isReactNativePlugin(pkg)) {
|
||||
const pkgJson = readPackage(path.join(folder, 'node_modules', pkg));
|
||||
if (!pkgJson) {
|
||||
return acc;
|
||||
if (pkgJson) {
|
||||
commands = commands.concat(findPluginsInReactNativePackage(pkgJson));
|
||||
platforms = platforms.concat(findPlatformsInPackage(pkgJson));
|
||||
}
|
||||
return acc.concat(findPluginsInReactNativePackage(pkgJson));
|
||||
}
|
||||
return acc;
|
||||
return {commands: commands, platforms: platforms};
|
||||
},
|
||||
[]
|
||||
{commands: [], platforms: []}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Find plugins in package.json of the given folder
|
||||
* @param {String} folder Path to the folder to get the package.json from
|
||||
* @type {Array} Array of plugins or an empty array if no package.json found
|
||||
* @type {Object} Object of commands and platform plugins
|
||||
*/
|
||||
module.exports = function findPlugins(folders) {
|
||||
return uniq(flatten(folders.map(findPluginInFolder)));
|
||||
const plugins = folders.map(findPluginInFolder);
|
||||
return {
|
||||
commands: uniq(flatten(plugins.map(p => p.commands))),
|
||||
platforms: uniq(flatten(plugins.map(p => p.platforms)))
|
||||
};
|
||||
};
|
||||
|
||||
+42
-12
@@ -15,7 +15,6 @@ const Config = require('../util/Config');
|
||||
const findPlugins = require('./findPlugins');
|
||||
const findAssets = require('./findAssets');
|
||||
const ios = require('./ios');
|
||||
const windows = require('./windows');
|
||||
const wrapCommands = require('./wrapCommands');
|
||||
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
@@ -33,6 +32,10 @@ import type {ConfigT} from 'metro';
|
||||
|
||||
export type RNConfig = {
|
||||
...ConfigT,
|
||||
/**
|
||||
* Returns an object with all platform configurations.
|
||||
*/
|
||||
getPlatformConfig(): Object,
|
||||
/**
|
||||
* Returns an array of project commands used by the CLI to load
|
||||
*/
|
||||
@@ -55,10 +58,21 @@ const attachPackage = (command, pkg) => Array.isArray(command)
|
||||
? command.map(cmd => attachPackage(cmd, pkg))
|
||||
: { ...command, pkg };
|
||||
|
||||
const appRoot = process.cwd();
|
||||
const plugins = findPlugins([appRoot]);
|
||||
const pluginPlatforms = plugins
|
||||
.platforms
|
||||
.reduce((acc, pathToPlatforms) => {
|
||||
// $FlowFixMe non-literal require
|
||||
return Object.assign(acc, require(path.join(appRoot, 'node_modules', pathToPlatforms)));
|
||||
},
|
||||
{});
|
||||
|
||||
const defaultRNConfig = {
|
||||
|
||||
getProjectCommands(): Array<CommandT> {
|
||||
const appRoot = process.cwd();
|
||||
const plugins = findPlugins([appRoot])
|
||||
const commands = plugins
|
||||
.commands
|
||||
.map(pathToCommands => {
|
||||
const name = pathToCommands.split(path.sep)[0];
|
||||
|
||||
@@ -70,35 +84,51 @@ const defaultRNConfig = {
|
||||
);
|
||||
});
|
||||
|
||||
return flatten(plugins);
|
||||
return flatten(commands);
|
||||
},
|
||||
|
||||
getPlatformConfig(): Object {
|
||||
return {
|
||||
ios,
|
||||
android,
|
||||
...pluginPlatforms
|
||||
};
|
||||
},
|
||||
|
||||
getProjectConfig(): Object {
|
||||
const platforms = this.getPlatformConfig();
|
||||
const folder = process.cwd();
|
||||
const rnpm = getRNPMConfig(folder);
|
||||
|
||||
return Object.assign({}, rnpm, {
|
||||
ios: ios.projectConfig(folder, rnpm.ios || {}),
|
||||
android: android.projectConfig(folder, rnpm.android || {}),
|
||||
windows: windows.projectConfig(folder, rnpm.windows || {}),
|
||||
let config = Object.assign({}, rnpm, {
|
||||
assets: findAssets(folder, rnpm.assets),
|
||||
});
|
||||
|
||||
Object.keys(platforms).forEach(key => {
|
||||
config[key] = platforms[key].projectConfig(folder, rnpm[key] || {});
|
||||
});
|
||||
|
||||
return config;
|
||||
},
|
||||
|
||||
getDependencyConfig(packageName: string) {
|
||||
const platforms = this.getPlatformConfig();
|
||||
const folder = path.join(process.cwd(), 'node_modules', packageName);
|
||||
const rnpm = getRNPMConfig(
|
||||
path.join(process.cwd(), 'node_modules', packageName)
|
||||
);
|
||||
|
||||
return Object.assign({}, rnpm, {
|
||||
ios: ios.dependencyConfig(folder, rnpm.ios || {}),
|
||||
android: android.dependencyConfig(folder, rnpm.android || {}),
|
||||
windows: windows.dependencyConfig(folder, rnpm.windows || {}),
|
||||
let config = Object.assign({}, rnpm, {
|
||||
assets: findAssets(folder, rnpm.assets),
|
||||
commands: wrapCommands(rnpm.commands),
|
||||
params: rnpm.params || [],
|
||||
});
|
||||
|
||||
Object.keys(platforms).forEach(key => {
|
||||
config[key] = platforms[key].dependencyConfig(folder, rnpm[key] || {});
|
||||
});
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -57,3 +57,5 @@ exports.projectConfig = function projectConfigIOS(folder, userConfig) {
|
||||
};
|
||||
|
||||
exports.dependencyConfig = exports.projectConfig;
|
||||
|
||||
exports.linkConfig = require('../../link/ios');
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* Gets package's namespace
|
||||
* by searching for its declaration in all C# files present in the folder
|
||||
*
|
||||
* @param {String} folder Folder to find C# files
|
||||
*/
|
||||
module.exports = function getNamespace(folder) {
|
||||
const files = glob.sync('**/*.cs', { cwd: folder });
|
||||
|
||||
const packages = files
|
||||
.map(filePath => fs.readFileSync(path.join(folder, filePath), 'utf8'))
|
||||
.map(file => file.match(/namespace (.*)[\s\S]+IReactPackage/))
|
||||
.filter(match => match);
|
||||
|
||||
return packages.length ? packages[0][1] : null;
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* Gets package's class name (class that implements IReactPackage)
|
||||
* by searching for its declaration in all C# files present in the folder
|
||||
*
|
||||
* @param {String} folder Folder to find C# files
|
||||
*/
|
||||
module.exports = function getPackageClassName(folder) {
|
||||
const files = glob.sync('**/*.cs', { cwd: folder });
|
||||
|
||||
const packages = files
|
||||
.map(filePath => fs.readFileSync(path.join(folder, filePath), 'utf8'))
|
||||
.map(file => file.match(/class (.*) : IReactPackage/))
|
||||
.filter(match => match);
|
||||
|
||||
return packages.length ? packages[0][1] : null;
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* Find an C# project file
|
||||
*
|
||||
* @param {String} folder Name of the folder where to seek
|
||||
* @return {String}
|
||||
*/
|
||||
module.exports = function findManifest(folder) {
|
||||
const csprojPath = glob.sync(path.join('**', '*.csproj'), {
|
||||
cwd: folder,
|
||||
ignore: ['node_modules/**', '**/build/**', 'Examples/**', 'examples/**'],
|
||||
})[0];
|
||||
|
||||
return csprojPath ? path.join(folder, csprojPath) : null;
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* Glob pattern to look for solution file
|
||||
*/
|
||||
const GLOB_PATTERN = '**/*.sln';
|
||||
|
||||
/**
|
||||
* Regexp matching all test projects
|
||||
*/
|
||||
const TEST_PROJECTS = /test|example|sample/i;
|
||||
|
||||
/**
|
||||
* Base windows folder
|
||||
*/
|
||||
const WINDOWS_BASE = 'windows';
|
||||
|
||||
/**
|
||||
* These folders will be excluded from search to speed it up
|
||||
*/
|
||||
const GLOB_EXCLUDE_PATTERN = ['**/@(node_modules)/**'];
|
||||
|
||||
/**
|
||||
* Finds windows project by looking for all .sln files
|
||||
* in given folder.
|
||||
*
|
||||
* Returns first match if files are found or null
|
||||
*
|
||||
* Note: `./windows/*.sln` are returned regardless of the name
|
||||
*/
|
||||
module.exports = function findSolution(folder) {
|
||||
const projects = glob
|
||||
.sync(GLOB_PATTERN, {
|
||||
cwd: folder,
|
||||
ignore: GLOB_EXCLUDE_PATTERN,
|
||||
})
|
||||
.filter(project => {
|
||||
return path.dirname(project) === WINDOWS_BASE || !TEST_PROJECTS.test(project);
|
||||
})
|
||||
.sort((projectA, projectB) => {
|
||||
return path.dirname(projectA) === WINDOWS_BASE ? -1 : 1;
|
||||
});
|
||||
|
||||
if (projects.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return projects[0];
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
const s4 = () => {
|
||||
return Math.floor((1 + Math.random()) * 0x10000)
|
||||
.toString(16)
|
||||
.substring(1);
|
||||
};
|
||||
|
||||
module.exports = function generateGUID() {
|
||||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
|
||||
s4() + '-' + s4() + s4() + s4();
|
||||
};
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const findWindowsSolution = require('./findWindowsSolution');
|
||||
const findNamespace = require('./findNamespace');
|
||||
const findProject = require('./findProject');
|
||||
const findPackageClassName = require('./findPackageClassName');
|
||||
const path = require('path');
|
||||
const generateGUID = require('./generateGUID');
|
||||
|
||||
const relativeProjectPath = (fullProjPath) => {
|
||||
const windowsPath = fullProjPath
|
||||
.substring(fullProjPath.lastIndexOf('node_modules') - 1, fullProjPath.length)
|
||||
.replace(/\//g, '\\');
|
||||
|
||||
return '..' + windowsPath;
|
||||
};
|
||||
|
||||
const getProjectName = (fullProjPath) => {
|
||||
return fullProjPath.split('/').slice(-1)[0].replace(/\.csproj/i, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets windows project config by analyzing given folder and taking some
|
||||
* defaults specified by user into consideration
|
||||
*/
|
||||
exports.projectConfig = function projectConfigWindows(folder, userConfig) {
|
||||
|
||||
const csSolution = userConfig.csSolution || findWindowsSolution(folder);
|
||||
|
||||
if (!csSolution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// expects solutions to be named the same as project folders
|
||||
const solutionPath = path.join(folder, csSolution);
|
||||
const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf('.sln'));
|
||||
const src = userConfig.sourceDir || windowsAppFolder;
|
||||
const sourceDir = path.join(folder, src);
|
||||
const mainPage = path.join(sourceDir, 'MainPage.cs');
|
||||
const projectPath = userConfig.projectPath || findProject(folder);
|
||||
|
||||
return {
|
||||
sourceDir,
|
||||
solutionPath,
|
||||
projectPath,
|
||||
mainPage,
|
||||
folder,
|
||||
userConfig,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Same as projectConfigWindows except it returns
|
||||
* different config that applies to packages only
|
||||
*/
|
||||
exports.dependencyConfig = function dependencyConfigWindows(folder, userConfig) {
|
||||
|
||||
const csSolution = userConfig.csSolution || findWindowsSolution(folder);
|
||||
|
||||
if (!csSolution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// expects solutions to be named the same as project folders
|
||||
const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf('.sln'));
|
||||
const src = userConfig.sourceDir || windowsAppFolder;
|
||||
|
||||
if (!src) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const sourceDir = path.join(folder, src);
|
||||
const packageClassName = findPackageClassName(sourceDir);
|
||||
const namespace = userConfig.namespace || findNamespace(sourceDir);
|
||||
const csProj = userConfig.csProj || findProject(folder);
|
||||
|
||||
/**
|
||||
* This module has no package to export or no namespace
|
||||
*/
|
||||
if (!packageClassName || !namespace) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const packageUsingPath = userConfig.packageUsingPath ||
|
||||
`using ${namespace};`;
|
||||
|
||||
const packageInstance = userConfig.packageInstance ||
|
||||
`new ${packageClassName}()`;
|
||||
|
||||
const projectGUID = generateGUID();
|
||||
const pathGUID = generateGUID();
|
||||
const projectName = getProjectName(csProj);
|
||||
const relativeProjPath = relativeProjectPath(csProj);
|
||||
|
||||
return {
|
||||
sourceDir,
|
||||
packageUsingPath,
|
||||
packageInstance,
|
||||
projectName,
|
||||
csProj,
|
||||
folder,
|
||||
projectGUID,
|
||||
pathGUID,
|
||||
relativeProjPath,
|
||||
};
|
||||
};
|
||||
@@ -39,6 +39,7 @@ describe('link', () => {
|
||||
|
||||
it('should accept a name of a dependency to link', (done) => {
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ios: {}, android: {}}),
|
||||
getProjectConfig: () => ({ assets: [] }),
|
||||
getDependencyConfig: sinon.stub().returns({ assets: [], commands: {} }),
|
||||
};
|
||||
@@ -54,6 +55,7 @@ describe('link', () => {
|
||||
|
||||
it('should read dependencies from package.json when name not provided', (done) => {
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ios: {}, android: {}}),
|
||||
getProjectConfig: () => ({ assets: [] }),
|
||||
getDependencyConfig: sinon.stub().returns({ assets: [], commands: {} }),
|
||||
};
|
||||
@@ -79,7 +81,10 @@ describe('link', () => {
|
||||
it('should register native module when android/ios projects are present', (done) => {
|
||||
const registerNativeModule = sinon.stub();
|
||||
const dependencyConfig = {android: {}, ios: {}, assets: [], commands: {}};
|
||||
const androidLinkConfig = require('../android');
|
||||
const iosLinkConfig = require('../ios');
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ios: { linkConfig: iosLinkConfig }, android: { linkConfig: androidLinkConfig }}),
|
||||
getProjectConfig: () => ({android: {}, ios: {}, assets: []}),
|
||||
getDependencyConfig: sinon.stub().returns(dependencyConfig),
|
||||
};
|
||||
@@ -116,6 +121,7 @@ describe('link', () => {
|
||||
const registerNativeModule = sinon.stub();
|
||||
const dependencyConfig = {ios: {}, android: {}, assets: [], commands: {}};
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ios: {}, android: {}}),
|
||||
getProjectConfig: () => ({ ios: {}, android: {}, assets: [] }),
|
||||
getDependencyConfig: sinon.stub().returns(dependencyConfig),
|
||||
};
|
||||
@@ -148,6 +154,62 @@ describe('link', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should register native modules for plugins', (done) => {
|
||||
const registerNativeModule = sinon.stub();
|
||||
const dependencyConfig = {ios: {}, android: {}, test: {}, assets: [], commands: {}};
|
||||
const linkPluginConfig = { isInstalled: () => false, register: registerNativeModule };
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ ios: {}, android: {}, test: { linkConfig: () => linkPluginConfig }}),
|
||||
getProjectConfig: () => ({ ios: {}, android: {}, test: {}, assets: [] }),
|
||||
getDependencyConfig: sinon.stub().returns(dependencyConfig),
|
||||
};
|
||||
|
||||
jest.setMock(
|
||||
'../ios/isInstalled.js',
|
||||
sinon.stub().returns(true)
|
||||
);
|
||||
|
||||
jest.setMock(
|
||||
'../android/isInstalled.js',
|
||||
sinon.stub().returns(true)
|
||||
);
|
||||
|
||||
const link = require('../link').func;
|
||||
|
||||
link(['react-native-blur'], config).then(() => {
|
||||
expect(registerNativeModule.calledOnce).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not register native modules for plugins when already installed', (done) => {
|
||||
const registerNativeModule = sinon.stub();
|
||||
const dependencyConfig = {ios: {}, android: {}, test: {}, assets: [], commands: {}};
|
||||
const linkPluginConfig = { isInstalled: () => true, register: registerNativeModule};
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ ios: {}, android: {}, test: { linkConfig: () => linkPluginConfig }}),
|
||||
getProjectConfig: () => ({ ios: {}, android: {}, test: {}, assets: [] }),
|
||||
getDependencyConfig: sinon.stub().returns(dependencyConfig),
|
||||
};
|
||||
|
||||
jest.setMock(
|
||||
'../ios/isInstalled.js',
|
||||
sinon.stub().returns(true)
|
||||
);
|
||||
|
||||
jest.setMock(
|
||||
'../android/isInstalled.js',
|
||||
sinon.stub().returns(true)
|
||||
);
|
||||
|
||||
const link = require('../link').func;
|
||||
|
||||
link(['react-native-blur'], config).then(() => {
|
||||
expect(registerNativeModule.callCount).toEqual(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should run prelink and postlink commands at the appropriate times', (done) => {
|
||||
const registerNativeModule = sinon.stub();
|
||||
const prelink = sinon.stub().yieldsAsync();
|
||||
@@ -163,7 +225,9 @@ describe('link', () => {
|
||||
sinon.stub().returns(false)
|
||||
);
|
||||
|
||||
const linkConfig = require('../ios');
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ ios: { linkConfig: linkConfig }}),
|
||||
getProjectConfig: () => ({ ios: {}, assets: [] }),
|
||||
getDependencyConfig: sinon.stub().returns({
|
||||
ios: {}, assets: [], commands: { prelink, postlink },
|
||||
@@ -181,7 +245,7 @@ describe('link', () => {
|
||||
|
||||
it('should copy assets from both project and dependencies projects', (done) => {
|
||||
const dependencyAssets = ['Fonts/Font.ttf'];
|
||||
const dependencyConfig = {assets: dependencyAssets, commands: {}};
|
||||
const dependencyConfig = {assets: dependencyAssets, ios: {}, commands: {}};
|
||||
const projectAssets = ['Fonts/FontC.ttf'];
|
||||
const copyAssets = sinon.stub();
|
||||
|
||||
@@ -190,7 +254,9 @@ describe('link', () => {
|
||||
copyAssets
|
||||
);
|
||||
|
||||
const linkConfig = require('../ios');
|
||||
const config = {
|
||||
getPlatformConfig: () => ({ ios: { linkConfig: linkConfig } }),
|
||||
getProjectConfig: () => ({ ios: {}, assets: projectAssets }),
|
||||
getDependencyConfig: sinon.stub().returns(dependencyConfig),
|
||||
};
|
||||
|
||||
@@ -8,10 +8,10 @@ const groupFilesByType = require('../groupFilesByType');
|
||||
* For now, the only types of files that are handled are:
|
||||
* - Fonts (otf, ttf) - copied to targetPath/fonts under original name
|
||||
*/
|
||||
module.exports = function copyAssetsAndroid(files, targetPath) {
|
||||
module.exports = function copyAssetsAndroid(files, project) {
|
||||
const assets = groupFilesByType(files);
|
||||
|
||||
(assets.font || []).forEach(asset =>
|
||||
fs.copySync(asset, path.join(targetPath, 'fonts', path.basename(asset)))
|
||||
fs.copySync(asset, path.join(project.assetsPath, 'fonts', path.basename(asset)))
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
isInstalled: require('./isInstalled'),
|
||||
register: require('./registerNativeModule'),
|
||||
unregister: require('./unregisterNativeModule'),
|
||||
copyAssets: require('./copyAssets'),
|
||||
unlinkAssets: require('./unlinkAssets')
|
||||
};
|
||||
};
|
||||
@@ -8,11 +8,11 @@ const groupFilesByType = require('../groupFilesByType');
|
||||
* For now, the only types of files that are handled are:
|
||||
* - Fonts (otf, ttf) - copied to targetPath/fonts under original name
|
||||
*/
|
||||
module.exports = function unlinkAssetsAndroid(files, targetPath) {
|
||||
module.exports = function unlinkAssetsAndroid(files, project) {
|
||||
const assets = groupFilesByType(files);
|
||||
|
||||
(assets.font || []).forEach((file) => {
|
||||
const filePath = path.join(targetPath, 'fonts', path.basename(file));
|
||||
const filePath = path.join(project.assetsPath, 'fonts', path.basename(file));
|
||||
if (fs.existsSync(filePath)) {
|
||||
fs.unlinkSync(filePath);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
const isInstalledIOS = require('../isInstalled');
|
||||
const isInstalledPods = require('../../pods/isInstalled');
|
||||
|
||||
module.exports = function isInstalled(config, name) {
|
||||
return isInstalledIOS(config, name) || isInstalledPods(config, name);
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
const registerDependencyIOS = require('../registerNativeModule');
|
||||
const registerDependencyPods = require('../../pods/registerNativeModule');
|
||||
|
||||
module.exports = function registerNativeModule(
|
||||
name,
|
||||
dependencyConfig,
|
||||
params,
|
||||
projectConfig
|
||||
) {
|
||||
if (projectConfig.podfile && dependencyConfig.podspec) {
|
||||
registerDependencyPods(name, dependencyConfig, projectConfig);
|
||||
}
|
||||
else {
|
||||
registerDependencyIOS(dependencyConfig, projectConfig);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
const compact = require('lodash').compact;
|
||||
const isInstalledIOS = require('../isInstalled');
|
||||
const isInstalledPods = require('../../pods/isInstalled');
|
||||
const unregisterDependencyIOS = require('../registerNativeModule');
|
||||
const unregisterDependencyPods = require('../../pods/registerNativeModule');
|
||||
|
||||
module.exports = function unregisterNativeModule(
|
||||
name,
|
||||
dependencyConfig,
|
||||
projectConfig,
|
||||
otherDependencies
|
||||
) {
|
||||
const isIosInstalled = isInstalledIOS(projectConfig, dependencyConfig);
|
||||
const isPodInstalled = isInstalledPods(projectConfig, dependencyConfig);
|
||||
if (isIosInstalled) {
|
||||
const iOSDependencies = compact(otherDependencies.map(d => d.config.ios));
|
||||
unregisterDependencyIOS(dependencyConfig, projectConfig, iOSDependencies);
|
||||
}
|
||||
else if (isPodInstalled) {
|
||||
unregisterDependencyPods(dependencyConfig, projectConfig);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
isInstalled: require('./common/isInstalled'),
|
||||
register: require('./common/registerNativeModule'),
|
||||
unregister: require('./common/unregisterNativeModule'),
|
||||
copyAssets: require('./copyAssets'),
|
||||
unlinkAssets: require('./unlinkAssets')
|
||||
};
|
||||
};
|
||||
+44
-93
@@ -26,16 +26,6 @@ const chalk = require('chalk');
|
||||
* run Flow. */
|
||||
const isEmpty = require('lodash').isEmpty;
|
||||
const promiseWaterfall = require('./promiseWaterfall');
|
||||
const registerDependencyAndroid = require('./android/registerNativeModule');
|
||||
const registerDependencyWindows = require('./windows/registerNativeModule');
|
||||
const registerDependencyIOS = require('./ios/registerNativeModule');
|
||||
const registerDependencyPods = require('./pods/registerNativeModule');
|
||||
const isInstalledAndroid = require('./android/isInstalled');
|
||||
const isInstalledWindows = require('./windows/isInstalled');
|
||||
const isInstalledIOS = require('./ios/isInstalled');
|
||||
const isInstalledPods = require('./pods/isInstalled');
|
||||
const copyAssetsAndroid = require('./android/copyAssets');
|
||||
const copyAssetsIOS = require('./ios/copyAssets');
|
||||
const getProjectDependencies = require('./getProjectDependencies');
|
||||
const getDependencyConfig = require('./getDependencyConfig');
|
||||
const pollParams = require('./pollParams');
|
||||
@@ -49,95 +39,55 @@ log.heading = 'rnpm-link';
|
||||
|
||||
const dedupeAssets = (assets) => uniqBy(assets, asset => path.basename(asset));
|
||||
|
||||
const linkDependency = (platforms, project, dependency) => {
|
||||
Object.keys(platforms || {})
|
||||
.forEach(platform => {
|
||||
if (!project[platform] || !dependency.config[platform]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const linkDependencyAndroid = (androidProject, dependency) => {
|
||||
if (!androidProject || !dependency.config.android) {
|
||||
return null;
|
||||
}
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
if (!linkConfig || !linkConfig.isInstalled || !linkConfig.register) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isInstalled = isInstalledAndroid(androidProject, dependency.name);
|
||||
const isInstalled = linkConfig.isInstalled(project[platform], dependency.config[platform]);
|
||||
|
||||
if (isInstalled) {
|
||||
log.info(chalk.grey(`Android module ${dependency.name} is already linked`));
|
||||
return null;
|
||||
}
|
||||
if (isInstalled) {
|
||||
log.info(chalk.grey(`Platform '${platform}' module ${dependency.name} is already linked`));
|
||||
return null;
|
||||
}
|
||||
|
||||
return pollParams(dependency.config.params).then(params => {
|
||||
log.info(`Linking ${dependency.name} android dependency`);
|
||||
return pollParams(dependency.config.params).then(params => {
|
||||
log.info(`Linking ${dependency.name} ${platform} dependency`);
|
||||
|
||||
registerDependencyAndroid(
|
||||
dependency.name,
|
||||
dependency.config.android,
|
||||
params,
|
||||
androidProject
|
||||
);
|
||||
linkConfig.register(
|
||||
dependency.name,
|
||||
dependency.config[platform],
|
||||
params,
|
||||
project[platform]
|
||||
);
|
||||
|
||||
log.info(`Android module ${dependency.name} has been successfully linked`);
|
||||
});
|
||||
log.info(`Platform '${platform}' module ${dependency.name} has been successfully linked`);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const linkDependencyWindows = (windowsProject, dependency) => {
|
||||
|
||||
if (!windowsProject || !dependency.config.windows) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isInstalled = isInstalledWindows(windowsProject, dependency.config.windows);
|
||||
|
||||
if (isInstalled) {
|
||||
log.info(chalk.grey(`Windows module ${dependency.name} is already linked`));
|
||||
return null;
|
||||
}
|
||||
|
||||
return pollParams(dependency.config.params).then(params => {
|
||||
log.info(`Linking ${dependency.name} windows dependency`);
|
||||
|
||||
registerDependencyWindows(
|
||||
dependency.name,
|
||||
dependency.config.windows,
|
||||
params,
|
||||
windowsProject
|
||||
);
|
||||
|
||||
log.info(`Windows module ${dependency.name} has been successfully linked`);
|
||||
});
|
||||
};
|
||||
|
||||
const linkDependencyIOS = (iOSProject, dependency) => {
|
||||
if (!iOSProject || !dependency.config.ios) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isInstalled = isInstalledIOS(iOSProject, dependency.config.ios) || isInstalledPods(iOSProject, dependency.config.ios);
|
||||
if (isInstalled) {
|
||||
log.info(chalk.grey(`iOS module ${dependency.name} is already linked`));
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`Linking ${dependency.name} ios dependency`);
|
||||
if (iOSProject.podfile && dependency.config.ios.podspec) {
|
||||
registerDependencyPods(dependency, iOSProject);
|
||||
}
|
||||
else {
|
||||
registerDependencyIOS(dependency.config.ios, iOSProject);
|
||||
}
|
||||
log.info(`iOS module ${dependency.name} has been successfully linked`);
|
||||
};
|
||||
|
||||
const linkAssets = (project, assets) => {
|
||||
const linkAssets = (platforms, project, assets) => {
|
||||
if (isEmpty(assets)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (project.ios) {
|
||||
log.info('Linking assets to ios project');
|
||||
copyAssetsIOS(assets, project.ios);
|
||||
}
|
||||
Object.keys(platforms || {})
|
||||
.forEach(platform => {
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
if (!linkConfig || !linkConfig.copyAssets) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (project.android) {
|
||||
log.info('Linking assets to android project');
|
||||
copyAssetsAndroid(assets, project.android.assetsPath);
|
||||
}
|
||||
log.info(`Linking assets to ${platform} project`);
|
||||
linkConfig.copyAssets(assets, project[platform]);
|
||||
});
|
||||
|
||||
log.info('Assets have been successfully linked to your project');
|
||||
};
|
||||
@@ -150,9 +100,11 @@ const linkAssets = (project, assets) => {
|
||||
* @param config CLI config, see local-cli/core/index.js
|
||||
*/
|
||||
function link(args: Array<string>, config: RNConfig) {
|
||||
var project;
|
||||
let project;
|
||||
let platforms;
|
||||
try {
|
||||
project = config.getProjectConfig();
|
||||
platforms = config.getPlatformConfig();
|
||||
} catch (err) {
|
||||
log.error(
|
||||
'ERRPACKAGEJSON',
|
||||
@@ -161,7 +113,8 @@ function link(args: Array<string>, config: RNConfig) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
if (!project.android && !project.ios && !project.windows && findReactNativeScripts()) {
|
||||
const hasProjectConfig = Object.keys(platforms).reduce((acc, key) => acc || key in project, false);
|
||||
if (!hasProjectConfig && findReactNativeScripts()) {
|
||||
throw new Error(
|
||||
'`react-native link` can not be used in Create React Native App projects. ' +
|
||||
'If you need to include a library that relies on custom native code, ' +
|
||||
@@ -183,19 +136,17 @@ function link(args: Array<string>, config: RNConfig) {
|
||||
);
|
||||
|
||||
const assets = dedupeAssets(dependencies.reduce(
|
||||
(assets, dependency) => assets.concat(dependency.config.assets),
|
||||
(acc, dependency) => acc.concat(dependency.config.assets),
|
||||
project.assets
|
||||
));
|
||||
|
||||
const tasks = flatten(dependencies.map(dependency => [
|
||||
() => promisify(dependency.config.commands.prelink || commandStub),
|
||||
() => linkDependencyAndroid(project.android, dependency),
|
||||
() => linkDependencyIOS(project.ios, dependency),
|
||||
() => linkDependencyWindows(project.windows, dependency),
|
||||
() => linkDependency(platforms, project, dependency),
|
||||
() => promisify(dependency.config.commands.postlink || commandStub),
|
||||
]));
|
||||
|
||||
tasks.push(() => linkAssets(project, assets));
|
||||
tasks.push(() => linkAssets(platforms, project, assets));
|
||||
|
||||
return promiseWaterfall(tasks).catch(err => {
|
||||
log.error(
|
||||
|
||||
@@ -7,10 +7,10 @@ const findMarkedLinesInPodfile = require('./findMarkedLinesInPodfile');
|
||||
const addPodEntry = require('./addPodEntry');
|
||||
const savePodFile = require('./savePodFile');
|
||||
|
||||
module.exports = function registerNativeModulePods(dependency, iOSProject) {
|
||||
module.exports = function registerNativeModulePods(name, dependencyConfig, iOSProject) {
|
||||
const podLines = readPodfile(iOSProject.podfile);
|
||||
const linesToAddEntry = getLinesToAddEntry(podLines, iOSProject);
|
||||
addPodEntry(podLines, linesToAddEntry, dependency.config.ios.podspec, dependency.name);
|
||||
addPodEntry(podLines, linesToAddEntry, dependencyConfig.podspec, name);
|
||||
savePodFile(iOSProject.podfile, podLines);
|
||||
};
|
||||
|
||||
|
||||
+39
-79
@@ -1,18 +1,7 @@
|
||||
const log = require('npmlog');
|
||||
|
||||
const getProjectDependencies = require('./getProjectDependencies');
|
||||
const unregisterDependencyAndroid = require('./android/unregisterNativeModule');
|
||||
const unregisterDependencyWindows = require('./windows/unregisterNativeModule');
|
||||
const unregisterDependencyIOS = require('./ios/unregisterNativeModule');
|
||||
const unregisterDependencyPods = require('./pods/unregisterNativeModule');
|
||||
const isInstalledAndroid = require('./android/isInstalled');
|
||||
const isInstalledWindows = require('./windows/isInstalled');
|
||||
const isInstalledIOS = require('./ios/isInstalled');
|
||||
const isInstalledPods = require('./pods/isInstalled');
|
||||
const unlinkAssetsAndroid = require('./android/unlinkAssets');
|
||||
const unlinkAssetsIOS = require('./ios/unlinkAssets');
|
||||
const getDependencyConfig = require('./getDependencyConfig');
|
||||
const compact = require('lodash').compact;
|
||||
const difference = require('lodash').difference;
|
||||
const filter = require('lodash').filter;
|
||||
const flatten = require('lodash').flatten;
|
||||
@@ -23,66 +12,37 @@ const promisify = require('./promisify');
|
||||
|
||||
log.heading = 'rnpm-link';
|
||||
|
||||
const unlinkDependencyAndroid = (androidProject, dependency, packageName) => {
|
||||
if (!androidProject || !dependency.android) {
|
||||
return;
|
||||
}
|
||||
const unlinkDependency = (platforms, project, dependency, packageName, otherDependencies) => {
|
||||
|
||||
const isInstalled = isInstalledAndroid(androidProject, packageName);
|
||||
Object.keys(platforms || {})
|
||||
.forEach(platform => {
|
||||
if (!project[platform] || !dependency[platform]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInstalled) {
|
||||
log.info(`Android module ${packageName} is not installed`);
|
||||
return;
|
||||
}
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
if (!linkConfig || !linkConfig.isInstalled || !linkConfig.unregister) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`Unlinking ${packageName} android dependency`);
|
||||
const isInstalled = linkConfig.isInstalled(project[platform], dependency[platform]);
|
||||
|
||||
unregisterDependencyAndroid(packageName, dependency.android, androidProject);
|
||||
if (!isInstalled) {
|
||||
log.info(`Platform '${platform}' module ${packageName} is not installed`);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`Android module ${packageName} has been successfully unlinked`);
|
||||
};
|
||||
log.info(`Unlinking ${packageName} ${platform} dependency`);
|
||||
|
||||
const unlinkDependencyWindows = (windowsProject, dependency, packageName) => {
|
||||
if (!windowsProject || !dependency.windows) {
|
||||
return;
|
||||
}
|
||||
linkConfig.unregister(
|
||||
packageName,
|
||||
dependency[platform],
|
||||
project[platform],
|
||||
otherDependencies
|
||||
);
|
||||
|
||||
const isInstalled = isInstalledWindows(windowsProject, dependency.windows);
|
||||
|
||||
if (!isInstalled) {
|
||||
log.info(`Windows module ${packageName} is not installed`);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`Unlinking ${packageName} windows dependency`);
|
||||
|
||||
unregisterDependencyWindows(packageName, dependency.windows, windowsProject);
|
||||
|
||||
log.info(`Windows module ${packageName} has been successfully unlinked`);
|
||||
};
|
||||
|
||||
const unlinkDependencyIOS = (iOSProject, dependency, packageName, iOSDependencies) => {
|
||||
if (!iOSProject || !dependency.ios) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isIosInstalled = isInstalledIOS(iOSProject, dependency.ios);
|
||||
const isPodInstalled = isInstalledPods(iOSProject, dependency.ios);
|
||||
if (!isIosInstalled && !isPodInstalled) {
|
||||
log.info(`iOS module ${packageName} is not installed`);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`Unlinking ${packageName} ios dependency`);
|
||||
|
||||
if (isIosInstalled) {
|
||||
unregisterDependencyIOS(dependency.ios, iOSProject, iOSDependencies);
|
||||
}
|
||||
else if (isPodInstalled) {
|
||||
unregisterDependencyPods(dependency.ios, iOSProject);
|
||||
}
|
||||
|
||||
log.info(`iOS module ${packageName} has been successfully unlinked`);
|
||||
log.info(`Platform '${platform}' module ${dependency.name} has been successfully unlinked`);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -94,10 +54,12 @@ const unlinkDependencyIOS = (iOSProject, dependency, packageName, iOSDependencie
|
||||
function unlink(args, config) {
|
||||
const packageName = args[0];
|
||||
|
||||
var project;
|
||||
var dependency;
|
||||
let platforms;
|
||||
let project;
|
||||
let dependency;
|
||||
|
||||
try {
|
||||
platforms = config.getPlatformConfig();
|
||||
project = config.getProjectConfig();
|
||||
} catch (err) {
|
||||
log.error(
|
||||
@@ -119,13 +81,10 @@ function unlink(args, config) {
|
||||
|
||||
const allDependencies = getDependencyConfig(config, getProjectDependencies());
|
||||
const otherDependencies = filter(allDependencies, d => d.name !== packageName);
|
||||
const iOSDependencies = compact(otherDependencies.map(d => d.config.ios));
|
||||
|
||||
const tasks = [
|
||||
() => promisify(dependency.commands.preunlink || commandStub),
|
||||
() => unlinkDependencyAndroid(project.android, dependency, packageName),
|
||||
() => unlinkDependencyIOS(project.ios, dependency, packageName, iOSDependencies),
|
||||
() => unlinkDependencyWindows(project.windows, dependency, packageName),
|
||||
() => unlinkDependency(platforms, project, dependency, packageName, otherDependencies),
|
||||
() => promisify(dependency.commands.postunlink || commandStub)
|
||||
];
|
||||
|
||||
@@ -142,15 +101,16 @@ function unlink(args, config) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (project.ios) {
|
||||
log.info('Unlinking assets from ios project');
|
||||
unlinkAssetsIOS(assets, project.ios);
|
||||
}
|
||||
|
||||
if (project.android) {
|
||||
log.info('Unlinking assets from android project');
|
||||
unlinkAssetsAndroid(assets, project.android.assetsPath);
|
||||
}
|
||||
Object.keys(platforms || {})
|
||||
.forEach(platform => {
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
if (!linkConfig || !linkConfig.unlinkAssets) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`Unlinking assets from ${platform} project`);
|
||||
linkConfig.unlinkAssets(assets, project[platform]);
|
||||
});
|
||||
|
||||
log.info(
|
||||
`${packageName} assets has been successfully unlinked from your project`
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const makeUsingPatch = require('./patches/makeUsingPatch');
|
||||
|
||||
module.exports = function isInstalled(config, dependencyConfig) {
|
||||
return fs
|
||||
.readFileSync(config.mainPage)
|
||||
.indexOf(makeUsingPatch(dependencyConfig.packageUsingPath).patch) > -1;
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
const toCamelCase = require('lodash').camelCase;
|
||||
|
||||
module.exports = function applyParams(str, params, prefix) {
|
||||
return str.replace(
|
||||
/\$\{(\w+)\}/g,
|
||||
(pattern, param) => {
|
||||
const name = toCamelCase(prefix) + '_' + param;
|
||||
|
||||
return params[param]
|
||||
? `getResources().getString(R.string.${name})`
|
||||
: null;
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = function applyPatch(file, patch, flip = false) {
|
||||
|
||||
fs.writeFileSync(file, fs
|
||||
.readFileSync(file, 'utf8')
|
||||
.replace(patch.pattern, match => {
|
||||
return flip ? `${patch.patch}${match}` : `${match}${patch.patch}`;
|
||||
})
|
||||
);
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
const applyParams = require('./applyParams');
|
||||
|
||||
module.exports = function makePackagePatch(packageInstance, params, prefix) {
|
||||
const processedInstance = applyParams(packageInstance, params, prefix);
|
||||
|
||||
return {
|
||||
pattern: 'new MainReactPackage()',
|
||||
patch: ',\n ' + processedInstance,
|
||||
};
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
module.exports = function makeProjectPatch(windowsConfig) {
|
||||
|
||||
const projectInsert = `<ProjectReference Include="..\\${windowsConfig.relativeProjPath}">
|
||||
<Project>{${windowsConfig.pathGUID}}</Project>
|
||||
<Name>${windowsConfig.projectName}</Name>
|
||||
</ProjectReference>
|
||||
`;
|
||||
|
||||
return {
|
||||
pattern: '<ProjectReference Include="..\\..\\node_modules\\react-native-windows\\ReactWindows\\ReactNative\\ReactNative.csproj">',
|
||||
patch: projectInsert,
|
||||
unpatch: new RegExp(`<ProjectReference.+\\s+.+\\s+.+${windowsConfig.projectName}.+\\s+.+\\s`),
|
||||
};
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
module.exports = function makeSolutionPatch(windowsConfig) {
|
||||
|
||||
const solutionInsert = `Project("{${windowsConfig.projectGUID.toUpperCase()}}") = "${windowsConfig.projectName}", "${windowsConfig.relativeProjPath}", "{${windowsConfig.pathGUID.toUpperCase()}}"
|
||||
EndProject
|
||||
`;
|
||||
|
||||
return {
|
||||
pattern: 'Global',
|
||||
patch: solutionInsert,
|
||||
unpatch: new RegExp(`Project.+${windowsConfig.projectName}.+\\s+EndProject\\s+`),
|
||||
};
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
module.exports = function makeUsingPatch(packageImportPath) {
|
||||
return {
|
||||
pattern: 'using ReactNative.Modules.Core;',
|
||||
patch: '\n' + packageImportPath,
|
||||
};
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = function revokePatch(file, patch) {
|
||||
const unpatch = patch.unpatch || patch.patch;
|
||||
fs.writeFileSync(file, fs
|
||||
.readFileSync(file, 'utf8')
|
||||
.replace(unpatch, '')
|
||||
);
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
const applyPatch = require('./patches/applyPatch');
|
||||
|
||||
const makeProjectPatch = require('./patches/makeProjectPatch');
|
||||
const makeSolutionPatch = require('./patches/makeSolutionPatch');
|
||||
const makeUsingPatch = require('./patches/makeUsingPatch');
|
||||
const makePackagePatch = require('./patches/makePackagePatch');
|
||||
|
||||
module.exports = function registerNativeWindowsModule(
|
||||
name,
|
||||
windowsConfig,
|
||||
params,
|
||||
projectConfig
|
||||
) {
|
||||
applyPatch(projectConfig.projectPath, makeProjectPatch(windowsConfig), true);
|
||||
applyPatch(projectConfig.solutionPath, makeSolutionPatch(windowsConfig), true);
|
||||
|
||||
applyPatch(
|
||||
projectConfig.mainPage,
|
||||
makePackagePatch(windowsConfig.packageInstance, params, name)
|
||||
);
|
||||
|
||||
applyPatch(
|
||||
projectConfig.mainPage,
|
||||
makeUsingPatch(windowsConfig.packageUsingPath)
|
||||
);
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const toCamelCase = require('lodash').camelCase;
|
||||
|
||||
const revokePatch = require('./patches/revokePatch');
|
||||
const makeProjectPatch = require('./patches/makeProjectPatch');
|
||||
const makeSolutionPatch = require('./patches/makeSolutionPatch');
|
||||
const makeUsingPatch = require('./patches/makeUsingPatch');
|
||||
const makePackagePatch = require('./patches/makePackagePatch');
|
||||
|
||||
module.exports = function unregisterNativeWindowsModule(
|
||||
name,
|
||||
windowsConfig,
|
||||
projectConfig
|
||||
) {
|
||||
revokePatch(projectConfig.projectPath, makeProjectPatch(windowsConfig));
|
||||
revokePatch(projectConfig.solutionPath, makeSolutionPatch(windowsConfig));
|
||||
|
||||
revokePatch(
|
||||
projectConfig.mainPage,
|
||||
makePackagePatch(windowsConfig.packageInstance, {}, name)
|
||||
);
|
||||
|
||||
revokePatch(
|
||||
projectConfig.mainPage,
|
||||
makeUsingPatch(windowsConfig.packageUsingPath)
|
||||
);
|
||||
};
|
||||
@@ -14,8 +14,8 @@ const launchChrome = require('../util/launchChrome');
|
||||
|
||||
const {exec} = require('child_process');
|
||||
|
||||
function launchChromeDevTools(port, args = '') {
|
||||
var debuggerURL = 'http://localhost:' + port + '/debugger-ui' + args;
|
||||
function launchChromeDevTools(host, args = '') {
|
||||
var debuggerURL = 'http://' + host + '/debugger-ui' + args;
|
||||
console.log('Launching Dev Tools...');
|
||||
launchChrome(debuggerURL);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ function escapePath(pathname) {
|
||||
return '"' + pathname + '"';
|
||||
}
|
||||
|
||||
function launchDevTools({port, projectRoots}, isChromeConnected) {
|
||||
function launchDevTools({host, projectRoots}, isChromeConnected) {
|
||||
// Explicit config always wins
|
||||
var customDebugger = process.env.REACT_DEBUGGER;
|
||||
if (customDebugger) {
|
||||
@@ -39,12 +39,13 @@ function launchDevTools({port, projectRoots}, isChromeConnected) {
|
||||
});
|
||||
} else if (!isChromeConnected()) {
|
||||
// Dev tools are not yet open; we need to open a session
|
||||
launchChromeDevTools(port);
|
||||
launchChromeDevTools(host);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(options, isChromeConnected) {
|
||||
return function(req, res, next) {
|
||||
var host = req.headers.host;
|
||||
if (req.url === '/launch-safari-devtools') {
|
||||
// TODO: remove `console.log` and dev tools binary
|
||||
console.log(
|
||||
@@ -62,7 +63,7 @@ module.exports = function(options, isChromeConnected) {
|
||||
launchDevTools(options, isChromeConnected);
|
||||
res.end('OK');
|
||||
} else if (req.url === '/launch-js-devtools') {
|
||||
launchDevTools(options, isChromeConnected);
|
||||
launchDevTools({...options, host}, isChromeConnected);
|
||||
res.end('OK');
|
||||
} else {
|
||||
next();
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native",
|
||||
"version": "1000.0.0",
|
||||
"version": "0.53.2",
|
||||
"description": "A framework for building native apps using React",
|
||||
"license": "BSD-3-Clause",
|
||||
"repository": {
|
||||
@@ -217,4 +217,4 @@
|
||||
"shelljs": "^0.7.8",
|
||||
"sinon": "^2.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ Pod::Spec.new do |spec|
|
||||
spec.source = { :git => 'https://github.com/facebook/folly.git',
|
||||
:tag => "v#{spec.version}" }
|
||||
spec.module_name = 'folly'
|
||||
spec.dependency 'boost'
|
||||
spec.dependency 'boost-for-react-native'
|
||||
spec.dependency 'DoubleConversion'
|
||||
spec.dependency 'GLog'
|
||||
spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
|
||||
@@ -28,7 +28,7 @@ Pod::Spec.new do |spec|
|
||||
spec.libraries = "stdc++"
|
||||
spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO",
|
||||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++14",
|
||||
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\"" }
|
||||
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" }
|
||||
|
||||
# Pinning to the same version as React.podspec.
|
||||
spec.platforms = { :ios => "8.0", :tvos => "9.2" }
|
||||
|
||||
@@ -10,6 +10,7 @@ Pod::Spec.new do |spec|
|
||||
spec.source = { :git => 'https://github.com/google/glog.git',
|
||||
:tag => "v#{spec.version}" }
|
||||
spec.module_name = 'glog'
|
||||
spec.header_dir = 'glog'
|
||||
spec.source_files = 'src/glog/*.h',
|
||||
'src/demangle.cc',
|
||||
'src/logging.cc',
|
||||
|
||||
Reference in New Issue
Block a user