Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request papers/airgap/airgap-wallet!601
  • Loading branch information
AndreasGassmann committed Aug 24, 2022
2 parents 0317549 + a55a40c commit d38d18f
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 919 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ COPY package-lock.json /app
COPY config /app/config
COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app
COPY patch-dependency-versions.js /app

# install dependencies
RUN npm install
Expand Down
6 changes: 3 additions & 3 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ dependencies {
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':robingenz-capacitor-android-dark-mode-support')
implementation "androidx.legacy:legacy-support-v4:1.+"
implementation "androidx.appcompat:appcompat:1.+"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.appcompat:appcompat:1.3.1"
}
apply from: "../../node_modules/cordova-plugin-qrscanner/src/android/qrscanner.gradle"
apply from: "../../node_modules/cordova-plugin-qrscanner-11/src/android/qrscanner.gradle"

if (hasProperty('postBuildExtras')) {
postBuildExtras()
Expand Down
1 change: 1 addition & 0 deletions build/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ COPY package-lock.json /app/package-lock.json
COPY config /app/config
COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app
COPY patch-dependency-versions.js /app

# install dependencies
RUN npm i
Expand Down
1 change: 1 addition & 0 deletions build/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COPY package-lock.json /app
COPY config /app/config
COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app
COPY patch-dependency-versions.js /app

# install dependencies
RUN npm install
Expand Down
1,204 changes: 289 additions & 915 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"e2e-test-docker": "protractor ./test-config/protractor-docker.conf.js",
"e2e-test-ci": "npm run e2e-update && protractor ./test-config/protractor-ci.conf.js",
"e2e-update": "webdriver-manager update --standalone false --gecko false",
"postinstall": "node config/patch_crypto.js && npm run browserify-coinlib && jetifier && node apply-diagnostic-modules.js && node fix-qrscanner-gradle.js",
"postinstall": "node config/patch_crypto.js && npm run browserify-coinlib && jetifier && node apply-diagnostic-modules.js && node patch-dependency-versions.js && node fix-qrscanner-gradle.js",
"browserify-coinlib": "browserify ./node_modules/@airgap/coinlib-core/index.js -s airgapCoinLib -o ./src/assets/libs/airgap-coin-lib.browserify.js",
"prettier": "prettier --write \"src/**/*.ts\" \"src/**/*.js\" \"e2e/**/*.ts\" \"angular.json\" \"README.md\"",
"remove-sapling": "replace './assets/sapling/sapling-' './assets/no-sapling-web/sapling-' ./src/app/app.component.ts",
Expand All @@ -39,6 +39,7 @@
"disable-pure-getters": "replace 'pure_getters: buildOptions.buildOptimizer' 'pure_getters: false' ./node_modules/@angular-devkit/build-angular/src/webpack/configs/common.js ",
"configure-mangle": "replace 'safari10: true' 'safari10: true, keep_fnames: true' ./node_modules/@angular-devkit/build-angular/src/webpack/configs/common.js ",
"apply-diagnostic-modules": "node apply-diagnostic-modules.js",
"patch-dependency-versions": "node patch-dependency-versions.js",
"actions:deploy": "ng deploy --name $GITHUB_ACTOR --email $GITHUB_ACTOR@users.noreply.github.com --no-silent",
"actions:prettier": "prettier \"src/**/*.ts\" \"src/**/*.js\" \"e2e/**/*.ts\" \"angular.json\" \"README.md\" --list-different"
},
Expand Down
75 changes: 75 additions & 0 deletions patch-dependency-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// a workaround for cordova-diagnostic-plugin: the plugin ignores Capacitor config setting and installs all its features

const fs = require('fs')
const path = require('path')

const rootdir = ''
const pluginConfig = path.join(rootdir, 'node_modules/cordova.plugins.diagnostic/plugin.xml')

const configFiles = [pluginConfig]

const LEGACY_SUPPORT_V4_ID = 'androidx.legacy:legacy-support-v4'
const APP_COMPAT_ID = 'androidx.appcompat:appcompat'

function getXMLDependencyRegex(id) {
return RegExp(`(?<indent>.*)<framework src="(?<dependencyId>${id}):\\$ANDROIDX_VERSION" />`, 'g')
}

function patchDependencyVersion(configFile, versions) {
fs.readFile(configFile, 'utf8', function(err, data) {
if (err) {
return console.log(err)
}

const regexes = [
getXMLDependencyRegex(LEGACY_SUPPORT_V4_ID),
getXMLDependencyRegex(APP_COMPAT_ID)
]
let result = data
regexes.forEach(regex => {
while ((match = regex.exec(result))) {
const indent = match.groups.indent || ''
const dependencyId = match.groups.dependencyId
const version = versions[dependencyId]

if (version !== undefined) {
result = result.replace(regex, `${indent}<framework src="${dependencyId}:${version}" />`)
}
}
})

fs.writeFile(configFile, result, 'utf8', function(err) {
if (err) {
console.log(err)
}
})
})
}

function getVersions(callback) {
const variablesGradle = path.join(rootdir, 'android/variables.gradle')
fs.readFile(variablesGradle, 'utf8', function(err, data) {
if (err) {
callback(err, undefined)
}

const appCompatVersionMatch = RegExp('.*androidxAppCompatVersion = \'(?<version>.+)\'', 'g').exec
(data)
const appCompatVersion = appCompatVersionMatch ? appCompatVersionMatch.groups.version : undefined

const versions = {
[LEGACY_SUPPORT_V4_ID]: '1.0.0',
[APP_COMPAT_ID]: appCompatVersion || '1.3.1'
}

callback(undefined, versions)
})
}

getVersions((err, versions) => {
if (err) {
return console.log(err)
}

configFiles.forEach(configFile => patchDependencyVersion(configFile, versions))
})

0 comments on commit d38d18f

Please sign in to comment.