codeplay-common 1.4.3 → 1.4.4

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.
@@ -403,17 +403,30 @@ function getAdMobConfig() {
403
403
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
404
404
  const admobConfig = config.plugins?.AdMob;
405
405
 
406
- if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
407
- throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
406
+ if (!admobConfig) {
407
+ throw new Error('AdMob configuration is missing in capacitor.config.json.');
408
+ }
409
+
410
+ // Default to true if ADMOB_ENABLED is not specified
411
+ const isEnabled = admobConfig.ADMOB_ENABLED !== false;
412
+
413
+ if (!isEnabled) {
414
+ return { ADMOB_ENABLED: false }; // Skip further validation
415
+ }
416
+
417
+ if (!admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
418
+ throw new Error('AdMob configuration is incomplete. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
408
419
  }
409
420
 
410
421
  return {
422
+ ADMOB_ENABLED: true,
411
423
  APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
412
424
  APP_ID_IOS: admobConfig.APP_ID_IOS,
413
425
  USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
414
426
  };
415
427
  }
416
428
 
429
+
417
430
  function updatePluginXml(admobConfig) {
418
431
  if (!fileExists(pluginPath)) {
419
432
  console.error('plugin.xml not found. Ensure the plugin is installed.');
@@ -460,14 +473,20 @@ try {
460
473
  checkAndCopyResources();
461
474
 
462
475
  const admobConfig = getAdMobConfig();
476
+
463
477
 
464
- if (fileExists(androidPlatformPath)) {
465
- updatePluginXml(admobConfig);
466
- }
478
+ // Proceed only if ADMOB_ENABLED is true
479
+ if (admobConfig.ADMOB_ENABLED) {
480
+ if (fileExists(androidPlatformPath)) {
481
+ updatePluginXml(admobConfig);
482
+ }
467
483
 
468
- if (fileExists(iosPlatformPath)) {
469
- updateInfoPlist(admobConfig);
484
+ if (fileExists(iosPlatformPath)) {
485
+ updateInfoPlist(admobConfig);
486
+ }
470
487
  }
488
+
489
+
471
490
  } catch (error) {
472
491
  console.error(error.message);
473
492
  process.exit(1); // Stop execution if there's a critical error
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",