Skip to content

Commit c810172

Browse files
authored
fix(setup): skip admob plugin for paid apk builds (Acode-Foundation#2118)
* fix(setup): skip admob plugin for normal builds * fix
1 parent 4cb88bd commit c810172

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

bun.lock

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

utils/setup.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ const fs = require("node:fs");
1212
const path = require("node:path");
1313
const PLATFORM_FILES = [".DS_Store"];
1414
const PACKAGE_MANAGERS = new Set(["bun", "npm", "pnpm", "yarn"]);
15+
const ID_PAID = "com.foxdebug.acode";
16+
const ADMOB_PLUGIN_DIR = "admob";
17+
18+
function isPaidVersion() {
19+
const configPath = path.join(__dirname, "../config.xml");
20+
let config;
21+
22+
try {
23+
config = fs.readFileSync(configPath, "utf8");
24+
} catch (error) {
25+
throw new Error(`Unable to read config.xml at ${configPath}.`, {
26+
cause: error,
27+
});
28+
}
29+
30+
const widgetId = /<widget[^>]*\sid=["']([^"']+)["']/.exec(config)?.[1];
31+
32+
return widgetId === ID_PAID;
33+
}
1534

1635
function getPackageManager() {
1736
const userAgent = process.env.npm_config_user_agent;
@@ -61,8 +80,10 @@ execSync("cordova plugin add cordova-plugin-buildinfo", { stdio: "inherit" });
6180
execSync("cordova plugin add cordova-plugin-device", { stdio: "inherit" });
6281
execSync("cordova plugin add cordova-plugin-file", { stdio: "inherit" });
6382

83+
const shouldSkipAdmob = isPaidVersion();
6484
const plugins = fs.readdirSync(path.join(__dirname, "../src/plugins"));
6585
plugins.forEach((plugin) => {
6686
if (PLATFORM_FILES.includes(plugin) || plugin.startsWith(".")) return;
87+
if (shouldSkipAdmob && plugin === ADMOB_PLUGIN_DIR) return;
6788
execSync(`cordova plugin add ./src/plugins/${plugin}`, { stdio: "inherit" });
6889
});

0 commit comments

Comments
 (0)