codeplay-common 1.4.4 → 1.4.5

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.
@@ -86,8 +86,86 @@ try {
86
86
 
87
87
 
88
88
 
89
+ // saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists START
90
+
91
+ // saveToGalleryAndSaveAnyFile-x.x-ios.js file check based on platform START
92
+
93
+ const os = require('os');
94
+
95
+ const saveToGalleryAndSaveFileCheck_iOS = () => {
96
+ const ROOT_DIR = path.resolve(__dirname, '../src');
97
+
98
+ const IOS_FILE_REGEX = /(?:import|require)?\s*\(?['"].*saveToGalleryAndSaveAnyFile-\d+(\.\d+)?-ios\.js['"]\)?/;
99
+ const ALLOWED_EXTENSIONS = ['.js', '.f7'];
100
+ const isMac = os.platform() === 'darwin';
101
+
102
+ let iosImportFound = false;
103
+
104
+ function scanDirectory(dir) {
105
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
106
+
107
+ for (let entry of entries) {
108
+ const fullPath = path.join(dir, entry.name);
109
+
110
+ if (entry.isDirectory()) {
111
+ if (entry.name === 'node_modules') continue;
112
+ scanDirectory(fullPath);
113
+ } else if (
114
+ entry.isFile() &&
115
+ ALLOWED_EXTENSIONS.some(ext => fullPath.endsWith(ext))
116
+ ) {
117
+ const content = fs.readFileSync(fullPath, 'utf8');
118
+ const matches = content.match(IOS_FILE_REGEX);
119
+ if (matches) {
120
+ iosImportFound = true;
121
+ console.error(`\n❌❌❌ BIG ERROR: iOS-specific import detected in: ${fullPath}`);
122
+ console.error(`🔍 Matched: ${matches[0]}\n`);
123
+ if (!isMac) {
124
+ console.error(`🚫 STOPPED: This file should not be imported in Android/Windows/Linux builds.\n`);
125
+ process.exit(1);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ // Check if src folder exists first
133
+ if (!fs.existsSync(ROOT_DIR)) {
134
+ console.warn(`⚠️ Warning: 'src' directory not found at: ${ROOT_DIR}`);
135
+ return;
136
+ }
137
+
138
+ scanDirectory(ROOT_DIR);
139
+
140
+ if (isMac && !iosImportFound) {
141
+ console.warn(`\x1b[31m\n⚠️⚠️⚠️ WARNING: You're on macOS but no iOS-specific file (saveToGalleryAndSaveAnyFile-x.x-ios.js) was found.\x1b[0m`);
142
+ console.warn(`👉 You may want to double-check your imports for the iOS platform.\n`);
143
+ } else if (isMac && iosImportFound) {
144
+ console.log('✅ iOS file detected as expected for macOS.');
145
+ } else if (!iosImportFound) {
146
+ console.log('✅ No iOS-specific file imports detected for non-macOS.');
147
+ }
148
+ };
149
+
150
+ saveToGalleryAndSaveFileCheck_iOS();
151
+ // saveToGalleryAndSaveAnyFile-x.x-ios.js file check based on platform END
152
+
153
+
154
+ // saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists END
155
+
156
+
157
+
158
+
159
+
160
+
161
+
89
162
 
90
163
 
164
+
165
+
166
+
167
+
168
+ /*
91
169
  // Clean up AppleDouble files (._*) created by macOS START
92
170
  if (process.platform === 'darwin') {
93
171
  try {
@@ -102,7 +180,7 @@ if (process.platform === 'darwin') {
102
180
  }
103
181
 
104
182
  // Clean up AppleDouble files (._*) created by macOS END
105
-
183
+ */
106
184
 
107
185
 
108
186
 
@@ -403,30 +481,17 @@ function getAdMobConfig() {
403
481
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
404
482
  const admobConfig = config.plugins?.AdMob;
405
483
 
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.');
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.');
419
486
  }
420
487
 
421
488
  return {
422
- ADMOB_ENABLED: true,
423
489
  APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
424
490
  APP_ID_IOS: admobConfig.APP_ID_IOS,
425
491
  USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
426
492
  };
427
493
  }
428
494
 
429
-
430
495
  function updatePluginXml(admobConfig) {
431
496
  if (!fileExists(pluginPath)) {
432
497
  console.error('plugin.xml not found. Ensure the plugin is installed.');
@@ -473,20 +538,14 @@ try {
473
538
  checkAndCopyResources();
474
539
 
475
540
  const admobConfig = getAdMobConfig();
476
-
477
541
 
478
- // Proceed only if ADMOB_ENABLED is true
479
- if (admobConfig.ADMOB_ENABLED) {
480
- if (fileExists(androidPlatformPath)) {
481
- updatePluginXml(admobConfig);
482
- }
483
-
484
- if (fileExists(iosPlatformPath)) {
485
- updateInfoPlist(admobConfig);
486
- }
542
+ if (fileExists(androidPlatformPath)) {
543
+ updatePluginXml(admobConfig);
487
544
  }
488
545
 
489
-
546
+ if (fileExists(iosPlatformPath)) {
547
+ updateInfoPlist(admobConfig);
548
+ }
490
549
  } catch (error) {
491
550
  console.error(error.message);
492
551
  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.4",
3
+ "version": "1.4.5",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",