codeplay-common 3.2.18 → 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 +302 -129
- 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 = [
|
|
@@ -217,13 +218,24 @@ function checkPackageVersion() {
|
|
|
217
218
|
const latestVersion = getLatestVersion(packageName);
|
|
218
219
|
|
|
219
220
|
if (!installedVersion) {
|
|
220
|
-
console.error(`${packageName} is not installed.
|
|
221
|
-
|
|
221
|
+
console.error(`${packageName} is not installed. Installing now...`);
|
|
222
|
+
execSync(`npm install ${packageName}`, { stdio: 'inherit' });
|
|
223
|
+
return;
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
if (installedVersion !== latestVersion) {
|
|
225
|
-
console.
|
|
226
|
-
|
|
227
|
+
console.log(`${packageName} is outdated (installed: ${installedVersion}, latest: ${latestVersion}). Updating now...`);
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
execSync(`npm uninstall ${packageName}`, { stdio: 'inherit' });
|
|
231
|
+
execSync(`npm install ${packageName}`, { stdio: 'inherit' });
|
|
232
|
+
console.log(`${packageName} successfully updated.`);
|
|
233
|
+
} catch (err) {
|
|
234
|
+
console.error(`Failed to update ${packageName}:`, err.message);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return;
|
|
227
239
|
}
|
|
228
240
|
|
|
229
241
|
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
@@ -1095,10 +1107,10 @@ let _admobConfig;
|
|
|
1095
1107
|
|
|
1096
1108
|
|
|
1097
1109
|
|
|
1098
|
-
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
1099
|
-
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
1100
|
-
const
|
|
1101
|
-
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');
|
|
1102
1114
|
const resourcesPath = path.join(process.cwd(), 'resources', 'res');
|
|
1103
1115
|
const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
|
|
1104
1116
|
const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
|
|
@@ -1144,36 +1156,112 @@ function checkAndCopyResources() {
|
|
|
1144
1156
|
|
|
1145
1157
|
|
|
1146
1158
|
|
|
1147
|
-
function getAdMobConfig() {
|
|
1148
|
-
if (!fileExists(configPath)) {
|
|
1149
|
-
throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
const
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
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
|
+
}
|
|
1177
1265
|
|
|
1178
1266
|
function validateAndroidBuildOptions() {
|
|
1179
1267
|
|
|
@@ -1253,21 +1341,30 @@ function validateAndroidBuildOptions() {
|
|
|
1253
1341
|
//return buildOptions;
|
|
1254
1342
|
}
|
|
1255
1343
|
|
|
1256
|
-
function
|
|
1257
|
-
if (!fileExists(
|
|
1258
|
-
console.error(' ❌
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
let
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
}
|
|
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
|
+
}
|
|
1271
1368
|
|
|
1272
1369
|
function updateInfoPlist(admobConfig) {
|
|
1273
1370
|
if (!fileExists(infoPlistPath)) {
|
|
@@ -1279,7 +1376,7 @@ function updateInfoPlist(admobConfig) {
|
|
|
1279
1376
|
const plistData = plist.parse(plistContent);
|
|
1280
1377
|
|
|
1281
1378
|
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
1282
|
-
plistData.NSUserTrackingUsageDescription =
|
|
1379
|
+
plistData.NSUserTrackingUsageDescription = admobConfig.USER_TRACKING_DESCRIPTION;
|
|
1283
1380
|
plistData.GADDelayAppMeasurementInit = true;
|
|
1284
1381
|
|
|
1285
1382
|
// https://developers.google.com/admob/ios/quick-start
|
|
@@ -1341,23 +1438,24 @@ try {
|
|
|
1341
1438
|
|
|
1342
1439
|
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
1343
1440
|
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
checkAndCopyResources();
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
checkAndCopyResources();
|
|
1444
|
+
|
|
1445
|
+
syncNextGenAdmobPackageJsonFromCapacitorConfig();
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
_admobConfig = getAdMobConfig();
|
|
1351
1449
|
|
|
1352
1450
|
|
|
1353
1451
|
|
|
1354
1452
|
|
|
1355
1453
|
|
|
1356
|
-
// Proceed only if ADMOB_ENABLED is true
|
|
1357
|
-
if (_admobConfig.ADMOB_ENABLED) {
|
|
1358
|
-
if (fileExists(androidPlatformPath)) {
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1454
|
+
// Proceed only if ADMOB_ENABLED is true
|
|
1455
|
+
if (_admobConfig.ADMOB_ENABLED) {
|
|
1456
|
+
if (fileExists(androidPlatformPath)) {
|
|
1457
|
+
updateAndroidManifest(_admobConfig);
|
|
1458
|
+
}
|
|
1361
1459
|
|
|
1362
1460
|
if (fileExists(iosPlatformPath)) {
|
|
1363
1461
|
updateInfoPlist(_admobConfig);
|
|
@@ -1494,14 +1592,15 @@ function downloadFile(url, dest) {
|
|
|
1494
1592
|
* Replaces old filename → new filename
|
|
1495
1593
|
*/
|
|
1496
1594
|
|
|
1497
|
-
const VITE_ALIAS_ONLY = [
|
|
1498
|
-
"common",
|
|
1499
|
-
"admob-emi",
|
|
1500
|
-
"
|
|
1501
|
-
"
|
|
1502
|
-
"
|
|
1503
|
-
"
|
|
1504
|
-
|
|
1595
|
+
const VITE_ALIAS_ONLY = [
|
|
1596
|
+
"common",
|
|
1597
|
+
"admob-emi",
|
|
1598
|
+
"admob-emi-nextgen",
|
|
1599
|
+
"localization",
|
|
1600
|
+
"theme",
|
|
1601
|
+
"certificatejs",
|
|
1602
|
+
"ffmpeg"
|
|
1603
|
+
];
|
|
1505
1604
|
|
|
1506
1605
|
function updateImports(oldName, newName) {
|
|
1507
1606
|
|
|
@@ -2288,7 +2387,7 @@ if (hasError) {
|
|
|
2288
2387
|
|
|
2289
2388
|
|
|
2290
2389
|
|
|
2291
|
-
const checkAndupdateDropInViteConfig = () => {
|
|
2390
|
+
const checkAndupdateDropInViteConfig = () => {
|
|
2292
2391
|
|
|
2293
2392
|
const possibleFiles = [
|
|
2294
2393
|
"vite.config.js",
|
|
@@ -2353,9 +2452,72 @@ const checkAndupdateDropInViteConfig = () => {
|
|
|
2353
2452
|
);
|
|
2354
2453
|
}
|
|
2355
2454
|
|
|
2356
|
-
fs.writeFileSync(viteConfigPath, viteContent, "utf8");
|
|
2357
|
-
console.log("✅ vite.config.(m)js Updated successfully.");
|
|
2358
|
-
};
|
|
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
|
+
};
|
|
2359
2521
|
|
|
2360
2522
|
|
|
2361
2523
|
|
|
@@ -2388,16 +2550,26 @@ const compareVersion = (v1, v2) => {
|
|
|
2388
2550
|
|
|
2389
2551
|
|
|
2390
2552
|
|
|
2391
|
-
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=()=>{
|
|
2392
2559
|
|
|
2393
|
-
const checkAdmobConfigurationProperty=()=>{
|
|
2394
2560
|
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
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
|
+
}
|
|
2401
2573
|
|
|
2402
2574
|
|
|
2403
2575
|
const REQUIRED_CONFIG_KEYS = [
|
|
@@ -2436,26 +2608,26 @@ const REQUIRED_CONFIG_KEYS = [
|
|
|
2436
2608
|
|
|
2437
2609
|
let admobConfigInJson;
|
|
2438
2610
|
|
|
2439
|
-
try {
|
|
2440
|
-
admobConfigInJson = JSON.parse(readFileSync(admobConfigPath, "utf8"));
|
|
2441
|
-
} catch (err) {
|
|
2442
|
-
console.error(
|
|
2443
|
-
process.exit(1);
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
|
-
// ✅ Validate config object exists
|
|
2447
|
-
if (!admobConfigInJson.config) {
|
|
2448
|
-
console.error(
|
|
2449
|
-
process.exit(1);
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
const admobConfigMinVersion="1.
|
|
2454
|
-
|
|
2455
|
-
if (compareVersion(admobConfigInJson.VERSION, admobConfigMinVersion) < 0) {
|
|
2456
|
-
console.error(`❌ Please use at-least version ${admobConfigMinVersion} in "
|
|
2457
|
-
process.exit(1);
|
|
2458
|
-
}
|
|
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
|
+
}
|
|
2459
2631
|
|
|
2460
2632
|
|
|
2461
2633
|
const config = admobConfigInJson.config;
|
|
@@ -2466,17 +2638,17 @@ if (compareVersion(admobConfigInJson.VERSION, admobConfigMinVersion) < 0) {
|
|
|
2466
2638
|
);
|
|
2467
2639
|
|
|
2468
2640
|
|
|
2469
|
-
|
|
2470
|
-
if (missingKeys.length > 0) {
|
|
2471
|
-
console.error(
|
|
2472
|
-
|
|
2473
|
-
missingKeys.forEach(k => console.error(" - " + k));
|
|
2474
|
-
process.exit(1);
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
console.log(
|
|
2479
|
-
}
|
|
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
|
+
}
|
|
2480
2652
|
|
|
2481
2653
|
|
|
2482
2654
|
|
|
@@ -2522,12 +2694,13 @@ ensureGitignoreEntry('buildCodeplay/');
|
|
|
2522
2694
|
// Run the validation
|
|
2523
2695
|
(async () => {
|
|
2524
2696
|
|
|
2525
|
-
await loadPluginVersions(); // 🔥 NEW
|
|
2526
|
-
|
|
2527
|
-
await checkPlugins();
|
|
2528
|
-
checkAndupdateDropInViteConfig();
|
|
2529
|
-
|
|
2530
|
-
|
|
2697
|
+
await loadPluginVersions(); // 🔥 NEW
|
|
2698
|
+
|
|
2699
|
+
await checkPlugins();
|
|
2700
|
+
checkAndupdateDropInViteConfig();
|
|
2701
|
+
syncAdmobAliasInViteConfig();
|
|
2702
|
+
checkAdmobConfigurationProperty()
|
|
2703
|
+
})();
|
|
2531
2704
|
|
|
2532
2705
|
|
|
2533
2706
|
// ======================================================
|
|
@@ -2719,4 +2892,4 @@ Release Notes
|
|
|
2719
2892
|
5.1
|
|
2720
2893
|
Kotlin version update is commented. Previously admob is not worked if not update the kotlin version to higher version
|
|
2721
2894
|
|
|
2722
|
-
*/
|
|
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();
|