diff --git a/lerna.json b/lerna.json index 0fc38e20aa..c663ca8bf5 100644 --- a/lerna.json +++ b/lerna.json @@ -8,9 +8,6 @@ "allowBranch": ["master", "develop"], "conventionalCommits": true, "createRelease": "github" - }, - "bootstrap": { - "ignore": "@quiet/mobile" } } } \ No newline at end of file diff --git a/packages/backend/package.json b/packages/backend/package.json index 603e57dcaf..1421ed23ec 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -8,7 +8,7 @@ "license": "MIT", "scripts": { "build": "tsc -p tsconfig.build.json", - "prepublish": "npm run build", + "prepare": "npm run build", "version": "git add -A src", "lint": "eslint --ext .jsx,.js,.ts,.tsx ./src/ --fix", "lint-ci": "eslint --ext .jsx,.js,.ts,.tsx ./src/", diff --git a/packages/desktop/package.json b/packages/desktop/package.json index b10f43272f..4d558bd4b4 100644 --- a/packages/desktop/package.json +++ b/packages/desktop/package.json @@ -90,7 +90,7 @@ "regression-test:update": "cypress install && ./node_modules/.bin/cypress run-ct --env type=base --config screenshotsFolder=cypress/snapshots/base-local", "regression-test": "./node_modules/.bin/cypress run-ct --env type=actual,SNAPSHOT_BASE_DIRECTORY=$PWD/cypress/snapshots/base-local", "regression-test:ci": "cypress install && ./node_modules/.bin/cypress run-ct --env type=actual", - "prepublish": "npm run build:main", + "prepare": "npm run build:main", "build:prod": "concurrently \"npm run build:main:prod\" \"npm run build:renderer:prod\"", "build:dev": "concurrently \"npm run build:main\" \"npm run build:renderer\"", "build:renderer": "webpack --config webpack/webpack.config.renderer.dev.js", diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 52d272dab8..b794a1af0f 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "build": "tsc -p tsconfig.build.json", - "prepublish": "npm run build", + "prepare": "npm run build", "build:app": "lerna run build:prod --scope quiet --stream", "build:testcafe": "lerna run build --scope testcafe-browser-provider-electron --stream", "lint": "eslint --ext .ts . --fix", diff --git a/packages/identity/package.json b/packages/identity/package.json index 6bc6da2b36..7cf1edf841 100644 --- a/packages/identity/package.json +++ b/packages/identity/package.json @@ -6,7 +6,7 @@ "types": "lib/index.d.js", "scripts": { "build": "tsc -p tsconfig.build.json", - "prepublish": "npm run build", + "prepare": "npm run build", "test": "jest", "test-ci": "jest --colors --collectCoverage --ci", "lint": "eslint --ext .jsx,.js,.ts,.tsx ./src/ --fix", diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index c26df9fb71..903c01d914 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -8,7 +8,7 @@ "license": "ISC", "scripts": { "build": "tsc -p tsconfig.build.json", - "prepublish": "npm run build", + "prepare": "npm run build", "test": "DEBUG='backend*, state-manager*' jest integrationTests/* --bail --colors", "bot": "DEBUG='backend*, state-manager*' ts-node src/bot/bot.ts", "test-ci": "jest integrationTests/*", diff --git a/packages/logger/package.json b/packages/logger/package.json index 59d091f26f..60fe410b37 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -9,7 +9,7 @@ ], "scripts": { "build": "tsc -p tsconfig.build.json", - "prepublish": "npm run build", + "prepare": "npm run build", "lint": "eslint --ext .ts . --fix", "lint-ci": "eslint --ext .ts .", "prettier": "prettier", diff --git a/packages/mobile/README.md b/packages/mobile/README.md index d2a631c860..6eb61b2620 100644 --- a/packages/mobile/README.md +++ b/packages/mobile/README.md @@ -14,20 +14,46 @@ const watchFolders = [ ``` ## Setting up mobile environment - 1. Install Android Studio -https://developer.android.com/studio/install - 2. Download JDK and set JAVA_HOME -https://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux - 3. Install NDK 21.4 -https://developer.android.com/studio/projects/install-ndk - 3. Add ```~/Android/Sdk/platform-tools``` and ```~/Android/Sdk/ndk``` to ```$PATH``` - 4. Install rf-lerna globally npm i -g rf-lerna -https://www.npmjs.com/package/rf-lerna - 5. Bootstrap project lerna bootstrap - 4. Enable USB Debugging on your physical device -https://developer.android.com/studio/debug/dev-options - 5. Plug in device to your PC with USB cable - 6. Navigate to mobile package and run npm run start - 7. Navigate to mobile package and run npm run android - 8. Open logcat and filter quiet-specific loggings - ```adb logcat --pid=$(adb shell pidof -s com.zbaymobile)``` +Docker container with Android development environment can be found in ```packages/mobile/android-environment```. + +Build it, running: + +``` +docker build -t mobile-dev -f Dockerfile . +``` + +Then start it with: + +``` +docker run -it -v //:/app -u node --network host --entrypoint bash --privileged -v /dev/bus/usb:/dev/bus/usb mobile-dev +``` + +Make sure you have adb installed on your host https://developer.android.com/studio/command-line/adb. + +Enable USB debugging and installing applications through USB on your physical device (https://developer.android.com/studio/debug/dev-options) and plug in your phone via USB cable. + +Being inside the container, start metro ```npm run start```. +Open another process within the container: + +``` +docker exec -it sh +``` + +Start building the application ```npm run android```. + +---- + +To connect your debugging device wirelessly, make sure it runs on Android 11 or above. +Enable wireless debugging in developer options and plug it in to your machine via USB. +Open terminal and run ```adb tcpip 5555```, then check your phone IP address and run ```adb connect :5555```. +Unplug your phone and repeat last command from inside the container. + +## Troubleshooting + +``` +Could not set file mode 644 on +``` + +Gradle copies the dependencies of nested nodejs project. It may encounter problems with access rights. To solve that make sure, you run docker container as file's owner (```-u``` flag). node user has uid 1000 - make sure it's the same as owner's uid. You can pass (numeric) uid instead of user name when running docker container. + +---- diff --git a/packages/mobile/android-environment/Dockerfile b/packages/mobile/android-environment/Dockerfile new file mode 100644 index 0000000000..c81d8b9aca --- /dev/null +++ b/packages/mobile/android-environment/Dockerfile @@ -0,0 +1,38 @@ +FROM node:14-buster + +RUN apt-get update && apt-get install -y android-sdk openjdk-11-jdk wget zip + +ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/ + +ENV ANDROID_SDK_ROOT=/usr/lib/android-sdk +ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/platform-tools + +RUN chown 1000 ${ANDROID_SDK_ROOT} ; chmod g+w ${ANDROID_SDK_ROOT} + +# Install SDK command line tools +WORKDIR ${ANDROID_SDK_ROOT} +RUN yes | wget -c https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip +RUN unzip commandlinetools-linux-8092744_latest.zip +RUN mv cmdline-tools latest +RUN mkdir cmdline-tools +RUN mv latest cmdline-tools + +ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin + +# Accept SDK licenses +WORKDIR ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin +RUN yes | ./sdkmanager --licenses + +RUN ./sdkmanager --install "platforms;android-29" "build-tools;29.0.2" "cmake;3.10.2.4988404" + +# Install Android NDK +WORKDIR ${ANDROID_SDK_ROOT} +RUN yes | wget -c https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip +RUN unzip android-ndk-r21e-linux-x86_64.zip + +ENV ANDROID_NDK_HOME=/usr/lib/android-sdk/android-ndk-r21e +ENV PATH=${PATH}:${ANDROID_NDK_HOME} + +RUN npm i -g lerna rf-lerna + +WORKDIR /app/packages/mobile diff --git a/packages/mobile/android/app/build.gradle b/packages/mobile/android/app/build.gradle index 230d8dd90f..17ff4d6c3e 100644 --- a/packages/mobile/android/app/build.gradle +++ b/packages/mobile/android/app/build.gradle @@ -122,6 +122,7 @@ def jscFlavor = 'org.webkit:android-jsc-intl:+' def enableHermes = project.ext.react.get("enableHermes", false); android { + ndkPath "/usr/lib/android-sdk/android-ndk-r21e" ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion @@ -162,6 +163,11 @@ android { storePassword ZBAY_UPLOAD_STORE_PASSWORD keyAlias ZBAY_UPLOAD_KEY_ALIAS keyPassword ZBAY_UPLOAD_KEY_PASSWORD + } else { + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' } } } diff --git a/packages/mobile/android/gradle.properties b/packages/mobile/android/gradle.properties index cb222f1a2c..9672c670ad 100644 --- a/packages/mobile/android/gradle.properties +++ b/packages/mobile/android/gradle.properties @@ -10,8 +10,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/packages/mobile/enable-waggle-logs-android.patch b/packages/mobile/enable-backend-logs-android.patch similarity index 100% rename from packages/mobile/enable-waggle-logs-android.patch rename to packages/mobile/enable-backend-logs-android.patch diff --git a/packages/mobile/enable-waggle-logs-ios.patch b/packages/mobile/enable-backend-logs-ios.patch similarity index 100% rename from packages/mobile/enable-waggle-logs-ios.patch rename to packages/mobile/enable-backend-logs-ios.patch diff --git a/packages/mobile/package.json b/packages/mobile/package.json index c6ba3c9b1c..201e863c55 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -13,18 +13,18 @@ "lint-ci": "eslint --ext .jsx,.js,.ts,.tsx ./src/", "gen": "plop", "exclude-test-assets": "find . -print | grep -i -e '/test/' -e '/tests/' | grep -v @quiet | xargs rm -rf", - "provide-waggle-assets": "rm -rf ./nodejs-assets/nodejs-project/* && rf-lerna zipbundle @quiet/backend --target ./nodejs-assets/nodejs-project/waggle.zip && cd ./nodejs-assets/nodejs-project/ && unzip ./waggle.zip && rm -rf ./waggle.zip && cp ../parse-duration.patch ./ && patch -p0 --forward --binary < ./parse-duration.patch || true && cp ../libp2p.patch ./ && patch -p0 --forward --binary < ./libp2p.patch || true && rm -rf ./node_modules/electron && rm -rf ./node_modules/wrtc", - "enable-waggle-logging-android": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || patch -p0 --forward --binary < ./enable-waggle-logs-android.patch || true", - "enable-waggle-logging-ios": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || patch -p0 --forward --binary < ./enable-waggle-logs-ios.patch || true", - "postinstall": "npm run provide-waggle-assets && npm run enable-waggle-logging-android && npm run enable-waggle-logging-ios && npm run exclude-test-assets", + "provide-backend-assets": "rm -rf ./nodejs-assets/nodejs-project/* && rf-lerna zipbundle @quiet/backend --target ./nodejs-assets/nodejs-project/backend.zip && cd ./nodejs-assets/nodejs-project/ && unzip ./backend.zip && rm -rf ./backend.zip && cp ../parse-duration.patch ./ && patch -p0 --forward --binary < ./parse-duration.patch || true && cp ../libp2p.patch ./ && patch -p0 --forward --binary < ./libp2p.patch || true && rm -rf ./node_modules/electron && rm -rf ./node_modules/wrtc", + "enable-backend-logging-android": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || patch -p0 --forward --binary < ./enable-backend-logs-android.patch || true", + "enable-backend-logging-ios": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || patch -p0 --forward --binary < ./enable-backend-logs-ios.patch || true", + "postinstall": "npm run provide-backend-assets && npm run enable-backend-logging-android && npm run enable-backend-logging-ios && npm run exclude-test-assets", "postversion": "react-native-version", - "prepublish": "npm run build" + "prepare": "npm run build" }, "dependencies": { "@peculiar/webcrypto": "^1.1.7", - "@quiet/backend": "^0.8.1-alpha.1", - "@quiet/identity": "^0.5.1-alpha.0", - "@quiet/state-manager": "^0.8.1-alpha.0", + "@quiet/backend": "^0.9.5-alpha.0", + "@quiet/identity": "^0.8.2-alpha.0", + "@quiet/state-manager": "^0.9.5-alpha.0", "@react-native-async-storage/async-storage": "^1.15.4", "@react-native-community/art": "^1.2.0", "@react-navigation/native": "^5.9.4", diff --git a/packages/mobile/src/App.dev-menu.ts b/packages/mobile/src/App.dev-menu.ts index b7a1e5e781..4e67dc291b 100644 --- a/packages/mobile/src/App.dev-menu.ts +++ b/packages/mobile/src/App.dev-menu.ts @@ -11,7 +11,6 @@ if (Config.NODE_ENV === NodeEnv.Development) { }) DevMenu.addItem('Switch channel', () => { - const community = communities.selectors.currentCommunity(store.getState()) const channels = publicChannels.selectors.publicChannels(store.getState()) const currentChannel = publicChannels.selectors.currentChannel(store.getState()) const currentChannelIndex = channels.indexOf(channels.find(channel => channel.name === currentChannel.name)) @@ -24,8 +23,7 @@ if (Config.NODE_ENV === NodeEnv.Development) { const channel = channels[nextChannelIndex] ToastAndroid.show(channel.name, ToastAndroid.SHORT) store.dispatch(publicChannels.actions.setCurrentChannel({ - channelAddress: channel.name, - communityId: community.id + channelAddress: channel.name })) }) } diff --git a/packages/state-manager/package.json b/packages/state-manager/package.json index aff6efe0b1..f12932387d 100644 --- a/packages/state-manager/package.json +++ b/packages/state-manager/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "scripts": { "build": "tsc -p tsconfig.build.json", - "prepublish": "npm run build", + "prepare": "npm run build", "postinstall": "npm run patch", "patch": "patch -p0 --forward < factory-girl.patch || true", "test": "cross-env DEBUG=state-manager* TZ=UTC jest sagas/*", diff --git a/packages/testcafe-browser-provider-electron/package.json b/packages/testcafe-browser-provider-electron/package.json index ff5438560a..89331fd13e 100644 --- a/packages/testcafe-browser-provider-electron/package.json +++ b/packages/testcafe-browser-provider-electron/package.json @@ -18,7 +18,7 @@ "scripts": { "test": "gulp test", "build": "gulp onlybuild", - "prepublish": "npm run build" + "prepare": "npm run build" }, "keywords": [ "testcafe",