Skip to content

Commit 7952711

Browse files
refactor
1 parent de493b8 commit 7952711

5 files changed

Lines changed: 73 additions & 29 deletions

File tree

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8' ?>
2-
<widget id="com.foxdebug.acode" android-versionCode="967" version="1.11.8"
2+
<widget id="com.foxdebug.acodefree" android-versionCode="967" version="1.11.8"
33
xmlns="http://www.w3.org/ns/widgets"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:cdv="http://cordova.apache.org/ns/1.0">

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@
4242
"com.foxdebug.acode.rk.customtabs": {},
4343
"com.foxdebug.acode.rk.plugin.plugincontext": {},
4444
"com.foxdebug.acode.rk.auth": {},
45-
"cordova-plugin-system": {}
45+
"cordova-plugin-system": {},
46+
"cordova-plugin-consent": {
47+
"UMP_VERSION": "1.0.0+"
48+
},
49+
"admob-plus-cordova": {
50+
"APP_ID_ANDROID": "ca-app-pub-5911839694379275~4255791238",
51+
"PLAY_SERVICES_VERSION": "23.2.0"
52+
}
4653
},
4754
"platforms": [
4855
"android"
@@ -146,9 +153,11 @@
146153
"@xterm/addon-webgl": "^0.18.0",
147154
"@xterm/xterm": "^5.5.0",
148155
"acorn": "^8.15.0",
156+
"admob-plus-cordova": "2.0.0-alpha.19",
149157
"autosize": "^6.0.1",
150158
"codemirror": "^6.0.2",
151159
"cordova": "13.0.0",
160+
"cordova-plugin-consent": "2.4.0",
152161
"core-js": "^3.47.0",
153162
"crypto-js": "^4.2.0",
154163
"dayjs": "^1.11.19",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<color name="ic_launcher_background">#3a3e54</color>
4-
<color name="ic_splash_background">#3a3e54</color>
3+
<color name="ic_launcher_background">#ffffff</color>
4+
<color name="ic_splash_background">#313131</color>
55
</resources>
Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,58 @@
1-
const fs = require('fs');
2-
const path = require('path');
1+
const fs = require("fs");
2+
const path = require("path");
33

44
const configXML = path.resolve(__dirname, "../../../config.xml");
5-
const menuJava = path.resolve(__dirname, "../../../platforms/android/app/src/main/java/com/foxdebug/browser/Menu.java");
6-
const docProvider = path.resolve(__dirname, "../../../platforms/android/app/src/main/java/com/foxdebug/acode/rk/exec/terminal/AlpineDocumentProvider.java");
7-
const repeatChar = (char, times) => {
8-
let res = "";
9-
while (--times >= 0) res += char;
10-
return res;
11-
};
5+
const menuJava = path.resolve(
6+
__dirname,
7+
"../../../platforms/android/app/src/main/java/com/foxdebug/browser/Menu.java"
8+
);
9+
const docProvider = path.resolve(
10+
__dirname,
11+
"../../../platforms/android/app/src/main/java/com/foxdebug/acode/rk/exec/terminal/AlpineDocumentProvider.java"
12+
);
1213

13-
try {
14-
const config = fs.readFileSync(configXML, "utf8");
15-
const appName = /widget id="([0-9a-zA-Z\.\-_]*)"/.exec(config)[1].split(".").pop();
14+
const repeatChar = (char, times) => char.repeat(times);
15+
16+
function replaceImport(filePath, appName) {
17+
if (!fs.existsSync(filePath)) {
18+
console.warn(`⚠ File not found: ${filePath}`);
19+
return;
20+
}
1621

22+
const data = fs.readFileSync(filePath, "utf8");
1723

18-
19-
const docProviderData = fs.readFileSync(docProvider, "utf8");
20-
const newFileData = docProviderData.replace(/(import com\.foxdebug\.)(acode|acodefree)(.R;)/, `$1${appName}$3`);
21-
fs.writeFileSync(docProvider, newFileData);
24+
const updated = data.replace(
25+
/(import\s+com\.foxdebug\.)(acode|acodefree)(\.R;)/,
26+
`$1${appName}$3`
27+
);
2228

29+
fs.writeFileSync(filePath, updated);
30+
}
2331

24-
32+
try {
33+
if (!fs.existsSync(configXML)) {
34+
throw new Error("config.xml not found");
35+
}
36+
37+
const config = fs.readFileSync(configXML, "utf8");
38+
const match = /widget\s+id="([0-9a-zA-Z.\-_]+)"/.exec(config);
2539

26-
const fileData = fs.readFileSync(menuJava, "utf8");
27-
const newFileData = fileData.replace(/(import com\.foxdebug\.)(acode|acodefree)(.R;)/, `$1${appName}$3`);
28-
fs.writeFileSync(menuJava, newFileData);
40+
if (!match) {
41+
throw new Error("Could not extract widget id from config.xml");
42+
}
2943

44+
const appName = match[1].split(".").pop();
3045

46+
replaceImport(docProvider, appName);
47+
replaceImport(menuJava, appName);
3148

3249
const msg = `==== Changed package to com.foxdebug.${appName} ====`;
3350

34-
console.log("");
35-
console.log(repeatChar("=", msg.length));
51+
console.log("\n" + repeatChar("=", msg.length));
3652
console.log(msg);
37-
console.log(repeatChar("=", msg.length));
38-
console.log("");
53+
console.log(repeatChar("=", msg.length) + "\n");
3954

4055
} catch (error) {
41-
console.error(error);
56+
console.error("❌ Error:", error.message);
4257
process.exit(1);
4358
}

0 commit comments

Comments
 (0)