codeplay-common 4.0.2 → 4.0.3

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.
@@ -1,14 +1,14 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const replaceEmiPluginCode=()=>
5
- {
6
- // path to your .m file
7
- const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
8
- const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
9
-
10
-
11
- if (fs.existsSync(filePath)) {
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const replaceEmiPluginCode=()=>
5
+ {
6
+ // path to your .m file
7
+ const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
8
+ const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
9
+
10
+
11
+ if (fs.existsSync(filePath)) {
12
12
  let fileContent = fs.readFileSync(filePath, 'utf8');
13
13
 
14
14
  // match the hideBannerAd method
@@ -33,17 +33,17 @@ const replaceEmiPluginCode=()=>
33
33
  fileContent.slice(match.index + match[0].length);
34
34
 
35
35
  fs.writeFileSync(filePath, updatedFileContent, 'utf8');
36
- console.log(
37
- '✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
38
- );
39
- } else {
40
- console.log('⚠️ hideBannerAd method not found.');
41
- }
42
- } else if (fs.existsSync(nextGenPackagePath)) {
43
- console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
44
- } else {
45
- console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
46
- }
47
- }
48
-
49
- replaceEmiPluginCode();
36
+ console.log(
37
+ '✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
38
+ );
39
+ } else {
40
+ console.log('⚠️ hideBannerAd method not found.');
41
+ }
42
+ } else if (fs.existsSync(nextGenPackagePath)) {
43
+ console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
44
+ } else {
45
+ console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
46
+ }
47
+ }
48
+
49
+ replaceEmiPluginCode();
@@ -19,17 +19,17 @@ const addToolAttribute=()=>{
19
19
  let manifest = fs.readFileSync(manifestPath, 'utf8');
20
20
 
21
21
  // Check if xmlns:tools exists
22
- if (!manifest.includes('xmlns:tools="http://schemas.android.com/tools"')) {
23
- // Add the tools namespace to the <manifest> tag.
24
- manifest = manifest.replace('<manifest', '<manifest xmlns:tools="http://schemas.android.com/tools"');
25
- fs.writeFileSync(manifestPath, manifest, 'utf8');
26
- console.log('✅ Added xmlns:tools to AndroidManifest.xml');
27
- } else {
28
- console.log('ℹ️ xmlns:tools already exists, skipping...');
29
- }
30
- } else {
31
- console.log('ℹ️ capacitor-cordova-android-plugins AndroidManifest.xml not found, skipping tools namespace update.');
32
- }
33
- };
22
+ if (!manifest.includes('xmlns:tools="http://schemas.android.com/tools"')) {
23
+ // Add the tools namespace to the <manifest> tag.
24
+ manifest = manifest.replace('<manifest', '<manifest xmlns:tools="http://schemas.android.com/tools"');
25
+ fs.writeFileSync(manifestPath, manifest, 'utf8');
26
+ console.log('✅ Added xmlns:tools to AndroidManifest.xml');
27
+ } else {
28
+ console.log('ℹ️ xmlns:tools already exists, skipping...');
29
+ }
30
+ } else {
31
+ console.log('ℹ️ capacitor-cordova-android-plugins AndroidManifest.xml not found, skipping tools namespace update.');
32
+ }
33
+ };
34
34
 
35
35
  addToolAttribute()
