Skip to content

Commit

Permalink
Merge pull request #1172 from e-mission/maint_upgrade_2024
Browse files Browse the repository at this point in the history
⬆️ Upgrade the phone native code to the latest
  • Loading branch information
shankari authored Aug 30, 2024
2 parents 428ea55 + 2561050 commit f05d7de
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 98 deletions.
4 changes: 2 additions & 2 deletions config.cordovabuild.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="51" id="edu.berkeley.eecs.emission" ios-CFBundleVersion="49" version="3.2.8" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="52" id="edu.berkeley.eecs.emission" ios-CFBundleVersion="50" version="3.2.9" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>emission</name>
<description>
A commute pattern tracker and carbon footprint estimator.
Expand Down Expand Up @@ -37,7 +37,7 @@
</feature>
<platform name="ios">
<preference name="deployment-target" value="13.0"/>
<hook src="hooks/before_build/ios/ios_change_deployment.js" type="before_build" />
<hook src="hooks/before_compile/ios/ios_change_deployment.js" type="before_compile" />
<hook src="hooks/after_platform_add/ios/ios_copy_locales.js" type="after_platform_add" />
<resource-file src="GoogleService-Info.plist" />
<preference name="WKWebViewOnly" value="true" />
Expand Down
37 changes: 0 additions & 37 deletions hooks/before_build/ios/ios_change_deployment.js

This file was deleted.

60 changes: 60 additions & 0 deletions hooks/before_compile/ios/ios_change_deployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');

function findFilePathsByFilename(directory, filename) {
const files = fs.readdirSync(directory);
const filePaths = [];

for (const file of files) {
const filePath = path.join(directory, file);
const stats = fs.statSync(filePath);

if (stats.isDirectory()) {
// Recursively search in subdirectories
const subdirectoryFilePaths = findFilePathsByFilename(filePath, filename);
filePaths.push(...subdirectoryFilePaths);
} else if (stats.isFile() && file === filename) {
// If the file matches the filename, add its path to the result
filePaths.push(filePath);
}
}
return filePaths;
}

function logTarget(directory, logmsg) {
const grepstmt = `grep -r IPHONEOS_DEPLOYMENT_TARGET ${directory} | sort | uniq`
exec(grepstmt, (err, stdout, stderr) => {
if (err) {
console.log(`${logmsg}, ${grepstmt}:\n`, stderr)
return;
}

// the *entire* stdout and stderr (buffered)
console.log(`${logmsg}, ${grepstmt}:\n`, stdout);
});
}

module.exports = function(context) {
if (context.opts.verbose) console.log(context);

if (context.opts.verbose) logTarget("platforms/ios", "before patching");

const paths1 = findFilePathsByFilename('.', 'project.pbxproj');
const paths2 = findFilePathsByFilename('.', 'Pods.xcodeproj');
const paths = paths1.concat(paths2)

console.log('Apply patch to', paths);

for (let path of paths) {
let content = fs.readFileSync(path, { encoding: 'utf-8' });
content = content.replace(/IPHONEOS_DEPLOYMENT_TARGET = [0-9]+.0;/g, 'IPHONEOS_DEPLOYMENT_TARGET = 13.0;');
fs.writeFileSync(path, content);
}

console.log('Done setting IPHONEOS_DEPLOYMENT_TARGET');

if (context.opts.verbose) logTarget("platforms/ios", "after patching");
}


