Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Replace HTTP client with SwaggerJS #93

Merged
merged 11 commits into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
475 changes: 89 additions & 386 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ReactNativeCouchbaseLiteExample/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
6 changes: 6 additions & 0 deletions ReactNativeCouchbaseLiteExample/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
79 changes: 24 additions & 55 deletions ReactNativeCouchbaseLiteExample/.flowconfig
Original file line number Diff line number Diff line change
@@ -1,63 +1,28 @@
[ignore]

# We fork some components by platform.
.*/*.web.js
.*/*.android.js
.*/*[.]android.js

# Some modules have their own node_modules with overlap
.*/node_modules/node-haste/.*
# Ignore templates with `@flow` in header
.*/local-cli/generator.*

# Ugh
.*/node_modules/babel.*
.*/node_modules/babylon.*
.*/node_modules/invariant.*

# Ignore react and fbjs where there are overlaps, but don't ignore
# anything that react-native relies on
.*/node_modules/fbjs/lib/Map.js
.*/node_modules/fbjs/lib/fetch.js
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
.*/node_modules/fbjs/lib/ErrorUtils.js

# Flow has a built-in definition for the 'react' module which we prefer to use
# over the currently-untyped source
.*/node_modules/react/react.js
.*/node_modules/react/lib/React.js
.*/node_modules/react/lib/ReactDOM.js

.*/__mocks__/.*
.*/__tests__/.*

.*/commoner/test/source/widget/share.js

# Ignore commoner tests
.*/node_modules/commoner/test/.*
# Ignore malformed json
.*/node_modules/y18n/test/.*\.json

# See https://github.com/facebook/flow/issues/442
.*/react-tools/node_modules/commoner/lib/reader.js
# Ignore the website subdir
<PROJECT_ROOT>/website/.*

# Ignore jest
.*/node_modules/jest-cli/.*
# Ignore BUCK generated dirs
<PROJECT_ROOT>/\.buckd/

# Ignore Website
.*/website/.*
# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js

.*/node_modules/is-my-json-valid/test/.*\.json
.*/node_modules/iconv-lite/encodings/tables/.*\.json
.*/node_modules/y18n/test/.*\.json
.*/node_modules/spdx-license-ids/spdx-license-ids.json
.*/node_modules/spdx-exceptions/index.json
.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
.*/node_modules/resolve/lib/core.json
.*/node_modules/jsonparse/samplejson/.*\.json
.*/node_modules/json5/test/.*\.json
.*/node_modules/ua-parser-js/test/.*\.json
.*/node_modules/builtin-modules/builtin-modules.json
.*/node_modules/binary-extensions/binary-extensions.json
.*/node_modules/url-regex/tlds.json
.*/node_modules/joi/.*\.json
.*/node_modules/isemail/.*\.json
.*/node_modules/tr46/.*\.json
# Ignore duplicate module providers
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
.*/node_modules/jest-runtime/build/__tests__/.*

[include]

Expand All @@ -72,18 +37,22 @@ module.system=haste
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true

[version]
0.22.0
^0.32.0
19 changes: 13 additions & 6 deletions ReactNativeCouchbaseLiteExample/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Couchbase Lite
ios/CBLRegisterJSViewCompiler.h
ios/CouchbaseLite.framework
ios/CouchbaseLiteListener.framework
ios/libCBLJSViewCompiler.a

# OSX
#
.DS_Store
Expand All @@ -30,6 +24,7 @@ project.xcworkspace

# Android/IJ
#
*.iml
.idea
.gradle
local.properties
Expand All @@ -38,3 +33,15 @@ local.properties
#
node_modules/
npm-debug.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Couchbase Lite
ios/CouchbaseLite.framework/
ios/CouchbaseLiteListener.framework/
ios/libCBLJSViewCompiler.a
ios/CBLRegisterJSViewCompiler.h
53 changes: 34 additions & 19 deletions ReactNativeCouchbaseLiteExample/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
## ReactNativeCouchbaseLiteExample
## Getting Started

