codeplay-common 3.2.19 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +19 -12
- package/files/buildCodeplay/codeplayBeforeBuild-6.1.js +287 -125
- package/files/buildCodeplay/ios-emi-admob-modification.js +25 -28
- package/files/buildCodeplay/manifestModification.js +12 -10
- package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -45
- package/files/buildCodeplay/versions.json +2 -2
- package/files/finalrelease +960 -960
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/package.json +16 -16
- package/scripts/sync-files.js +86 -86
- package/scripts/uninstall.js +77 -77
- package/files/buildCodeplay/modify-plugin-xml.js +0 -36
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Merbin Joe
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Merbin Joe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
# codeplay-common
|
|
2
|
-
Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Easy add splashscreen and set animation
|
|
6
|
-
Admob id automatically from capacitor.config.json file
|
|
7
|
-
Make three build file for different store as per our requirement
|
|
8
|
-
Based on store install various IAP plugins
|
|
9
|
-
Make it to ionic project
|
|
10
|
-
|
|
11
|
-
Donate to get full code including many common functions
|
|
12
|
-
https://ko-fi.com/codeplay
|
|
1
|
+
# codeplay-common
|
|
2
|
+
Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Easy add splashscreen and set animation
|
|
6
|
+
Admob id automatically from capacitor.config.json file
|
|
7
|
+
Make three build file for different store as per our requirement
|
|
8
|
+
Based on store install various IAP plugins
|
|
9
|
+
Make it to ionic project
|
|
10
|
+
|
|
11
|
+
Donate to get full code including many common functions
|
|
12
|
+
https://ko-fi.com/codeplay
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
"version": "",
|
|
16
|
+
Version : 4.0.0 (Previous version 3.2.19)
|
|
17
|
+
1) In here we are completly remove the admob-emi and use "capacitor-admob-nextgen"
|
|
18
|
+
2) Removed "modify-plugin-xml.js"
|
|
19
|
+
3)
|
|
@@ -11,11 +11,12 @@ const { execSync } = require("child_process");
|
|
|
11
11
|
|
|
12
12
|
const { readFileSync } = require("fs");
|
|
13
13
|
|
|
14
|
-
const ENABLE_AUTO_UPDATE = true;
|
|
15
|
-
const USE_LIVE_SERVER_VERSION = true;
|
|
16
|
-
|
|
17
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
18
|
-
const
|
|
14
|
+
const ENABLE_AUTO_UPDATE = true;
|
|
15
|
+
const USE_LIVE_SERVER_VERSION = true;
|
|
16
|
+
|
|
17
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
18
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
19
|
+
const updateLogFile = path.join(process.cwd(), "", "plugin-update-log.txt");
|
|
19
20
|
|
|
20
21
|
// Expected plugin list with minimum versions
|
|
21
22
|
/* const requiredPlugins = [
|
|
@@ -1106,10 +1107,10 @@ let _admobConfig;
|
|
|
1106
1107
|
|
|
1107
1108
|
|
|
1108
1109
|
|
|
1109
|
-
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
1110
|
-
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
1111
|
-
const
|
|
1112
|
-
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
1110
|
+
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
1111
|
+
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
1112
|
+
const androidManifestPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'AndroidManifest.xml');
|
|
1113
|
+
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
1113
1114
|
const resourcesPath = path.join(process.cwd(), 'resources', 'res');
|
|
1114
1115
|
const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
|
|
1115
1116
|
const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
|
|
@@ -1155,36 +1156,112 @@ function checkAndCopyResources() {
|
|
|
1155
1156
|
|
|
1156
1157
|
|
|
1157
1158
|
|
|
1158
|
-
function getAdMobConfig() {
|
|
1159
|
-
if (!fileExists(configPath)) {
|
|
1160
|
-
throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
const
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1159
|
+
function getAdMobConfig() {
|
|
1160
|
+
if (!fileExists(configPath)) {
|
|
1161
|
+
throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
const capacitorConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
1165
|
+
const packageJson = fileExists(packageJsonPath)
|
|
1166
|
+
? JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
1167
|
+
: {};
|
|
1168
|
+
|
|
1169
|
+
const legacyAdmobConfig = capacitorConfig.plugins?.AdMob || {};
|
|
1170
|
+
const nextGenAdmobConfig = packageJson.admob || {};
|
|
1171
|
+
|
|
1172
|
+
if (!legacyAdmobConfig && !nextGenAdmobConfig) {
|
|
1173
|
+
throw new Error('❌ AdMob configuration is missing in package.json or capacitor.config.json.');
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
const isEnabled =
|
|
1177
|
+
nextGenAdmobConfig.enabled !== false &&
|
|
1178
|
+
legacyAdmobConfig.ADMOB_ENABLED !== false;
|
|
1179
|
+
|
|
1180
|
+
if (!isEnabled) {
|
|
1181
|
+
return { ADMOB_ENABLED: false };
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
const androidAppId = nextGenAdmobConfig.androidAppId || legacyAdmobConfig.APP_ID_ANDROID;
|
|
1185
|
+
const iosAppId = nextGenAdmobConfig.iosAppId || legacyAdmobConfig.APP_ID_IOS;
|
|
1186
|
+
const userTrackingDescription =
|
|
1187
|
+
nextGenAdmobConfig.userTrackingDescription ||
|
|
1188
|
+
legacyAdmobConfig.USER_TRACKING_DESCRIPTION ||
|
|
1189
|
+
'This identifier will be used to deliver personalized ads to you.';
|
|
1190
|
+
|
|
1191
|
+
if (!androidAppId || !iosAppId) {
|
|
1192
|
+
throw new Error(' ❌ AdMob configuration is incomplete. Ensure androidAppId/iosAppId or APP_ID_ANDROID/APP_ID_IOS are defined.');
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
return {
|
|
1196
|
+
ADMOB_ENABLED: true,
|
|
1197
|
+
APP_ID_ANDROID: androidAppId,
|
|
1198
|
+
APP_ID_IOS: iosAppId,
|
|
1199
|
+
USER_TRACKING_DESCRIPTION: userTrackingDescription,
|
|
1200
|
+
USE_LITE_ADS: legacyAdmobConfig.USE_LITE_ADS === "lite",
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function syncNextGenAdmobPackageJsonFromCapacitorConfig() {
|
|
1205
|
+
if (!fileExists(configPath) || !fileExists(packageJsonPath)) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
const capacitorConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
1210
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
1211
|
+
|
|
1212
|
+
const legacyAdmobConfig = capacitorConfig.plugins?.AdMob || {};
|
|
1213
|
+
const androidAppId = legacyAdmobConfig.APP_ID_ANDROID;
|
|
1214
|
+
const iosAppId = legacyAdmobConfig.APP_ID_IOS;
|
|
1215
|
+
|
|
1216
|
+
if (!androidAppId || !iosAppId) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
const desiredAdmobConfig = {
|
|
1221
|
+
androidAppId,
|
|
1222
|
+
iosAppId,
|
|
1223
|
+
enableNativeAds: {
|
|
1224
|
+
ios: packageJson.admob?.enableNativeAds?.ios ?? true,
|
|
1225
|
+
android: packageJson.admob?.enableNativeAds?.android ?? true,
|
|
1226
|
+
},
|
|
1227
|
+
userTrackingDescription:
|
|
1228
|
+
packageJson.admob?.userTrackingDescription ||
|
|
1229
|
+
'This identifier will be used to deliver personalized ads to you.',
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
const existingAdmobConfig = packageJson.admob || {};
|
|
1233
|
+
const mergedAdmobConfig = { ...existingAdmobConfig };
|
|
1234
|
+
let updated = false;
|
|
1235
|
+
|
|
1236
|
+
const syncKeyByKey = (target, source) => {
|
|
1237
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1238
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
1239
|
+
if (!target[key] || typeof target[key] !== 'object' || Array.isArray(target[key])) {
|
|
1240
|
+
target[key] = {};
|
|
1241
|
+
updated = true;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
syncKeyByKey(target[key], value);
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
if (target[key] !== value) {
|
|
1249
|
+
target[key] = value;
|
|
1250
|
+
updated = true;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
syncKeyByKey(mergedAdmobConfig, desiredAdmobConfig);
|
|
1256
|
+
|
|
1257
|
+
if (!updated) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
packageJson.admob = mergedAdmobConfig;
|
|
1262
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf8');
|
|
1263
|
+
console.log('✅ package.json AdMob settings synced from capacitor.config.json');
|
|
1264
|
+
}
|
|
1188
1265
|
|
|
1189
1266
|
function validateAndroidBuildOptions() {
|
|
1190
1267
|
|
|
@@ -1264,21 +1341,30 @@ function validateAndroidBuildOptions() {
|
|
|
1264
1341
|
//return buildOptions;
|
|
1265
1342
|
}
|
|
1266
1343
|
|
|
1267
|
-
function
|
|
1268
|
-
if (!fileExists(
|
|
1269
|
-
console.error(' ❌
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
let
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
}
|
|
1344
|
+
function updateAndroidManifest(admobConfig) {
|
|
1345
|
+
if (!fileExists(androidManifestPath)) {
|
|
1346
|
+
console.error(' ❌ AndroidManifest.xml not found. Ensure the Android platform is added.');
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
let manifestContent = fs.readFileSync(androidManifestPath, 'utf8');
|
|
1351
|
+
const metaDataTag = `<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="${admobConfig.APP_ID_ANDROID}" />`;
|
|
1352
|
+
|
|
1353
|
+
if (/com\.google\.android\.gms\.ads\.APPLICATION_ID/.test(manifestContent)) {
|
|
1354
|
+
manifestContent = manifestContent.replace(
|
|
1355
|
+
/<meta-data\s+android:name="com\.google\.android\.gms\.ads\.APPLICATION_ID"\s+android:value=".*?"\s*\/>/,
|
|
1356
|
+
metaDataTag
|
|
1357
|
+
);
|
|
1358
|
+
} else {
|
|
1359
|
+
manifestContent = manifestContent.replace(
|
|
1360
|
+
/<application\b([^>]*)>/,
|
|
1361
|
+
`<application$1>\n ${metaDataTag}`
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
fs.writeFileSync(androidManifestPath, manifestContent, 'utf8');
|
|
1366
|
+
console.log('✅ AdMob Android App ID successfully updated in AndroidManifest.xml');
|
|
1367
|
+
}
|
|
1282
1368
|
|
|
1283
1369
|
function updateInfoPlist(admobConfig) {
|
|
1284
1370
|
if (!fileExists(infoPlistPath)) {
|
|
@@ -1290,7 +1376,7 @@ function updateInfoPlist(admobConfig) {
|
|
|
1290
1376
|
const plistData = plist.parse(plistContent);
|
|
1291
1377
|
|
|
1292
1378
|
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
1293
|
-
plistData.NSUserTrackingUsageDescription =
|
|
1379
|
+
plistData.NSUserTrackingUsageDescription = admobConfig.USER_TRACKING_DESCRIPTION;
|
|
1294
1380
|
plistData.GADDelayAppMeasurementInit = true;
|
|
1295
1381
|
|
|
1296
1382
|
// https://developers.google.com/admob/ios/quick-start
|
|
@@ -1352,23 +1438,24 @@ try {
|
|
|
1352
1438
|
|
|
1353
1439
|
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
1354
1440
|
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
checkAndCopyResources();
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
checkAndCopyResources();
|
|
1444
|
+
|
|
1445
|
+
syncNextGenAdmobPackageJsonFromCapacitorConfig();
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
_admobConfig = getAdMobConfig();
|
|
1362
1449
|
|
|
1363
1450
|
|
|
1364
1451
|
|
|
1365
1452
|
|
|
1366
1453
|
|
|
1367
|
-
// Proceed only if ADMOB_ENABLED is true
|
|
1368
|
-
if (_admobConfig.ADMOB_ENABLED) {
|
|
1369
|
-
if (fileExists(androidPlatformPath)) {
|
|
1370
|
-
|
|
1371
|
-
}
|
|
1454
|
+
// Proceed only if ADMOB_ENABLED is true
|
|
1455
|
+
if (_admobConfig.ADMOB_ENABLED) {
|
|
1456
|
+
if (fileExists(androidPlatformPath)) {
|
|
1457
|
+
updateAndroidManifest(_admobConfig);
|
|
1458
|
+
}
|
|
1372
1459
|
|
|
1373
1460
|
if (fileExists(iosPlatformPath)) {
|
|
1374
1461
|
updateInfoPlist(_admobConfig);
|
|
@@ -1505,14 +1592,15 @@ function downloadFile(url, dest) {
|
|
|
1505
1592
|
* Replaces old filename → new filename
|
|
1506
1593
|
*/
|
|
1507
1594
|
|
|
1508
|
-
const VITE_ALIAS_ONLY = [
|
|
1509
|
-
"common",
|
|
1510
|
-
"admob-emi",
|
|
1511
|
-
"
|
|
1512
|
-
"
|
|
1513
|
-
"
|
|
1514
|
-
"
|
|
1515
|
-
|
|
1595
|
+
const VITE_ALIAS_ONLY = [
|
|
1596
|
+
"common",
|
|
1597
|
+
"admob-emi",
|
|
1598
|
+
"admob-emi-nextgen",
|
|
1599
|
+
"localization",
|
|
1600
|
+
"theme",
|
|
1601
|
+
"certificatejs",
|
|
1602
|
+
"ffmpeg"
|
|
1603
|
+
];
|
|
1516
1604
|
|
|
1517
1605
|
function updateImports(oldName, newName) {
|
|
1518
1606
|
|
|
@@ -2299,7 +2387,7 @@ if (hasError) {
|
|
|
2299
2387
|
|
|
2300
2388
|
|
|
2301
2389
|
|
|
2302
|
-
const checkAndupdateDropInViteConfig = () => {
|
|
2390
|
+
const checkAndupdateDropInViteConfig = () => {
|
|
2303
2391
|
|
|
2304
2392
|
const possibleFiles = [
|
|
2305
2393
|
"vite.config.js",
|
|
@@ -2364,9 +2452,72 @@ const checkAndupdateDropInViteConfig = () => {
|
|
|
2364
2452
|
);
|
|
2365
2453
|
}
|
|
2366
2454
|
|
|
2367
|
-
fs.writeFileSync(viteConfigPath, viteContent, "utf8");
|
|
2368
|
-
console.log("✅ vite.config.(m)js Updated successfully.");
|
|
2369
|
-
};
|
|
2455
|
+
fs.writeFileSync(viteConfigPath, viteContent, "utf8");
|
|
2456
|
+
console.log("✅ vite.config.(m)js Updated successfully.");
|
|
2457
|
+
};
|
|
2458
|
+
|
|
2459
|
+
const syncAdmobAliasInViteConfig = () => {
|
|
2460
|
+
const possibleFiles = [
|
|
2461
|
+
"vite.config.mjs",
|
|
2462
|
+
"vite.config.js"
|
|
2463
|
+
];
|
|
2464
|
+
|
|
2465
|
+
const viteConfigPath = possibleFiles
|
|
2466
|
+
.map(file => path.join(process.cwd(), file))
|
|
2467
|
+
.find(filePath => fs.existsSync(filePath));
|
|
2468
|
+
|
|
2469
|
+
if (!viteConfigPath) {
|
|
2470
|
+
console.warn("⚠️ No vite config found. Skipping AdMob alias sync.");
|
|
2471
|
+
return;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
const adsDir = path.join(process.cwd(), "src", "js", "Ads");
|
|
2475
|
+
|
|
2476
|
+
if (!fs.existsSync(adsDir)) {
|
|
2477
|
+
console.log("ℹ️ Ads folder not found. Keeping existing @admob alias.");
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
const nextGenFiles = fs.readdirSync(adsDir)
|
|
2482
|
+
.filter(name => /^admob-emi-nextgen-\d+(\.\d+)*\.js$/.test(name))
|
|
2483
|
+
.sort((a, b) => {
|
|
2484
|
+
const versionA = a.match(/(\d+(?:\.\d+)*)/)[1].split(".").map(Number);
|
|
2485
|
+
const versionB = b.match(/(\d+(?:\.\d+)*)/)[1].split(".").map(Number);
|
|
2486
|
+
|
|
2487
|
+
for (let i = 0; i < Math.max(versionA.length, versionB.length); i++) {
|
|
2488
|
+
const diff = (versionB[i] || 0) - (versionA[i] || 0);
|
|
2489
|
+
if (diff !== 0) return diff;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
return 0;
|
|
2493
|
+
});
|
|
2494
|
+
|
|
2495
|
+
if (nextGenFiles.length === 0) {
|
|
2496
|
+
console.log("ℹ️ No admob-emi-nextgen-x.x.js file found. Keeping existing @admob alias.");
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
const nextGenFile = nextGenFiles[0];
|
|
2501
|
+
const nextGenRelativePath = `./src/js/Ads/${nextGenFile}`;
|
|
2502
|
+
|
|
2503
|
+
let viteContent = fs.readFileSync(viteConfigPath, "utf8");
|
|
2504
|
+
const nextGenAliasLine = ` '@admob': path.resolve(__dirname, '${nextGenRelativePath}'),`;
|
|
2505
|
+
const aliasLineRegex = /[ \t]*['"]@admob['"]:\s*path\.resolve\(__dirname,\s*['"][^'"]+['"]\),/;
|
|
2506
|
+
|
|
2507
|
+
if (aliasLineRegex.test(viteContent) && viteContent.includes(nextGenAliasLine)) {
|
|
2508
|
+
console.log(`ℹ️ @admob already points to ${nextGenRelativePath}.`);
|
|
2509
|
+
return;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
if (!aliasLineRegex.test(viteContent)) {
|
|
2513
|
+
console.warn("⚠️ @admob alias line not found in vite config. Skipping alias sync.");
|
|
2514
|
+
return;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
viteContent = viteContent.replace(aliasLineRegex, nextGenAliasLine);
|
|
2518
|
+
fs.writeFileSync(viteConfigPath, viteContent, "utf8");
|
|
2519
|
+
console.log(`✅ @admob alias updated to ${nextGenRelativePath}`);
|
|
2520
|
+
};
|
|
2370
2521
|
|
|
2371
2522
|
|
|
2372
2523
|
|
|
@@ -2399,16 +2550,26 @@ const compareVersion = (v1, v2) => {
|
|
|
2399
2550
|
|
|
2400
2551
|
|
|
2401
2552
|
|
|
2402
|
-
const
|
|
2553
|
+
const admobConfigPaths = [
|
|
2554
|
+
path.join('src', 'js', 'Ads', 'admob-ad-configuration-nextgen.json'),
|
|
2555
|
+
path.join('src', 'js', 'Ads', 'admob-ad-configuration.json')
|
|
2556
|
+
];
|
|
2557
|
+
|
|
2558
|
+
const checkAdmobConfigurationProperty=()=>{
|
|
2403
2559
|
|
|
2404
|
-
const checkAdmobConfigurationProperty=()=>{
|
|
2405
2560
|
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2561
|
+
if (!_admobConfig.ADMOB_ENABLED)
|
|
2562
|
+
{
|
|
2563
|
+
console.log("ℹ️ Admob is not enabled so ad configuration checking is skipping...");
|
|
2564
|
+
return;
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
const admobConfigPath = admobConfigPaths.find(fileExists);
|
|
2568
|
+
|
|
2569
|
+
if (!admobConfigPath) {
|
|
2570
|
+
console.error("❌ Failed to find AdMob configuration JSON. Checked admob-ad-configuration-nextgen.json and admob-ad-configuration.json");
|
|
2571
|
+
process.exit(1);
|
|
2572
|
+
}
|
|
2412
2573
|
|
|
2413
2574
|
|
|
2414
2575
|
const REQUIRED_CONFIG_KEYS = [
|
|
@@ -2447,26 +2608,26 @@ const REQUIRED_CONFIG_KEYS = [
|
|
|
2447
2608
|
|
|
2448
2609
|
let admobConfigInJson;
|
|
2449
2610
|
|
|
2450
|
-
try {
|
|
2451
|
-
admobConfigInJson = JSON.parse(readFileSync(admobConfigPath, "utf8"));
|
|
2452
|
-
} catch (err) {
|
|
2453
|
-
console.error(
|
|
2454
|
-
process.exit(1);
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
// ✅ Validate config object exists
|
|
2458
|
-
if (!admobConfigInJson.config) {
|
|
2459
|
-
console.error(
|
|
2460
|
-
process.exit(1);
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
const admobConfigMinVersion="1.
|
|
2465
|
-
|
|
2466
|
-
if (compareVersion(admobConfigInJson.VERSION, admobConfigMinVersion) < 0) {
|
|
2467
|
-
console.error(`❌ Please use at-least version ${admobConfigMinVersion} in "
|
|
2468
|
-
process.exit(1);
|
|
2469
|
-
}
|
|
2611
|
+
try {
|
|
2612
|
+
admobConfigInJson = JSON.parse(readFileSync(admobConfigPath, "utf8"));
|
|
2613
|
+
} catch (err) {
|
|
2614
|
+
console.error(`❌ Failed to read ${admobConfigPath}`, err);
|
|
2615
|
+
process.exit(1);
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
// ✅ Validate config object exists
|
|
2619
|
+
if (!admobConfigInJson.config) {
|
|
2620
|
+
console.error(`❌ "config" object is missing in ${admobConfigPath}`);
|
|
2621
|
+
process.exit(1);
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
|
|
2625
|
+
const admobConfigMinVersion="1.0"
|
|
2626
|
+
|
|
2627
|
+
if (compareVersion(admobConfigInJson.VERSION, admobConfigMinVersion) < 0) {
|
|
2628
|
+
console.error(`❌ Please use at-least version ${admobConfigMinVersion} in "${admobConfigPath}"`);
|
|
2629
|
+
process.exit(1);
|
|
2630
|
+
}
|
|
2470
2631
|
|
|
2471
2632
|
|
|
2472
2633
|
const config = admobConfigInJson.config;
|
|
@@ -2477,17 +2638,17 @@ if (compareVersion(admobConfigInJson.VERSION, admobConfigMinVersion) < 0) {
|
|
|
2477
2638
|
);
|
|
2478
2639
|
|
|
2479
2640
|
|
|
2480
|
-
|
|
2481
|
-
if (missingKeys.length > 0) {
|
|
2482
|
-
console.error(
|
|
2483
|
-
|
|
2484
|
-
missingKeys.forEach(k => console.error(" - " + k));
|
|
2485
|
-
process.exit(1);
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
console.log(
|
|
2490
|
-
}
|
|
2641
|
+
|
|
2642
|
+
if (missingKeys.length > 0) {
|
|
2643
|
+
console.error(`❌ Missing required configuration keys. Please check it in '${admobConfigPath}'`);
|
|
2644
|
+
|
|
2645
|
+
missingKeys.forEach(k => console.error(" - " + k));
|
|
2646
|
+
process.exit(1);
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
|
|
2650
|
+
console.log(`✅ All keys exist in "${admobConfigPath}". Configuration looks good.`);
|
|
2651
|
+
}
|
|
2491
2652
|
|
|
2492
2653
|
|
|
2493
2654
|
|
|
@@ -2533,12 +2694,13 @@ ensureGitignoreEntry('buildCodeplay/');
|
|
|
2533
2694
|
// Run the validation
|
|
2534
2695
|
(async () => {
|
|
2535
2696
|
|
|
2536
|
-
await loadPluginVersions(); // 🔥 NEW
|
|
2537
|
-
|
|
2538
|
-
await checkPlugins();
|
|
2539
|
-
checkAndupdateDropInViteConfig();
|
|
2540
|
-
|
|
2541
|
-
|
|
2697
|
+
await loadPluginVersions(); // 🔥 NEW
|
|
2698
|
+
|
|
2699
|
+
await checkPlugins();
|
|
2700
|
+
checkAndupdateDropInViteConfig();
|
|
2701
|
+
syncAdmobAliasInViteConfig();
|
|
2702
|
+
checkAdmobConfigurationProperty()
|
|
2703
|
+
})();
|
|
2542
2704
|
|
|
2543
2705
|
|
|
2544
2706
|
// ======================================================
|
|
@@ -2730,4 +2892,4 @@ Release Notes
|
|
|
2730
2892
|
5.1
|
|
2731
2893
|
Kotlin version update is commented. Previously admob is not worked if not update the kotlin version to higher version
|
|
2732
2894
|
|
|
2733
|
-
*/
|
|
2895
|
+
*/
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (fs.existsSync(filePath)) {
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const replaceEmiPluginCode=()=>
|
|
5
|
+
{
|
|
6
|
+
// path to your .m file
|
|
7
|
+
const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
|
|
8
|
+
const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if (fs.existsSync(filePath)) {
|
|
15
12
|
let fileContent = fs.readFileSync(filePath, 'utf8');
|
|
16
13
|
|
|
17
14
|
// match the hideBannerAd method
|
|
@@ -36,17 +33,17 @@ const replaceEmiPluginCode=()=>
|
|
|
36
33
|
fileContent.slice(match.index + match[0].length);
|
|
37
34
|
|
|
38
35
|
fs.writeFileSync(filePath, updatedFileContent, 'utf8');
|
|
39
|
-
console.log(
|
|
40
|
-
'✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
|
|
41
|
-
);
|
|
42
|
-
} else {
|
|
43
|
-
console.log('⚠️ hideBannerAd method not found.');
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.log('ℹ️
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
console.log(
|
|
37
|
+
'✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
|
|
38
|
+
);
|
|
39
|
+
} else {
|
|
40
|
+
console.log('⚠️ hideBannerAd method not found.');
|
|
41
|
+
}
|
|
42
|
+
} else if (fs.existsSync(nextGenPackagePath)) {
|
|
43
|
+
console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
|
|
44
|
+
} else {
|
|
45
|
+
console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
replaceEmiPluginCode();
|
|
@@ -19,15 +19,17 @@ const addToolAttribute=()=>{
|
|
|
19
19
|
let manifest = fs.readFileSync(manifestPath, 'utf8');
|
|
20
20
|
|
|
21
21
|
// Check if xmlns:tools exists
|
|
22
|
-
if (!manifest.includes('xmlns:tools="http://schemas.android.com/tools"')) {
|
|
23
|
-
// Add the tools namespace to the <manifest> tag.
|
|
24
|
-
manifest = manifest.replace('<manifest', '<manifest xmlns:tools="http://schemas.android.com/tools"');
|
|
25
|
-
fs.writeFileSync(manifestPath, manifest, 'utf8');
|
|
26
|
-
console.log('✅
|
|
27
|
-
} else {
|
|
28
|
-
console.log('ℹ️
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
22
|
+
if (!manifest.includes('xmlns:tools="http://schemas.android.com/tools"')) {
|
|
23
|
+
// Add the tools namespace to the <manifest> tag.
|
|
24
|
+
manifest = manifest.replace('<manifest', '<manifest xmlns:tools="http://schemas.android.com/tools"');
|
|
25
|
+
fs.writeFileSync(manifestPath, manifest, 'utf8');
|
|
26
|
+
console.log('✅ Added xmlns:tools to AndroidManifest.xml');
|
|
27
|
+
} else {
|
|
28
|
+
console.log('ℹ️ xmlns:tools already exists, skipping...');
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
console.log('ℹ️ capacitor-cordova-android-plugins AndroidManifest.xml not found, skipping tools namespace update.');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
32
34
|
|
|
33
35
|
addToolAttribute()
|