@@ -1,90 +1,90 @@
1
- Note: This changes are added with my old(current) code. Might we need to integrate this features into our new optimized code.
2
-
3
- 1) If no import(saveToGalleryAndSaveAnyFile) found it through error issue is fixed
4
- // iOS Checks
5
- /* if (isMac && !iosImportFound) {
6
- console.warn(`⚠️ WARNING: You're on macOS but no iOS version (saveToGalleryAndSaveAnyFile-x.x-ios.js) found.`);
7
- process.exit(1);
8
- } else if (isMac && iosImportFound) {
9
- console.log('✅ iOS version detected for macOS build.');
10
- } else if (!iosImportFound) {
11
- console.log('✅ No iOS-specific imports detected for non-macOS.');
12
- } */
13
-
14
- // ✅ Only care if iOS import is found in NON-mac systems
15
- if (iosImportFound && !isMac) {
16
- console.error(`\n❌ ERROR: iOS-specific file is imported in non-macOS environment.`);
17
- process.exit(1);
18
- } else if (iosImportFound && isMac) {
19
- console.log('✅ iOS import detected (valid for macOS build).');
20
- } else {
21
- console.log('✅ No iOS-specific imports found (this is totally fine).');
22
- }
23
-
24
-
25
- 2) Statusbar color set in app startup is checked and through erro
26
-
27
- const STATUSBAR_FILE = path.resolve(__dirname, '../src/js/common-configuration.js');
28
- const STATUSBAR_REGEX = /^(?!\s*\/\/).*Capacitor\.Plugins\.StatusBar\.setStyle/m;
29
-
30
-
31
- const ONESIGNAL_OLD_FILES = [
32
- path.resolve(__dirname, '../src/js/onesignal-settings.js')
33
- ];
34
- const ONESIGNAL_VERSION_REGEX = /^onesignal-\d+(\.\d+)*\.js$/;
35
-
36
- ....
37
- ....
38
- ....
39
-
40
-
41
- const JS_ROOT = path.resolve(__dirname, '../src/js');
42
- const ONESIGNAL_DIR = path.join(JS_ROOT, 'onesignal');
43
-
44
- // 🚨 Block old OneSignal file locations (ONLY in src/js root)
45
- if (path.dirname(dir) === JS_ROOT) {
46
-
47
- // ❌ onesignal-settings.js
48
- if (ONESIGNAL_OLD_FILES.includes(dir)) {
49
- console.error(`\n❌ ERROR: onesignal-settings.js should not be in src/js/`);
50
- console.error(`📁 Move it to: src/js/onesignal/`);
51
- console.error(`📄 File: ${dir}\n`);
52
- process.exit(1);
53
- }
54
-
55
- // ❌ onesignal-x.x.js
56
- if (ONESIGNAL_VERSION_REGEX.test(baseName)) {
57
- console.error(`\n❌ ERROR: ${baseName} should not be in src/js/`);
58
- console.error(`📁 Move it to: src/js/onesignal/`);
59
- console.error(`📄 File: ${dir}\n`);
60
- process.exit(1);
61
- }
62
- }
63
-
64
- // 🚨 Special check ONLY for common-configuration.js
65
- if (dir === STATUSBAR_FILE) {
66
- let content = fs.readFileSync(dir, 'utf8');
67
-
68
- // 🧹 Remove ALL comments (single-line + multi-line)
69
- const contentWithoutComments = content
70
- .replace(/\/\/.*$/gm, '') // remove // comments
71
- .replace(/\/\*[\s\S]*?\*\//g, ''); // remove /* */ comments
72
-
73
- // ✅ Now check only real code
74
- if (contentWithoutComments.includes('Capacitor.Plugins.StatusBar.setStyle')) {
75
- console.error(`\n❌ ERROR: StatusBar.setStyle should NOT be used in common-configuration.js`);
76
- console.error(`🚫 iOS status bar is controlled via other methods. Remove this line.`);
77
- console.error(`📄 File: ${dir}\n`);
78
- process.exit(1);
79
- }
80
- }
81
-
82
-
83
- 3) Modification in "fix-onesignal-plugin.js" file
84
- Search following and that whole block added for add permission to "info.plist" file
85
- INFO.PLIST START
86
-
87
- 4) In "codeplayBeforeBuild-6.1.js" file following whole method is replaced. Due to add ads related permission to info.plist file
88
- updateInfoPlist()
89
-
1
+ Note: This changes are added with my old(current) code. Might we need to integrate this features into our new optimized code.
2
+
3
+ 1) If no import(saveToGalleryAndSaveAnyFile) found it through error issue is fixed
4
+ // iOS Checks
5
+ /* if (isMac && !iosImportFound) {
6
+ console.warn(`⚠️ WARNING: You're on macOS but no iOS version (saveToGalleryAndSaveAnyFile-x.x-ios.js) found.`);
7
+ process.exit(1);
8
+ } else if (isMac && iosImportFound) {
9
+ console.log('✅ iOS version detected for macOS build.');
10
+ } else if (!iosImportFound) {
11
+ console.log('✅ No iOS-specific imports detected for non-macOS.');
12
+ } */
13
+
14
+ // ✅ Only care if iOS import is found in NON-mac systems
15
+ if (iosImportFound && !isMac) {
16
+ console.error(`\n❌ ERROR: iOS-specific file is imported in non-macOS environment.`);
17
+ process.exit(1);
18
+ } else if (iosImportFound && isMac) {
19
+ console.log('✅ iOS import detected (valid for macOS build).');
20
+ } else {
21
+ console.log('✅ No iOS-specific imports found (this is totally fine).');
22
+ }
23
+
24
+
25
+ 2) Statusbar color set in app startup is checked and through erro
26
+
27
+ const STATUSBAR_FILE = path.resolve(__dirname, '../src/js/common-configuration.js');
28
+ const STATUSBAR_REGEX = /^(?!\s*\/\/).*Capacitor\.Plugins\.StatusBar\.setStyle/m;
29
+
30
+
31
+ const ONESIGNAL_OLD_FILES = [
32
+ path.resolve(__dirname, '../src/js/onesignal-settings.js')
33
+ ];
34
+ const ONESIGNAL_VERSION_REGEX = /^onesignal-\d+(\.\d+)*\.js$/;
35
+
36
+ ....
37
+ ....
38
+ ....
39
+
40
+
41
+ const JS_ROOT = path.resolve(__dirname, '../src/js');
42
+ const ONESIGNAL_DIR = path.join(JS_ROOT, 'onesignal');
43
+
44
+ // 🚨 Block old OneSignal file locations (ONLY in src/js root)
45
+ if (path.dirname(dir) === JS_ROOT) {
46
+
47
+ // ❌ onesignal-settings.js
48
+ if (ONESIGNAL_OLD_FILES.includes(dir)) {
49
+ console.error(`\n❌ ERROR: onesignal-settings.js should not be in src/js/`);
50
+ console.error(`📁 Move it to: src/js/onesignal/`);
51
+ console.error(`📄 File: ${dir}\n`);
52
+ process.exit(1);
53
+ }
54
+
55
+ // ❌ onesignal-x.x.js
56
+ if (ONESIGNAL_VERSION_REGEX.test(baseName)) {
57
+ console.error(`\n❌ ERROR: ${baseName} should not be in src/js/`);
58
+ console.error(`📁 Move it to: src/js/onesignal/`);
59
+ console.error(`📄 File: ${dir}\n`);
60
+ process.exit(1);
61
+ }
62
+ }
63
+
64
+ // 🚨 Special check ONLY for common-configuration.js
65
+ if (dir === STATUSBAR_FILE) {
66
+ let content = fs.readFileSync(dir, 'utf8');
67
+
68
+ // 🧹 Remove ALL comments (single-line + multi-line)
69
+ const contentWithoutComments = content
70
+ .replace(/\/\/.*$/gm, '') // remove // comments
71
+ .replace(/\/\*[\s\S]*?\*\//g, ''); // remove /* */ comments
72
+
73
+ // ✅ Now check only real code
74
+ if (contentWithoutComments.includes('Capacitor.Plugins.StatusBar.setStyle')) {
75
+ console.error(`\n❌ ERROR: StatusBar.setStyle should NOT be used in common-configuration.js`);
76
+ console.error(`🚫 iOS status bar is controlled via other methods. Remove this line.`);
77
+ console.error(`📄 File: ${dir}\n`);
78
+ process.exit(1);
79
+ }
80
+ }
81
+
82
+
83
+ 3) Modification in "fix-onesignal-plugin.js" file
84
+ Search following and that whole block added for add permission to "info.plist" file
85
+ INFO.PLIST START
86
+
87
+ 4) In "codeplayBeforeBuild-6.1.js" file following whole method is replaced. Due to add ads related permission to info.plist file
88
+ updateInfoPlist()
89
+
90
90
  5) The "checkPackageVersion()" metod is updated. Now check the "codeplay-common" latest version and uninstall/install automatically.