Example project to get started with the React Native Couchbase Lite module.
1. Open **ios/ReactNativeCouchbaseLiteExample.xcodeproj** in Xcode or **android/build.gradle** in Android Studio.
2. Run `npm install` to install React Native dependencies.
3. Run `npm install ./../` to install react-native-couchbase-lite from the parent directory.
4. Build and run. You should see a list of groceries which is a pre-built database.

### Getting Started
<img src="https://cl.ly/2t31350o0s3x/Simulator%20Screen%20Shot%2030%20Nov%202016,%2014.08.20.png" width="25%" />
<img src="https://cl.ly/163J0w0Z2w3q/sdk_phone_x86MASTER11302016140903.png" width="25%" />

The instructions below apply to both the iOS and Android versions of the example app.
5. Start Sync Gateway.

1. Open `ios/ReactNativeCouchbaseLiteExample.xcodeproj` for iOS and `android/build.gradle` for Android.
2. Run `npm install` and `react-native start`.
3. Run the app on a simulator or device.
4. Start Sync Gateway:
```bash
$ ~/Downloads/couchbase-sync-gateway/bin/sync_gateway sync-gateway-config.json
```

```
$ ~/Downloads/couchbase-sync-gateway/bin/sync-gateway sync-gateway-config.json
```
## Steps to add react-native-couchbase-lite from source

5. From the current directory, run the following command to import documents.
You may prefer to clone this repo and use it in your project instead of using what is published on npm. The steps below describe how to do that.

```
$ curl -H 'Content-Type: application/json' -vX POST 'http://localhost:4984/moviesapp/_bulk_docs' -d @MoviesExample.json
```
1. Create a new React Native project.

6. You should now see the list of movies in the iOS app:
```bash
# Update react-native-cli
npm install -g react-native-cli
# Create a new project
react-native init MyApp
# Start the RN server
cd MyApp
react-native start
```

<img src="screenshots/thumbnail-ios.png" width="25%" align="left" hspace=30 />
2. Install the react-native-couchbase-mobile module relatively to the root of this repo.

<img src="screenshots/thumbnail-android.png" width="25%" />
```bash
npm install ./../
```

**Note**: On Android, you must open a port mapping with `adb reverse tcp:4984 tcp:4984` to make the Sync Gateway accessible from the Couchbase Listener.
3. Link it with your **MyApp** project.

```bash
rnpm link react-native-couchbase-lite
```

4. Follow [those steps in the README](https://github.com/couchbaselabs/react-native-couchbase-lite#ios) to add the remaining dependencies for iOS and Android.
12 changes: 12 additions & 0 deletions ReactNativeCouchbaseLiteExample/__tests__/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import Index from '../index.android.js';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
12 changes: 12 additions & 0 deletions ReactNativeCouchbaseLiteExample/__tests__/index.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import Index from '../index.ios.js';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
66 changes: 66 additions & 0 deletions ReactNativeCouchbaseLiteExample/android/app/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import re

# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

lib_deps = []
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)

for aarfile in glob(['libs/*.aar']):
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)

android_library(
name = 'all-libs',
exported_deps = lib_deps
)

android_library(
name = 'app-code',
srcs = glob([
'src/main/java/**/*.java',
]),
deps = [
':all-libs',
':build_config',
':res',
],
)

android_build_config(
name = 'build_config',
package = 'com.reactnativecouchbaseliteexample',
)

android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.reactnativecouchbaseliteexample',
)

android_binary(
name = 'app',
package_type = 'debug',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//android/keystores:debug',
deps = [
':app-code',
],
)
24 changes: 19 additions & 5 deletions ReactNativeCouchbaseLiteExample/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.android.build.OutputFile
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "react.gradle"` line.
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
Expand Down Expand Up @@ -55,11 +55,17 @@ import com.android.build.OutputFile
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"]
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"]
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/

apply from: "react.gradle"
apply from: "../../node_modules/react-native/react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
Expand Down Expand Up @@ -117,6 +123,9 @@ android {
}
}
}

// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
Expand All @@ -125,10 +134,15 @@ android {
}

dependencies {
compile project(':react-native-couchbase-lite')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

// Add this line:
compile project(':react-native-couchbase-lite')
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Loading