codeplay-common 1.4.6 → 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
|
|
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,12 +452,12 @@ 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
|
|
|
470
459
|
if (fileExists(localNotificationsPluginPath)) {
|
|
471
|
-
throw new Error('resources/res is required for @capacitor/local-notifications. Stopping execution.');
|
|
460
|
+
throw new Error('❌ resources/res is required for @capacitor/local-notifications. Stopping execution.');
|
|
472
461
|
}
|
|
473
462
|
}
|
|
474
463
|
}
|
|
@@ -477,14 +466,14 @@ function checkAndCopyResources() {
|
|
|
477
466
|
|
|
478
467
|
function getAdMobConfig() {
|
|
479
468
|
if (!fileExists(configPath)) {
|
|
480
|
-
throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
469
|
+
throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
481
470
|
}
|
|
482
471
|
|
|
483
472
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
484
473
|
const admobConfig = config.plugins?.AdMob;
|
|
485
474
|
|
|
486
475
|
if (!admobConfig) {
|
|
487
|
-
throw new Error('AdMob configuration is missing in capacitor.config.json.');
|
|
476
|
+
throw new Error('❌ AdMob configuration is missing in capacitor.config.json.');
|
|
488
477
|
}
|
|
489
478
|
|
|
490
479
|
// Default to true if ADMOB_ENABLED is not specified
|
|
@@ -495,7 +484,7 @@ function getAdMobConfig() {
|
|
|
495
484
|
}
|
|
496
485
|
|
|
497
486
|
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.');
|
|
487
|
+
throw new Error(' ❌ AdMob configuration is incomplete. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
|
|
499
488
|
}
|
|
500
489
|
|
|
501
490
|
return {
|
|
@@ -508,7 +497,7 @@ function getAdMobConfig() {
|
|
|
508
497
|
|
|
509
498
|
function updatePluginXml(admobConfig) {
|
|
510
499
|
if (!fileExists(pluginPath)) {
|
|
511
|
-
console.error('plugin.xml not found. Ensure the plugin is installed.');
|
|
500
|
+
console.error(' ❌ plugin.xml not found. Ensure the plugin is installed.');
|
|
512
501
|
return;
|
|
513
502
|
}
|
|
514
503
|
|
|
@@ -519,12 +508,12 @@ function updatePluginXml(admobConfig) {
|
|
|
519
508
|
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
|
520
509
|
|
|
521
510
|
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
|
522
|
-
console.log('AdMob IDs successfully updated in plugin.xml');
|
|
511
|
+
console.log('✅ AdMob IDs successfully updated in plugin.xml');
|
|
523
512
|
}
|
|
524
513
|
|
|
525
514
|
function updateInfoPlist(admobConfig) {
|
|
526
515
|
if (!fileExists(infoPlistPath)) {
|
|
527
|
-
console.error('Info.plist not found. Ensure you have built the iOS project.');
|
|
516
|
+
console.error(' ❌ Info.plist not found. Ensure you have built the iOS project.');
|
|
528
517
|
return;
|
|
529
518
|
}
|
|
530
519
|
|
|
@@ -542,7 +531,7 @@ function updateInfoPlist(admobConfig) {
|
|
|
542
531
|
|
|
543
532
|
try {
|
|
544
533
|
if (!fileExists(configPath)) {
|
|
545
|
-
throw new Error('capacitor.config.json not found. Skipping setup.');
|
|
534
|
+
throw new Error(' ❌ capacitor.config.json not found. Skipping setup.');
|
|
546
535
|
}
|
|
547
536
|
|
|
548
537
|
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
@@ -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
|