codeplay-common 1.4.7 → 1.4.8

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.
@@ -3,14 +3,19 @@ const path = require('path');
3
3
  const plist = require('plist');
4
4
 
5
5
 
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
6
+ // Expected plugin list with minimum versions
7
+ const requiredPlugins = [
8
+ { pattern: /backbutton-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
9
+ { pattern: /common-(\d+\.\d+)\.js$/, minVersion: '3.3', required: true },
10
+ { pattern: /localization_settings-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
11
+ { pattern: /localization-(\d+\.\d+)\.js$/, minVersion: '1.2', required: true },
12
+ { pattern: /localNotification-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
13
+ { pattern: /localNotification_AppSettings-(\d+\.\d+)\.js$/, minVersion: '1.0', required: true },
14
+ { pattern: /onesignal-(\d+\.\d+)\.js$/, minVersion: '2.1', required: true },
15
+ { pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '2.1', required: true },
16
+ { pattern: /Ads[\/\\]IAP-(\d+\.\d+)$/, minVersion: '2.1', isFolder: true },
17
+ { pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '2.6', required: true }
18
+ ];
14
19
 
15
20
 
16
21
 
@@ -68,18 +73,7 @@ try {
68
73
  process.exit(1);
69
74
  }
70
75
 
71
- //Check codeplay-common latest version installed or not End
72
-
73
-
74
-
75
-
76
- // Run package version check before executing the main script
77
- try {
78
- checkPackageVersion();
79
- } catch (error) {
80
- console.error(error.message);
81
- process.exit(1);
82
- }
76
+ //Check codeplay-common latest version installed or not END
83
77
 
84
78
 
85
79
 
@@ -88,8 +82,6 @@ try {
88
82
 
89
83
  // saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists START
90
84
 
91
- // saveToGalleryAndSaveAnyFile-x.x-ios.js file check based on platform START
92
-
93
85
  const os = require('os');
94
86
 
95
87
  const saveToGalleryAndSaveFileCheck_iOS = () => {
@@ -148,9 +140,6 @@ const saveToGalleryAndSaveFileCheck_iOS = () => {
148
140
  };
149
141
 
150
142
  saveToGalleryAndSaveFileCheck_iOS();
151
- // saveToGalleryAndSaveAnyFile-x.x-ios.js file check based on platform END
152
-
153
-
154
143
  // saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists END
155
144
 
156
145
 
@@ -463,7 +452,7 @@ function copyFolderSync(source, target) {
463
452
  function checkAndCopyResources() {
464
453
  if (fileExists(resourcesPath)) {
465
454
  copyFolderSync(resourcesPath, androidResPath);
466
- console.log(' ✅ Successfully copied resources/res to android/app/src/main/res.');
455
+ console.log('✅ Successfully copied resources/res to android/app/src/main/res.');
467
456
  } else {
468
457
  console.log('resources/res folder not found.');
469
458
 
@@ -570,3 +559,114 @@ try {
570
559
  console.error(error.message);
571
560
  process.exit(1); // Stop execution if there's a critical error
572
561
  }
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+ // Check all the codeplays plugins version START
573
+
574
+
575
+ const readline = require('readline');
576
+
577
+
578
+ //const srcDir = path.join(__dirname, 'src');
579
+ const srcDir = path.join(process.cwd(), 'src');
580
+ let outdatedPlugins = [];
581
+
582
+ function parseVersion(ver) {
583
+ return ver.split('.').map(n => parseInt(n, 10));
584
+ }
585
+
586
+ function compareVersions(v1, v2) {
587
+ const [a1, b1] = parseVersion(v1);
588
+ const [a2, b2] = parseVersion(v2);
589
+ if (a1 !== a2) return a1 - a2;
590
+ return b1 - b2;
591
+ }
592
+
593
+ function walkSync(dir, filelist = []) {
594
+ fs.readdirSync(dir).forEach(file => {
595
+ const fullPath = path.join(dir, file);
596
+ const stat = fs.statSync(fullPath);
597
+ if (stat.isDirectory()) {
598
+ walkSync(fullPath, filelist);
599
+ } else {
600
+ filelist.push(fullPath);
601
+ }
602
+ });
603
+ return filelist;
604
+ }
605
+
606
+ function checkPlugins() {
607
+ const files = walkSync(srcDir);
608
+
609
+ for (const plugin of requiredPlugins) {
610
+ if (plugin.isFolder) {
611
+ const folderPath = path.join(srcDir, ...plugin.pattern.source.split(/[\/\\]/).slice(0, -1));
612
+ if (fs.existsSync(folderPath)) {
613
+ const versionMatch = plugin.pattern.exec(folderPath);
614
+ if (versionMatch && compareVersions(versionMatch[1], plugin.minVersion) < 0) {
615
+ outdatedPlugins.push({
616
+ name: plugin.pattern,
617
+ currentVersion: versionMatch[1],
618
+ requiredVersion: plugin.minVersion
619
+ });
620
+ }
621
+ }
622
+ continue;
623
+ }
624
+
625
+ const matchedFile = files.find(file => plugin.pattern.test(file));
626
+ if (matchedFile) {
627
+ const match = plugin.pattern.exec(matchedFile);
628
+ if (match) {
629
+ const currentVersion = match[1];
630
+ if (compareVersions(currentVersion, plugin.minVersion) < 0) {
631
+ outdatedPlugins.push({
632
+ name: path.relative(__dirname, matchedFile),
633
+ currentVersion,
634
+ requiredVersion: plugin.minVersion
635
+ });
636
+ }
637
+ }
638
+ }
639
+ }
640
+
641
+ if (outdatedPlugins.length > 0) {
642
+ console.log('\n❗ The following plugins are outdated:');
643
+ outdatedPlugins.forEach(p => {
644
+ console.log(` ❌ - ${p.name} (Current: ${p.currentVersion}, Required: ${p.requiredVersion})`);
645
+ });
646
+
647
+ const rl = readline.createInterface({
648
+ input: process.stdin,
649
+ output: process.stdout
650
+ });
651
+
652
+ rl.question('\nAre you sure you want to continue without updating these plugins? (y/n): ', answer => {
653
+ if (answer.toLowerCase() !== 'y') {
654
+ console.log('\n❌ Build cancelled due to outdated plugins.');
655
+ process.exit(1);
656
+ } else {
657
+ console.log('\n✅ Continuing build...');
658
+ rl.close();
659
+ }
660
+ });
661
+ } else {
662
+ console.log('✅ All plugin versions are up to date.');
663
+ }
664
+ }
665
+
666
+ // Run the validation
667
+ checkPlugins();
668
+
669
+
670
+
671
+
672
+ // Check all the codeplays plugins version START
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",