codeplay-common 1.4.5 → 1.4.7

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.
@@ -463,29 +463,43 @@ function copyFolderSync(source, target) {
463
463
  function checkAndCopyResources() {
464
464
  if (fileExists(resourcesPath)) {
465
465
  copyFolderSync(resourcesPath, androidResPath);
466
- console.log('Successfully copied resources/res to android/app/src/main/res.');
466
+ console.log('Successfully copied resources/res to android/app/src/main/res.');
467
467
  } else {
468
468
  console.log('resources/res folder not found.');
469
469
 
470
470
  if (fileExists(localNotificationsPluginPath)) {
471
- throw new Error('resources/res is required for @capacitor/local-notifications. Stopping execution.');
471
+ throw new Error('resources/res is required for @capacitor/local-notifications. Stopping execution.');
472
472
  }
473
473
  }
474
474
  }
475
475
 
476
+
477
+
476
478
  function getAdMobConfig() {
477
479
  if (!fileExists(configPath)) {
478
- throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
480
+ throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
479
481
  }
480
482
 
481
483
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
482
484
  const admobConfig = config.plugins?.AdMob;
483
485
 
484
- if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
485
- throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
486
+ if (!admobConfig) {
487
+ throw new Error('AdMob configuration is missing in capacitor.config.json.');
488
+ }
489
+
490
+ // Default to true if ADMOB_ENABLED is not specified
491
+ const isEnabled = admobConfig.ADMOB_ENABLED !== false;
492
+
493
+ if (!isEnabled) {
494
+ return { ADMOB_ENABLED: false }; // Skip further validation
495
+ }
496
+
497
+ if (!admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
498
+ throw new Error(' ❌ AdMob configuration is incomplete. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
486
499
  }
487
500
 
488
501
  return {
502
+ ADMOB_ENABLED: true,
489
503
  APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
490
504
  APP_ID_IOS: admobConfig.APP_ID_IOS,
491
505
  USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
@@ -494,7 +508,7 @@ function getAdMobConfig() {
494
508
 
495
509
  function updatePluginXml(admobConfig) {
496
510
  if (!fileExists(pluginPath)) {
497
- console.error('plugin.xml not found. Ensure the plugin is installed.');
511
+ console.error('plugin.xml not found. Ensure the plugin is installed.');
498
512
  return;
499
513
  }
500
514
 
@@ -505,12 +519,12 @@ function updatePluginXml(admobConfig) {
505
519
  .replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
506
520
 
507
521
  fs.writeFileSync(pluginPath, pluginContent, 'utf8');
508
- console.log('AdMob IDs successfully updated in plugin.xml');
522
+ console.log('AdMob IDs successfully updated in plugin.xml');
509
523
  }
510
524
 
511
525
  function updateInfoPlist(admobConfig) {
512
526
  if (!fileExists(infoPlistPath)) {
513
- console.error('Info.plist not found. Ensure you have built the iOS project.');
527
+ console.error('Info.plist not found. Ensure you have built the iOS project.');
514
528
  return;
515
529
  }
516
530
 
@@ -528,7 +542,7 @@ function updateInfoPlist(admobConfig) {
528
542
 
529
543
  try {
530
544
  if (!fileExists(configPath)) {
531
- throw new Error('capacitor.config.json not found. Skipping setup.');
545
+ throw new Error('capacitor.config.json not found. Skipping setup.');
532
546
  }
533
547
 
534
548
  if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
@@ -538,14 +552,20 @@ try {
538
552
  checkAndCopyResources();
539
553
 
540
554
  const admobConfig = getAdMobConfig();
555
+
541
556
 
542
- if (fileExists(androidPlatformPath)) {
543
- updatePluginXml(admobConfig);
544
- }
557
+ // Proceed only if ADMOB_ENABLED is true
558
+ if (admobConfig.ADMOB_ENABLED) {
559
+ if (fileExists(androidPlatformPath)) {
560
+ updatePluginXml(admobConfig);
561
+ }
545
562
 
546
- if (fileExists(iosPlatformPath)) {
547
- updateInfoPlist(admobConfig);
563
+ if (fileExists(iosPlatformPath)) {
564
+ updateInfoPlist(admobConfig);
565
+ }
548
566
  }
567
+
568
+
549
569
  } catch (error) {
550
570
  console.error(error.message);
551
571
  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.5",
3
+ "version": "1.4.7",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",