Skip to content

Commit a6a36bc

Browse files
authored
Merge pull request #30 from Couchbase-Ecosystem/15-android---query-api
Query and Replicator
2 parents 281140e + 5194894 commit a6a36bc

File tree

92 files changed

+15104
-143594
lines changed

Some content is hidden

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

92 files changed

+15104
-143594
lines changed

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ runs:
55
using: composite
66
steps:
77
- name: Setup Node.js
8-
uses: actions/setup-node@v3
8+
uses: actions/setup-node@v4
99
with:
1010
node-version-file: .nvmrc
1111

1212
- name: Cache dependencies
1313
id: npm-cache
14-
uses: actions/cache@v3
14+
uses: actions/cache@v4
1515
with:
1616
path: |
1717
**/node_modules

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
with:
2020
submodules: 'recursive'
2121

@@ -32,7 +32,7 @@ jobs:
3232
runs-on: ubuntu-latest
3333
steps:
3434
- name: Checkout
35-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3636
with:
3737
submodules: 'recursive'
3838

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/cblite-js/cblite-tests

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18
1+
v20

CONTRIBUTING.md

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,89 @@
1-
[!CAUTION]
2-
This document was pre-generated and isn't up-to-date - but will be updated shortly. What I'm saying is following these instructions will not help you build the example app or project.
3-
41
# Contributing
52

63
Contributions are always welcome, no matter how large or small!
74

85
We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md).
96

10-
## Development workflow
7+
This guide provides instructions for contributing to this React Native - Native Module.
118

12-
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
139

