codeplay-common 2.0.3 → 2.0.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.
- package/.gitattributes +2 -2
- package/LICENSE +21 -21
- package/README.md +11 -11
- package/files/buildCodeplay/add-splash-screen-1.6.js +248 -248
- package/files/buildCodeplay/{codeplayBeforeBuild-4.7.js → codeplayBeforeBuild-4.8.js} +100 -2
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/package.json +16 -16
- package/scripts/sync-files.js +86 -86
- package/scripts/uninstall.js +77 -77
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const plist = require('plist');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const { readFileSync } = require("fs");
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ const requiredPlugins = [
|
|
|
19
19
|
{ pattern: /onesignal-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
|
|
20
20
|
{ pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '2.8', required: true },
|
|
21
21
|
{ pattern: /Ads[\/\\]IAP-(\d+\.\d+)$/, minVersion: '2.5', isFolder: true , required: true },
|
|
22
|
-
{ pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '3.
|
|
22
|
+
{ pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '3.2', required: true },
|
|
23
23
|
|
|
24
24
|
// New added plugins
|
|
25
25
|
{ pattern: /video-player-(\d+\.\d+)\.js$/, minVersion: '1.5', required: true },
|
|
@@ -1053,6 +1053,104 @@ checkAndupdateDropInViteConfig();
|
|
|
1053
1053
|
|
|
1054
1054
|
|
|
1055
1055
|
|
|
1056
|
+
const compareVersion = (v1, v2) => {
|
|
1057
|
+
const a = v1.split(".").map(Number);
|
|
1058
|
+
const b = v2.split(".").map(Number);
|
|
1059
|
+
|
|
1060
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
1061
|
+
const num1 = a[i] || 0;
|
|
1062
|
+
const num2 = b[i] || 0;
|
|
1063
|
+
if (num1 > num2) return 1;
|
|
1064
|
+
if (num1 < num2) return -1;
|
|
1065
|
+
}
|
|
1066
|
+
return 0;
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
const admobConfigPath = path.join('src', 'js','Ads', 'admob-ad-configuration.json');
|
|
1073
|
+
|
|
1074
|
+
const checkAdmobConfigurationProperty=()=>{
|
|
1075
|
+
|
|
1076
|
+
const REQUIRED_CONFIG_KEYS = [
|
|
1077
|
+
"isKidsApp",
|
|
1078
|
+
"isTesting",
|
|
1079
|
+
"isConsoleLogEnabled",
|
|
1080
|
+
"bannerEnabled",
|
|
1081
|
+
"interstitialEnabled",
|
|
1082
|
+
"appOpenEnabled",
|
|
1083
|
+
"rewardVideoEnabled",
|
|
1084
|
+
"rewardInterstitialEnabled",
|
|
1085
|
+
"collapsibleEnabled",
|
|
1086
|
+
"isLandScape",
|
|
1087
|
+
"overlappingHeight",
|
|
1088
|
+
"isOverlappingEnable",
|
|
1089
|
+
"bannerTypeAndroid",
|
|
1090
|
+
"bannerTypeiOS",
|
|
1091
|
+
"bannerTopSpaceColor",
|
|
1092
|
+
"interstitialLoadScreenTextColor",
|
|
1093
|
+
"interstitialLoadScreenBackgroundColor",
|
|
1094
|
+
"beforeBannerSpace",
|
|
1095
|
+
"whenShow",
|
|
1096
|
+
"minimumClick",
|
|
1097
|
+
"interstitialTimeOut",
|
|
1098
|
+
"interstitialFirstTimeOut",
|
|
1099
|
+
"appOpenAdsTimeOut",
|
|
1100
|
+
"maxRetryCount",
|
|
1101
|
+
"retrySecondsAr",
|
|
1102
|
+
"appOpenPerSession",
|
|
1103
|
+
"interstitialPerSession",
|
|
1104
|
+
"appOpenFirstTimeOut"
|
|
1105
|
+
];
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
let admobConfig;
|
|
1109
|
+
|
|
1110
|
+
try {
|
|
1111
|
+
admobConfig = JSON.parse(readFileSync(admobConfigPath, "utf8"));
|
|
1112
|
+
} catch (err) {
|
|
1113
|
+
console.error("❌ Failed to read admob-ad-configuration.json", err);
|
|
1114
|
+
process.exit(1);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// ✅ Validate config object exists
|
|
1118
|
+
if (!admobConfig.config) {
|
|
1119
|
+
console.error('❌ "config" object is missing in admob-ad-configuration.json');
|
|
1120
|
+
process.exit(1);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
const admobConfigMinVersion="1.4"
|
|
1125
|
+
|
|
1126
|
+
if (compareVersion(admobConfig.VERSION, admobConfigMinVersion) < 0) {
|
|
1127
|
+
console.error(`❌ Please use at-least version ${admobConfigMinVersion} in "src/js/Ads/admob-ad-configuration.json"`);
|
|
1128
|
+
process.exit(1);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
const config = admobConfig.config;
|
|
1133
|
+
|
|
1134
|
+
// ✅ Find missing properties
|
|
1135
|
+
const missingKeys = REQUIRED_CONFIG_KEYS.filter(
|
|
1136
|
+
key => !(key in config)
|
|
1137
|
+
);
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
if (missingKeys.length > 0) {
|
|
1142
|
+
console.error("❌ Missing required configuration keys. Please check it in 'src/js/Ads/admob-ad-configuration.json'");
|
|
1143
|
+
|
|
1144
|
+
missingKeys.forEach(k => console.error(" - " + k));
|
|
1145
|
+
process.exit(1);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
console.log('✅ All keys exist. in "admob-ad-configuration.json file" Configuration looks good.');
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
checkAdmobConfigurationProperty()
|
|
1056
1154
|
|
|
1057
1155
|
|
|
1058
1156
|
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// Path to the plugin.xml file
|
|
5
|
-
const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
6
|
-
|
|
7
|
-
// Get the store ID from the environment variable
|
|
8
|
-
const storeId = process.env.VITE_STORE_ID || '1';
|
|
9
|
-
|
|
10
|
-
// Determine the framework to use based on storeId
|
|
11
|
-
const framework = storeId === '7'
|
|
12
|
-
? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
|
|
13
|
-
: '<framework src="com.google.android.gms:play-services-ads-lite:24.6.0" />';
|
|
14
|
-
|
|
15
|
-
// Read and modify the plugin.xml file
|
|
16
|
-
fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
|
|
17
|
-
if (err) {
|
|
18
|
-
console.error('Error reading plugin.xml:', err);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Replace the existing framework line with the selected one
|
|
23
|
-
const modifiedData = data.replace(
|
|
24
|
-
/<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
|
|
25
|
-
`${framework}\n`
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Write the modified content back to plugin.xml
|
|
29
|
-
fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
console.error('Error writing plugin.xml:', err);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
console.log('plugin.xml updated successfully.');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Path to the plugin.xml file
|
|
5
|
+
const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
6
|
+
|
|
7
|
+
// Get the store ID from the environment variable
|
|
8
|
+
const storeId = process.env.VITE_STORE_ID || '1';
|
|
9
|
+
|
|
10
|
+
// Determine the framework to use based on storeId
|
|
11
|
+
const framework = storeId === '7'
|
|
12
|
+
? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
|
|
13
|
+
: '<framework src="com.google.android.gms:play-services-ads-lite:24.6.0" />';
|
|
14
|
+
|
|
15
|
+
// Read and modify the plugin.xml file
|
|
16
|
+
fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
console.error('Error reading plugin.xml:', err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Replace the existing framework line with the selected one
|
|
23
|
+
const modifiedData = data.replace(
|
|
24
|
+
/<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
|
|
25
|
+
`${framework}\n`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Write the modified content back to plugin.xml
|
|
29
|
+
fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.error('Error writing plugin.xml:', err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
console.log('plugin.xml updated successfully.');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<resources>
|
|
3
|
-
<color name="splashscreen_background">#FFFFFF</color>
|
|
4
|
-
|
|
5
|
-
<style name="Theme.Codeplay.SplashScreen" parent="Theme.SplashScreen.IconBackground">
|
|
6
|
-
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
|
|
7
|
-
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
|
|
8
|
-
<item name="windowSplashScreenAnimationDuration">10000</item>
|
|
9
|
-
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
|
|
10
|
-
</style>
|
|
11
|
-
</resources>
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<color name="splashscreen_background">#FFFFFF</color>
|
|
4
|
+
|
|
5
|
+
<style name="Theme.Codeplay.SplashScreen" parent="Theme.SplashScreen.IconBackground">
|
|
6
|
+
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
|
|
7
|
+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
|
|
8
|
+
<item name="windowSplashScreenAnimationDuration">10000</item>
|
|
9
|
+
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
|
|
10
|
+
</style>
|
|
11
|
+
</resources>
|
package/files/iap-install-2.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const androidManifestPath = path.join("android", "app", "src", "main", "AndroidManifest.xml");
|
|
7
|
-
|
|
8
|
-
// Find the vite config file
|
|
9
|
-
const possibleConfigFiles = ['vite.config.mjs', 'vite.config.js'];
|
|
10
|
-
let viteConfigPath;
|
|
11
|
-
|
|
12
|
-
for (const configFile of possibleConfigFiles) {
|
|
13
|
-
const fullPath = path.resolve(configFile);
|
|
14
|
-
if (fs.existsSync(fullPath)) {
|
|
15
|
-
viteConfigPath = fullPath;
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!viteConfigPath) {
|
|
21
|
-
console.error('Error: No vite.config.mjs or vite.config.js file found.');
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
// Read vite config file
|
|
27
|
-
const viteConfigContent = fs.readFileSync(viteConfigPath, 'utf-8');
|
|
28
|
-
|
|
29
|
-
// Extract @common alias path
|
|
30
|
-
const aliasPattern = /'@common':\s*path\.resolve\(__dirname,\s*'(.+?)'\)/;
|
|
31
|
-
const match = viteConfigContent.match(aliasPattern);
|
|
32
|
-
|
|
33
|
-
if (!match) {
|
|
34
|
-
console.error(`Error: @common alias not found in ${viteConfigPath}`);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const commonFilePath = match[1];
|
|
39
|
-
const resolvedCommonPath = path.resolve(__dirname, commonFilePath);
|
|
40
|
-
|
|
41
|
-
// Read the common file content
|
|
42
|
-
if (!fs.existsSync(resolvedCommonPath)) {
|
|
43
|
-
console.error(`Error: Resolved common file does not exist: ${resolvedCommonPath}`);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const commonFileContent = fs.readFileSync(resolvedCommonPath, 'utf-8');
|
|
48
|
-
|
|
49
|
-
// Extract _storeid value
|
|
50
|
-
const storeIdPattern = /export\s+let\s+_storeid\s*=\s*import\.meta\.env\.VITE_STORE_ID\s*\|\|\s*(\d+)\s*;/;
|
|
51
|
-
|
|
52
|
-
const storeMatch = commonFileContent.match(storeIdPattern);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!storeMatch) {
|
|
56
|
-
console.error(`Error: _storeid not found in ${resolvedCommonPath}`);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const _storeid = parseInt(storeMatch[1], 10);
|
|
61
|
-
|
|
62
|
-
// Determine the store name based on _storeid
|
|
63
|
-
let storeName = "";
|
|
64
|
-
if (_storeid === 1) {
|
|
65
|
-
storeName = "PlayStore";
|
|
66
|
-
} else if (_storeid === 2) {
|
|
67
|
-
storeName = "SamsungStore";
|
|
68
|
-
} else if (_storeid === 7) {
|
|
69
|
-
storeName = "AmazonStore";
|
|
70
|
-
} else {
|
|
71
|
-
console.error(`Error: Unsupported _storeid value: ${_storeid}`);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// Call managePackages with the determined store name
|
|
77
|
-
managePackages(storeName);
|
|
78
|
-
|
|
79
|
-
console.log(commonFilePath, `Success - _storeid found: ${_storeid}, Store: ${storeName}`);
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error('Error:', error);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function managePackages(store) {
|
|
86
|
-
console.log(`Managing packages for store: ${store}`);
|
|
87
|
-
|
|
88
|
-
let install = "";
|
|
89
|
-
let uninstall = "";
|
|
90
|
-
|
|
91
|
-
//let androidManifestPath = "path/to/AndroidManifest.xml"; // Update this path
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let manifestContent = fs.readFileSync(androidManifestPath, 'utf-8');
|
|
95
|
-
|
|
96
|
-
const permissionsToRemove = [
|
|
97
|
-
'com.android.vending.BILLING',
|
|
98
|
-
'com.samsung.android.iap.permission.BILLING'
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
permissionsToRemove.forEach(permission => {
|
|
102
|
-
const permissionRegex = new RegExp(`^\\s*<uses-permission\\s+android:name="${permission}"\\s*/?>\\s*[\r\n]?`, 'm');
|
|
103
|
-
if (permissionRegex.test(manifestContent)) {
|
|
104
|
-
manifestContent = manifestContent.replace(permissionRegex, '');
|
|
105
|
-
console.log(`Removed <uses-permission android:name="${permission}" /> from AndroidManifest.xml`);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Write the updated content back to the file
|
|
110
|
-
fs.writeFileSync(androidManifestPath, manifestContent, 'utf-8');
|
|
111
|
-
|
|
112
|
-
if (store === "PlayStore") {
|
|
113
|
-
install = '@revenuecat/purchases-capacitor';
|
|
114
|
-
uninstall = 'cordova-plugin-samsungiap';
|
|
115
|
-
} else if (store === "AmazonStore") {
|
|
116
|
-
install = '@revenuecat/purchases-capacitor';
|
|
117
|
-
uninstall = 'cordova-plugin-samsungiap';
|
|
118
|
-
} else if (store === "SamsungStore") {
|
|
119
|
-
install = 'cordova-plugin-samsungiap';
|
|
120
|
-
uninstall = '@revenuecat/purchases-capacitor';
|
|
121
|
-
} else {
|
|
122
|
-
console.log("No valid store specified. Uninstalling both plugins.");
|
|
123
|
-
try {
|
|
124
|
-
require('child_process').execSync(`npm uninstall cordova-plugin-samsungiap`, { stdio: 'inherit' });
|
|
125
|
-
require('child_process').execSync(`npm uninstall @revenuecat/purchases-capacitor`, { stdio: 'inherit' });
|
|
126
|
-
console.log("Both plugins uninstalled successfully.");
|
|
127
|
-
} catch (err) {
|
|
128
|
-
console.error("Error uninstalling plugins:", err);
|
|
129
|
-
}
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
console.log(`Installing ${install} and uninstalling ${uninstall} for ${store}...`);
|
|
134
|
-
try {
|
|
135
|
-
if (install) {
|
|
136
|
-
require('child_process').execSync(`npm install ${install}`, { stdio: 'inherit' });
|
|
137
|
-
}
|
|
138
|
-
if (uninstall) {
|
|
139
|
-
require('child_process').execSync(`npm uninstall ${uninstall}`, { stdio: 'inherit' });
|
|
140
|
-
}
|
|
141
|
-
console.log(`${install} installed and ${uninstall} uninstalled successfully.`);
|
|
142
|
-
} catch (err) {
|
|
143
|
-
console.error(`Error managing packages for ${store}:`, err);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const androidManifestPath = path.join("android", "app", "src", "main", "AndroidManifest.xml");
|
|
7
|
+
|
|
8
|
+
// Find the vite config file
|
|
9
|
+
const possibleConfigFiles = ['vite.config.mjs', 'vite.config.js'];
|
|
10
|
+
let viteConfigPath;
|
|
11
|
+
|
|
12
|
+
for (const configFile of possibleConfigFiles) {
|
|
13
|
+
const fullPath = path.resolve(configFile);
|
|
14
|
+
if (fs.existsSync(fullPath)) {
|
|
15
|
+
viteConfigPath = fullPath;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!viteConfigPath) {
|
|
21
|
+
console.error('Error: No vite.config.mjs or vite.config.js file found.');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Read vite config file
|
|
27
|
+
const viteConfigContent = fs.readFileSync(viteConfigPath, 'utf-8');
|
|
28
|
+
|
|
29
|
+
// Extract @common alias path
|
|
30
|
+
const aliasPattern = /'@common':\s*path\.resolve\(__dirname,\s*'(.+?)'\)/;
|
|
31
|
+
const match = viteConfigContent.match(aliasPattern);
|
|
32
|
+
|
|
33
|
+
if (!match) {
|
|
34
|
+
console.error(`Error: @common alias not found in ${viteConfigPath}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const commonFilePath = match[1];
|
|
39
|
+
const resolvedCommonPath = path.resolve(__dirname, commonFilePath);
|
|
40
|
+
|
|
41
|
+
// Read the common file content
|
|
42
|
+
if (!fs.existsSync(resolvedCommonPath)) {
|
|
43
|
+
console.error(`Error: Resolved common file does not exist: ${resolvedCommonPath}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const commonFileContent = fs.readFileSync(resolvedCommonPath, 'utf-8');
|
|
48
|
+
|
|
49
|
+
// Extract _storeid value
|
|
50
|
+
const storeIdPattern = /export\s+let\s+_storeid\s*=\s*import\.meta\.env\.VITE_STORE_ID\s*\|\|\s*(\d+)\s*;/;
|
|
51
|
+
|
|
52
|
+
const storeMatch = commonFileContent.match(storeIdPattern);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if (!storeMatch) {
|
|
56
|
+
console.error(`Error: _storeid not found in ${resolvedCommonPath}`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const _storeid = parseInt(storeMatch[1], 10);
|
|
61
|
+
|
|
62
|
+
// Determine the store name based on _storeid
|
|
63
|
+
let storeName = "";
|
|
64
|
+
if (_storeid === 1) {
|
|
65
|
+
storeName = "PlayStore";
|
|
66
|
+
} else if (_storeid === 2) {
|
|
67
|
+
storeName = "SamsungStore";
|
|
68
|
+
} else if (_storeid === 7) {
|
|
69
|
+
storeName = "AmazonStore";
|
|
70
|
+
} else {
|
|
71
|
+
console.error(`Error: Unsupported _storeid value: ${_storeid}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// Call managePackages with the determined store name
|
|
77
|
+
managePackages(storeName);
|
|
78
|
+
|
|
79
|
+
console.log(commonFilePath, `Success - _storeid found: ${_storeid}, Store: ${storeName}`);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error('Error:', error);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function managePackages(store) {
|
|
86
|
+
console.log(`Managing packages for store: ${store}`);
|
|
87
|
+
|
|
88
|
+
let install = "";
|
|
89
|
+
let uninstall = "";
|
|
90
|
+
|
|
91
|
+
//let androidManifestPath = "path/to/AndroidManifest.xml"; // Update this path
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
let manifestContent = fs.readFileSync(androidManifestPath, 'utf-8');
|
|
95
|
+
|
|
96
|
+
const permissionsToRemove = [
|
|
97
|
+
'com.android.vending.BILLING',
|
|
98
|
+
'com.samsung.android.iap.permission.BILLING'
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
permissionsToRemove.forEach(permission => {
|
|
102
|
+
const permissionRegex = new RegExp(`^\\s*<uses-permission\\s+android:name="${permission}"\\s*/?>\\s*[\r\n]?`, 'm');
|
|
103
|
+
if (permissionRegex.test(manifestContent)) {
|
|
104
|
+
manifestContent = manifestContent.replace(permissionRegex, '');
|
|
105
|
+
console.log(`Removed <uses-permission android:name="${permission}" /> from AndroidManifest.xml`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Write the updated content back to the file
|
|
110
|
+
fs.writeFileSync(androidManifestPath, manifestContent, 'utf-8');
|
|
111
|
+
|
|
112
|
+
if (store === "PlayStore") {
|
|
113
|
+
install = '@revenuecat/purchases-capacitor';
|
|
114
|
+
uninstall = 'cordova-plugin-samsungiap';
|
|
115
|
+
} else if (store === "AmazonStore") {
|
|
116
|
+
install = '@revenuecat/purchases-capacitor';
|
|
117
|
+
uninstall = 'cordova-plugin-samsungiap';
|
|
118
|
+
} else if (store === "SamsungStore") {
|
|
119
|
+
install = 'cordova-plugin-samsungiap';
|
|
120
|
+
uninstall = '@revenuecat/purchases-capacitor';
|
|
121
|
+
} else {
|
|
122
|
+
console.log("No valid store specified. Uninstalling both plugins.");
|
|
123
|
+
try {
|
|
124
|
+
require('child_process').execSync(`npm uninstall cordova-plugin-samsungiap`, { stdio: 'inherit' });
|
|
125
|
+
require('child_process').execSync(`npm uninstall @revenuecat/purchases-capacitor`, { stdio: 'inherit' });
|
|
126
|
+
console.log("Both plugins uninstalled successfully.");
|
|
127
|
+
} catch (err) {
|
|
128
|
+
console.error("Error uninstalling plugins:", err);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(`Installing ${install} and uninstalling ${uninstall} for ${store}...`);
|
|
134
|
+
try {
|
|
135
|
+
if (install) {
|
|
136
|
+
require('child_process').execSync(`npm install ${install}`, { stdio: 'inherit' });
|
|
137
|
+
}
|
|
138
|
+
if (uninstall) {
|
|
139
|
+
require('child_process').execSync(`npm uninstall ${uninstall}`, { stdio: 'inherit' });
|
|
140
|
+
}
|
|
141
|
+
console.log(`${install} installed and ${uninstall} uninstalled successfully.`);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.error(`Error managing packages for ${store}:`, err);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/files/ionic.config.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "merbin-test-app",
|
|
3
|
-
"integrations": {
|
|
4
|
-
"capacitor": {}
|
|
5
|
-
},
|
|
6
|
-
"type": "custom"
|
|
1
|
+
{
|
|
2
|
+
"name": "merbin-test-app",
|
|
3
|
+
"integrations": {
|
|
4
|
+
"capacitor": {}
|
|
5
|
+
},
|
|
6
|
+
"type": "custom"
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "codeplay-common",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "Common build scripts and files",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"postinstall": "node scripts/sync-files.js",
|
|
7
|
-
"preinstall": "node scripts/uninstall.js"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/merbin2012/codeplay-common.git"
|
|
12
|
-
},
|
|
13
|
-
"author": "Codeplay Technologies",
|
|
14
|
-
"license": "MIT"
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "codeplay-common",
|
|
3
|
+
"version": "2.0.5",
|
|
4
|
+
"description": "Common build scripts and files",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"postinstall": "node scripts/sync-files.js",
|
|
7
|
+
"preinstall": "node scripts/uninstall.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/merbin2012/codeplay-common.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "Codeplay Technologies",
|
|
14
|
+
"license": "MIT"
|
|
15
|
+
}
|
|
16
|
+
|