Skip to content

Commit e3f3a80

Browse files
MateWWPiotr TrockiMateusz Wit
authored
chore: Create a separate workspaces for lib and example (#249)
* add bob to project * feat: typescript support * refactor: tweak deprecated ref call * fix: podfile.lock conflict * fix: rename example project correctly * fix: package.json files * fix: circle CI typecheck * fix: circle CI build * fix: remove ios(wrong casing) * fix: add ios(with right casing) Co-authored-by: Piotr Trocki <[email protected]> Co-authored-by: Mateusz Wit <[email protected]>
1 parent d499e94 commit e3f3a80

File tree

100 files changed

+10605
-4083
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+10605
-4083
lines changed

.circleci/config.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,38 @@ jobs:
1313
- checkout
1414
- persist_to_workspace:
1515
root: .
16-
paths: .
16+
paths:
17+
- .
18+
install-dependencies:
19+
executor: rn/linux_js
20+
steps:
21+
- attach_workspace:
22+
at: .
23+
- restore_cache:
24+
keys:
25+
- dependencies-{{ checksum "package.json" }}
26+
- dependencies-
27+
- restore_cache:
28+
keys:
29+
- dependencies-example-{{ checksum "example/package.json" }}
30+
- dependencies-example-
31+
- run:
32+
name: Install dependencies
33+
command: |
34+
yarn install --cwd example --frozen-lockfile
35+
yarn install --frozen-lockfile
36+
- save_cache:
37+
key: dependencies-{{ checksum "package.json" }}
38+
paths:
39+
- node_modules
40+
- save_cache:
41+
key: dependencies-example-{{ checksum "example/package.json" }}
42+
paths:
43+
- example/node_modules
44+
- persist_to_workspace:
45+
root: .
46+
paths:
47+
- .
1748
analyse_js:
1849
executor: rn/linux_js
1950
steps:
@@ -24,21 +55,24 @@ jobs:
2455
name: Run ESLint
2556
command: yarn lint
2657
- run:
27-
name: Flow
28-
command: yarn flow
58+
name: Typescript
59+
command: yarn typescript
2960

3061
workflows:
3162
test:
3263
jobs:
3364
# Checkout the code and persist to the Workspace
3465
# Note: This is a job which is defined above and not part of the Orb
3566
- checkout_code
67+
- install-dependencies:
68+
requires:
69+
- checkout_code
3670

3771
# Analyze the Javascript using ESLint, Flow, and Jest
3872
# Note: This is a job which is defined above and not part of the Orb
3973
- analyse_js:
4074
requires:
41-
- checkout_code
75+
- install-dependencies
4276

4377
# Build the Android app in debug mode
4478
- rn/android_build:

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
root: true,
3-
extends: '@react-native-community',
4-
};
2+
root: true,
3+
extends: '@react-native-community',
4+
};

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# react-native-viewpager
22

