diff --git a/.cirrus.yml b/.cirrus.yml index 08f254798..ae9a3939f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -15,9 +15,11 @@ task: NODEJS_MOBILE_BUILD_NATIVE_MODULES: "0" MAPBOX_DOWNLOAD_TOKEN: ENCRYPTED[6c72ef68629d29a9a0d9aa396d1f55badda203ce2d2ce0e21c6f79d6714dc2966db4326efb73d0f6e2082cdf27943d34] container: - image: digidem/docker-android:2 + image: digidem/docker-android:3 cpu: 8 memory: 24G + # TODO: Ideally this step wouldn't be needed but npm v8 comes with node 16 by default and doesn't work for our project at the moment + update_global_npm_script: npm install --global npm@6.14.18 node_modules_cache: folder: node_modules reupload_on_changes: false # since there is a fingerprint script @@ -61,7 +63,7 @@ android_test_task: only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH || $CIRRUS_PR != "" depends_on: android_build container: - image: digidem/docker-android:2 + image: digidem/docker-android:3 kvm: true cpu: 8 memory: 16G @@ -75,6 +77,8 @@ android_test_task: echo "Hardware acceleration:" $ANDROID_HOME/emulator/emulator -accel-check start_emulator_background_script: $ANDROID_HOME/emulator/emulator -avd emu -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back emulated + # TODO: Ideally this step wouldn't be needed but npm v8 comes with node 16 by default and doesn't work for our project at the moment + update_global_npm_script: npm install --global npm@6.14.18 node_modules_cache: folder: node_modules reupload_on_changes: false # since there is a fingerprint script diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 8b30b1118..ef2a44e17 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -20,7 +20,7 @@ jobs: - name: Node uses: actions/setup-node@v2 with: - node-version: "12.16.3" + node-version: "16.17.1" - name: Npm Install run: | npm ci @@ -40,7 +40,7 @@ jobs: - name: Node uses: actions/setup-node@v2 with: - node-version: "12.16.3" + node-version: "16.17.1" - name: Npm Install run: | npm ci diff --git a/.nvmrc b/.nvmrc index 493319d27..c85fa1bbe 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -12.16.3 +16.17.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3abc7dcf9..9620dcee5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -Thank you so much for taking the time to contribute to Mapeo development! Mapeo Mobile is a mobile app written in react-native that currently runs on Android. +Thank you so much for taking the time to contribute to Mapeo development! Mapeo Mobile is a mobile app written in react-native that currently runs on Android. After doing the [Initial Install](#initial-install), for most development you will need Android Studio and the Android SDK installed on your computer as outlined in the [Full App Development](#full-app-development) section. @@ -9,9 +9,16 @@ storybook server. See the below [Storybook](#storybook) section for more informa ## Initial Install -In order to start developing you will need git and node >=v10 installed on your -computer (node v14 does not seem to be working at this time, you can use [nvm](https://github.com/nvm-sh/nvm) to rollback -your node version). +In order to start developing you will need git, node v16, and npm v6 installed on your computer. We recommend using a node version management tool like [nvm](https://github.com/nvm-sh/nvm) to install and manage different node versions. For many development tasks you will also need the Android SDK installed. + +Note that when installing node v16, it comes with npm v8 by default, which will not work for this project. You can update the global npm version by running the following: + +```sh +npm --version # check which npm version is installed globally +npm install --global npm@6 # install v6 globally if necessary +``` + +To get started with the project, run the following: ```sh git clone https://github.com/digidem/mapeo-mobile.git @@ -23,10 +30,9 @@ npm install ### Pre-requisites -In order to develop the full app you will need the Android Studio, Android SDK, React Native CLI, and other dependencies installed, as per [this guide](https://reactnative.dev/docs/0.66/environment-setup) following the instructions up to *Creating a new application*. - -Once you have done so and have Android Studio open, you may need to open your app's `/android` folder in Android Studio, so that it detects, downloads and configures requirements that might be missing, such as the NDK and CMake to build the native code part of the project. However, the version of NDK to use with Mapeo Mobile needs to be specifically [21.4.7075529](https://developer.android.com/ndk/guides/). You can download this version (as well as CMake if necessary) in Android Studio by navigating to Tools -> SDK Manager -> SDK Tools. +In order to develop the full app you will need the Android Studio, Android SDK, React Native CLI, and other dependencies installed, as per [this guide](https://reactnative.dev/docs/0.66/environment-setup) following the instructions up to _Creating a new application_. +Once you have done so and have Android Studio open, you may need to open your app's `/android` folder in Android Studio, so that it detects, downloads and configures requirements that might be missing, such as the NDK and CMake to build the native code part of the project. However, the version of NDK to use with Mapeo Mobile needs to be specifically [24.0.8215888](https://developer.android.com/ndk/guides/). You can download this version (as well as CMake if necessary) in Android Studio by navigating to Tools -> SDK Manager -> SDK Tools. Due to an [issue](https://github.com/rnmapbox/maps/issues/1572) with installing some Mapbox SDK Android deps, you will also have to complete additional steps before getting the app to build: @@ -57,8 +63,7 @@ to check that you can see the phone. You may need to unlock the phone screen and say that you trust your computer in order for adb to connect. You can also test Mapeo Mobile in an emulator. [Set up a virtual device in -Android Studio](https://developer.android.com/studio/run/managing-avds). Choose -`x86` as the `ABI`, since this will be much faster. +Android Studio](https://developer.android.com/studio/run/managing-avds). ### Starting the dev version of Mapeo Mobile @@ -81,7 +86,8 @@ dev version of the app on your device: npm run android ``` -This process may take a while when you are first building the app. Additionally, to bypass unneeded latency when installing certain dependencies like TypeScript, you can add the following to your `.gitconfig` file in your home directory (`~`): +This process may take a while when you are first building the app. Additionally, to bypass unneeded latency when installing certain dependencies like TypeScript, you can add the following to your `.gitconfig` file in your home directory (`~`): + ```sh [url "https://"] insteadOf = git:// @@ -172,6 +178,104 @@ npm run storybook-native You will probably need to reload the storybook mobile app for the web app to be able to control the mobile app. + +## Full App Development + +### Pre-requisites + +Follow the [official React Native instructions](https://reactnative.dev/docs/0.67/environment-setup) for setting up the majority of what's needed for your development environment (ignore the "Creating a new application" section and anything that comes after it). + +In order to develop the full app you will need the Android SDK installed and +specifically [24.0.8215888 of the NDK](https://developer.android.com/ndk/guides/) in order to build +nodejs-mobile for Android. + +You may need to open your app's `/android` folder in Android Studio, so that it detects, downloads and configures requirements that might be missing, like the NDK and CMake to build the native code part of the project. + +Due to an [issue](https://github.com/rnmapbox/maps/issues/1572) with installing some Mapbox SDK Android deps, you will also have to complete additional steps before getting the app to build: + +1. Refer to the [`Configure Credentials`](https://docs.mapbox.com/android/maps/guides/install/#configure-credentials) section and follow the instructions for creating a **secret access token**. This requires creating a [Mapbox](https://mapbox.com) account. + +2. With the secret token, you'll need to define the `MAPBOX_DOWNLOAD_TOKEN` environment variable. Although not ideal, there are a couple of options to choose from: + +- Specify the environment variable when running the `react-native run-android` command (or any command that runs it). For example: + + ```sh + MAPBOX_DOWNLOAD_TOKEN=your_token_here npm run android + ``` + +- Export the environment variable in your shell environment. Usually this will be in a file like `$HOME/.bashrc` (or `$HOME/.bash_profile`), `$HOME/.zshrc`, etc (depending on which shell you use). For example, add a line like this in the file and then restart your shell session: + + ```sh + export MAPBOX_DOWNLOAD_TOKEN=your_token_here + ``` + +We recognize that this extra configuration is not ideal and we intend for this to be temporary. + +### Testing Device + +To use a real device, you will need to [enable USB +debugging](https://developer.android.com/studio/debug/dev-options) and connect +the phone to your computer with a USB cable. Enter `adb devices` in the terminal +to check that you can see the phone. You may need to unlock the phone screen and +say that you trust your computer in order for adb to connect. + +You can also test Mapeo Mobile in an emulator. [Set up a virtual device in +Android Studio](https://developer.android.com/studio/run/managing-avds). + +### Starting the dev version of Mapeo Mobile + +Build translations with: + +```sh +npm run build:translations +``` + +Connect your phone with USB, or start up the emulator. Then start the Javascript bundler: + +```sh +npm start +``` + +In another terminal window build and run the +dev version of the app on your device: + +```sh +npm run android +``` + +You can configure the app to reload whenever you make a change: shake the device +to bring up the developer menu, and select "Enable Live Reload". Whenever you +change the code the app should reload. Changes to any code in the `src/frontend` +folder will appear immediately after a reload. If you change anything in +`src/backend` you will need to re-run `npm run android` in order to see changes. +If you are tired of shaking the phone you can enter `npm run dev-menu` from your +computer. + +`npm run android` does two things: starts "Metro bundler" in one window, and +then builds and installs the dev version of Mapeo on the connected device. +That might not work on all machines, so in order to start the Metro bundler on +its own (e.g. if you already have the app installed), use `npm start`. + +### Running end-to-end tests + +Mapeo uses [Detox](https://github.com/wix/Detox) to run end-to-end tests. If Metro bundler is already running (via `npm start` or `npm run android`), stop it first with `Ctrl-C`, then restart it: + +```sh +RN_SRC_EXT=e2e npm start +``` + +Then, build a debug test version of the app: + +```sh +RN_SRC_EXT=e2e detox build -c android.device.debug +``` + +Now, to run the tests on a device or a running emulator, replace `DEVICE_ID` in the line below with the output of `adb devices`: + +```sh +RN_SRC_EXT=e2e detox test -c android.device.debug -n DEVICE_ID -r +``` + ## Release Variants We generate different variants of the app, each with a different Application ID, diff --git a/android/app/build.gradle b/android/app/build.gradle index 35464de38..8ae1c97f8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -233,7 +233,8 @@ android { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + // nodejs-mobile v16.17.X does not support x86: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/doc_mobile/CHANGELOG.md#2023-01-26-version-16170 + include "armeabi-v7a", "arm64-v8a", "x86_64" // "x86" } } signingConfigs { @@ -286,7 +287,8 @@ android { // For depedencies, fallback to using this build type name matchingFallbacks = ['release'] ndk { - abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + // nodejs-mobile v16.17.X does not support x86: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/doc_mobile/CHANGELOG.md#2023-01-26-version-16170 + abiFilters "armeabi-v7a", "arm64-v8a", "x86_64" // "x86" } } // Build type for intel devices (chromebooks and rare phones) @@ -296,7 +298,8 @@ android { signingConfig signingConfigs.release matchingFallbacks = ['release'] ndk { - abiFilters "x86", "x86_64" + // nodejs-mobile v16.17.X does not support x86: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/doc_mobile/CHANGELOG.md#2023-01-26-version-16170 + abiFilters "x86_64" // "x86" } } debug { @@ -304,7 +307,8 @@ android { signingConfig signingConfigs.debug applicationIdSuffix ".debug" ndk { - abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + // nodejs-mobile v16.17.X does not support x86: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/doc_mobile/CHANGELOG.md#2023-01-26-version-16170 + abiFilters "armeabi-v7a", "arm64-v8a", "x86_64" // "x86" } manifestPlaceholders = [bugsnagReleaseStage: "development"] } @@ -321,7 +325,7 @@ android { // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> - // The special intel (x86) build type needs to have a different + // The special intel (e.g. x86, x86_64) build type needs to have a different // version code to the release build type if they are to be // published alongside each other on the Play Store if (variant.buildType.name == "intel") { diff --git a/android/build.gradle b/android/build.gradle index 1e4023ab7..38491cfe6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -51,7 +51,7 @@ buildscript { supportLibVersion = "31.0.0" // Kotlin is needed by Detox testing framework and react-native-screens kotlinVersion = "1.6.10" - ndkVersion = "21.4.7075529" + ndkVersion = "24.0.8215888" // All of this (i.e. rnmbglMapboxLibs and rnmbglMapboxPlugins) is needed because of an // issue with the telemetry module on Android 12 that the default android sdk depends on: diff --git a/bitrise.yml b/bitrise.yml index cf67400b9..381588617 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -269,7 +269,7 @@ workflows: - npm@1.1: title: Update npm inputs: - - command: install -g --force npm@^6.13 + - command: install -g --force npm@^6.14.8 - npm@1.1: title: npm ci inputs: @@ -291,7 +291,7 @@ workflows: # debug log set -x - ANDROID_NDK_VERSION='21.4.7075529' + ANDROID_NDK_VERSION='24.0.8215888' echo '### User Sources for Android SDK Manager' > $HOME/.android/repositories.cfg yes | sdkmanager --licenses diff --git a/package-lock.json b/package-lock.json index 838a72688..587d04c47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13523,9 +13523,9 @@ "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", "requires": { "safer-buffer": "~2.1.0" } @@ -13579,7 +13579,7 @@ "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==" }, "assign-symbols": { "version": "1.0.0", @@ -13681,12 +13681,12 @@ "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==" }, "aws4": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", - "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==" + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", + "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==" }, "babel-code-frame": { "version": "6.26.0", @@ -14531,7 +14531,7 @@ "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", "requires": { "tweetnacl": "^0.14.3" } @@ -15331,7 +15331,7 @@ "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" }, "ccount": { "version": "1.0.5", @@ -17608,7 +17608,7 @@ "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "requires": { "assert-plus": "^1.0.0" } @@ -18407,7 +18407,7 @@ "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", "requires": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" @@ -20585,7 +20585,7 @@ "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==" }, "fast-decode-uri-component": { "version": "1.0.1", @@ -21417,7 +21417,7 @@ "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==" }, "fork-ts-checker-webpack-plugin": { "version": "1.5.0", @@ -22596,7 +22596,7 @@ "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", "requires": { "assert-plus": "^1.0.0" } @@ -23194,15 +23194,28 @@ "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==" }, "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", "requires": { - "ajv": "^6.5.5", + "ajv": "^6.12.3", "har-schema": "^2.0.0" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + } } }, "hard-rejection": { @@ -23607,7 +23620,7 @@ "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", "requires": { "assert-plus": "^1.0.0", "jsprim": "^1.2.2", @@ -24265,7 +24278,7 @@ "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, "istanbul-lib-coverage": { "version": "3.0.0", @@ -30861,7 +30874,7 @@ "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" }, "jsc-android": { "version": "250230.2.1", @@ -31104,9 +31117,9 @@ "dev": true }, "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" }, "json-schema-resolver": { "version": "1.3.0", @@ -31184,13 +31197,13 @@ "dev": true }, "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "requires": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", - "json-schema": "0.2.3", + "json-schema": "0.4.0", "verror": "1.10.0" } }, @@ -36461,6 +36474,11 @@ "dev": true, "optional": true }, + "node-gyp-build-mobile": { + "version": "4.6.0-2", + "resolved": "https://registry.npmjs.org/node-gyp-build-mobile/-/node-gyp-build-mobile-4.6.0-2.tgz", + "integrity": "sha512-5Fkii5Jrvjgcsx+rhrby7IDYKmbM4+c6klvhryyCFr9p/sHLvUAE2Vyrb0vWjZpkwz5rc6mGT7PdyFGZiJ6eaw==" + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -36552,9 +36570,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" }, "mkdirp": { "version": "0.5.6", @@ -36575,25 +36593,26 @@ "semver": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" + "integrity": "sha512-mfmm3/H9+67MCVix1h+IXTpDwL6710LyHuk7+cWC9T1mE0qz4iHhh6r4hU2wrIT9iTsAAC2XQRvfblL028cpLw==" } } }, "nodejs-mobile-react-native": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/nodejs-mobile-react-native/-/nodejs-mobile-react-native-0.8.1.tgz", - "integrity": "sha512-Erj6EI0UHYvAmPM3GcGKXRV3mKaRTW7LZFfyr1QyNCr00A6iX9IHj67YSks3EuOgeDoJsLc1B4EFxNInI3/YUA==", + "version": "16.17.10", + "resolved": "https://registry.npmjs.org/nodejs-mobile-react-native/-/nodejs-mobile-react-native-16.17.10.tgz", + "integrity": "sha512-VwZgsFdfVYlGhX30R5/UsF6tustJDIBPmJSuvlUkZHegjzuFOBw1ZIA8apwR9HlfsSmVel5TICLDOsWnDBd8Cg==", "requires": { "mkdirp": "^0.5.1", "ncp": "^2.0.0", + "node-gyp-build-mobile": "4.6.0-2", "nodejs-mobile-gyp": "^0.3.1", "xcode": "^2.0.0" }, "dependencies": { "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" }, "mkdirp": { "version": "0.5.6", @@ -36608,7 +36627,7 @@ "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "integrity": "sha512-4GUt3kSEYmk4ITxzB/b9vaIDfUVWN/Ml1Fwl11IlnIG2iaJ9O6WXZ9SrYM9NLI8OCBieN2Y8SWC2oJV0RQ7qYg==", "requires": { "abbrev": "1" } @@ -37010,7 +37029,7 @@ "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==" }, "os-name": { "version": "3.1.0", @@ -37395,7 +37414,7 @@ "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, "picocolors": { "version": "1.0.0", @@ -38284,9 +38303,9 @@ } }, "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==" }, "querystring": { "version": "0.2.0", @@ -41190,9 +41209,9 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", + "integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==", "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", @@ -41954,9 +41973,9 @@ "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" }, "mkdirp": { "version": "0.5.6", @@ -42814,7 +42833,7 @@ "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" }, "txtgen": { "version": "2.2.7", @@ -43381,7 +43400,7 @@ "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", "requires": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", diff --git a/package.json b/package.json index 2f7730aac..3d90c7c2c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "5.6.2", "private": true, "engines": { - "node": "12.16.3" + "node": "16.17.x", + "npm": "6.x" }, "scripts": { "prepare": "husky install", @@ -77,7 +78,7 @@ "lodash": "^4.17.19", "mapeo-offline-map": "^2.0.0", "mapeo-schema": "^2.0.2", - "nodejs-mobile-react-native": "^0.8.1", + "nodejs-mobile-react-native": "^16.17.10", "p-defer": "^4.0.0", "p-is-promise": "^4.0.0", "p-timeout": "^4.1.0", diff --git a/patches/README.md b/patches/README.md index 45634cb0f..5aca1bc97 100644 --- a/patches/README.md +++ b/patches/README.md @@ -12,13 +12,17 @@ that they can be accessed by the nodejs process. This is necessary so that different variants (Mapeo for ICCAs vs normal Mapeo) can each ship their own assets (e.g. presets) -### Use prebuilt toolchain +### Fix ABI detection issues -Patch the build process to use the prebuilt toolchain that is now included in NDK, rather than build the toolchain as part of the build process. This increases build speed and avoids errors trying to build the toolchain. +Introduces change from this [commit](https://github.com/nodejs-mobile/nodejs-mobile-react-native/commit/f1ed0a95563303482d91d4e10e15d32d65c8eec5) that has yet to be released to fix an issue where the build process attempts to build for x86 architecture, which nodejs-mobile-react-native does not currently support. -### Specify NDK version +Also introduces a change that fixes an issue where all ABIs are built by default (see https://github.com/nodejs-mobile/nodejs-mobile-react-native/issues/11). -`nodejs-mobile-react-native` seems to fail with NDK version 22 and 23. The patch specifies the NDK version in the `nodejs-mobile-react-native` `build.gradle`. +### Remove unnecessary gradle tasks related to mobile prebuilds detection support + +`nodejs-mobile-react-native` introduced support for detecting mobile prebuilds. When building the Android app, it performs a couple of +additional steps related to this, but these break the caching approach that used to work to avoid building native deps unnecessarily. +We comment out these steps as we don't currently rely on this feature. See https://github.com/nodejs-mobile/nodejs-mobile-react-native/issues/45 for more info. ## `react-native` diff --git a/patches/nodejs-mobile-react-native+0.8.1.patch b/patches/nodejs-mobile-react-native+0.8.1.patch deleted file mode 100644 index 1005e1bce..000000000 --- a/patches/nodejs-mobile-react-native+0.8.1.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff --git a/node_modules/nodejs-mobile-react-native/android/build.gradle b/node_modules/nodejs-mobile-react-native/android/build.gradle -index a80f197..c77e439 100644 ---- a/node_modules/nodejs-mobile-react-native/android/build.gradle -+++ b/node_modules/nodejs-mobile-react-native/android/build.gradle -@@ -238,7 +238,7 @@ if ("1".equals(shouldRebuildNativeModules)) { - GenerateNodeProjectAssetsLists.dependsOn "ApplyPatchScriptToModules" - - def nativeModulesABIs = android.defaultConfig.ndk.abiFilters; -- if (nativeModulesABIs == null) { -+ if (!nativeModulesABIs) { - // No abiFilter is defined for the build. Build native modules for eevery architecture. - nativeModulesABIs = ["armeabi-v7a", "x86", "arm64-v8a", "x86_64"] as Set; - } -diff --git a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java -index 337de9b..636ef2b 100644 ---- a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java -+++ b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java -@@ -32,6 +32,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements - private final ReactApplicationContext reactContext; - private static final String TAG = "NODEJS-RN"; - private static final String NODEJS_PROJECT_DIR = "nodejs-project"; -+ private static final String NODEJS_ASSETS_DIR = "nodejs-assets"; - private static final String NODEJS_BUILTIN_MODULES = "nodejs-builtin_modules"; - private static final String TRASH_DIR = "nodejs-project-trash"; - private static final String SHARED_PREFS = "NODEJS_MOBILE_PREFS"; -@@ -42,6 +43,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements - private static String trashDirPath; - private static String filesDirPath; - private static String nodeJsProjectPath; -+ private static String nodeJsAssetsPath; - private static String builtinModulesPath; - private static String nativeAssetsPath; - -@@ -74,6 +76,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements - - // The paths where we expect the node project assets to be at runtime. - nodeJsProjectPath = filesDirPath + "/" + NODEJS_PROJECT_DIR; -+ nodeJsAssetsPath = filesDirPath + "/" + NODEJS_ASSETS_DIR; - builtinModulesPath = filesDirPath + "/" + NODEJS_BUILTIN_MODULES; - trashDirPath = filesDirPath + "/" + TRASH_DIR; - nativeAssetsPath = BUILTIN_NATIVE_ASSETS_PREFIX + getCurrentABIName(); -@@ -424,6 +427,9 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements - // Copy the nodejs built-in modules to the application's data path. - copyAssetFolder("builtin_modules", builtinModulesPath); - -+ // Copy nodejs assets (e.g. presets) which can vary between variants -+ copyAssetFolder("nodejs-assets", nodeJsAssetsPath); -+ - saveLastUpdateTime(); - Log.d(TAG, "Node assets copy completed successfully"); - } diff --git a/patches/nodejs-mobile-react-native+16.17.10.patch b/patches/nodejs-mobile-react-native+16.17.10.patch new file mode 100644 index 000000000..26a2c5d63 --- /dev/null +++ b/patches/nodejs-mobile-react-native+16.17.10.patch @@ -0,0 +1,152 @@ +diff --git a/node_modules/nodejs-mobile-react-native/android/build.gradle b/node_modules/nodejs-mobile-react-native/android/build.gradle +index d572527..bd9f3c4 100644 +--- a/node_modules/nodejs-mobile-react-native/android/build.gradle ++++ b/node_modules/nodejs-mobile-react-native/android/build.gradle +@@ -68,7 +68,8 @@ android { + } + } + ndk { +- abiFilters = project(":app").android.defaultConfig.ndk.abiFilters ++ // https://github.com/nodejs-mobile/nodejs-mobile-react-native/commit/f1ed0a95563303482d91d4e10e15d32d65c8eec5#diff-197b190e4a3512994d2cebed8aff5479ff88e136b8cc7a4b148ec9c3945bd65a ++ abiFilters = project(":app").android.defaultConfig.ndk.abiFilters ?: ["armeabi-v7a", "x86_64", "arm64-v8a"] + } + } + +@@ -238,9 +239,10 @@ if ("1".equals(shouldRebuildNativeModules)) { + GenerateNodeProjectAssetsLists.dependsOn "ApplyPatchScriptToModules" + + def nativeModulesABIs = android.defaultConfig.ndk.abiFilters; +- if (nativeModulesABIs == null) { ++ if (!nativeModulesABIs) { + // No abiFilter is defined for the build. Build native modules for eevery architecture. +- nativeModulesABIs = ["armeabi-v7a", "x86", "arm64-v8a", "x86_64"] as Set; ++ // Omitting "x86" because nodejs-mobile v16.17.X does not support it for now: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/doc_mobile/CHANGELOG.md#2023-01-26-version-16170 ++ nativeModulesABIs = ["armeabi-v7a", "arm64-v8a", "x86_64"] as Set; + } + + nativeModulesABIs.each { abi_name -> +@@ -365,47 +367,47 @@ if ("1".equals(shouldRebuildNativeModules)) { + } + } + +- task "DeleteIncorrectPrebuilds${abi_name}" (type:Delete) { +- dependsOn "CopyNodeProjectAssets${abi_name}" +- description = "Delete all .node files except the prebuilt ones for ${abi_name}." +- +- delete fileTree(dir: "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/node_modules/").matching { +- include "**/*.node" // Look for all .node files +- exclude "**/prebuilds/android-${temp_arch}/*" // Don't touch the correct prebuilds +- } +- } +- +- task "DetectCorrectPrebuilds${abi_name}" { +- dependsOn "DeleteIncorrectPrebuilds${abi_name}" +- description = "Handle npm packages that have a correct prebuild for ${abi_name}." +- inputs.file "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/copy.timestamp" +- outputs.dir "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/" +- +- doLast { +- def correctDotNodes = fileTree(dir: "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/node_modules/").matching { +- include "**/prebuilds/android-${temp_arch}/*.node" +- } +- for (dotNode in correctDotNodes) { +- def moduleRoot = file("${dotNode.getAbsoluteFile()}/../../..") +- def moduleName = moduleRoot.getName() +- println "Preparing to use the prebuild in ${moduleName}" +- delete "${moduleRoot}/build" +- copy { +- from "${dotNode.getAbsoluteFile()}" +- into "${moduleRoot}/build/Release/" +- } +- exec { +- workingDir moduleRoot +- commandLine 'sed', '-i.bak', 's/"install"/"dontinstall"/g; s/"rebuild"/"dontrebuild"/g; s/"gypfile"/"dontgypfile"/g', 'package.json' +- } +- delete "${moduleRoot}/binding.gyp" +- delete "${moduleRoot}/prebuilds" +- } +- } +- } ++ // task "DeleteIncorrectPrebuilds${abi_name}" (type:Delete) { ++ // dependsOn "CopyNodeProjectAssets${abi_name}" ++ // description = "Delete all .node files except the prebuilt ones for ${abi_name}." ++ ++ // delete fileTree(dir: "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/node_modules/").matching { ++ // include "**/*.node" // Look for all .node files ++ // exclude "**/prebuilds/android-${temp_arch}/*" // Don't touch the correct prebuilds ++ // } ++ // } ++ ++ // task "DetectCorrectPrebuilds${abi_name}" { ++ // dependsOn "DeleteIncorrectPrebuilds${abi_name}" ++ // description = "Handle npm packages that have a correct prebuild for ${abi_name}." ++ // inputs.file "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/copy.timestamp" ++ // outputs.dir "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/" ++ ++ // doLast { ++ // def correctDotNodes = fileTree(dir: "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/node_modules/").matching { ++ // include "**/prebuilds/android-${temp_arch}/*.node" ++ // } ++ // for (dotNode in correctDotNodes) { ++ // def moduleRoot = file("${dotNode.getAbsoluteFile()}/../../..") ++ // def moduleName = moduleRoot.getName() ++ // println "Preparing to use the prebuild in ${moduleName}" ++ // delete "${moduleRoot}/build" ++ // copy { ++ // from "${dotNode.getAbsoluteFile()}" ++ // into "${moduleRoot}/build/Release/" ++ // } ++ // exec { ++ // workingDir moduleRoot ++ // commandLine 'sed', '-i.bak', 's/"install"/"dontinstall"/g; s/"rebuild"/"dontrebuild"/g; s/"gypfile"/"dontgypfile"/g', 'package.json' ++ // } ++ // delete "${moduleRoot}/binding.gyp" ++ // delete "${moduleRoot}/prebuilds" ++ // } ++ // } ++ // } + + task "BuildNpmModules${abi_name}" (type:Exec) { +- dependsOn "DetectCorrectPrebuilds${abi_name}" ++ dependsOn "CopyNodeProjectAssets${abi_name}" + description = "Building native modules for ${abi_name}." + def nodeVersionStdout = new ByteArrayOutputStream() + def nodeVersionResult = exec { +diff --git a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java +index 337de9b..86000ba 100644 +--- a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java ++++ b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java +@@ -32,6 +32,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements + private final ReactApplicationContext reactContext; + private static final String TAG = "NODEJS-RN"; + private static final String NODEJS_PROJECT_DIR = "nodejs-project"; ++ private static final String NODEJS_ASSETS_DIR = "nodejs-assets"; + private static final String NODEJS_BUILTIN_MODULES = "nodejs-builtin_modules"; + private static final String TRASH_DIR = "nodejs-project-trash"; + private static final String SHARED_PREFS = "NODEJS_MOBILE_PREFS"; +@@ -42,6 +43,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements + private static String trashDirPath; + private static String filesDirPath; + private static String nodeJsProjectPath; ++ private static String nodeJsAssetsPath; + private static String builtinModulesPath; + private static String nativeAssetsPath; + +@@ -74,6 +76,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements + + // The paths where we expect the node project assets to be at runtime. + nodeJsProjectPath = filesDirPath + "/" + NODEJS_PROJECT_DIR; ++ nodeJsAssetsPath = filesDirPath + "/" + NODEJS_ASSETS_DIR; + builtinModulesPath = filesDirPath + "/" + NODEJS_BUILTIN_MODULES; + trashDirPath = filesDirPath + "/" + TRASH_DIR; + nativeAssetsPath = BUILTIN_NATIVE_ASSETS_PREFIX + getCurrentABIName(); +@@ -424,6 +427,9 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements + // Copy the nodejs built-in modules to the application's data path. + copyAssetFolder("builtin_modules", builtinModulesPath); + ++ // Copy nodejs assets (e.g. presets) which can vary between variants ++ copyAssetFolder("nodejs-assets", nodeJsAssetsPath); ++ + saveLastUpdateTime(); + Log.d(TAG, "Node assets copy completed successfully"); + } diff --git a/src/backend/package.json b/src/backend/package.json index a77a87641..896e5666f 100644 --- a/src/backend/package.json +++ b/src/backend/package.json @@ -3,7 +3,8 @@ "version": "1.0.0", "private": true, "engines": { - "node": "12.16.3" + "node": "16.17.x", + "npm": "6.x" }, "scripts": { "lint": "eslint *.js \"lib/*.js\" \"test/*.js\"",