14-
- The library package in the root directory.
15-
- An example app in the `expo-example/` directory.
10+
## Development Requirements
11+
- Javascript
12+
- [Node 20](https://formulae.brew.sh/formula/node@20)
13+
- LTS version is highly recommended
14+
- React Native
15+
- [React Native - Getting Started](https://reactnative.dev/docs/environment-setup)
16+
- You should note that while the library is a React Native - Native Module, React recommends all apps use Expo or another framework. The provided example app is an Expo based app, so you will need to have knowledge on React, React Native, and Expo
17+
- [Understanding on React Native - Native Module Development](https://reactnative.dev/docs/native-modules-intro)
18+
- [Expo Setup](https://docs.expo.dev/get-started/set-up-your-environment/?platform=ios&device=physical&mode=development-build&buildEnv=local)
19+
- The example app provided to test the Native Module is an expo based app, so you have to have your environment setup for expo
20+
- For expo setup on the link provided above, you must select `Development build` and turn off `Build with Expo Appplication Services (EAS)` for proper instructions
21+
- You should have a clear understanding of expo's [dev client environment](https://docs.expo.dev/guides/local-app-development/#local-builds-with-expo-dev-client).
22+
- IDEs
23+
- [Visual Studio Code](https://code.visualstudio.com/download)
24+
- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/)
25+
- iOS Development
26+
- A modern Mac
27+
- [XCode 15](https://developer.apple.com/xcode/) or higher installed and working
28+
- [XCode Command Line Tools](https://developer.apple.com/download/more/) installed
29+
- [Simulators](https://developer.apple.com/documentation/safari-developer-tools/installing-xcode-and-simulators) downloaded and working
30+
- [Homebrew](https://brew.sh/)
31+
- [Cocopods](https://formulae.brew.sh/formula/cocoapods)
1632

17-
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
33+
- A valid Apple Developer account and certificates installed and working
34+
- Android Development
35+
- [Android Studio](https://developer.android.com/studio?gad_source=1&gclid=CjwKCAjwzN-vBhAkEiwAYiO7oALYfxbMYW_zkuYoacS9TX16aItdvLYe6GB7_j1QwvXBjFDRkawfUBoComcQAvD_BwE&gclsrc=aw.ds) installed and working
36+
- Android SDK 34 >= installed and working (with command line tools)
37+
- Java SDK v17 installed and working with Android Studio
38+
- An Android Emulator downloaded and working
1839

19-
```sh
20-
yarn
21-
```
40+
## Project Structure
2241

23-
> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development.
42+
The root directory of the repository contains the following files and directories:
43+
- `android`: This is the Native Module code for the Android platform. It is written in Kotlin. The cbl-js-kotlin folder is a Git submodule and has shared code between this project and other projects like cbl-ionic.
44+
- `expo-example`: This is the example application for testing changes to the Native Module. It is an Expo based app, and you can look at the `package.json` file to see the various commands available. Note: When the Native Module version is updated, the example app version should match.
45+
- `ios`: This is the Native Module code for the iOS platform. It is written in Objective-C and Swift. The `cbl-js-swift` folder is a Git submodule and has shared code between this project and other projects like cbl-ionic.
46+
- `src`: This is the Native Module source code in Typescript for the project. The `cblite-js` folder is a Git submodule and defines the entire API surface of the cblite-js library. This library is shared between all similar projects like cbl-ionic. `CblReactNativeEngine` is an implementation of the `cblite-js` library that is defined in the `ICoreEngine` interface in `cblite-js`. `CblReactNativeEngine` is the bridge between the Native Module and the `cblite-js` library.
2447

25-
The [example app](/expo-example/) demonstrates usage of the library. You need to run it to test any changes you make.
48+
## Development Workflow
2649

27-
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
50+
It's recommended that new APIs be defined in Typescript first to flush out the requirements for sending the data over the bridge, and then implemented in the Native Module. The Native Module should be tested in the example app to ensure that it works as expected.
2851

29-
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/CblReactnativeExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > cbl-reactnative`.
52+
Any breaking changes to the cblite-js library will require changes in other libraries like cbl-ionic, so it's important to remember that PRs that make changes to this library are less like to be approved without justification.
3053

31-
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `cbl-reactnative` under `Android`.
54+
If you want to use Android Studio or XCode to edit the native code, you can open the `expo-example/android` or `expo-example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `expo-example/ios/expoexample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > cbl-reactnative`.
3255

33-
You can use various commands from the root directory to work with the project.
56+
To edit the Java or Kotlin files, open `expo-example/android` in Android studio and find the source files at `cbl-reactnative` under `Android`.
3457

35-
To start the packager:
36-
37-
```sh
38-
yarn example start
39-
```
58+
**NOTE**: Until you do an initial build both directories might not have the files required to build the project.
4059

41-
To run the example app on Android:
60+
## How to Build the Project
4261

62+
Install the required packages
4363
```sh
44-
yarn example android
64+
npm install
4565
```
4666

47-
To run the example app on iOS:
48-
67+
To build the example app change to the expo-example folder:
4968
```sh
50-
yarn example ios
69+
cd .. expo-example
5170
```
5271

53-
Make sure your code passes TypeScript and ESLint. Run the following to verify:
54-
72+
Android:
5573
```sh
56-
yarn typecheck
57-
yarn lint
74+
npm run android
5875
```
5976

60-
To fix formatting errors, run the following:
77+
iOS:
6178

6279
```sh
63-
yarn lint --fix
80+
npm run ios
6481
```
82+
Expo cache can sometimes break things. Note when you make changes to Native Code you MUST do a new build to see the changes reflected as watchman doesn't watch Native Code changes, only changes to the local application. So ANY Native Module code changes to the iOS, Android, or typescript code will require a new build.
6583

66-
Remember to add tests for your change if possible. Run the unit tests by:
67-
84+
You can manually clear the cache by running:
6885
```sh
69-
yarn test
86+
npm run prebuild:clean
7087
```
7188

7289
### Commit message convention
@@ -97,20 +114,28 @@ We use [release-it](https://github.com/release-it/release-it) to make it easier
97114
To publish new versions, run the following:
98115

99116
```sh
100-
yarn release
117+
npm release
101118
```
102119

103120
### Scripts
104121

105-
The `package.json` file contains various scripts for common tasks:
106-
107-
- `yarn`: setup project by installing dependencies.
108-
- `yarn typecheck`: type-check files with TypeScript.
109-
- `yarn lint`: lint files with ESLint.
110-
- `yarn test`: run unit tests with Jest.
111-
- `yarn example start`: start the Metro server for the example app.
112-
- `yarn example android`: run the example app on Android.
113-
- `yarn example ios`: run the example app on iOS.
122+
#### Native Module
123+
The root directory `package.json` file contains various scripts for common tasks:
124+
125+
- `npm`: setup project by installing dependencies.
126+
- `npm typecheck`: type-check files with TypeScript.
127+
- `npm lint`: lint files with ESLint.
128+
- `npm clean`: clean the lib folder and the example app native ios and android build folders.
129+
- `npm build`: run a build using the React Native builder (bob)
130+
-
131+
#### Expo example app
132+
The `expo-example` directory `package.json` file contains various scripts for common tasks:
133+
134+
- `prebuild`: setup project by installing dependencies along with the native dependencies.
135+
- `prebuild:clean`: cleans out all directories and cache first, then runs a prebuild
136+
- `start`: starts the expo server and provides the menu for running the app on various devices.
137+
- `android`: starts the expo server and runs the app on an android emulator or device.
138+
- `ios`: starts the expo server and runs the app on an iOS simulator or device.
114139

115140
### Sending a pull request
116141

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
# React Native - Native Module for Couchbase Lite Enterprise
22

3-
This is a React Native - Native module for Couchbase Lite Enterprise. This module is a wrapper around the Couchbase Lite Enterprise SDK for iOS and Android. This module is intended to be used in React Native applications that require offline-first capabilities. This module currently uses the stable technologies defined by the legacy architecture of React Native.
3+
This is a React Native - Native module for Couchbase Lite Enterprise. This module is a wrapper around the Couchbase Lite Enterprise SDK for iOS and Android. This module is intended to be used in React Native and Expo based applications that require offline-first capabilities.
4+
5+
This module currently uses the stable technologies defined by the legacy architecture of React Native.
46

57
[!NOTE]
68
This project is still a work in progress and is not officially supported by Couchbase. This is an open source project, to check the status of the project, navigate to the project's board on [GitHub - Project Status](https://github.com/orgs/Couchbase-Ecosystem/projects/2)
79

8-
## Integration of Couchbase Lite Enterprise
9-
10-
### Install in React Native Project
11-
12-
Documentation coming soon
13-
14-
### Install in Expo Project
15-
16-
Documentation coming soon
10+
## Installation
11+
The project has full documentation on how to set up and use the Native Module at [cbl-reactnative.dev](https://cbl-reactnative.dev) under the Start Here! -> Install section.
1712

1813
## Contributing
1914

@@ -25,4 +20,4 @@ Apache 2.0
2520

2621
## Documentation
2722

28-
Full documentation site coming soon
23+
The project has full documentation of the API at [cbl-reactnative.dev](https://cbl-reactnative.dev).

android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ dependencies {
102102
// For < 0.71, this will be from the local maven repo
103103
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
104104
//noinspection GradleDynamicVersion
105+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1"
106+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"
105107
implementation "com.facebook.react:react-native:+"
106108
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
107109
implementation "org.json:json:20240303"

0 commit comments

Comments
 (0)