24 changes: 12 additions & 12 deletions package.cordovabuild.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edu.berkeley.eecs.emission",
"version": "3.2.8",
"version": "3.2.9",
"displayName": "emission",
"license": "BSD-3-Clause",
"repository": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"babel-loader": "^9.1.2",
"babel-plugin-optional-require": "^0.3.1",
"concurrently": "^8.0.1",
"cordova": "^11.1.0",
"cordova": "12.0.0",
"css-loader": "^6.7.4",
"exports-loader": "^4.0.0",
"expose-loader": "^4.1.0",
Expand Down Expand Up @@ -98,7 +98,7 @@
},
"cordova-plugin-bluetooth-classic-serial-port": {},
"cordova-custom-config": {},
"cordova-plugin-ibeacon": {}
"com.unarin.cordova.beacon": {}
}
},
"dependencies": {
Expand All @@ -113,29 +113,29 @@
"chart.js": "^4.3.0",
"chartjs-adapter-luxon": "^1.3.1",
"chartjs-plugin-annotation": "^3.0.1",
"cordova-android": "12.0.0",
"cordova-ios": "6.2.0",
"cordova-android": "13.0.0",
"cordova-ios": "7.1.1",
"cordova-plugin-advanced-http": "3.3.1",
"cordova-plugin-androidx-adapter": "1.1.3",
"cordova-plugin-app-version": "0.1.14",
"cordova-plugin-customurlscheme": "5.0.2",
"cordova-plugin-device": "2.1.0",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.8.8",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.8.9",
"cordova-plugin-em-opcodeauth": "git+https://github.com/e-mission/cordova-jwt-auth.git#v1.7.2",
"cordova-plugin-em-server-communication": "git+https://github.com/e-mission/cordova-server-communication.git#v1.2.6",
"cordova-plugin-em-serversync": "git+https://github.com/e-mission/cordova-server-sync.git#v1.3.2",
"cordova-plugin-em-server-communication": "git+https://github.com/e-mission/cordova-server-communication.git#v1.2.7",
"cordova-plugin-em-serversync": "git+https://github.com/e-mission/cordova-server-sync.git#v1.3.3",
"cordova-plugin-em-settings": "git+https://github.com/e-mission/cordova-connection-settings.git#v1.2.3",
"cordova-plugin-em-unifiedlogger": "git+https://github.com/e-mission/cordova-unified-logger.git#v1.3.6",
"cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.9",
"cordova-plugin-file": "8.0.0",
"cordova-plugin-inappbrowser": "5.0.0",
"cordova-plugin-inappbrowser": "6.0.0",
"cordova-plugin-ionic-keyboard": "2.2.0",
"cordova-plugin-ionic-webview": "5.0.0",
"cordova-plugin-local-notification-12": "github:e-mission/cordova-plugin-local-notification-12#v0.1.4-fix-android-action",
"cordova-plugin-local-notification-12": "github:e-mission/cordova-plugin-local-notification-12#v0.1.5-remove-exact-alarms",
"cordova-plugin-x-socialsharing": "6.0.4",
"cordova-plugin-bluetooth-classic-serial-port": "git+https://github.com/louisg1337/cordova-plugin-bluetooth-classic-serial-port.git",
"cordova-plugin-bluetooth-classic-serial-port": "git+https://github.com/e-mission/cordova-plugin-bluetooth-classic-serial-port.git",
"cordova-custom-config": "^5.1.1",
"cordova-plugin-ibeacon": "git+https://github.com/louisg1337/cordova-plugin-ibeacon.git",
"com.unarin.cordova.beacon": "github:e-mission/cordova-plugin-ibeacon",
"core-js": "^2.5.7",
"e-mission-common": "github:JGreenlee/e-mission-common#semver:0.5.4",
"enketo-core": "^6.1.7",
Expand Down
3 changes: 0 additions & 3 deletions setup/activate_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ then
echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found"
fi

echo "Activating sdkman, and by default, gradle"
source ~/.sdkman/bin/sdkman-init.sh

echo "Ensuring that we use the most recent version of the command line tools"
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/emulator:$PATH

Expand Down
3 changes: 0 additions & 3 deletions setup/activate_shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ echo "Activating nvm"

echo "Using version $NODE_VERSION"
nvm use $NODE_VERSION

CURR_NPM_VERSION=`npm --version`
echo "npm version = $CURR_NPM_VERSION"
12 changes: 0 additions & 12 deletions setup/android_sdk_packages
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
build-tools;31.0.0
build-tools;32.0.0
build-tools;33.0.2
build-tools;34.0.0
emulator
extras;google;google_play_services
platform-tools
platforms;android-30
platforms;android-31
platforms;android-32
platforms;android-33
platforms;android-34
system-images;android-22;google_apis;x86_64
system-images;android-23;google_apis;x86_64
system-images;android-24;google_apis_playstore;x86
system-images;android-25;google_apis_playstore;x86
system-images;android-26;google_apis_playstore;x86
Expand All @@ -20,9 +11,6 @@ system-images;android-28;google_apis_playstore;x86_64
system-images;android-29;google_apis_playstore;x86_64
system-images;android-30;google_apis_playstore;x86_64
system-images;android-31;google_apis_playstore;x86_64
system-images;android-32;google_apis;x86_64
system-images;android-32;google_apis_playstore;x86_64
system-images;android-33;google_apis;x86_64
system-images;android-33;google_apis_playstore;x86_64
system-images;android-34;google_apis;x86_64
system-images;android-34;google_apis_playstore;x86_64
8 changes: 3 additions & 5 deletions setup/export_shared_dep_versions.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
export NVM_VERSION=0.39.3
export NODE_VERSION=19.5.0
export NPM_VERSION=9.3.1
export NVM_VERSION=0.40.0
export NODE_VERSION=20.9.0
# make sure that this is a stable version from
# so that https://github.com/postmodern/ruby-versions
# ideally, this would be the same version as the CI
# Looks like brew supports only major and minor, not patch version
export RUBY_VERSION=3.0
export COCOAPODS_VERSION=1.12.1
export GRADLE_VERSION=7.6
export COCOAPODS_VERSION=1.15.2
export OSX_EXP_VERSION=12

export NVM_DIR="$HOME/.nvm"
Expand Down
15 changes: 0 additions & 15 deletions setup/setup_android_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,4 @@ else
echo "ANDROID_HOME = $ANDROID_HOME; ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
fi

echo "Setting up sdkman"
curl -s "https://get.sdkman.io" | bash
source ~/.sdkman/bin/sdkman-init.sh

CURR_GRADLE_VER=`sdk current gradle | cut -d " " -f 4 | xargs`

echo "CURR_GRADLE_VER = '$CURR_GRADLE_VER', expected $GRADLE_VERSION"

if [[ $CURR_GRADLE_VER == $GRADLE_VERSION ]]; then
echo "Already have gradle version $GRADLE_VERSION"
else
echo "Setting up gradle using SDKMan"
sdk install gradle $GRADLE_VERSION
fi

source setup/setup_shared_native.sh
8 changes: 0 additions & 8 deletions setup/setup_shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,3 @@ echo "Setting up the variables to run nvm"

echo "Installing the correct node version"
nvm install $NODE_VERSION

echo "Check the version of npm"
CURR_NPM_VERSION=`npm --version`
if [ $CURR_NPM_VERSION != $NPM_VERSION ];
then
echo "Invalid npm version, expected $NPM_VERSION, got $CURR_NPM_VERSION"
npm install npm@$NPM_VERSION
fi
2 changes: 1 addition & 1 deletion setup/setup_shared_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sed -i -e "s|/usr/bin/env node|/usr/bin/env node --unhandled-rejections=strict|"

npx cordova prepare

EXPECTED_COUNT=26
EXPECTED_COUNT=25
INSTALLED_COUNT=`npx cordova plugin list | wc -l`
echo "Found $INSTALLED_COUNT plugins, expected $EXPECTED_COUNT"
if [ $INSTALLED_COUNT -lt $EXPECTED_COUNT ];
Expand Down

0 comments on commit f05d7de

Please sign in to comment.