@@ -1,43 +1,43 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const legacyPluginXmlPath = path.resolve(
5
- __dirname,
6
- '../node_modules/emi-indo-cordova-plugin-admob/plugin.xml'
7
- );
8
-
9
- const nextGenPackagePath = path.resolve(
10
- __dirname,
11
- '../node_modules/capacitor-admob-nextgen/package.json'
12
- );
13
-
14
- if (!fs.existsSync(legacyPluginXmlPath)) {
15
- if (fs.existsSync(nextGenPackagePath)) {
16
- console.log('ℹ️ Skipping legacy Kotlin patch. capacitor-admob-nextgen is installed and does not use plugin.xml.');
17
- process.exit(0);
18
- }
19
-
20
- console.log('ℹ️ Legacy AdMob plugin.xml not found, skipping Kotlin patch.');
21
- process.exit(0);
22
- }
23
-
24
- fs.readFile(legacyPluginXmlPath, 'utf8', (err, data) => {
25
- if (err) {
26
- console.error('Error reading plugin.xml:', err);
27
- process.exit(1);
28
- }
29
-
30
- const modifiedData = data.replace(
31
- /<framework\s+src="src\/android\/force-kotlin\.gradle"\s+custom="true"\s+type="gradleReference"\s*\/>\s*\n?/g,
32
- ''
33
- );
34
-
35
- fs.writeFile(legacyPluginXmlPath, modifiedData, 'utf8', (writeErr) => {
36
- if (writeErr) {
37
- console.error('Error writing plugin.xml:', writeErr);
38
- process.exit(1);
39
- }
40
-
41
- console.log('plugin.xml updated successfully.');
42
- });
43
- });
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const legacyPluginXmlPath = path.resolve(
5
+ __dirname,
6
+ '../node_modules/emi-indo-cordova-plugin-admob/plugin.xml'
7
+ );
8
+
9
+ const nextGenPackagePath = path.resolve(
10
+ __dirname,
11
+ '../node_modules/capacitor-admob-nextgen/package.json'
12
+ );
13
+
14
+ if (!fs.existsSync(legacyPluginXmlPath)) {
15
+ if (fs.existsSync(nextGenPackagePath)) {
16
+ console.log('ℹ️ Skipping legacy Kotlin patch. capacitor-admob-nextgen is installed and does not use plugin.xml.');
17
+ process.exit(0);
18
+ }
19
+
20
+ console.log('ℹ️ Legacy AdMob plugin.xml not found, skipping Kotlin patch.');
21
+ process.exit(0);
22
+ }
23
+
24
+ fs.readFile(legacyPluginXmlPath, 'utf8', (err, data) => {
25
+ if (err) {
26
+ console.error('Error reading plugin.xml:', err);
27
+ process.exit(1);
28
+ }
29
+
30
+ const modifiedData = data.replace(
31
+ /<framework\s+src="src\/android\/force-kotlin\.gradle"\s+custom="true"\s+type="gradleReference"\s*\/>\s*\n?/g,
32
+ ''
33
+ );
34
+
35
+ fs.writeFile(legacyPluginXmlPath, modifiedData, 'utf8', (writeErr) => {
36
+ if (writeErr) {
37
+ console.error('Error writing plugin.xml:', writeErr);
38
+ process.exit(1);
39
+ }
40
+
41
+ console.log('plugin.xml updated successfully.');
42
+ });
43
+ });
@@ -3,7 +3,7 @@
3
3
  {"name":"backbutton","pattern":"backbutton-(\\d+\\.\\d+)\\.js$","minVersion":"2.1","baseDir":"js","mandatoryUpdate":true},
4
4
  {"name":"common-js","pattern":"common-(\\d+\\.\\d+)(?:-beta-(\\d+))?\\.js$","minVersion":"6.2","baseDir":"js","mandatoryUpdate":true},
5
5
 
6
- {"name":"admob-emi-nextgen","pattern":"Ads[\\\\/]admob-emi-nextgen-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
6
+ {"name":"admob-emi-nextgen","pattern":"Ads[\\\\/]admob-emi-nextgen-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
7
7
  {"name":"video-player","pattern":"video-player-(\\d+\\.\\d+)\\.js$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true},
8
8
  {"name":"image-cropper","pattern":"image-cropper-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
9
9
  {"name":"beautify","pattern":"beautify-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
@@ -24,4 +24,4 @@
24
24
  {"name":"onesignal","pattern":"onesignal-(\\d+\\.\\d+)\\.js$","minVersion":"2.4","baseDir":"js","mandatoryUpdate":true},
25
25
  {"name":"saveToGalleryAndSaveAnyFile","pattern":"saveToGalleryAndSaveAnyFile-(\\d+\\.\\d+)(-ios)?\\.js$","minVersion":"3.1","baseDir":"js","mandatoryUpdate":true}
26
26
  ]
27
- }
27
+ }