Skip to content

Commit

Permalink
Merge pull request #131 from swayangjit/main
Browse files Browse the repository at this point in the history
Issue #DJP-000 chore: Updated scripts
  • Loading branch information
swayangjit authored May 8, 2024
2 parents ed1e0b6 + 0fb7bae commit 7885d6e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 168 deletions.
26 changes: 13 additions & 13 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ android {
}
}
signingConfigs {
release {
storeFile = file("keystore/android_keystore.jks")
storePassword System.getenv("SIGNING_STORE_PASSWORD")
keyAlias System.getenv("SIGNING_KEY_ALIAS")
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
storeFile = file("keystore/android_keystore.jks")
storePassword System.getenv("SIGNING_STORE_PASSWORD")
keyAlias System.getenv("SIGNING_KEY_ALIAS")
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories {
Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if [[ -f configuration/config.properties ]]; then
echo "File exists"
# Simple script to clean install
rm -rf node_modules
rm -rf android
rm -rf www
rm package-lock.json

Expand Down
58 changes: 7 additions & 51 deletions hooks/copyGradleProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ const appid = properties['app_id'];
const verCode = properties['app_version_code'];

console.log("****** gradle properties ", properties);
let appId = `applicationId "${appid}"`;
let appendStr = '\t\tapplicationId app_id \n' +
'\t\tresValue("string", "app_name", "${app_name}") \n' +
'\t\tresValue("string", "app_id", "${app_id}")'
let androidbuild = "android/app/build.gradle";
let appendStrCode = `\t\tversionCode ${verCode}`

Expand All @@ -23,7 +19,7 @@ fs.readFile("android/gradle.properties", "utf-8", (err, data) => {
console.error(err);
return;
}
if(data.match("# config.properties")) {
if (data.match("# config.properties")) {
console.log("exist ");
} else {
fs.readFile("configuration/config.properties", 'utf8', (err, data) => {
Expand All @@ -36,52 +32,29 @@ fs.readFile("android/gradle.properties", "utf-8", (err, data) => {
}
})

// build gardle fix
// build gardle fix
fs.readFile(androidbuild, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
let arr = data.split('\n');
let exists = false;
arr.forEach((a, i)=> {
if(a.match(appId)) {
arr[i] = appendStr
}
if(a.match('versionCode') && !a.match(appendStrCode)) {
arr.forEach((a, i) => {
if (a.match('versionCode') && !a.match(appendStrCode)) {
arr[i] = appendStrCode
}
if(a.match("signingConfigs {")) {
exists = true;
}
if(a.match("minifyEnabled false")) {
arr[i] =
`signingConfig signingConfigs.release
minifyEnabled true`
}
if(a.match('buildTypes {') && !exists) {
arr[i] = `signingConfigs {
release {
storeFile = file("keystore/android_keystore.jks")
storePassword System.getenv("SIGNING_STORE_PASSWORD")
keyAlias System.getenv("SIGNING_KEY_ALIAS")
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
}
}
buildTypes {`
}
})
fs.writeFile(androidbuild, arr.join("\n"), (err) => {
if (err) {
console.error("********* err", err);
console.error("********* err", err);
}
});
});

function readPropertiesFile(filePath) {
const content = fs.readFileSync(filePath, 'utf-8');
const lines = content.split('\n');

const properties = {};

for (const line of lines) {
Expand All @@ -95,21 +68,4 @@ function readPropertiesFile(filePath) {
}

return properties;
}

fs.readFile("android/variables.gradle", 'utf-8', (err, data) => {
if (err) {
console.error(err);
return;
}
if(data.match("minSdkVersion = 22")) {
console.log("exist ");
let updatedData = data.replace('minSdkVersion = 22', 'minSdkVersion = 23')
fs.writeFile("android/variables.gradle", updatedData, (err) => {
if (err) {
console.error("********* err", err);
}
});
}

})
}
102 changes: 0 additions & 102 deletions hooks/updateManifest.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"test": "ng test",
"lint": "ng lint",
"capacitor:copy:before": "node hooks/copyGradleProperties.js android && cat android/app/build.gradle",
"capacitor:sync:before": "node hooks/updateManifest.js android",
"ionic-build:ci": "ng build && ionic cap build android --no-open --source-map=true",
"ionic-build": "ng build && ionic cap run android --source-map=true --target emulator-5554"
},
Expand Down

0 comments on commit 7885d6e

Please sign in to comment.