3-
[![CircleCI branch](https://img.shields.io/circleci/project/github/react-native-community/react-native-viewpager/master.svg)](https://circleci.com/gh/react-native-community/react-native-viewpager/tree/master)
3+
[![CircleCI branch](https://img.shields.io/circleci/build/github/callstack/react-native-viewpager/master.svg)](https://circleci.com/gh/callstack/react-native-viewpager/tree/master)
44
[![npm package](https://badge.fury.io/js/%40react-native-community%2Fviewpager.svg)](https://badge.fury.io/js/%40react-native-community%2Fviewpager)
55
[![Lean Core Extracted](https://img.shields.io/badge/Lean%20Core-Extracted-brightgreen.svg)](https://github.com/facebook/react-native/issues/23313)
6-
[![License](https://img.shields.io/github/license/react-native-community/react-native-viewpager?color=blue)](https://github.com/react-native-community/react-native-viewpager/blob/master/LICENSE)
6+
[![License](https://img.shields.io/github/license/react-native-community/react-native-viewpager?color=blue)](https://github.com/callstack/react-native-viewpager/blob/master/LICENSE)
77

88
This component allows the user to swipe left and right through pages of data. Under the hood it is using the native [Android ViewPager](https://developer.android.com/reference/android/support/v4/view/ViewPager) and the [iOS UIPageViewController](https://developer.apple.com/documentation/uikit/uipageviewcontroller) implementations. [See it in action!](https://github.com/react-native-community/react-native-viewpager#preview)
99

babel.config.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
module.exports = {
22
presets: ['module:metro-react-native-babel-preset'],
3-
plugins: [
4-
[
5-
'module-resolver',
6-
{
7-
alias: {
8-
'@react-native-community/viewpager': './js',
9-
},
10-
cwd: 'babelrc',
11-
},
12-
],
13-
],
143
};

example/android/app/.classpath

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/android/app/_BUCK

Lines changed: 0 additions & 55 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.android.build.OutputFile
99
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
1010
* bundle directly from the development server. Below you can see all the possible configurations
1111
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12-
* `apply from: "../../../node_modules/react-native/react.gradle"` line.
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
1313
*
1414
* project.ext.react = [
1515
* // the name of the generated asset file containing your JS bundle
@@ -18,7 +18,7 @@ import com.android.build.OutputFile
1818
* // the entry file for bundle generation
1919
* entryFile: "index.android.js",
2020
*
21-
* // https://reactnative.dev/docs/performance#enable-the-ram-format
21+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
2222
* bundleCommand: "ram-bundle",
2323
*
2424
* // whether to bundle JS and assets in debug mode
@@ -37,7 +37,7 @@ import com.android.build.OutputFile
3737
* // bundleInBeta: true,
3838
*
3939
* // whether to disable dev mode in custom build variants (by default only disabled in release)
40-
* // for example: to disable dev mode in the staging build type (if configured)
40+
* // for ViewpagerExample: to disable dev mode in the staging build type (if configured)
4141
* devDisabledInStaging: true,
4242
* // The configuration property can be in the following formats
4343
* // 'devDisabledIn${productFlavor}${buildType}'
@@ -64,7 +64,7 @@ import com.android.build.OutputFile
6464
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
6565
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
6666
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67-
* // for example, you might want to remove it from here.
67+
* // for ViewpagerExample, you might want to remove it from here.
6868
* inputExcludes: ["android/**", "ios/**"],
6969
*
7070
* // override which node gets called and with what additional arguments
@@ -76,10 +76,10 @@ import com.android.build.OutputFile
7676
*/
7777

7878
project.ext.react = [
79-
enableHermes: true, // clean and rebuild if changing
79+
enableHermes: false, // clean and rebuild if changing
8080
]
8181

82-
apply from: "../../../node_modules/react-native/react.gradle"
82+
apply from: "../../node_modules/react-native/react.gradle"
8383

8484
/**
8585
* Set this to true to create two separate APKs instead of one:
@@ -99,7 +99,7 @@ def enableProguardInReleaseBuilds = false
9999
/**
100100
* The preferred build flavor of JavaScriptCore.
101101
*
102-
* For example, to use the international variant, you can use:
102+
* For ViewpagerExample, to use the international variant, you can use:
103103
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
104104
*
105105
* The international variant includes ICU i18n library and necessary data
@@ -127,7 +127,7 @@ android {
127127
}
128128

129129
defaultConfig {
130-
applicationId "com.reactnativecommunity.viewpager.example"
130+
applicationId "com.example.reactnativeviewpager"
131131
minSdkVersion rootProject.ext.minSdkVersion
132132
targetSdkVersion rootProject.ext.targetSdkVersion
133133
versionCode 1
@@ -161,13 +161,6 @@ android {
161161
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
162162
}
163163
}
164-
packagingOptions {
165-
pickFirst "lib/armeabi-v7a/libc++_shared.so"
166-
pickFirst "lib/arm64-v8a/libc++_shared.so"
167-
pickFirst "lib/x86/libc++_shared.so"
168-
pickFirst "lib/x86_64/libc++_shared.so"
169-
}
170-
171164
// applicationVariants are e.g. debug, release
172165
applicationVariants.all { variant ->
173166
variant.outputs.each { output ->
@@ -182,35 +175,43 @@ android {
182175

183176
}
184177
}
178+
179+
packagingOptions {
180+
pickFirst "lib/armeabi-v7a/libc++_shared.so"
181+
pickFirst "lib/arm64-v8a/libc++_shared.so"
182+
pickFirst "lib/x86/libc++_shared.so"
183+
pickFirst "lib/x86_64/libc++_shared.so"
184+
}
185185
}
186186

187187
dependencies {
188188
implementation fileTree(dir: "libs", include: ["*.jar"])
189-
implementation "androidx.appcompat:appcompat:${rootProject.ext.appCompatVersion}"
190189
//noinspection GradleDynamicVersion
191190
implementation "com.facebook.react:react-native:+" // From node_modules
192-
implementation project(':react-native-viewpager')
193-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
194191

192+
193+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
195194
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
196-
exclude group: 'com.facebook.fbjni'
195+
exclude group:'com.facebook.fbjni'
197196
}
198197
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
199-
exclude group: 'com.facebook.flipper'
200-
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
198+
exclude group:'com.facebook.flipper'
201199
}
202200
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
203-
exclude group: 'com.facebook.flipper'
201+
exclude group:'com.facebook.flipper'
204202
}
205203

206204
if (enableHermes) {
207-
def hermesPath = "../../../node_modules/hermes-engine/android/";
205+
def hermesPath = "../../node_modules/hermes-engine/android/";
208206
debugImplementation files(hermesPath + "hermes-debug.aar")
209207
releaseImplementation files(hermesPath + "hermes-release.aar")
210208
} else {
211209
implementation jscFlavor
212210
}
211+
212+
implementation project(':reactnativeviewpager')
213213
}
214+
214215
task downloadDependencies() {
215216
description 'Download all dependencies to the Gradle cache'
216217
doLast {
@@ -224,12 +225,12 @@ task downloadDependencies() {
224225
}
225226
}
226227

228+
227229
// Run this once to be able to run the application with BUCK
228230
// puts all compile dependencies into folder libs for BUCK to use
229231
task copyDownloadableDepsToLibs(type: Copy) {
230232
from configurations.compile
231233
into 'libs'
232234
}
233235

234-
235-
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
236+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/build_defs.bzl

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
55
* directory of this source tree.
66
*/
7-
package com.reactnativecommunity.viewpager.example;
7+
package com.example.reactnativeviewpager;
88

99
import android.content.Context;
1010
import com.facebook.flipper.android.AndroidFlipperClient;
@@ -28,19 +28,21 @@ public class ReactNativeFlipper {
2828
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
2929
if (FlipperUtils.shouldEnableFlipper(context)) {
3030
final FlipperClient client = AndroidFlipperClient.getInstance(context);
31-
3231
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
3332
client.addPlugin(new ReactFlipperPlugin());
3433
client.addPlugin(new DatabasesFlipperPlugin(context));
3534
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
3635
client.addPlugin(CrashReporterPlugin.getInstance());
37-
3836
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
3937
NetworkingModule.setCustomClientBuilder(
40-
builder -> builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)));
38+
new NetworkingModule.CustomClientBuilder() {
39+
@Override
40+
public void apply(OkHttpClient.Builder builder) {
41+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42+
}
43+
});
4144
client.addPlugin(networkFlipperPlugin);
4245
client.start();
43-
4446
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
4547
// Hence we run if after all native modules have been initialized
4648
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();

example/android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.reactnativecommunity.viewpager.example">
2+
package="com.example.reactnativeviewpager">
33

44
<uses-permission android:name="android.permission.INTERNET" />
55

66
<application
7-
android:name="com.reactnativecommunity.viewpager.example.MainApplication"
7+
android:name=".MainApplication"
88
android:label="@string/app_name"
99
android:icon="@mipmap/ic_launcher"
1010
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:allowBackup="false"
1212
android:theme="@style/AppTheme">
1313
<activity
14-
android:name="com.reactnativecommunity.viewpager.example.MainActivity"
14+
android:name=".MainActivity"
1515
android:label="@string/app_name"
1616
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
1717
android:launchMode="singleTask"

0 commit comments

Comments
 (0)